import type { FunctionN, Lazy, Predicate, Refinement } from "../Function"; import type { Option } from "../Option"; import type { Either } from "./model"; /** * ```haskell * left :: e -> Left e * ``` * * Constructs a new `Either` holding a `Left` value. This usually represents a failure, due to the right-bias of this structure * * @category Constructors * @since 1.0.0 */ export declare const left: (e: E) => Either; /** * ```haskell * right :: a -> Right a * ``` * * Constructs a new `Either` holding a `Right` value. This usually represents a successful value due to the right bias of this structure * * @category Constructors * @since 1.0.0 */ export declare const right: (a: A) => Either; /** * * ```haskell * fromNullable :: (() -> e) -> ?a -> Either e a * ``` * Takes a default and a nullable value, if the value is not nully, turn it into a `Right`, if the value is nully use the provided default as a `Left` * * @category Constructors * @since 1.0.0 */ export declare const fromNullable: (e: Lazy) => (a: A) => Either>; /** * ```haskell * _partial :: (() -> a, (* -> e)) -> Either e a * ``` * * Constructs a new `Either` from a function that might throw * * @category Constructors * @since 1.0.0 */ export declare const partial_: (a: Lazy, onThrow: (reason: unknown) => E) => Either; /** * ```haskell * partial :: (* -> e) -> (() -> a) -> Either e a * ``` * * Constructs a new `Either` from a function that might throw * * @category Constructors * @since 1.0.0 */ export declare const partial: (onError: (reason: unknown) => E) => (a: Lazy) => Either; /** * ```haskell * _partialK :: (((a, b, ...) -> c), (* -> e)) -> ((a, b, ...) -> Either e c) * ``` * * @category Constructors * @since 1.0.0 */ export declare const partialK_: ( f: FunctionN, onThrow: (reason: unknown) => E ) => (...args: A) => Either; /** * ```haskell * partialK :: (* -> e) -> ((a, b, ...) -> c) -> ((a, b, ...) -> Either e c) * ``` * * @category Constructors * @since 1.0.0 */ export declare const partialK: ( onThrow: (reason: unknown) => E ) => (f: FunctionN) => (...args: A) => Either; export declare type Json = boolean | number | string | null | JsonArray | JsonRecord; export interface JsonRecord extends Readonly> {} export interface JsonArray extends ReadonlyArray {} /** * ```haskell * _parseJSON :: (String, (* -> e)) -> Either e Json * ``` * * Converts a JavaScript Object Notation (JSON) string into an object. * * @category Constructors * @since 1.0.0 */ export declare const parseJson_: (s: string, onThrow: (reason: unknown) => E) => Either; /** * ```haskell * parseJSON :: (* -> e) -> String -> Either e Json * ``` * * Converts a JavaScript Object Notation (JSON) string into an object. * * @category Constructors * @since 1.0.0 */ export declare const parseJson: (onThrow: (reason: unknown) => E) => (s: string) => Either; /** * ```haskell * _stringifyJSON :: (*, (* -> E)) -> Either e String * ``` * * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * * @category Constructors * @since 1.0.0 */ export declare const stringifyJson_: (u: unknown, onThrow: (reason: unknown) => E) => Either; /** * ```haskell * stringifyJSON :: (* -> E) -> * -> Either e String * ``` * * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. * * @category Constructors * @since 1.0.0 */ export declare const stringifyJSON: (onThrow: (reason: unknown) => E) => (u: unknown) => Either; /** * ```haskell * _fromMaybe :: (Maybe a, (() -> e)) -> Either e a * ``` * * @category Constructors * @since 1.0.0 */ export declare const fromOption_: (fa: Option, onNothing: Lazy) => Either; /** * ```haskell * fromMaybe :: (() -> e) -> Maybe a -> Either e a * ``` * * @category Constructors * @since 1.0.0 */ export declare const fromOption: (onNothing: Lazy) => (fa: Option) => Either; /** * ```haskell * _fromPredicate :: (a, (a is b), (a -> e)) -> Either e b * _fromPredicate :: (a, (a -> Boolean), (a -> e)) -> Either e a * ``` * * @category Constructors * @since 1.0.0 */ export declare const fromPredicate_: { (a: A, refinement: Refinement, onFalse: (a: A) => E): Either; (a: A, predicate: Predicate, onFalse: (a: A) => E): Either; }; /** * ```haskell * fromPredicate :: ((a is b), (a -> e)) -> a -> Either e b * fromPredicate :: ((a -> Boolean), (a -> e)) -> a -> Either e a * ``` * * @category Constructors * @since 1.0.0 */ export declare const fromPredicate: { (refinement: Refinement, onFalse: (a: A) => E): (a: A) => Either; (predicate: Predicate, onFalse: (a: A) => E): (a: A) => Either; }; //# sourceMappingURL=constructors.d.ts.map