1{-# language AllowAmbiguousTypes #-}
2{-# language DataKinds #-}
3{-# language EmptyCase #-}
4{-# language FlexibleInstances #-}
5{-# language LambdaCase #-}
6{-# language MultiParamTypeClasses #-}
7{-# language RankNTypes #-}
8{-# language ScopedTypeVariables #-}
9{-# language StandaloneKindSignatures #-}
10{-# language TypeApplications #-}
11{-# language TypeFamilies #-}
12{-# language TypeOperators #-}
13{-# language UndecidableInstances #-}
15module Rel8.Generic.Map
16 ( GMap, GMappable (gmap, gunmap)
21import Data.Kind ( Constraint, Type )
23 ( (:+:)( L1, R1 ), (:*:)( (:*:) ), K1( K1 ), M1( M1 ), U1( U1 ), V1
28import Rel8.FCF ( Eval, Exp )
31type GMap :: (Type -> Exp Type) -> (Type -> Type) -> Type -> Type
32type family GMap f rep where
33 GMap f (M1 i c rep) = M1 i c (GMap f rep)
35 GMap f (rep1 :+: rep2) = GMap f rep1 :+: GMap f rep2
37 GMap f (rep1 :*: rep2) = GMap f rep1 :*: GMap f rep2
38 GMap f (K1 i a) = K1 i (Eval (f a))
41type GMappable :: (Type -> Exp Constraint) -> (Type -> Type) -> Constraint
42class GMappable constraint rep where
45 -> (forall a. Eval (constraint a) => a -> Eval (f a))
51 -> (forall a. Eval (constraint a) => Eval (f a) -> a)
56instance GMappable constraint rep => GMappable constraint (M1 i c rep) where
57 gmap proxy f (M1 a) = M1 (gmap @constraint proxy f a)
58 gunmap proxy f (M1 a) = M1 (gunmap @constraint proxy f a)
61instance GMappable constraint V1 where
66instance (GMappable constraint rep1, GMappable constraint rep2) =>
67 GMappable constraint (rep1 :+: rep2)
70 L1 a -> L1 (gmap @constraint proxy f a)
71 R1 a -> R1 (gmap @constraint proxy f a)
72 gunmap proxy f = \case
73 L1 a -> L1 (gunmap @constraint proxy f a)
74 R1 a -> R1 (gunmap @constraint proxy f a)
77instance GMappable constraint U1 where
82instance (GMappable constraint rep1, GMappable constraint rep2) =>
83 GMappable constraint (rep1 :*: rep2)
85 gmap proxy f (a :*: b) =
86 gmap @constraint proxy f a :*: gmap @constraint proxy f b
87 gunmap proxy f (a :*: b) =
88 gunmap @constraint proxy f a :*: gunmap @constraint proxy f b
91instance Eval (constraint a) => GMappable constraint (K1 i a) where
92 gmap _ f (K1 a) = K1 (f a)
93 gunmap _ f (K1 a) = K1 (f a)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list