Functors #
This module provides additional lemmas, definitions, and instances for Functor
s.
Main definitions #
Functor.Const α
is the functor that sends all types toα
.Functor.AddConst α
isFunctor.Const α
but for whenα
has an additive structure.Functor.Comp F G
for functorsF
andG
is the functor composition ofF
andG
.Liftp
andLiftr
respectively lift predicates and relations on a typeα
toF α
. Terms ofF α
are considered to, in some sense, contain values of typeα
.
Tags #
functor, applicative
Const α
is the constant functor, mapping every type to α
. When
α
has a monoid structure, Const α
has an Applicative
instance.
(If α
has an additive monoid structure, see Functor.AddConst
.)
Equations
- Functor.Const α _β = α
Instances For
Const.mk
is the canonical map α → Const α β
(the identity), and
it can be used as a pattern to extract this value.
Equations
- Functor.Const.mk x = x
Instances For
The map operation of the Const γ
functor.
Equations
- Functor.Const.map _f x = x
Instances For
Equations
- Functor.Const.functor = { map := @Functor.Const.map γ, mapConst := fun {α β} => Functor.Const.map ∘ Function.const β }
Equations
- Functor.Const.instInhabitedConst = { default := default }
AddConst α
is a synonym for constant functor Const α
, mapping
every type to α
. When α
has an additive monoid structure,
AddConst α
has an Applicative
instance. (If α
has a
multiplicative monoid structure, see Functor.Const
.)
Equations
Instances For
AddConst.mk
is the canonical map α → AddConst α β
, which is the identity,
where AddConst α β = Const α β
. It can be used as a pattern to extract this value.
Equations
- Functor.AddConst.mk x = x
Instances For
Equations
- Functor.AddConst.functor = Functor.Const.functor
Equations
- (_ : LawfulFunctor (Functor.AddConst γ)) = (_ : LawfulFunctor (Functor.Const γ))
Equations
- Functor.instInhabitedAddConst = { default := default }
Functor.Comp
is a wrapper around Function.Comp
for types.
It prevents Lean's type class resolution mechanism from trying
a Functor (Comp F id)
when Functor F
would do.
Equations
- Functor.Comp F G α = F (G α)
Instances For
Construct a term of Comp F G α
from a term of F (G α)
, which is the same type.
Can be used as a pattern to extract a term of F (G α)
.
Equations
- Functor.Comp.mk x = x
Instances For
Extract a term of F (G α)
from a term of Comp F G α
, which is the same type.
Equations
- Functor.Comp.run x = x
Instances For
The map operation for the composition Comp F G
of functors F
and G
.
Equations
- Functor.Comp.map h x = match x with | x => Functor.Comp.mk ((fun x x_1 => x <$> x_1) h <$> x)
Instances For
Equations
- Functor.Comp.functor = { map := @Functor.Comp.map F G inst inst, mapConst := fun {α β} => Functor.Comp.map ∘ Function.const β }
The <*>
operation for the composition of applicative functors.
Equations
- Functor.Comp.seq x x = match x, x with | f, g => match g () with | x => Functor.Comp.mk (Seq.seq ((fun x x_1 => Seq.seq x fun x => x_1) <$> f) fun x_1 => x)
Instances For
Equations
- Functor.Comp.instPureComp = { pure := fun {α} x => Functor.Comp.mk (pure (pure x)) }
Equations
- Functor.Comp.instSeqComp = { seq := fun {α β} f x => Functor.Comp.seq f x }
Equations
- Functor.Comp.instApplicativeComp = Applicative.mk
If we consider x : F α
to, in some sense, contain values of type α
,
predicate Liftp p x
holds iff every value contained by x
satisfies p
.
Equations
- Functor.Liftp p x = ∃ u, Subtype.val <$> u = x
Instances For
If we consider x : F α
to, in some sense, contain values of type α
, then
Liftr r x y
relates x
and y
iff (1) x
and y
have the same shape and
(2) we can pair values a
from x
and b
from y
so that r a b
holds.
Equations
Instances For
If we consider x : F α
to, in some sense, contain values of type α
, then
supp x
is the set of values of type α
that x
contains.
Equations
- Functor.supp x = {y | ⦃p : α → Prop⦄ → Functor.Liftp p x → p y}
Instances For
If f
is a functor, if fb : f β
and a : α
, then mapConstRev fb a
is the result of
applying f.map
to the constant function β → α
sending everything to a
, and then
evaluating at fb
. In other words it's const a <$> fb
.
Equations
- a $> b = Functor.mapConst b a
Instances For
If f
is a functor, if fb : f β
and a : α
, then mapConstRev fb a
is the result of
applying f.map
to the constant function β → α
sending everything to a
, and then
evaluating at fb
. In other words it's const a <$> fb
.
Equations
- Functor.«term_$>_» = Lean.ParserDescr.trailingNode `Functor.term_$>_ 100 101 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " $> ") (Lean.ParserDescr.cat `term 101))