GHC 6.10.1 type puzzler

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Wed Nov 19 12:12:22 EST 2008


> > test2 :: Box a -> a -> [a]
> > test2 box x = go x
> >  where
> > --  go :: a -> [a]
> >    go y = [(val box), y]
> 
> > Couldn't match expected type `a1' against inferred type `a'

You need to turn on {-# ScopedTypedVariables #-}.
See
    http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#scoped-type-variables

Your first example works without this extension, because the local
definition 'go' is fully polymorphic.  However, in the second example,
the type variable 'a' in the signature of 'go' is not fully polymorphic
- it must be exactly the _same_ 'a' as in the top-level signature.

Regards,
    Malcolm


More information about the Glasgow-haskell-users mailing list