diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/users_guide/glasgow_exts.xml | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index 3d9e45c8e3..04cb5e6007 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -11718,39 +11718,25 @@ necessary to be able to define generic instances automatically. <para> For example, a user-defined datatype of trees <literal>data UserTree a = Node a -(UserTree a) (UserTree a) | Leaf</literal> gets the following representation: +(UserTree a) (UserTree a) | Leaf</literal> in a <literal>Main</literal> module +gets the following representation: <programlisting> instance Generic (UserTree a) where -- Representation type type Rep (UserTree a) = - M1 D D1UserTree ( - M1 C C1_0UserTree ( - M1 S NoSelector (K1 R a) - :*: M1 S NoSelector (K1 R (UserTree a)) - :*: M1 S NoSelector (K1 R (UserTree a))) - :+: M1 C C1_1UserTree U1) + M1 D ('MetaData "UserTree" "Main" 'False) ( + M1 C ('MetaCons "Node" 'PrefixI 'False) ( + M1 S ('MetaSel "") (K1 R a) + :*: M1 S ('MetaSel "") (K1 R (UserTree a)) + :*: M1 S ('MetaSel "") (K1 R (UserTree a))) + :+: M1 C ('MetaCons "Leaf" 'PrefixI 'False) U1) -- Conversion functions from (Node x l r) = M1 (L1 (M1 (M1 (K1 x) :*: M1 (K1 l) :*: M1 (K1 r)))) from Leaf = M1 (R1 (M1 U1)) to (M1 (L1 (M1 (M1 (K1 x) :*: M1 (K1 l) :*: M1 (K1 r))))) = Node x l r to (M1 (R1 (M1 U1))) = Leaf - --- Meta-information -data D1UserTree -data C1_0UserTree -data C1_1UserTree - -instance Datatype D1UserTree where - datatypeName _ = "UserTree" - moduleName _ = "Main" - -instance Constructor C1_0UserTree where - conName _ = "Node" - -instance Constructor C1_1UserTree where - conName _ = "Leaf" </programlisting> This representation is generated automatically if a |