[Haskell-cafe] The danger of not specifying types (was The danger
of Monad ((->) r))
Jules Bean
jules at jellybean.co.uk
Tue May 15 06:15:20 EDT 2007
Tomasz Zielonka wrote:
> My mistake was that I forgot about db and wrote:
>
> concatStmts s1 s2 = s1 >> s2
>
> And it was accepted because I had the Monad instance for ((->) r) in
> scope (from Control.Monad.Trans I guess)!
>
The danger in overloading is that you are relying on the compiler to
infer which instance you mean. This is perhaps most visible with Monad
which has so many common instances ([], (r ->), Maybe, etc).
When writing monadic expressions in large projects, I recommend
annotating them with the types you really want.
Jules
More information about the Haskell-Cafe
mailing list