strictness Questions
9
Solved
What does Weak Head Normal Form (WHNF) mean? What does Head Normal form (HNF) and Normal Form (NF) mean?
Real World Haskell states:
The familiar seq function evaluates an expression to what we
cal...
Titrate asked 29/7, 2011 at 12:13
1
Solved
I have several different implementations of the same function. The difference lies in the use of bang patterns. The question is, why does perimeterNaiveFast work the same as perimeterStrictFast?
Be...
Runner asked 17/12, 2020 at 20:44
8
Solved
We all know (or should know) that Haskell is lazy by default. Nothing is evaluated until it must be evaluated. So when must something be evaluated? There are points where Haskell must be strict. I ...
Nomi asked 20/9, 2011 at 19:34
1
Haskell pattern matching is often head strict, for example,f (x:xs) = ...
requires input list to be evaluated to (thunk : thunk). But sometimes such evaluation is not needed and function can afford...
Dulciedulcify asked 15/9, 2018 at 12:40
2
Solved
So I have an existential data type with a single strict field:
data Uncurry (a :: i -> j -> *) (z :: (i,j)) =
forall x y. z ~ '(x,y) => Uncurry !(a x y)
Experimentation using unsafeSi...
Bonnee asked 19/9, 2017 at 12:5
1
Solved
If we look at the containers package. They have Data.Map.Strict, but there is no equivalent Data.Set.Strict. Would it make sense for it to exist?
Freytag asked 27/4, 2017 at 20:52
1
Solved
I'm reading about strict data constructors. The linked Wiki article states that,
"strictness annotations can make performance worse [because] a strictness annotation forces the compiler to ensu...
Everetteverette asked 12/1, 2017 at 21:25
1
Solved
The following
(&&) :: Bool -> Bool -> Bool
False && _ = False
True && False = False
True && True = True
has the desired short-circuit property False &&a...
Norean asked 30/10, 2016 at 12:6
1
So, Haskell seq function forces the evaluation of it's first argument and returns the second. Consequently it is an infix operator. If you want to force the evaluation of an expression, intuitively...
Phosphorus asked 22/9, 2016 at 17:19
1
Solved
I was looking at some Haskell source code and came across a pattern match with !_, the code is here: http://hackage.haskell.org/package/base-4.9.0.0/docs/src/GHC.List.html#unsafeTake
take n xs | 0...
Sinaloa asked 11/9, 2016 at 16:21
4
Solved
For example, I have an operation fnB :: a -> Bool that makes no sense until fnA :: Bool returns False. In C I may compose these two operations in one if block:
if( fnA && fnB(a) ){ doSo...
Perverse asked 30/9, 2011 at 15:21
2
Solved
Somewhat mystified by the following code. In non-toy version of the problem I'm trying to do a monadic computation in a monad Result, the values of which can only be constructed from within IO. See...
Berryman asked 31/5, 2016 at 6:40
2
I have seen many talks / read blog posts that you should have strict fields in data to avoid various performance issues, e.g.:
data Person = Person
{ personName :: !Text
, personBirthday :: !UTC...
Perpetuate asked 7/1, 2016 at 13:50
1
For another answer of mine, I wrote the following code, providing diagonally traversed Universe instances for enumerable Generics (it's slightly updated from the version there, but uses the same lo...
Rwanda asked 8/5, 2014 at 16:22
1
Solved
From GHC user guide it seems like most Pat can be PBangPat, but there are a few exceptions. e.g. top-level bangs in a module (like !main) aren't allowed and x : !xs fails to parse x : (!xs) parses ...
Platinocyanide asked 3/8, 2015 at 14:46
4
Solved
This may now be a bit fuzzy, but I've been wondering that for a while. To my knowledge with !, one can make sure a parameter for a data constructor is being evaluated before the value is constructe...
Yaroslavl asked 20/12, 2011 at 14:16
2
Solved
Can someone help me understand the following definition from Wadler's paper titled "Comprehending Monads"? (Excerpt is from section 3.2/page 9, i.e., the "Strictness Monad" subs...
Irony asked 17/10, 2014 at 15:52
1
Solved
So we have:
import Control.Monad.Writer.Strict
type M a = Writer (Map Key Val) a
for some Key and Val.
Everything works okay as long as we don't look at the collected outputs:
report comp = d...
Legion asked 9/9, 2014 at 15:56
3
Solved
I am trying to write a simple program in Haskell. It should basically run two shell commands in parallel. Here is the code:
import System.Cmd
import System.Exit
import Control.Monad
exitCodeToBoo...
Eudemonism asked 11/4, 2014 at 12:38
1
Solved
In Haskell, the term spine strictness is often mentioned in relation to lazy evaluation. Though I have a vague understanding of that it means, it would be nice to have a more concrete explanation a...
Doretheadoretta asked 7/3, 2014 at 12:2
2
Solved
I'm learning Haskell and currently trying to wrap my head around monads. While playing with some random number generation I got tripped on lazy evaluation once again. In an effort to simplify somet...
Trigonometry asked 19/12, 2013 at 18:39
3
I quite like Haskell, however one of the main things that concerns me about Haskell the difficulty in reasoning about space usage. Basically the possibility of thunks and recursion seem to make som...
Turboprop asked 19/4, 2013 at 3:59
3
Solved
I have this code:
import Data.List
newList_bad lst = foldl' (\acc x -> acc ++ [x*2]) [] lst
newList_good lst = foldl' (\acc x -> x*2 : acc) [] lst
These functions return lists with each e...
Try asked 18/2, 2013 at 14:27
3
Solved
Follow <Real World Haskell> , it is said foldl' are strict version of foldl.
But it's hard for me to understand , what does strict mean??
foldl f z0 xs0 = lgo z0 xs0
where
lgo z [] = z
l...
Lusty asked 11/1, 2013 at 13:28
4
Solved
I always thought that replacing an expression x :: () with () :: () would be one of the most basic optimizations during compiling Haskell programs. Since () has a single inhabitant, no matter what ...
Properly asked 2/12, 2012 at 19:48
1 Next >
© 2022 - 2024 — McMap. All rights reserved.