boolean overview
Added in v2.2.0
Table of contents
instances
BooleanAlgebra
Signature
export declare const BooleanAlgebra: BA.BooleanAlgebra<boolean>
Added in v2.10.0
Eq
Signature
export declare const Eq: E.Eq<boolean>
Added in v2.10.0
MonoidAll
boolean
monoid under conjunction.
The empty
value is true
.
Signature
export declare const MonoidAll: Monoid<boolean>
Example
import { MonoidAll } from 'fp-ts/boolean'
assert.deepStrictEqual(MonoidAll.concat(true, true), true)
assert.deepStrictEqual(MonoidAll.concat(true, false), false)
Added in v2.10.0
MonoidAny
boolean
monoid under disjunction.
The empty
value is false
.
Signature
export declare const MonoidAny: Monoid<boolean>
Example
import { MonoidAny } from 'fp-ts/boolean'
assert.deepStrictEqual(MonoidAny.concat(true, true), true)
assert.deepStrictEqual(MonoidAny.concat(true, false), true)
assert.deepStrictEqual(MonoidAny.concat(false, false), false)
Added in v2.10.0
Ord
Signature
export declare const Ord: O.Ord<boolean>
Added in v2.10.0
SemigroupAll
boolean
semigroup under conjunction.
Signature
export declare const SemigroupAll: Semigroup<boolean>
Example
import { SemigroupAll } from 'fp-ts/boolean'
assert.deepStrictEqual(SemigroupAll.concat(true, true), true)
assert.deepStrictEqual(SemigroupAll.concat(true, false), false)
Added in v2.10.0
SemigroupAny
boolean
semigroup under disjunction.
Signature
export declare const SemigroupAny: Semigroup<boolean>
Example
import { SemigroupAny } from 'fp-ts/boolean'
assert.deepStrictEqual(SemigroupAny.concat(true, true), true)
assert.deepStrictEqual(SemigroupAny.concat(true, false), true)
assert.deepStrictEqual(SemigroupAny.concat(false, false), false)
Added in v2.10.0
Show
Signature
export declare const Show: S.Show<boolean>
Added in v2.10.0
pattern matching
fold
Alias of match
.
Signature
export declare const fold: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A
Added in v2.2.0
foldW
Alias of matchW
.
Signature
export declare const foldW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B
Added in v2.10.0
match
Defines the fold over a boolean value. Takes two thunks onTrue
, onFalse
and a boolean
value. If value
is false, onFalse()
is returned, otherwise onTrue()
.
Signature
export declare const match: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A
Example
import { some, map } from 'fp-ts/Option'
import { pipe } from 'fp-ts/function'
import { match } from 'fp-ts/boolean'
assert.deepStrictEqual(
pipe(
some(true),
map(
match(
() => 'false',
() => 'true'
)
)
),
some('true')
)
Added in v2.10.0
matchW
Less strict version of match
.
The W
suffix (short for Widening) means that the handler return types will be merged.
Signature
export declare const matchW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B
Added in v2.10.0
refinements
isBoolean
Signature
export declare const isBoolean: Refinement<unknown, boolean>
Added in v2.11.0