ANNOUNCE: GHC 5.03.20020410 snapshot released

Ralf Hinze ralf@informatik.uni-bonn.de
Thu, 18 Apr 2002 14:59:51 +0200


--------------Boundary-00=_RFLRSKT21I2N9VV6K0ST
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Am Donnerstag, 18. April 2002 14:12 schrieb Simon Marlow:
> > Ralf Hinze <ralf@informatik.uni-bonn.de> writes:
> > > BTW, does this version support rank-n types?
> >
> > IIRC the previous snapshot did.  So presumably this one does
> > too?
>
> Yes, it does.
>
> Simon

That's what I feared ;-). Ok, here is my first attempt at defining
a rank-3 function (code attached). ghci responds
---
ralf/Haskell> ghci -v -fglasgow-exts Rank3.lhs
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 5.03.20020410, for Ha=
skell=20
98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Glasgow Haskell Compiler, Version 5.03.20020410, for Haskell 98, compiled=
 by=20
GHC version 5.03.20020410
<...>
*** Typechecker:

Rank3.lhs:20:
    Illegal polymorphic type: forall b1 b2.
                              (b1 -> b2) -> h1 f1 b1 -> h2 f2 b2
    In the type: forall h1 h2 a1 a2.
                 (forall f1 f2.
                  (forall c1 c2. (c1 -> c2) -> f1 c1 -> f2 c2)
                  -> forall b1 b2. (b1 -> b2) -> h1 f1 b1 -> h2 f2 b2)
                 -> (a1 -> a2) -> HFix h1 a1 -> HFix h2 a2
    While checking the type signature for `mapHFix'
---
Do I have to hoist the forall quantifiers in bla -> forall a . blub mysel=
f? At
least, the code typechecks then.

Cheers, Ralf



--------------Boundary-00=_RFLRSKT21I2N9VV6K0ST
Content-Type: text/x-literate-haskell;
  charset="iso-8859-1";
  name="Rank3.lhs"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="Rank3.lhs"

ghci -v -fglasgow-exts Rank3.lhs

> data Fork a                   =  ForkC a a
>
> mapFork                       :: forall a1 a2 . (a1 -> a2) -> (Fork a1 -> Fork a2)
> mapFork mapA (ForkC a1 a2)    =  ForkC (mapA a1) (mapA a2)

> data SequF s a		=  EmptyF | ZeroF (s (Fork a)) | OneF a (s (Fork a))
>
> newtype HFix h a		=  HIn (h (HFix h) a)
>
> type Sequ                     =  HFix SequF

> mapSequF                      :: forall s1 s2 . (forall b1 b2 . (b1 -> b2) -> (s1 b1 -> s2 b2))
>                                                 -> (forall a1 a2 . (a1 -> a2) -> (SequF s1 a1 -> SequF s2 a2))
> mapSequF mapS mapA EmptyF	=  EmptyF
> mapSequF mapS mapA (ZeroF as) =  ZeroF (mapS (mapFork mapA) as)
> mapSequF mapS mapA (OneF a as)=  OneF (mapA a) (mapS (mapFork mapA) as)

> mapHFix                       :: forall h1 h2 . (forall f1 f2 . (forall c1 c2 . (c1 -> c2) -> (f1 c1 -> f2 c2))
>                                                                 -> (forall b1 b2 . (b1 -> b2) -> (h1 f1 b1 -> h2 f2 b2)))
>                                                 -> (forall a1 a2 . (a1 -> a2) -> (HFix h1 a1 -> HFix h2 a2))
> mapHFix mapH mapA (HIn v)     =  HIn (mapH (mapHFix mapH) mapA v)

> mapSequ                       :: forall a1 a2 . (a1 -> a2) -> (Sequ a1 -> Sequ a2)
> mapSequ			=  mapHFix mapSequF

> main				=  putStrLn "hello world"
--------------Boundary-00=_RFLRSKT21I2N9VV6K0ST--