The Functor
typeclass only contains the operations of a functor.
LawfulFunctor
further asserts that these operations satisfy the laws of a functor,
including the preservation of the identity and composition laws:
id <$> x = x
(h ∘ g) <$> x = h <$> g <$> x
- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
Instances
The Applicative
typeclass only contains the operations of an applicative functor.
LawfulApplicative
further asserts that these operations satisfy the laws of an applicative functor:
pure id <*> v = v
pure (·∘·) <*> u <*> v <*> w = u <*> (v <*> w)
pure f <*> pure x = pure (f x)
u <*> pure y = pure (· y) <*> u
- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
- seqLeft_eq : ∀ {α β : Type u} (x : f α) (y : f β), (SeqLeft.seqLeft x fun (x : Unit) => y) = Seq.seq (Function.const β <$> x) fun (x : Unit) => y
- seqRight_eq : ∀ {α β : Type u} (x : f α) (y : f β), (SeqRight.seqRight x fun (x : Unit) => y) = Seq.seq (Function.const α id <$> x) fun (x : Unit) => y
Instances
The Monad
typeclass only contains the operations of a monad.
LawfulMonad
further asserts that these operations satisfy the laws of a monad,
including associativity and identity laws for bind
:
pure x >>= f = f x
x >>= pure = x
x >>= f >>= g = x >>= (fun x => f x >>= g)
LawfulMonad.mk'
is an alternative constructor containing useful defaults for many fields.
- map_const : ∀ {α β : Type u}, Functor.mapConst = Functor.map ∘ Function.const β
- seqLeft_eq : ∀ {α β : Type u} (x : m α) (y : m β), (SeqLeft.seqLeft x fun (x : Unit) => y) = Seq.seq (Function.const β <$> x) fun (x : Unit) => y
- seqRight_eq : ∀ {α β : Type u} (x : m α) (y : m β), (SeqRight.seqRight x fun (x : Unit) => y) = Seq.seq (Function.const α id <$> x) fun (x : Unit) => y
Instances
An alternative constructor for LawfulMonad
which has more
defaultable fields in the common case.