Haskell FlatMap
- by mvid
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?