type checking fails with a correct type

Isaac Dupree ml at isaac.cedarswampstudios.org
Thu Apr 30 13:08:15 EDT 2009


Brandon S. Allbery KF8NH wrote:
> On Apr 30, 2009, at 09:52 , Jan Jakubuv wrote:
> >    *Main> :t nonsense
> >    nonsense :: (SUBST s) => t -> Maybe s
> >
> > But, when I put this signature into the code (that is, when the
> > commented
> > line above is uncommented) then type checking fails with the following
> > error:
> >
> >    Ambiguous type variable `s' in the constraint:
> >      `SUBST s'
>
> http://www.haskell.org/pipermail/haskell-cafe/2008-April/041397.html
> http://hackage.haskell.org/trac/ghc/ticket/1897
>
> The type really is ambiguous according to GHC's rules, because you're
> missing some relationships.  As I understand it (which may well be
> wrong), f you leave off the explicit typing it will successfully infer
> everything including the missing relationship; but if you explicitly
> type it you prevent inference of the missing relationship.

hmm, strange, is this a "feature" of Haskell-98? :
The definition threatens to be polymorphic recursion.
Without a type-signature, the type-checker will assume that the recursion is 
monomorphic and proceed accordingly.
With a type-signature, the type-checker doesn't do that (so therefore it's 
ambiguous).

-Isaac


More information about the Glasgow-haskell-users mailing list