Skip to main content

Boolean

Instances

Pattern matching

Refinements

Instances

BooleanAlgebra

Signature

export declare const BooleanAlgebra: BA.BooleanAlgebra<boolean>

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

Eq

Signature

export declare const Eq: E.Eq<boolean>

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

MonoidAll

boolean monoid under conjunction.

The empty value is true.

Signature

export declare const MonoidAll: Monoid<boolean>

Details

  • Added in 0.1.0

Example

import { MonoidAll } from '@fp-tx/core/boolean'

assert.deepStrictEqual(MonoidAll.concat(true, true), true)
assert.deepStrictEqual(MonoidAll.concat(true, false), false)

License

  • MIT – Copyright (c) 2017-present Giulio Canti

MonoidAny

boolean monoid under disjunction.

The empty value is false.

Signature

export declare const MonoidAny: Monoid<boolean>

Details

  • Added in 0.1.0

Example

import { MonoidAny } from '@fp-tx/core/boolean'

assert.deepStrictEqual(MonoidAny.concat(true, true), true)
assert.deepStrictEqual(MonoidAny.concat(true, false), true)
assert.deepStrictEqual(MonoidAny.concat(false, false), false)

License

  • MIT – Copyright (c) 2017-present Giulio Canti

Ord

Signature

export declare const Ord: O.Ord<boolean>

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

SemigroupAll

boolean semigroup under conjunction.

Signature

export declare const SemigroupAll: Semigroup<boolean>

Details

  • Added in 0.1.0

Example

import { SemigroupAll } from '@fp-tx/core/boolean'

assert.deepStrictEqual(SemigroupAll.concat(true, true), true)
assert.deepStrictEqual(SemigroupAll.concat(true, false), false)

License

  • MIT – Copyright (c) 2017-present Giulio Canti

SemigroupAny

boolean semigroup under disjunction.

Signature

export declare const SemigroupAny: Semigroup<boolean>

Details

  • Added in 0.1.0

Example

import { SemigroupAny } from '@fp-tx/core/boolean'

assert.deepStrictEqual(SemigroupAny.concat(true, true), true)
assert.deepStrictEqual(SemigroupAny.concat(true, false), true)
assert.deepStrictEqual(SemigroupAny.concat(false, false), false)

License

  • MIT – Copyright (c) 2017-present Giulio Canti

Show

Signature

export declare const Show: S.Show<boolean>

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

Pattern matching

fold

Alias of match.

Signature

export declare const fold: <A>(onFalse: LazyArg<A>, onTrue: LazyArg<A>) => (value: boolean) => A

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

foldW

Alias of matchW.

Signature

export declare const foldW: <A, B>(onFalse: LazyArg<A>, onTrue: LazyArg<B>) => (value: boolean) => A | B

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

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

Details

  • Added in 0.1.0

Example

import { some, map } from '@fp-tx/core/Option'
import { pipe } from '@fp-tx/core/function'
import { match } from '@fp-tx/core/boolean'

assert.deepStrictEqual(
pipe(
some(true),
map(
match(
() => 'false',
() => 'true',
),
),
),
some('true'),
)

License

  • MIT – Copyright (c) 2017-present Giulio Canti

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

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti

Refinements

isBoolean

Signature

export declare const isBoolean: Refinement<unknown, boolean>

Details

  • Added in 0.1.0

License

  • MIT – Copyright (c) 2017-present Giulio Canti