Skip to content

Warn when a function's type indicates that it's unnecessarily monadic

Motivation

Newbies to Haskell often write functions like f x y = return (x + y + 10), which drag monads in unnecessarily.

Proposal

When a function uses monads unnecessarily, emit a warning. I think this definition of "unnecessarily" is both correct and rigorous enough to implement: if a function has a polymorphic type, a type variable appears only in positive position, and no constraints refer to that type variable except for Functor, Applicative, Monad, and MonadFix instances, then it's unnecessarily monadic.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information