0 | module Data.CT.Functor.Instances
2 | import Data.CT.Category.Definition
3 | import Data.CT.Category.Instances
4 | import Data.CT.Functor.Definition
6 | import Data.Container.Base
7 | import Data.Container.Additive
11 | id = MkFunctor id id
15 | IndCat : (c : Cat) -> Type
16 | IndCat c = Functor c (opCat Cat)
19 | Const : {c : Cat} -> IndCat c
20 | Const = MkFunctor (\_ => c) (\_ => id)
24 | FamObj : {c : Cat} -> (a : Type) -> Cat
25 | FamObj a = MkCat (a -> c.Obj) (\a', b' => (x : a) -> c.Hom (a' x) (b' x))
28 | FamMor : {c : Cat} ->
29 | {x, y : Type} -> (x -> y) -> Functor (FamObj {c=c} y) (FamObj {c=c} x)
30 | FamMor f = MkFunctor (. f) (\j, xx => j (f xx))
34 | FamIndCat : {c : Cat} -> IndCat TypeCat
35 | FamIndCat = MkFunctor (\a => FamObj {c=c} a) FamMor
39 | Base : Functor DLens TypeCat
40 | Base = MkFunctor Shp (.fwd)
44 | FamDLens : {c : Cat} -> IndCat DLens
45 | FamDLens = composeFunctors Base (FamIndCat {c=c})
49 | AddBase : Functor AddDLens TypeCat
50 | AddBase = MkFunctor (.Shp) (.fwd)
53 | FamAddDLens : {c : Cat} -> IndCat AddDLens
54 | FamAddDLens = composeFunctors AddBase (FamIndCat {c=c})
77 | IndexedType : Type -> Type
78 | IndexedType a = a -> Type
81 | TypeDPair : {a : Type} -> IndexedType a -> Type
82 | TypeDPair fam = (x : a ** fam x)
85 | TypeDFun : {a : Type} -> IndexedType a -> Type
86 | TypeDFun fam = (x : a) -> fam x
90 | IndexedCont : Cont -> Type
91 | IndexedCont c = c.Shp -> Cont
94 | ContDPair : {a : Cont} -> IndexedCont a -> Cont
95 | ContDPair a' = ((
x ** t)
: DPair a.Shp (Shp . a')) !> (a' x).Pos t
98 | ContProbDPair : {a : Cont} -> IndexedCont a -> Cont
99 | ContProbDPair a' = (((x, d) ** t) : DPair (a.Shp, Double) (Shp . a' . fst)) !>
104 | IndexedAddCont : AddCont -> Type
105 | IndexedAddCont c = c.Shp -> AddCont
108 | AddContDPair : {a : AddCont} -> IndexedAddCont a -> AddCont
109 | AddContDPair a' = MkAddCont
110 | (((
x ** t)
: DPair a.Shp ((.Shp) . a')) !> (a' x).Pos t)
111 | {mon=(?MonDPairAddCont
)}
115 | AddContDFunFinite : {n : Nat} -> (Fin n -> AddCont) -> AddCont
116 | AddContDFunFinite {n = 0} i = Scalar
117 | AddContDFunFinite {n = (S k)} i = i 0 >< AddContDFunFinite (i . FS)
120 | indexShp : {n : Nat} -> {i : Fin n -> AddCont} ->
122 | (AddContDFunFinite i).Shp -> (i j).Shp
123 | indexShp {n = (S k)} FZ (s, _) = s
124 | indexShp {n = (S k)} {i} (FS y) (_, ss) = indexShp {i=i . FS} y ss
127 | AddContDFunction : {a : AddCont} -> IndexedAddCont a -> AddCont
128 | AddContDFunction a' = MkAddCont
129 | ((s : (x : a.Shp) -> (a' x).Shp) !> ((x : a.Shp) -> (a' x).Pos (s x)))
130 | {mon=(?MonDFunctionAddCont
)}
144 | ContDPairSimple : (c : Cont) -> IndexedCont c -> Cont
145 | ContDPairSimple c fam =
146 | (st : (s : c.Shp ** (fam s).Shp)) !>
147 | (fam (fst st)).Pos (snd st)
160 | ContDFun : (c : Cont) -> IndexedCont c -> Cont
162 | (f : ((s : c.Shp) -> (fam s).Shp)) !>
163 | (s : c.Shp ** (p : c.Pos s ** (fam s).Pos (f s)))
171 | constFam : {c : Cont} -> Cont -> IndexedCont c
172 | constFam d = \_ => d
176 | trivialFam : {c : Cont} -> IndexedCont c
177 | trivialFam = \_ => ((_ : ()) !> Void)
181 | boolFam : {c : Cont} -> IndexedCont c
182 | boolFam = \_ => ((_ : Bool) !> Void)
198 | ContUniverse : Cont
199 | ContUniverse = (t : Type) !> t
204 | famFromChart : (c : Cont) -> (f : c =&> ContUniverse) -> IndexedCont c
205 | famFromChart c f = \s => ((_ : f.fwd s) !> Void)