- ~
- forall
- Lazy IO, conduits, ...
WHNF, seq- catch, throw
- text, bytestring
- react-flux, ghcjs
a n | n > 0 = n | True = -n
Guards can go on one line
f 0 = 1 ; f n = n * f (n-1)
This works in GHCi
k :: Int ; k = 4
So does this
Just undefined `seq` 42
Demonstrates that Just expr
is in WHNF
a `seq` b `seq` f a b
Forces a and b
ReaderT [String] (WriterT [String] ((StateT StdGen) (ST s))) (Image PixelRGB16)
withFile "b.txt" ReadMode hGetContents
hGetContents: illegal operation (delayed read on closed handle)
withFile "b.txt" ReadMode $ \h -> hGetContents h >>= putStr
f $! x = x `seq` f x
seq :: a -> b -> b -- evaluates a to WHNF when seq a b is evaluated to WHNF
hGetContents h = IO.hGetContents h >>= \s -> length s `seq` return s
-- strict version
Just (2+2)
(1+1, 2+2)
'h' : ("e" ++ "llo")
\x -> 2 + 2