0 | module Data.Container.Base.Extension.Instances
5 | import Data.Container.Base.Object.Definition
6 | import Data.Container.Base.Extension.Definition
7 | import Data.Container.Base.Properties.Definitions
9 | import Data.Container.Base.Object.Instances
16 | namespace ExtensionsOfMainExamples
19 | Scalar' : Type -> Type
20 | Scalar' = Ext Scalar
24 | Pair' : Type -> Type
29 | Either' : Type -> Type
30 | Either' = Ext Either
34 | Maybe' : Type -> Type
39 | List' : Type -> Type
44 | Vect' : (n : Nat) -> Type -> Type
45 | Vect' n = Ext (Vect n)
49 | Stream' : Type -> Type
50 | Stream' = Ext Stream
54 | BinTree' : Type -> Type
55 | BinTree' = Ext BinTree
59 | BinTreeNode' : Type -> Type
60 | BinTreeNode' = Ext BinTreeNode
64 | BinTreeLeaf' : Type -> Type
65 | BinTreeLeaf' = Ext BinTreeLeaf
80 | composeExtensions : List Cont -> Type -> Type
81 | composeExtensions = foldr (\c, f => (Ext c) . f) (Ext Scalar)
83 | namespace ComposeExtensionsVect
85 | composeExtensions : Vect n Cont -> Type -> Type
86 | composeExtensions = foldr @{straightforward} (\c, f => (Ext c) . f) (Ext Scalar)
89 | [fe] {shape : List Cont} -> Functor (composeExtensions shape) where
90 | map {shape = []} f = map f
91 | map {shape = (s :: ss)} f = (map @{fe} f <$>)
94 | EmptyExt : {0 c : Cont} -> IsNaperian c => Ext c Unit
95 | EmptyExt @{MkIsNaperian _} = () <| \_ => ()
98 | liftA2ConstCont : IsNaperian c => Ext c a -> Ext c b -> Ext c (a, b)
99 | liftA2ConstCont @{MkIsNaperian _} ea eb = () <| (\x => (index ea x, index eb x))
105 | IsNaperian c => Applicative (Ext c) where
106 | pure @{MkIsNaperian _} a = () <| \_ => a
107 | (<*>) fs xs @{MkIsNaperian _} = uncurry ($) <$> liftA2ConstCont fs xs
114 | positionsCont : {0 c : Cont} -> {sh : c.Shp} -> Ext c (c.Pos sh)
115 | positionsCont = sh <| id
121 | set : {0 c : Cont} -> InterfaceOnPositions c Eq =>
122 | (e : Ext c x) -> c.Pos (shapeExt e) -> x -> Ext c x
123 | set {c=(s !> p)} @{MkI _} (sh <| contentAt) i x
124 | = sh <| updateAt contentAt (i, x)