summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2010-07-07 23:09:07 +0000
committerIan Lynagh <igloo@earth.li>2010-07-07 23:09:07 +0000
commit9dd44fc697ab716d5566150c8c3236a0f00a2778 (patch)
tree3b95f12ad277b12d7e472080b24a722a245df26a /docs
parentc9bb6b63aa1f479a3dd3679c7e4c2c69471a4912 (diff)
downloadhaskell-9dd44fc697ab716d5566150c8c3236a0f00a2778.tar.gz
Add docs for DatatypeContexts extension
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/glasgow_exts.xml20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml
index f8cd504a84..bf825455e1 100644
--- a/docs/users_guide/glasgow_exts.xml
+++ b/docs/users_guide/glasgow_exts.xml
@@ -1894,6 +1894,26 @@ not <literal>*</literal> then an explicit kind annotation must be used
Nevertheless, they can be useful when defining "phantom types".</para>
</sect2>
+<sect2 id="datatype-contexts">
+<title>Data type contexts</title>
+
+<para>Haskell allows datatypes to be given contexts, e.g.</para>
+
+<programlisting>
+data Eq a => Set a = NilSet | ConsSet a (Set a)
+</programlisting>
+
+<para>give constructors with types:</para>
+
+<programlisting>
+NilSet :: Set a
+ConsSet :: Eq a => a -> Set a -> Set a
+</programlisting>
+
+<para>In GHC this feature is an extension called
+<literal>DatatypeContexts</literal>, and on by default.</para>
+</sect2>
+
<sect2 id="infix-tycons">
<title>Infix type constructors, classes, and type variables</title>