From 395f018ba53d1bc09a03aa5083032dc96c911c6c Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Mon, 11 Sep 2006 16:28:43 +0000 Subject: [PATCH] Document postfix operators --- docs/users_guide/glasgow_exts.xml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 0fb3dd1..7e08583 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. + + + -- 1.7.10.4