Hello Henry,

Changes to GHC regarding the treatment of higher-rank types required a few changes to that test too. You have to eta-expand the application of mkTT and give it a type signature. Therefore, main becomes

print $ gzip (\x y -> mkTT maxS x y) genCom1 genCom2

and you have to add the type signature

mkTT :: (Typeable a, Typeable b, Typeable c) => (a -> a -> a) -> b -> c -> Maybe c .

Then this example should work.

As to why exactly these changes are necessary, you might want to check the GHC manual section on arbitrary-rank polymorphism (http://haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#universal-quantification).


Cheers,
Pedro

On Sat, Feb 14, 2009 at 21:55, Henry Laxen <nadine.and.henry@pobox.com> wrote:
Dear Group,

When trying to run the example at:
http://www.cs.vu.nl/boilerplate/testsuite/gzip/Main.hs
ghc 6.10.1 says

   A pattern type signature cannot bind scoped type variables `a'
     unless the pattern has a rigid type context
   In the pattern: f :: a -> a -> a
   In the definition of `mkTT':
       mkTT (f :: a -> a -> a) x y
              = case (cast x, cast y) of {
                  (Just (x' :: a), Just (y' :: a)) -> cast (f x' y')
                  _ -> Nothing }
   In the definition of `main':
       main = print $ gzip (mkTT maxS) genCom1 genCom2
            where
                genCom1 = everywhere (mkT (double "Joost")) genCom
                genCom2 = everywhere (mkT (double "Marlow")) genCom
                double x (E (p@(P y _)) (S s)) | x == y = E p (S (2 * s))
                double _ e = e
                maxS (S x) (S y) = S (max x y)
                ....
Failed, modules loaded: CompanyDatatypes.

---------------------------------------------------------------------
I must admit I don't really know what to make of this.  Any insights would
be appreciated.
Thanks.
Henry Laxen

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe