[jhc] Rank 2 types error

Roman Cheplyaka roma at ro-che.info
Wed Feb 8 23:55:47 CET 2012


The following program is accepted by GHC 7 with -XRank2Types:

    class C a where
        f :: a -> a

    newtype R = R (forall a . C a => a)

    instance C R where
        f (R x) = R $ f x

    main = return ()

jhc 0.8 gives the following error:

    [1 of 1] Main             (...............jhci: user error (
    What:    failure
    Why:     Signature too Weak: [] does not imply [Main.C Main.v11]
    Where:   on line 7 in j.hs
    in the explicitly typed Instance at .iMain.f.Main.R (Main.R Main.6_x)
      = Main.R Jhc.Basics.$ Main.f Main.6_x		{- on line 7 -}
    Compilation of module: Main)

Is this difference in behaviour intended, and how can I make something
like that compile?

Roman I. Cheplyaka :: http://ro-che.info/

More information about the jhc mailing list