1
------------------------------------------------------------------------
2
-- The Agda standard library
4
-- Applicative functors on indexed sets (predicates)
5
------------------------------------------------------------------------
7
-- Note that currently the applicative functor laws are not included
10
module Category.Applicative.Predicate where
12
open import Category.Functor.Predicate
13
open import Data.Product
16
open import Relation.Unary
17
open import Relation.Unary.PredicateTransformer using (Pt)
19
------------------------------------------------------------------------
21
record RawPApplicative {i ℓ} {I : Set i} (F : Pt I ℓ) :
23
infixl 4 _⊛_ _<⊛_ _⊛>_
27
pure : ∀ {P} → P ⊆ F P
28
_⊛_ : ∀ {P Q} → F (P ⇒ Q) ⊆ F P ⇒ F Q
30
rawPFunctor : RawPFunctor F
32
{ _<$>_ = λ g x → pure g ⊛ x
36
open module RF = RawPFunctor rawPFunctor public
38
_<⊛_ : ∀ {P Q} → F P ⊆ const (∀ {j} → F Q j) ⇒ F P
39
x <⊛ y = const <$> x ⊛ y
41
_⊛>_ : ∀ {P Q} → const (∀ {i} → F P i) ⊆ F Q ⇒ F Q
42
x ⊛> y = flip const <$> x ⊛ y
44
_⊗_ : ∀ {P Q} → F P ⊆ F Q ⇒ F (P ∩ Q)
45
x ⊗ y = (_,_) <$> x ⊛ y
47
zipWith : ∀ {P Q R} → (P ⊆ Q ⇒ R) → F P ⊆ F Q ⇒ F R
48
zipWith f x y = f <$> x ⊛ y