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
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
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
Signature
export declare const contramap: <A, B>(f: (b: B) => A) => <E>(fa: Const<E, A>) => Const<E, B>
Added in v2.0.0
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
Signature
export declare const make: <E, A = never>(e: E) => Const<E, A>
Added in v2.0.0
Signature
export declare const Bifunctor: Bifunctor2<'Const'>
Added in v2.7.0
Signature
export declare const Contravariant: Contravariant2<'Const'>
Added in v2.7.0
Signature
export declare const Functor: Functor2<'Const'>
Added in v2.7.0
Signature
export declare const URI: 'Const'
Added in v2.0.0
Signature
export type URI = typeof URI
Added in v2.0.0
Signature
export declare const const_: Functor2<'Const'> & Contravariant2<'Const'> & Bifunctor2<'Const'>
Added in v2.0.0
Signature
export declare function getApplicative<E>(M: Monoid<E>): Applicative2C<URI, E>
Added in v2.0.0
Signature
export declare function getApply<E>(S: Semigroup<E>): Apply2C<URI, E>
Added in v2.0.0
Signature
export declare const getBooleanAlgebra: <E, A>(H: BooleanAlgebra<E>) => BooleanAlgebra<Const<E, A>>
Added in v2.6.0
Signature
export declare const getBounded: <E, A>(B: Bounded<E>) => Bounded<Const<E, A>>
Added in v2.6.0
Signature
export declare const getEq: <E, A>(E: Eq<E>) => Eq<Const<E, A>>
Added in v2.0.0
Signature
export declare const getHeytingAlgebra: <E, A>(H: HeytingAlgebra<E>) => HeytingAlgebra<Const<E, A>>
Added in v2.6.0
Signature
export declare const getMonoid: <E, A>(M: Monoid<E>) => Monoid<Const<E, A>>
Added in v2.6.0
Signature
export declare const getOrd: <E, A>(O: Ord<E>) => Ord<Const<E, A>>
Added in v2.6.0
Signature
export declare const getRing: <E, A>(S: Ring<E>) => Ring<Const<E, A>>
Added in v2.6.0
Signature
export declare const getSemigroup: <E, A>(S: Semigroup<E>) => Semigroup<Const<E, A>>
Added in v2.6.0
Signature
export declare const getSemiring: <E, A>(S: Semiring<E>) => Semiring<Const<E, A>>
Added in v2.6.0
Signature
export declare function getShow<E, A>(S: Show<E>): Show<Const<E, A>>
Added in v2.0.0
Signature
export type Const<E, A> = E & { readonly _A: A }
Added in v2.0.0