From 9dd44fc697ab716d5566150c8c3236a0f00a2778 Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Wed, 7 Jul 2010 23:09:07 +0000 Subject: [PATCH] Add docs for DatatypeContexts extension --- docs/users_guide/glasgow_exts.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index f8cd504..bf82545 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -1894,6 +1894,26 @@ not * then an explicit kind annotation must be used Nevertheless, they can be useful when defining "phantom types". + +Data type contexts + +Haskell allows datatypes to be given contexts, e.g. + + +data Eq a => Set a = NilSet | ConsSet a (Set a) + + +give constructors with types: + + +NilSet :: Set a +ConsSet :: Eq a => a -> Set a -> Set a + + +In GHC this feature is an extension called +DatatypeContexts, and on by default. + + Infix type constructors, classes, and type variables -- 1.7.10.4