Skip to content

Commit b031881

Browse files
committed
[fix] changed container record fields to start with uppercase
1 parent 484e22c commit b031881

File tree

11 files changed

+54
-49
lines changed

11 files changed

+54
-49
lines changed

src/Architectures/Transformer/Attention.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ causalMask : {a : Type} -> Num a =>
8181
AllApplicative [c] =>
8282
CTensor [c, c] a -> CTensor [c, c] a
8383
causalMask attentionMatrix =
84-
let contShape : c.shp
84+
let contShape : c.Shp
8585
contShape = shapeExt (shapeExt (GetT attentionMatrix))
8686
in maskedFill attentionMatrix (not <$> cTriBool contShape) minusInfinity

src/Data/Container/Applicative/Definition.idr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public export prefix 0 #
2424

2525
||| Convenience functions so we dont have to keep writing GetC
2626
public export
27-
(.shp) : ContA -> Type
28-
(.shp) c = (GetC c) .shp
27+
(.Shp) : ContA -> Type
28+
(.Shp) c = (GetC c) .Shp
2929

3030
public export
31-
(.pos) : (c : ContA) -> c.shp -> Type
32-
(.pos) c sh = (GetC c) .pos sh
31+
(.Pos) : (c : ContA) -> c.Shp -> Type
32+
(.Pos) c sh = (GetC c) .Pos sh
3333

3434
-- alternative method of using applicative instances, not sure yet if this is better
3535
public export
@@ -55,9 +55,9 @@ oneToTwoAppl @{Cons} = Cons
5555
-- composeExtensionsA conts a -> Ext (composeContainersA conts) a
5656
-- ToContainerComp {conts = []} ce = ce
5757
-- ToContainerComp {conts = [c]} ce = ce
58-
-- ToContainerComp {conts = (c :: d :: cs)} (shp <| idx) =
58+
-- ToContainerComp {conts = (c :: d :: cs)} (Shp <| idx) =
5959
-- let rst = (ToContainerComp {conts=(d :: cs)}) . idx
60-
-- in (shp <| shapeExt . rst) <| (\(cp ** fsh) => index (rst cp) fsh)
60+
-- in (Shp <| shapeExt . rst) <| (\(cp ** fsh) => index (rst cp) fsh)
6161

6262
-- public export
6363
-- FromContainerComp : {conts : List ContA} ->
@@ -128,13 +128,13 @@ oneToTwoAppl @{Cons} = Cons
128128
-- ||| Hence, just like with EmptyExt we provide convenience functions to create this unit shape easily
129129
-- public export
130130
-- emptyShapeCubicalTensor : {shape : List Nat} ->
131-
-- (composeContainersA (Vect <$> shape)) .shp
131+
-- (composeContainersA (Vect <$> shape)) .Shp
132132
-- emptyShapeCubicalTensor {shape = []} = ()
133133
-- emptyShapeCubicalTensor {shape = (_ :: _)}
134134
-- = () <| (\_ => emptyShapeCubicalTensor)
135135

136136
-- shapeOfCubicalTensorIsUnit : {shape : List Nat} ->
137-
-- (composeContainersA (Vect <$> shape)) .shp = ()
137+
-- (composeContainersA (Vect <$> shape)) .Shp = ()
138138
-- shapeOfCubicalTensorIsUnit {shape = []} = Refl
139139
-- shapeOfCubicalTensorIsUnit {shape = (s :: ss)}
140140
-- = rewrite shapeOfCubicalTensorIsUnit {shape = ss} in ?afasdf

src/Data/Container/Extension/Definition.idr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import Misc
1111
public export
1212
record Ext (c : Cont) (x : Type) where
1313
constructor (<|)
14-
shapeExt : c.shp
15-
index : c.pos shapeExt -> x
14+
shapeExt : c.Shp
15+
index : c.Pos shapeExt -> x
1616

1717
||| Container c can be said to be "full off" a type x
1818
||| `fullOf` is sometimes used as infix operator to aid readability
@@ -33,7 +33,7 @@ Functor ((Ext d) . (Ext c)) where
3333
||| Container setter
3434
public export
3535
set : {c : Cont} -> InterfaceOnPositions c Eq =>
36-
(e : Ext c x) -> c.pos (shapeExt e) -> x -> Ext c x
36+
(e : Ext c x) -> c.Pos (shapeExt e) -> x -> Ext c x
3737
set {c=(s !> p)} @{MkI} (sh <| contentAt) i x
3838
= sh <| updateAt contentAt (i, x)
3939

