X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fglasgow_exts.xml;h=f7b66d9735b33f5f6d638f7d6875f7248dfb5e79;hb=163d12852002a67c5b661b4b3e7e3c5bb6faa5f3;hp=a1930880d6658114bc66414204c77663ed43fc14;hpb=da43a382ccc7d3c57068976c312dc583fddc7498;p=ghc-hetmet.git diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index a193088..f7b66d9 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -2434,7 +2434,8 @@ declarations. Define your own instances! Declaring data types with explicit constructor signatures -GHC allows you to declare an algebraic data type by +When the GADTSyntax extension is enabled, +GHC allows you to declare an algebraic data type by giving the type signatures of constructors explicitly. For example: data Maybe a where @@ -8919,7 +8920,7 @@ An example will give the idea: - import Generics + import Data.Generics class Bin a where toBin :: a -> [Int] @@ -8939,7 +8940,7 @@ An example will give the idea: This class declaration explains how toBin and fromBin work for arbitrary data types. They do so by giving cases for unit, product, and sum, -which are defined thus in the library module Generics: +which are defined thus in the library module Data.Generics: data Unit = Unit @@ -8961,14 +8962,16 @@ where clause and over-ride whichever methods you please. To use generics you need to - Use the flags (to enable the extra syntax), - (to generate extra per-data-type code), - and (to make the Generics library - available. + + Use the flags (to enable the + extra syntax and generate extra per-data-type code), + and (to make the + Data.Generics module available. + - Import the module Generics from the - lang package. This import brings into + Import the module Data.Generics from the + syb package. This import brings into scope the data types Unit, :*:, and :+:. (You don't need this import if you don't mention these types