[project @ 2002-10-11 16:56:09 by simonpj]
authorsimonpj <unknown>
Fri, 11 Oct 2002 16:56:09 +0000 (16:56 +0000)
committersimonpj <unknown>
Fri, 11 Oct 2002 16:56:09 +0000 (16:56 +0000)
Document infix type constructors

ghc/docs/users_guide/glasgow_exts.sgml

index cbfe208..5c3e74e 100644 (file)
@@ -420,6 +420,33 @@ contains up to date information on recursive monadic bindings.
 
 </sect2>
 
+
+<sect2> <title> Infix type constructors </title>
+
+<para>GHC supports infix type constructors, much as it supports infix data constructors.  For example:
+<programlisting>
+  infixl 5 :+:
+
+  data a :+: b = Inl a | Inr b
+
+  f :: a `Either` b -> a :+: b
+  f (Left x) = Inl x
+</programlisting>
+</para>
+<para>The lexical 
+syntax of an infix type constructor is just like that of an infix data constructor: either
+it's an operator beginning with ":", or it is an ordinary (alphabetic) type constructor enclosed in
+back-quotes.</para>
+
+<para>
+When you give a fixity declaration, the fixity applies to both the data constructor and the
+type constructor with the specified name.  You cannot give different fixities to the type constructor T
+and the data constructor T.
+</para>
+
+
+</sect2>
+
    <!-- ===================== PARALLEL LIST COMPREHENSIONS ===================  -->
 
   <sect2 id="parallel-list-comprehensions">