@@ -48,7 +48,7 @@ namespace ExtProofs
4848
public export
4949
mapIndexCont : {0 f : a -> b} -> {c : Cont} ->
5050
(l : c `fullOf` a) ->
51-
(ps : c.pos (shapeExt (f <$> l))) ->
51+
(ps : c.Pos (shapeExt (f <$> l))) ->
5252
f (index l (rewrite sym (mapShapeExt {f=f} l) in ps))
5353
= index (f <$> l) ps
5454
mapIndexCont {c=shp !> pos} (sh <| contentAt) ps = Refl
@@ -68,9 +68,9 @@ namespace EqExt
6868
shapesEqual : e1.shapeExt = e2.shapeExt
6969
||| For each position in that shape, the values must be equal
7070
||| Relying on rewrite to get the correct type for the position
71-
valuesEqual : (p : c.pos (e1.shapeExt)) ->
71+
valuesEqual : (p : c.Pos (e1.shapeExt)) ->
7272
e1.index p =
73-
e2.index (rewrite__impl (c.pos) (sym shapesEqual) p)
73+
e2.index (rewrite__impl (c.Pos) (sym shapesEqual) p)
7474
{-
7575
Another alternative is to use DecEq, and a different explicit rewrite
7676
-}

src/Data/Container/Extension/Instances.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ public export
113113
||| The definition in Data.Functor.positions is for Naperian containers
114114
||| i.e. containers with a unit shape
115115
public export
116-
positionsCont : {sh : c.shp} -> Ext c (c.pos sh)
116+
positionsCont : {sh : c.Shp} -> Ext c (c.Pos sh)
117117
positionsCont = sh <| id

src/Data/Container/Morphism/Definition.idr

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,24 @@ namespace DependentLenses
2424
public export
2525
record (=%>) (c1, c2 : Cont) where
2626
constructor (<%!)
27-
fwd : c1.shp -> c2.shp
28-
bwd : (x : c1.shp) -> c2.pos (fwd x) -> c1.pos x
27+
fwd : c1.Shp -> c2.Shp
28+
bwd : (x : c1.Shp) -> c2.Pos (fwd x) -> c1.Pos x
2929

3030
%name (=%>) f, g, h
3131

3232

3333
||| Constructor for closed dependent lens
3434
public export
3535
(!%) : {0 c1, c2 : Cont} ->
36-
((x : c1.shp) -> (y : c2.shp ** (c2.pos y -> c1.pos x))) ->
36+
((x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))) ->
3737
c1 =%> c2
3838
(!%) f = (\x => fst (f x)) <%! (\x => snd (f x))
39+
40+
public export
41+
(%!) : {0 c1, c2 : Cont} ->
42+
(f : c1 =%> c2) ->
43+
(x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))
44+
(%!) f x = (f.fwd x ** f.bwd x)
3945

4046
||| Composition of dependent lenses
4147
public export
@@ -58,14 +64,14 @@ namespace DependentCharts
5864
public export
5965
record (=&>) (c1, c2 : Cont) where
6066
constructor (<&!)
61-
fwd : c1.shp -> c2.shp
62-
fwd' : (x : c1.shp) -> c1.pos x -> c2.pos (fwd x)
67+
fwd : c1.Shp -> c2.Shp
68+
fwd' : (x : c1.Shp) -> c1.Pos x -> c2.Pos (fwd x)
6369

6470

6571
||| Constructor for closed dependent chart
6672
public export
6773
(!&) : {0 c1, c2 : Cont} ->
68-
((x : c1.shp) -> (y : c2.shp ** (c1.pos x -> c2.pos y))) ->
74+
((x : c1.Shp) -> (y : c2.Shp ** (c1.Pos x -> c2.Pos y))) ->
6975
c1 =&> c2
7076
(!&) f = (\x => fst (f x)) <&! (\x => snd (f x))
7177

