Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alex D
GHC
Commits
395f018b
Commit
395f018b
authored
Sep 11, 2006
by
simonpj@microsoft.com
Browse files
Document postfix operators
parent
67c2b6a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/users_guide/glasgow_exts.xml
View file @
395f018b
...
...
@@ -905,6 +905,38 @@ fromInteger :: Integer -> Bool -> Bool
you should be all right.
</para>
</sect2>
<sect2
id=
"postfix-operators"
>
<title>
Postfix operators
</title>
<para>
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
<programlisting>
(e !)
</programlisting>
is equivalent (from the point of view of both type checking and execution) to the expression
<programlisting>
((!) e)
</programlisting>
(for any expression
<literal>
e
</literal>
and operator
<literal>
(!)
</literal>
.
The strict Haskell 98 interpretation is that the section is equivalent to
<programlisting>
(\y -> (!) e y)
</programlisting>
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.
</para>
<para>
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.)
</para>
<para>
The extension does not extend to the left-hand side of function
definitions; you must define such a function in prefix form.
</para>
</sect2>
</sect1>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment