Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
6c0743c4
Commit
6c0743c4
authored
Jan 15, 2013
by
jpm@cs.ox.ac.uk
Browse files
Add Generic instances to GHC.Generics representation types
parent
8564b7f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
libraries/base/GHC/Generics.hs
View file @
6c0743c4
...
...
@@ -63,38 +63,38 @@ data V1 p
-- | Unit: used for constructors without arguments
data
U1
p
=
U1
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Used for marking occurrences of the parameter
newtype
Par1
p
=
Par1
{
unPar1
::
p
}
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Recursive calls of kind * -> *
newtype
Rec1
f
p
=
Rec1
{
unRec1
::
f
p
}
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Constants, additional parameters and recursion of kind *
newtype
K1
i
c
p
=
K1
{
unK1
::
c
}
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Meta-information (constructor names, etc.)
newtype
M1
i
c
f
p
=
M1
{
unM1
::
f
p
}
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Sums: encode choice between constructors
infixr
5
:+:
data
(
:+:
)
f
g
p
=
L1
(
f
p
)
|
R1
(
g
p
)
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Products: encode multiple arguments to constructors
infixr
6
:*:
data
(
:*:
)
f
g
p
=
f
p
:*:
g
p
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Composition of functors
infixr
7
:.:
newtype
(
:.:
)
f
g
p
=
Comp1
{
unComp1
::
f
(
g
p
)
}
deriving
(
Eq
,
Read
,
Show
)
deriving
(
Eq
,
Read
,
Show
,
Generic
)
-- | Tag for K1: recursion (of kind *)
data
R
...
...
@@ -159,12 +159,12 @@ class Constructor c where
-- | Datatype to represent the arity of a tuple.
data
Arity
=
NoArity
|
Arity
Int
deriving
(
Eq
,
Show
,
Ord
,
Read
)
deriving
(
Eq
,
Show
,
Ord
,
Read
,
Generic
)
-- | Datatype to represent the fixity of a constructor. An infix
-- | declaration directly corresponds to an application of 'Infix'.
data
Fixity
=
Prefix
|
Infix
Associativity
Int
deriving
(
Eq
,
Show
,
Ord
,
Read
)
deriving
(
Eq
,
Show
,
Ord
,
Read
,
Generic
)
-- | Get the precedence of a fixity value.
prec
::
Fixity
->
Int
...
...
@@ -175,7 +175,7 @@ prec (Infix _ n) = n
data
Associativity
=
LeftAssociative
|
RightAssociative
|
NotAssociative
deriving
(
Eq
,
Show
,
Ord
,
Read
)
deriving
(
Eq
,
Show
,
Ord
,
Read
,
Generic
)
-- | Representable types of kind *.
-- This class is derivable in GHC with the DeriveGeneric flag on.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment