X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=0ca2a5370abc302826e2843531e1eb3ffccf92b3;hb=2f6ad11fa0c2995d950c91fd4301f23aceeb443b;hp=110679070b048a548e4a52e7aa78e9e622c349fc;hpb=5d7b55731e31c04ba76d670d0176e32f121fc5e4;p=ghc-hetmet.git diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 1106790..0ca2a53 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -905,6 +905,38 @@ fromInteger :: Integer -> Bool -> Bool you should be all right. + + +Postfix operators + + +GHC allows a small extension to the syntax of left operator sections, which +allows you to define postfix operators. The extension is this: the left section + + (e !) + +is equivalent (from the point of view of both type checking and execution) to the expression + + ((!) e) + +(for any expression e and operator (!). +The strict Haskell 98 interpretation is that the section is equivalent to + + (\y -> (!) e y) + +That is, the operator must be a function of two arguments. GHC allows it to +take only one argument, and that in turn allows you to write the function +postfix. + +Since this extension goes beyond Haskell 98, it should really be enabled +by a flag; but in fact it is enabled all the time. (No Haskell 98 programs +change their behaviour, of course.) + +The extension does not extend to the left-hand side of function +definitions; you must define such a function in prefix form. + + + @@ -3236,7 +3268,7 @@ f xs = ys ++ ys The type signature for f brings the type variable a into scope; it scopes over the entire definition of f. -In particular, it is in scope at the type signature for y. +In particular, it is in scope at the type signature for ys. In Haskell 98 it is not possible to declare a type for ys; a major benefit of scoped type variables is that it becomes possible to do so. @@ -3871,8 +3903,8 @@ declaration, but only if the data type could also have been declared in Haskell-98 syntax. For example, these two declarations are equivalent data Maybe1 a where { - Nothing1 :: Maybe a ; - Just1 :: a -> Maybe a + Nothing1 :: Maybe1 a ; + Just1 :: a -> Maybe1 a } deriving( Eq, Ord ) data Maybe2 a = Nothing2 | Just2 a @@ -6030,7 +6062,7 @@ r) GHCziBase.ZMZN GHCziBase.Char -> GHCziBase.ZMZN GHCziBase.Cha r) -> tpl2}) - (%note "foo" + (%note "bar" eta); @@ -6132,9 +6164,6 @@ that it is well typed. Generic classes - (Note: support for generic classes is currently broken in - GHC 5.02). - The ideas behind this extension are described in detail in "Derivable type classes", Ralf Hinze and Simon Peyton Jones, Haskell Workshop, Montreal Sept 2000, pp94-105.