Why does "return Nothing" return Nothing?

Viewed 1760

"return a" is supposed to wrap a in the context of some Monad:

*Main> :i return
class Applicative m => Monad (m :: * -> *) where
  ...
  return :: a -> m a
  ...
        -- Defined in ‘GHC.Base’

If I ask GHCI what the type of "return Nothing" is, it conforms to that:

*Main> :t return Nothing
return Nothing :: Monad m => m (Maybe a)

But if I evaluate it, I see no outer Monad, just the inner Maybe:

*Main>  return Nothing
Nothing
1 Answers
Related