module Data.MultiGenerics where
import Test.QuickCheck.Gen
newtype Fix (f :: (k -> *) -> k -> *) (ix :: k) = Fix { unFix :: f (Fix f) ix }
data family Sing (a :: k)
class SingI (a :: k) where
sing :: Sing a
class ShowM (f :: k -> *) where
showM :: f ix -> String
class EqM (f :: k -> *) where
eqM :: f ix -> f xi -> Bool
type GenM f = forall ix. Sing ix -> Gen (f ix)
class ArbitraryM (f :: k -> *) where
arbitraryM :: GenM f
class Generic1m (f :: (k -> *) -> k -> *) where
type Rep1m f :: (k -> *) -> k -> *
from1k :: f a ix -> Rep1m f a ix
to1k :: Rep1m f a ix -> f a ix
data V1m p ix
instance Generic1m V1m where
type Rep1m V1m = V1m
from1k = undefined
to1k = undefined
data U1m p ix = U1m
deriving (Eq, Ord, Read, Show)
instance Generic1m U1m where
type Rep1m U1m = U1m
from1k = id
to1k = id
newtype Par1m (xi :: k) (p :: k -> *) (ix :: k)
= Par1m { unPar1m :: p xi }
instance Generic1m (Par1m xi) where
type Rep1m (Par1m xi) = Par1m xi
from1k = id
to1k = id
newtype Rec1m (f :: * -> *) (xi :: k) (p :: k -> *) (ix :: k)
= Rec1m { unRec1m :: f (p xi) }
instance Generic1m (Rec1m f xi) where
type Rep1m (Rec1m f xi) = Rec1m f xi
from1k (Rec1m x) = Rec1m x
to1k (Rec1m x) = Rec1m x
newtype K1m i c p ix = K1m { unK1m :: c }
deriving (Eq, Ord, Read, Show)
instance Generic1m (K1m i c) where
type Rep1m (K1m i c) = K1m i c
from1k = id
to1k = id
infixr 5 :++:
data (:++:) (f :: (k -> *) -> k -> *) (g :: (k -> *) -> k -> *) p ix
= L1m (f p ix) | R1m (g p ix)
deriving (Eq, Ord, Read, Show)
instance (Generic1m f, Generic1m g) => Generic1m (f :++: g) where
type Rep1m (f :++: g) = (f :++: g)
from1k = id
to1k = id
infixr 6 :**:
data (:**:) f g p ix = f p ix :**: g p ix
deriving (Eq, Ord, Read, Show)
instance (Generic1m f, Generic1m g) => Generic1m (f :**: g) where
type Rep1m (f :**: g) = (f :**: g)
from1k = id
to1k = id
data Tag1m (f :: (k -> *) -> k -> *) (xi :: k) (p :: k -> *) (ix :: k) where
Tag1m :: f p ix -> Tag1m f ix p ix
instance Generic1m f => Generic1m (Tag1m f xi) where
type Rep1m (Tag1m f xi) = Tag1m f xi
from1k = id
to1k = id