[Haskell-beginners] which Applicative instance?
math.simplex at gmail.com
Sun Nov 15 05:35:17 UTC 2015
On 11/14/2015 9:58 PM, Kim-Ee Yeoh wrote:
> Yes it is. The default instance is IO. It's a common gotcha, see
> and the example of how "return True" defaults to IO Bool.
Thanks Kim-Ee, that makes it clear.
> 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
Thanks, but it just seemed the most straightforward thing to do at my
present level of understanding.
Are there substantially different ways to define sequenceA? I'm
interested to read the arguments if you can give a pointer to a post
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners