← Back

Modules

Leios

  • Abstract
  • Base
  • Blocks
  • Config
  • Defaults
  • FFD
  • Foreign.BaseTypes
  • Foreign.HsTypes
  • Foreign.Types
  • Foreign.Util
  • KeyRegistration
  • Network
  • Prelude
  • Protocol
  • Short
  • Short.Decidable
  • Short.Trace.Verifier
  • Short.Trace.Verifier.Test
  • Simplified
  • Simplified.Deterministic
  • SpecStructure
  • Traces
  • Voting
  • VRF
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
{-# OPTIONS --without-K #-}
module Class.Applicative.Core where
 
open import Class.Prelude
open import Class.Core
open import Class.Functor.Core
 
record Applicative (F : Type↑) : Typeω where
infixl 4 _<*>_ _⊛_ _<*_ _<⊛_ _*>_ _⊛>_
infix 4 _⊗_
 
field
overlap ⦃ super ⦄ : Functor F
pure : A → F A
_<*>_ : F (A → B) → F A → F B
_⊛_ = _<*>_
 
_<*_ : F A → F B → F A
x <* y = const <$> x ⊛ y
 
_*>_ : F A → F B → F B
x *> y = constᵣ <$> x ⊛ y
 
_<⊛_ = _<*_; _⊛>_ = _*>_
 
_⊗_ : F A → F B → F (A × B)
x ⊗ y = (_,_) <$> x ⊛ y
 
zipWithA : (A → B → C) → F A → F B → F C
zipWithA f x y = f <$> x ⊛ y
 
zipA : F A → F B → F (A × B)
zipA = zipWithA _,_
 
open Applicative ⦃...⦄ public
 
record Applicative₀ (F : Type↑) : Typeω where
field
overlap ⦃ super ⦄ : Applicative F
ε₀ : F A
open Applicative₀ ⦃...⦄ public
 
record Alternative (F : Type↑) : Typeω where
infixr 3 _<|>_
field _<|>_ : F A → F A → F A
open Alternative ⦃...⦄ public
 
infix -1 ⋃⁺_ ⋃_
 
⋃⁺_ : ⦃ Alternative F ⦄ → List⁺ (F A) → F A
⋃⁺_ = foldr₁ _<|>_
 
⋃_ : ⦃ Applicative₀ F ⦄ → ⦃ Alternative F ⦄ → List (F A) → F A
⋃_ = foldr _<|>_ ε₀