Haskell FlatMap
Posted
by mvid
on Stack Overflow
See other posts from Stack Overflow
or by mvid
Published on 2010-06-07T02:31:36Z
Indexed on
2010/06/07
2:42 UTC
Read the original article
Hit count: 298
I am a beginner interested in Haskell, and I have been trying to implement the flatmap (>>=) on my own to better understand it. Currently I have
flatmap :: (t -> a) -> [t] -> [a]
flatmap _ [] = []
flatmap f (x:xs) = f x : flatmap f xs
which implements the "map" part but not the "flat".
Most of the modifications I make result in the disheartening and fairly informationless
Occurs check: cannot construct the infinite type: a = [a]
When generalising the type(s) for `flatmap'
error.
What am I missing?
© Stack Overflow or respective owner