projects
/
ghc-prim.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f7c04d8
)
Use type families
author
jpm@cs.uu.nl
<unknown>
Wed, 15 Dec 2010 10:08:25 +0000
(10:08 +0000)
committer
jpm@cs.uu.nl
<unknown>
Wed, 15 Dec 2010 10:08:25 +0000
(10:08 +0000)
GHC/Generics.hs
patch
|
blob
|
history
diff --git
a/GHC/Generics.hs
b/GHC/Generics.hs
index
7f5b86f
..
cf61c6c
100644
(file)
--- a/
GHC/Generics.hs
+++ b/
GHC/Generics.hs
@@
-20,6
+20,7
@@
data (:*:) a b = a :*: b
{-# OPTIONS_GHC -XTypeSynonymInstances #-}
{-# OPTIONS_GHC -XTypeOperators #-}
{-# OPTIONS_GHC -XKindSignatures #-}
{-# OPTIONS_GHC -XTypeSynonymInstances #-}
{-# OPTIONS_GHC -XTypeOperators #-}
{-# OPTIONS_GHC -XKindSignatures #-}
+{-# OPTIONS_GHC -XTypeFamilies #-}
module GHC.Generics (
-- * Generic representation types
module GHC.Generics (
-- * Generic representation types
@@
-34,6
+35,9
@@
module GHC.Generics (
, Datatype(..), Constructor(..), Selector(..), NoSelector
, Fixity(..), Associativity(..), Arity(..), prec
, Datatype(..), Constructor(..), Selector(..), NoSelector
, Fixity(..), Associativity(..), Arity(..), prec
+ -- * Representation type families
+ , Rep0, Rep1
+
-- * Representable type classes
, Representable0(..), Representable1(..)
-- * Representable type classes
, Representable0(..), Representable1(..)
@@
-171,18
+175,22
@@
data Associativity = LeftAssociative
-- | Representable types of kind *
-- | Representable types of kind *
-class Representable0 a rep where
+class Representable0 a where
+ -- | Representation type
+ type Rep0 a :: * -> *
-- | Convert from the datatype to its representation
-- | Convert from the datatype to its representation
- from0 :: a -> rep x
+ from0 :: a -> Rep0 a x
-- | Convert from the representation to the datatype
-- | Convert from the representation to the datatype
- to0 :: rep x -> a
+ to0 :: Rep0 a x -> a
-- | Representable types of kind * -> *
class Representable1 f rep where
-- | Representable types of kind * -> *
class Representable1 f rep where
+ -- | Representation type
+ type Rep1 f :: * -> *
-- | Convert from the datatype to its representation
-- | Convert from the datatype to its representation
- from1 :: f a -> rep a
+ from1 :: f a -> Rep1 f a
-- | Convert from the representation to the datatype
-- | Convert from the representation to the datatype
- to1 :: rep a -> f a
+ to1 :: Rep1 f a -> f a
--------------------------------------------------------------------------------
-- Representation for base types
--------------------------------------------------------------------------------
-- Representation for base types