API / Js / Types

Types

Provide utilities for manipulating JS types.

symbol

RESCRIPT
type symbol

Js symbol type (only available in ES6)

bigint_val

RESCRIPT
type bigint_val

Js bigint type only available in ES2020

obj_val

RESCRIPT
type obj_val

undefined_val

RESCRIPT
type undefined_val

This type has only one value undefined

null_val

RESCRIPT
type null_val

This type has only one value null

function_val

RESCRIPT
type function_val

t

RESCRIPT
type t<_> = | Undefined: t<undefined_val> | Null: t<null_val> | Boolean: t<bool> | Number: t<float> | String: t<string> | Function: t<function_val> | Object: t<obj_val> | Symbol: t<symbol> | BigInt: t<bigint_val>

test

RESCRIPT
let test: ('a, t<'b>) => bool

test(value, t) returns true if value is typeof t, otherwise false. This is useful for doing runtime reflection on any given value.

Examples

RESCRIPT
test("test", String) == true test(() => true, Function) == true test("test", Boolean) == false

tagged_t

RESCRIPT
type tagged_t = | JSFalse | JSTrue | JSNull | JSUndefined | JSNumber(float) | JSString(string) | JSFunction(function_val) | JSObject(obj_val) | JSSymbol(symbol) | JSBigInt(bigint_val)

classify

RESCRIPT
let classify: 'a => tagged_t