0 | module Control.ApplicativeB
2 | import Control.FunctorB
7 | interface FunctorB k t => ApplicativeB k t | t where
8 | constructor MkApplicativeB
9 | bpure_ : {0 f : _} -> ((0 a : k) -> f a) -> t f
11 | bprod : {0 f,g : _} -> t f -> t g -> t (\x => (f x, g x))
14 | bpure : {0 f : _} -> ApplicativeB k t => ({0 a : k} -> f a) -> t f
15 | bpure fun = bpure_ (\_ => fun)
17 | public export %inline
18 | bempty : {0 g : k -> Type} -> Alternative f => ApplicativeB k t => t (f . g)
19 | bempty = bpure empty
24 | -> {auto app : ApplicativeB k t}
25 | -> ({0 a : k} -> f a -> g a -> h a)
29 | bzipWith fun tf tg = bmap (\(x,y) => fun x y) $
bprod tf tg
34 | -> {auto app : ApplicativeB k t}
35 | -> ({0 a : k} -> f a -> g a -> h a -> i a)
40 | bzipWith3 fun tf tg th = bmap (\(x,y,z) => fun x y z) $
bprod tf (bprod tg th)
43 | public export %inline
44 | pure : {0 f : _} -> ApplicativeB k t => ({0 a : k} -> f a) -> t f
49 | {auto app : ApplicativeB k t}
50 | -> {0 f,g : k -> Type}
51 | -> t (\x => f x -> g x)
54 | (<*>) x y = bzipWith id x y