Arnaud Spiwack
Most of the time: it doesn't even remotely matters
atomicPut :: Handle -> String -> IO ()
atomicPut h line =
withMVar lock $ \_ -> do
hPutStrLn h lineor :: [Bool] -> Bool
or = foldr (||) False
any :: (a -> Bool) -> [a] -> Bool
any p = or . map pzipWith1 :: (a -> b) -> [a] -> [b]
zipWith2 :: (a -> b -> c) -> [a] -> [b] -> [c]
zipWith3 :: (a -> b -> c -> d) -> [a] -> [b] -> [c] -> [d]
zipWith4 :: (a -> b -> c -> d -> e) -> [a] -> [b] -> [c] -> [d] -> [e]
zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]⁝
zipWith5 :: (a -> b -> c -> d -> e -> f) -> [a] -> [b] -> [c] -> [d] -> [e] -> [f]
zipWith5 f as bs cs ds es = f <$> as <*> bs <*> cs <*> ds <*> es(<$>) :: (a -> b) -> [a] -> [b]
(<*>) :: [a -> b] -> [a] -> [b]“The answer to all questions in Haskell is ‘bottom’.”
— Simon Peyton Jones
f :: Bool -> Bool -> Int
f _ False = 1
f True False = 2
f _ _ = 3f :: T a -> U a -> Int
f (TBool b1) (UBool b2) = 0data U a where
UChar :: Char -> U Char
UBool :: Bool -> U Bool data T a where
TInt :: Int -> T Int
TBool :: Bool -> T Boolmap :: (a -> b) -> [a] -> [b]
map f [] = []
map f (a:as) = f a : map f aslength :: [a] -> Integer
length [] = 0
length (_:as) = 1 + length aslength :: [a] -> Integer
length = go 0
where
go :: Integer -> [a] -> Integer
go acc [] = acc
go acc (_:as) = go (acc+1) aslength :: [a] -> Integer
length = go 0
where
go :: Integer -> [a] -> Integer
go !acc [] = acc
go !acc (_:as) = go (acc+1) asObserving a lazy value changes its state
This slide is intentionally left blank
readFile :: FilePath -> IO StringLimitations:
readFile :: FilePath -> IO Stringlines :: String -> [String]read :: Read a => String -> af :: Read a => FilePath -> IO [a]
f p = (map read . lines) <$> readFile pLimitations:
… { … , foo : { … }, … } …(…, Object (<thunk>, Field "foo" (Object …), <thunk>), …)traceEvent "START PureCode" $
somePureCode¿¿Where do I put
traceEvent "STOP PureCode"??
Laziness has a real implementation cost
— Simon Peyton Jones (2003)
“Every call-by-value language has given into the siren call of side effects.”
— Simon Peyton Jones (2003)
https://slides.com/aspiwack/hx2020
Thank you for listening