5 | ||| Containers capture the idea that datatypes consist of groups of memory
6 | ||| locations where data can be stored. Locations for a particular group are
7 | ||| referred to as 'positions' and a particular group is referred to as a
8 | ||| 'shape'.
12 | ||| A type of shapes
14 | ||| For each shape, a set of positions
21 | ||| Constant container, one where positions do not depend on shapes
26 | ||| Constant container, one where positions do not depend on shapes
31 | ||| Naperian container: a constant container with a single shape
36 | ||| Convenience datatype for storing the data that a container `c` has an
37 | ||| interface `i` on its positions
38 | ||| TODO does the argument of MkI need to be auto implicit?
41 | ||| For every shape `s` the set of positions `c.Pos s` has that interface
45 | ||| A container is finite when for every shape the set of positions is finite.
46 | ||| Examples: vectors, lists, but also finite binary trees.
47 | ||| Note, provision of a finite instance for trees requires a choice of a tree
48 | ||| traversal. (All of these choices isomorphic, but are necessary to make)
53 | ||| A container is Naperian when the set of shapes is `Unit`, i.e. when it
54 | ||| contains only one set of positions.
55 | ||| Examples: Scalar, UnitCont, Pair, Vect n, Stream.
56 | ||| Notably, Naperian does not imply Finite, as the `Stream` example shows.
69 | -- ||| If we have a Naperian container, we can always produce (the unique)
70 | -- ||| inhabitant of it shape
71 | -- public export
72 | -- naperianShape : IsNaperian c => c.Shp
73 | -- naperianShape @{(MkIsNaperian pos)} = ()
74 | --
79 | ||| A container is cubical whenever it is Finite and Naperian
80 | ||| Effectively, captures `Vect n` containers, up to isomorphism
81 | ||| Examples: for any `n : Nat`, `Vect n`. Those are all the examples, up to
82 | ||| isomorphism. Notably, this also includes a container whose unique set of
83 | ||| positions is the set of positions of a binary tree of a particular shape.
84 | ||| This is isomorphic to the `Vect k` container, for some `k`, assuming a
85 | ||| choice of tree traversal (though all of them yield the same `k`). Here
86 | ||| `k` corresponds to the number of positions in that binary tree
95 | ||| We call dimension the size of the set of positions of a finite container
101 | ||| Used in learning, where we want to know that the tangent space over a
102 | ||| particular parameter is equal to the parameter space itself