nanomath/src/boolean/type.js

15 lines
438 B
JavaScript
Raw Normal View History

import {BooleanT} from './BooleanT.js'
import {match} from '#core/TypePatterns.js'
import {Returns, TypeOfTypes, Undefined} from '#core/Type.js'
import {NumberT} from '#number/NumberT.js'
const bool = f => Returns(BooleanT, f)
export const boolean = [
match(BooleanT, bool(p => p)),
match(NumberT, bool(a => !!a)),
match(TypeOfTypes, bool(() => true)),
match(Undefined, bool(() => false)),
match([], bool(() => false))
]