Maybe monad construction
问题 I'm currently struggling with a new element of Haskell: Monads. Therefore I was introduced to this by an example of creating a (>>=) operator that executes a function on a Maybe type (taking its actual integer value as argument to it) only if it's not equal to Nothing , and otherwise return Nothing : (>>=) :: Maybe a -> (a -> Maybe b) -> Maybe b Nothing >>= _ = Nothing (Just x) >>= f = f x However, I'm not quite sure how this works with the following usage of it: eval (Val n) = Just n eval