[Haskell-beginners] which Applicative instance?

Graham Gill 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
> https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/interactive-evaluation.html#actions-at-prompt 
> <https://downloads.haskell.org/%7Eghc/latest/docs/html/users_guide/interactive-evaluation.html#actions-at-prompt>
> 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...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151115/28f74461/attachment.html>

More information about the Beginners mailing list