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
91 | IndexedCont : Cont -> Type
92 | IndexedCont c = c.Shp -> Cont
95 | ContDPair : {a : Cont} -> IndexedCont a -> Cont
96 | ContDPair a' = ((
x ** t)
: DPair a.Shp (Shp . a')) !> (a' x).Pos t
99 | ContProbDPair : {a : Cont} -> IndexedCont a -> Cont
100 | ContProbDPair a' = (((x, d) ** t) : DPair (a.Shp, Double) (Shp . a' . fst)) !>
105 | IndexedAddCont : AddCont -> Type
106 | IndexedAddCont c = c.Shp -> AddCont
109 | AddContDPair : {a : AddCont} -> IndexedAddCont a -> AddCont
110 | AddContDPair a' = MkAddCont
111 | (((
x ** t)
: DPair a.Shp ((.Shp) . a')) !> (a' x).Pos t)
112 | {mon=(?MonDPairAddCont
)}
116 | AddContDFunFinite : {n : Nat} -> (Fin n -> AddCont) -> AddCont
117 | AddContDFunFinite {n = 0} i = Scalar
118 | AddContDFunFinite {n = (S k)} i = i 0 >< AddContDFunFinite (i . FS)
121 | indexShp : {n : Nat} -> {i : Fin n -> AddCont} ->
123 | (AddContDFunFinite i).Shp -> (i j).Shp
124 | indexShp {n = (S k)} FZ (s, _) = s
125 | indexShp {n = (S k)} {i} (FS y) (_, ss) = indexShp {i=i . FS} y ss
128 | AddContDFunction : {a : AddCont} -> IndexedAddCont a -> AddCont
129 | AddContDFunction a' = MkAddCont
130 | ((s : (x : a.Shp) -> (a' x).Shp) !> ((x : a.Shp) -> (a' x).Pos (s x)))
131 | {mon=(?MonDFunctionAddCont
)}
145 | ContDPairSimple : (c : Cont) -> IndexedCont c -> Cont
146 | ContDPairSimple c fam =
147 | (st : (s : c.Shp ** (fam s).Shp)) !>
148 | (fam (fst st)).Pos (snd st)
161 | ContDFun : (c : Cont) -> IndexedCont c -> Cont
163 | (f : ((s : c.Shp) -> (fam s).Shp)) !>
164 | (s : c.Shp ** (p : c.Pos s ** (fam s).Pos (f s)))
172 | constFam : {c : Cont} -> Cont -> IndexedCont c
173 | constFam d = \_ => d
177 | trivialFam : {c : Cont} -> IndexedCont c
178 | trivialFam = \_ => ((_ : ()) !> Void)
182 | boolFam : {c : Cont} -> IndexedCont c
183 | boolFam = \_ => ((_ : Bool) !> Void)