
14 Nov
2015
14 Nov
'15
9:58 p.m.
On Sun, Nov 15, 2015 at 9:29 AM, Graham Gill
:t pure
More simply pure :: Applicative f => a -> f a
pure [1..5] [1,2,3,4,5]
a must match a list of Nums, but then where did f go? Is ghci using some default instance?
Yes it is. The default instance is IO. It's a common gotcha, see https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-... and the example of how "return True" defaults to IO Bool. Might I compliment you on this: sequenceA' :: Applicative f => [f a] -> f [a] sequenceA' = foldr (\fa fla -> (:) <$> fa <*> fla) (pure []) There are strong arguments that this is the best way of writing sequenceA. -- Kim-Ee