Const overview
The Const
type constructor, which wraps its first type argument and ignores its second. That is, Const<E, A>
is isomorphic to E
for any A
.
Const
has some useful instances. For example, the Applicative
instance allows us to collect results using a Monoid
while ignoring return values.
Added in v2.0.0
Table of contents
constructors
make
Signature
export declare const make: <E, A = never>(e: E) => Const<E, A>
Added in v2.0.0
error handling
mapLeft
Map a function over the first type argument of a bifunctor.
Signature
export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: Const<E, A>) => Const<G, A>
Added in v2.6.2
instances
Bifunctor
Signature
export declare const Bifunctor: Bifunctor2<'Const'>
Added in v2.7.0
Contravariant
Signature
export declare const Contravariant: Contravariant2<'Const'>
Added in v2.7.0
Functor
Signature
export declare const Functor: Functor2<'Const'>
Added in v2.7.0
getApplicative
Signature
export declare function getApplicative<E>(M: Monoid<E>): Applicative2C<URI, E>
Added in v2.0.0
getApply
Signature
export declare function getApply<E>(S: Semigroup<E>): Apply2C<URI, E>
Added in v2.0.0
getBooleanAlgebra
Signature
export declare const getBooleanAlgebra: <E, A>(H: BooleanAlgebra<E>) => BooleanAlgebra<Const<E, A>>
Added in v2.6.0
getBounded
Signature
export declare const getBounded: <E, A>(B: Bounded<E>) => Bounded<Const<E, A>>
Added in v2.6.0
getEq
Signature
export declare const getEq: <E, A>(E: Eq<E>) => Eq<Const<E, A>>
Added in v2.0.0
getHeytingAlgebra
Signature
export declare const getHeytingAlgebra: <E, A>(H: HeytingAlgebra<E>) => HeytingAlgebra<Const<E, A>>
Added in v2.6.0
getMonoid
Signature
export declare const getMonoid: <E, A>(M: Monoid<E>) => Monoid<Const<E, A>>
Added in v2.6.0
getOrd
Signature
export declare const getOrd: <E, A>(O: Ord<E>) => Ord<Const<E, A>>
Added in v2.6.0
getRing
Signature
export declare const getRing: <E, A>(S: Ring<E>) => Ring<Const<E, A>>
Added in v2.6.0
getSemigroup
Signature
export declare const getSemigroup: <E, A>(S: Semigroup<E>) => Semigroup<Const<E, A>>
Added in v2.6.0
getSemiring
Signature
export declare const getSemiring: <E, A>(S: Semiring<E>) => Semiring<Const<E, A>>
Added in v2.6.0
getShow
Signature
export declare function getShow<E, A>(S: Show<E>): Show<Const<E, A>>
Added in v2.0.0
mapping
bimap
Map a pair of functions over the two type arguments of the bifunctor.
Signature
export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: Const<E, A>) => Const<G, B>
Added in v2.6.2
flap
Signature
export declare const flap: <A>(a: A) => <E, B>(fab: Const<E, (a: A) => B>) => Const<E, B>
Added in v2.10.0
map
map
can be used to turn functions (a: A) => B
into functions (fa: F<A>) => F<B>
whose argument and return types use the type constructor F
to represent some computational context.
Signature
export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: Const<E, A>) => Const<E, B>
Added in v2.0.0
model
Const (type alias)
Signature
export type Const<E, A> = E & { readonly _A: A }
Added in v2.0.0
type lambdas
URI
Signature
export declare const URI: 'Const'
Added in v2.0.0
URI (type alias)
Signature
export type URI = typeof URI
Added in v2.0.0
utils
contramap
Signature
export declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>
Added in v2.0.0
zone of death
const_
This instance is deprecated, use small, specific instances instead. For example if a function needs a Functor
instance, pass C.Functor
instead of C.const_
(where C
is from import C from 'fp-ts/Const'
)
Signature
export declare const const_: Functor2<'Const'> & Contravariant2<'Const'> & Bifunctor2<'Const'>
Added in v2.0.0