Boolean overview
Various functions to aid in working with booleans. You may also find the Predicate
module relevant.
Added in v0.1.0
Table of contents
1 Typeclass Instances
Bounded
A Bounded
instance for booleans.
Signature
export declare const Bounded: Bounded<boolean>
Bounded :: Bounded boolean
Example
import { Bounded } from 'fp-ts-std/Boolean'
assert.strictEqual(Bounded.top, true)
assert.strictEqual(Bounded.bottom, false)
Added in v0.17.0
Enum
An Enum
instance for booleans.
Signature
export declare const Enum: _Enum<boolean>
Enum :: _Enum boolean
Example
import * as O from 'fp-ts/Option'
import { Enum } from 'fp-ts-std/Boolean'
assert.deepStrictEqual(Enum.succ(false), O.some(true))
assert.deepStrictEqual(Enum.succ(true), O.none)
assert.deepStrictEqual(Enum.pred(true), O.some(false))
assert.deepStrictEqual(Enum.pred(false), O.none)
Added in v0.17.0
3 Functions
and
Returns true
if both arguments are true
, else false
. Equivalent to logical conjunction.
Signature
export declare const and: (x: boolean) => Endomorphism<boolean>
and :: boolean -> Endomorphism boolean
Example
import { and } from 'fp-ts-std/Boolean'
assert.strictEqual(and(true)(true), true)
assert.strictEqual(and(true)(false), false)
Added in v0.4.0
invert
Invert a boolean.
Signature
export declare const invert: Endomorphism<boolean>
invert :: Endomorphism boolean
Example
import { invert } from 'fp-ts-std/Boolean'
assert.strictEqual(invert(true), false)
assert.strictEqual(invert(false), true)
Added in v0.4.0
or
Returns true
if one or both arguments are true
, else false
. Equivalent to logical disjunction.
Signature
export declare const or: (x: boolean) => Endomorphism<boolean>
or :: boolean -> Endomorphism boolean
Example
import { or } from 'fp-ts-std/Boolean'
assert.strictEqual(or(true)(false), true)
assert.strictEqual(or(false)(false), false)
Added in v0.4.0
xor
Returns true
if one argument is true
and the other is false
, else false
. Equivalent to exclusive logical disjunction.
Signature
export declare const xor: (x: boolean) => Endomorphism<boolean>
xor :: boolean -> Endomorphism boolean
Example
import { xor } from 'fp-ts-std/Boolean'
assert.strictEqual(xor(true)(false), true)
assert.strictEqual(xor(true)(true), false)
Added in v0.4.0