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
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.
Instances
Use simp [← bind_pure_comp]
rather than simp [map_eq_pure_bind]
,
as bind_pure_comp
is in the default simp set, so also using map_eq_pure_bind
would cause a loop.
An alternative constructor for LawfulMonad
which has more
defaultable fields in the common case.