[Haskell-cafe] Type inference; always

Derek Elkins derek.a.elkins at gmail.com
Sun May 18 13:10:38 EDT 2008

On Sun, 2008-05-18 at 16:57 +0000, Luke Palmer wrote:
> 2008/5/18 Peter Verswyvelen <bf3 at telenet.be>:
> > In Haskell, I sometimes have to annotate code with type info because the
> > type-inferer otherwise fails (even with -XNoMonomorphismRestriction).
> > Surely, most of the time this is because I was writing buggy code, but
> > sometimes, type annotation just seems needed to get a successful compilation
> > (luckily not as often as in C# 3.0)
> Then you must either be programming using extensions or you have found
> a bug.  Haskell 98 should never require annotations (modulo
> monomorphism).  

This is incorrect.  There are two (other) situations where you need type
annotations in Haskell 98.  One situation is when you use polymorphic
recursion, but that is pretty rare unless you are writing nested data
types.  The other situation is when not enough information is provided
to resolve a typeclass constraint, e.g. good ole show . read.

More information about the Haskell-Cafe mailing list