syntax of RULES pragmas?

Simon Peyton-Jones simonpj@microsoft.com
Thu, 16 May 2002 07:03:13 -0700


You need -fglasgow-exts.  (Should ignore a pragma without
-fglasgow-exts,
and does so now, but 5.03 gave the bad message you found.)

The manual is wrong; spaces between the variables is right.

Simon

| -----Original Message-----
| From: Janis Voigtlaender [mailto:voigt@orchid.inf.tu-dresden.de]=20
| Sent: 16 May 2002 14:49
| To: glasgow-haskell-users@haskell.org
| Subject: syntax of RULES pragmas?
|=20
|=20
| Hi,
|=20
| I was trying to play with GHC 5.02's RULES pragmas, but=20
| failed due to syntax problems.
|=20
| When trying:
|=20
|   {-# RULES "map/map" forall f g xs. map f (map g xs) =3D map=20
| (f.g) xs #-}
|=20
|   main =3D print (map id (map id "Hello"))
|=20
| I get:
|=20
|   ghc5 test.hs -O
|   test.hs:1: Variable not in scope: `forall'
|=20
|   test.hs:1: Variable not in scope: `f'
|=20
|   test.hs:1: Variable not in scope: `g'
|=20
|   test.hs:1: Variable not in scope: `xs'
|=20
|   test.hs:1: Variable not in scope: `f'
|=20
|   test.hs:1: Variable not in scope: `g'
|=20
|   test.hs:1: Variable not in scope: `xs'
|=20
|   test.hs:1: Variable not in scope: `f'
|=20
|   test.hs:1: Variable not in scope: `g'
|=20
|   test.hs:1: Variable not in scope: `xs'
|   Exit 1
|=20
|=20
| With:
|=20
|   {-# RULES "map/map" forall f g xs.=20
|   map f (map g xs) =3D map (f.g) xs #-}
|=20
|   main =3D print (map id (map id "Hello"))
|=20
| I get:
|=20
|   test.hs:2: parse error (possibly incorrect indentation)
|   Exit 1
|=20
|=20
| In the user's doc on http://www.haskell.org/ghc/ I also saw=20
| the syntax:
|=20
|   {-# RULES "map/map" forall f,g,xs. map f (map g xs) =3D map=20
| (f.g) xs #-}
|=20
|   main =3D print (map id (map id "Hello"))
|=20
| which fails with:
|=20
|   test.hs:1: parse error on input `,'
|   Exit 1
|=20
|=20
| So how exactly do I have to specify a rewrite rule? Any hints=20
| appreciated.
|=20
| Thanks, Janis.
|=20
|=20
| --
| Janis Voigtlaender
| http://wwwtcs.inf.tu-dresden.de/~voigt/
| mailto:voigt@tcs.inf.tu-dresden.de
| _______________________________________________
| Glasgow-haskell-users mailing list=20
| Glasgow-haskell-users@haskell.org=20
| http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users
|=20