0 | module Data.Container.Base.Extension.Instances
5 | import Data.Container.Base.Object.Definition
6 | import Data.Container.Base.Object.Instances
7 | import Data.Container.Base.Extension.Definition
14 | namespace ExtensionsOfMainExamples
17 | Scalar' : Type -> Type
18 | Scalar' = Ext Scalar
22 | Pair' : Type -> Type
27 | Either' : Type -> Type
28 | Either' = Ext Either
32 | Maybe' : Type -> Type
37 | List' : Type -> Type
42 | Vect' : (n : Nat) -> Type -> Type
43 | Vect' n = Ext (Vect n)
47 | Stream' : Type -> Type
48 | Stream' = Ext Stream
52 | BinTree' : Type -> Type
53 | BinTree' = Ext BinTree
57 | BinTreeNode' : Type -> Type
58 | BinTreeNode' = Ext BinTreeNode
62 | BinTreeLeaf' : Type -> Type
63 | BinTreeLeaf' = Ext BinTreeLeaf
78 | composeExtensions : List Cont -> Type -> Type
79 | composeExtensions = foldr (\c, f => (Ext c) . f) (Ext Scalar)
81 | namespace ComposeExtensionsVect
83 | composeExtensions : Vect n Cont -> Type -> Type
84 | composeExtensions = foldr @{straightforward} (\c, f => (Ext c) . f) (Ext Scalar)
87 | [fe] {shape : List Cont} -> Functor (composeExtensions shape) where
88 | map {shape = []} f = map f
89 | map {shape = (s :: ss)} f = (map @{fe} f <$>)
92 | EmptyExt : {0 c : Cont} -> IsNaperian c => Ext c Unit
93 | EmptyExt @{MkIsNaperian _} = () <| \_ => ()
96 | liftA2ConstCont : IsNaperian c => Ext c a -> Ext c b -> Ext c (a, b)
97 | liftA2ConstCont @{MkIsNaperian _} ea eb = () <| (\x => (index ea x, index eb x))
103 | IsNaperian c => Applicative (Ext c) where
104 | pure @{MkIsNaperian _} a = () <| \_ => a
105 | (<*>) fs xs @{MkIsNaperian _} = uncurry ($) <$> liftA2ConstCont fs xs
112 | positionsCont : {0 c : Cont} -> {sh : c.Shp} -> Ext c (c.Pos sh)
113 | positionsCont = sh <| id