@@ -102,7 +108,7 @@ valContMap {c1=(shp !> pos)} {c2=(shp' !> pos')} (fwd <&! fwd')
102108
-- public export
103109
-- record (~%>) (c1, c2 : ContF R) where
104110
-- constructor (<~!)
105-
-- fwd' : c1.shp' -> c2.shp'
111+
-- fwd' : c1.Shp' -> c2.Shp'
106112

107113

108114
-- upd : c1 ~%> c2 ->

src/Data/Container/Object/Definition.idr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ module Data.Container.Object.Definition
22

33
||| Containers capture the idea that datatypes consist of memory locations where
44
||| data can be stored. Each memory location is a one 'shape' of data, and
5-
||| there are `shp : Type` many of them. These locations are usually referred
5+
||| there are `Shp : Type` many of them. These locations are usually referred
66
||| to as 'positions'
77
public export
88
record Cont where
99
constructor (!>)
1010
||| A type of shapes
11-
shp : Type
11+
Shp : Type
1212
||| For each shape, a set of positions
13-
pos : shp -> Type
13+
Pos : Shp -> Type
1414

1515
export typebind infixr 0 !>
1616

@@ -20,6 +20,6 @@ export typebind infixr 0 !>
2020
||| a container `c` has an interface `i` on its positions
2121
public export
2222
data InterfaceOnPositions : (c : Cont) -> (i : Type -> Type) -> Type where
23-
||| For every shape s the set of positions c.pos s has that interface
24-
MkI : (p : (s : c.shp) -> i (c.pos s)) =>
23+
||| For every shape s the set of positions c.Pos s has that interface
24+
MkI : (p : (s : c.Shp) -> i (c.Pos s)) =>
2525
InterfaceOnPositions c i

src/Data/Container/Object/Instances.idr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ Tensor = foldr (>@) Scalar
108108
public export
109109
InternalLens : Cont -> Cont -> Cont
110110
InternalLens c d
111-
= (f : ((x : c.shp) -> (y : d.shp ** d.pos y -> c.pos x)))
112-
!> (xx : c.shp ** d.pos (fst (f xx)))
111+
= (f : ((x : c.Shp) -> (y : d.Shp ** d.Pos y -> c.Pos x)))
112+
!> (xx : c.Shp ** d.Pos (fst (f xx)))
113113

114114
||| From https://www.cs.ox.ac.uk/people/samuel.staton/papers/cie10.pdf
115115
public export
116116
CartesianClosure : Cont -> Cont -> Cont
117117
CartesianClosure c d
118-
= (f : ((x : c.shp) -> (y : d.shp ** d.pos y -> Maybe (c.pos x))))
119-
!> (xx : c.shp ** yy' : d.pos (fst (f xx)) ** ?cartesianClosureImpl)
118+
= (f : ((x : c.Shp) -> (y : d.Shp ** d.Pos y -> Maybe (c.Pos x))))
119+
!> (xx : c.Shp ** yy' : d.Pos (fst (f xx)) ** ?cartesianClosureImpl)
120120

121121
||| Constant container, positions do not depend on shapes
122122
||| Some of the above containers can be refactored in terms of these

src/Data/Container/Products.idr

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ public export infixr 0 >@
1616
||| Categorical product of containers
1717
public export
1818
(>*<) : Cont -> Cont -> Cont
19-
(shp !> pos) >*< (shp' !> pos')
20-
= ((s, s') : (shp, shp')) !> Either (pos s) (pos' s')
19+
c1 >*< c2 = ((s, s') : (c1.Shp, c2.Shp)) !> (c1.Pos s, c2.Pos s')
2120

2221
||| Non-categorical product of containers, often also called
23-
||| 'Hancock' (Scotland), 'Dirichlet' (Spivak ), or 'Tensor product' (various)
22+
||| 'Hancock' (Scotland), 'Dirichlet' (Spivak), or 'Tensor product' (various)
2423
||| Monoid with CUnit
2524
public export
2625
(><) : Cont -> Cont -> Cont
27-
(shp !> pos) >< (shp' !> pos') = ((s, s') : (shp, shp')) !> (pos s, pos' s')
26+
c1 >< c2 = ((s, s') : (c1.Shp, c2.Shp)) !> (c1.Pos s, c2.Pos s')
2827

2928

3029
||| Coproduct of containers
@@ -39,19 +38,19 @@ public export
3938
||| Monoid with Scalar
4039
public export
4140
(>@) : Cont -> Cont -> Cont
42-
c >@ d = (ex : Ext c d.shp) !> (cp : c.pos (shapeExt ex) ** d.pos (index ex cp))
41+
c >@ d = (ex : Ext c d.Shp) !> (cp : c.Pos (shapeExt ex) ** d.Pos (index ex cp))
4342

4443
public export infixr 0 @>
4544

4645
||| Diagrammatic composition of containers
4746
public export
4847
(@>) : Cont -> Cont -> Cont
49-
c @> d = (ex : Ext d c.shp) !> (dp : d.pos (shapeExt ex) ** c.pos (index ex dp))
48+
c @> d = (ex : Ext d c.Shp) !> (dp : d.Pos (shapeExt ex) ** c.Pos (index ex dp))
5049

5150

5251
||| Derivative of a container
53-
||| Given c=(shp !> pos) the derivative can be thought of as
54-
||| a shape s : shp, a distinguished position p : pos s, and the set of *all other positions*
52+
||| Given c=(Shp !> pos) the derivative can be thought of as
53+
||| a shape s : Shp, a distinguished position p : pos s, and the set of *all other positions*
5554
public export
5655
Deriv : (c : Cont) ->
5756
InterfaceOnPositions c DecEq =>

src/Data/Container/TreeUtils.idr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ namespace ApplicativeRoseTree
166166
AtNode : {ts : (GetC c) `fullOf` (RoseTreeShape c)} ->
167167
RoseTreePos c (NodeS ts)
168168
SubTree : {ts : (GetC c) `fullOf` (RoseTreeShape c)} ->
169-
(ps : c.pos (shapeExt ts)) -> -- position in a given list
169+
(ps : c.Pos (shapeExt ts)) -> -- position in a given list
170170
RoseTreePos c (index ts ps) -> -- position in the shape of RoseTree at a location specified by ps
171171
RoseTreePos c (NodeS ts)
172172

@@ -176,7 +176,7 @@ namespace ApplicativeRoseTree
176176
AtNode : {ts : (GetC c) `fullOf` (RoseTreeShape c)} ->
177177
RoseTreePosNode c (NodeS ts)
178178
SubTree : {ts : (GetC c) `fullOf` (RoseTreeShape c)} ->
179-
(ps : c.pos (shapeExt ts)) -> -- position in a given list
179+
(ps : c.Pos (shapeExt ts)) -> -- position in a given list
180180
RoseTreePosNode c (index ts ps) -> -- position in the sub-tree at the above defined position
181181
RoseTreePosNode c (NodeS ts)
182182

@@ -185,7 +185,7 @@ namespace ApplicativeRoseTree
185185
data RoseTreePosLeaf : (c : ContA) -> (t : RoseTreeShape c) -> Type where
186186
AtLeaf : RoseTreePosLeaf c LeafS
187187
SubTree : {ts : (GetC c) `fullOf` (RoseTreeShape c)} ->
188-
(ps : c.pos (shapeExt ts)) -> -- position in a given list
188+
(ps : c.Pos (shapeExt ts)) -> -- position in a given list
189189
RoseTreePosLeaf c (index ts ps) -> -- position in the sub-tree at the above defined position
190190
RoseTreePosLeaf c (NodeS ts)
191191

src/Data/Tensor/Tensor.idr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ namespace TensorInstances
555555
||| Naperian instance here
556556
public export
557557
positions : {c : Cont} ->
558-
{sh : c.shp} -> CTensor [c] (c.pos sh)
558+
{sh : c.Shp} -> CTensor [c] (c.Pos sh)
559559
positions = extToVector positionsCont
560560

561561
namespace ShowInstance
@@ -771,7 +771,7 @@ namespace SetterGetter
771771
data Index : (shape : List Cont) -> (t : CTensor shape dtype) -> Type where
772772
Nil : {val : dtype} -> Index [] (embed val)
773773
(::) : {t : CTensor (c :: cs) dtype} ->
774-
(p : c.pos (shapeExt (extractTopExt t))) ->
774+
(p : c.Pos (shapeExt (extractTopExt t))) ->
775775
Index cs (index (extractTopExt t) p) ->
776776
Index (c :: cs) t
777777

0 commit comments

Comments
 (0)