Hacker News new | ask | show | jobs
by mrkgnao 3245 days ago
It won't satisfy the properties you've come to expect from the implementations you know for lists, optionals (Maybe), and so on.

Suppose you're going over some code, where you have something of the form

   xs >>= someFunction
(where xs is a list) and you change someFunction to "return":

   xs >>= return
Then you'd expect, from experience, that you can rewrite this to just

   xs
(which you can check works with all the monads you know about) but that doesn't hold for this wonky definition of the Monad instance for lists. Indeed, note that return for lists has the definition

   return x = [x]
so, with our bad >>=,

   [1, 2, 3] >>= return
   = concat (reverse (map (\x -> [x]) [1, 2, 3]))
   = concat (reverse ([[1], [2], [3]]))
   = concat [[3], [2], [1]]
   = [3, 2, 1]
which is not the same as [1, 2, 3].

https://wiki.haskell.org/Monad_laws