on 97d89cf help sign in
29 lines 646 B history raw
1{-# language DataKinds #-}
2{-# language StandaloneKindSignatures #-}
3{-# language TypeFamilies #-}
4{-# language TypeOperators #-}
6module Rel8.Generic.Map
7 ( GMap
8 )
9where
11-- base
12import Data.Kind ( Type )
13import GHC.Generics
14 ( (:+:), (:*:), K1, M1, U1, V1
15 )
16import Prelude ()
18-- rel8
19import Rel8.FCF ( Eval, Exp )
22type GMap :: (Type -> Exp Type) -> (Type -> Type) -> Type -> Type
23type family GMap f rep where
24 GMap f (M1 i c rep) = M1 i c (GMap f rep)
25 GMap _ V1 = V1
26 GMap f (rep1 :+: rep2) = GMap f rep1 :+: GMap f rep2
27 GMap _ U1 = U1
28 GMap f (rep1 :*: rep2) = GMap f rep1 :*: GMap f rep2
29 GMap f (K1 i a) = K1 i (Eval (f a))