/**
* Performs unsafe coercion of types
*
* @tsplus macro identity
*/
export function unsafeCoerce(a: A): B {
return a as any
}
/**
* Models () => A
*/
export interface Lazy {
(): A
}
/**
* Models (a: A) => a is B
*/
export interface Refinement {
(a: A): a is B
}
/**
* Models (a: A) => A
*/
export interface Endomorphism {
(a: A): A
}
/**
* Models (...args: A) => B
*/
export interface FunctionN, B> {
(...args: A): B
}
/**
* Models a function argument which is evaluated lazily.
*
* For example:
*
* ```typescript
* declare function succeed(a: () => A): Effect
* ```
*
* @tsplus type tsplus/LazyArgument
*/
export interface LazyArg {
(): A
}
/**
* Will raise if called
*/
export function absurd(_: never): A {
throw new Error("Called `absurd` function which should be uncallable")
}
/**
* A constant function that always return A
*/
export function constant(a: A): Lazy {
return () => a
}
/**
* A thunk that returns always `false`
*/
export function constFalse(): boolean {
return false
}
/**
* A thunk that returns always `null`
*/
export function constNull(): null {
return null
}
/**
* A thunk that returns always `true`
*/
export function constTrue(): boolean {
return true
}
/**
* A thunk that returns always `undefined`
*/
export function constUndefined(): undefined {
return
}
/**
* A thunk that returns always `void`
*/
export function constVoid(): void {
return
}
/**
* Flips the order of the arguments of a function of two arguments.
*/
export function flip(f: (a: A, b: B) => C): (b: B, a: A) => C {
return (b, a) => f(a, b)
}
/**
* Identity function
*
* @tsplus macro identity
*/
export function identity(a: A): A {
return a
}
/**
* Force string to be literal
*
* @tsplus macro identity
*/
export function literal(k: K): K {
return k
}
/**
* Type Hole, to be used while implementing functions where you need a placeholder
*/
export function hole(): T {
throw new Error("Hole should never be called")
}
export * from "@tsplus/stdlib/data/Function/pipe"