I implemented sequenceA
:
sequenceA :: Applicative f => [f a] -> f [a]
sequenceA [] = pure []
sequenceA (x:xs) = (++) <$> (fmap (\y -> [y]) x) <*> sequenceA xs
I don't like the fact that I'm making a new list, and then concatenating the result via ++
.
However, I'm not sure how to make use of cons, i.e. :
, in this function.
Please critique it.