3 ms·
Invalid Haskell code in the article: case getSomeData of Nothing -> Nothing Just a -> a Unless there's something about a that I don't know.
by davidgrenier 8y ago
Invalid Haskell code in the article:
case getSomeData of
Nothing -> Nothing
Just a -> a
Unless there's something about a that I don't know.
- dmead 8y agohow is this invalid? it's covering both constructors for maybe.
- davidgrenier 8y agoThe resulting type of the expression is inconsistent. First case returns a Maybe, second case returns whatever the type of a is. edit: replaced option with maybe.
- dmead 8y agoAh right you are. It's missing something to unwrap from the maybe type at least.
- moomin 8y agoI think it’d work if the initial type was “Maybe Maybe x”, (in which the function is join) but I seriously doubt that was what was intended. The roach motel aspect of monads is not underestimating.
- moomin 8y agoGrief, I need a proof-reader.