- Number
- String
- Boolean
- Array
- Int
- Maybe
- Either
- Tuple
- Nullable
- OneOf
- Record
- Variant
- VariantEncFlat
- VariantEncNested
- VariantEncNested
- Function
- Promise
- Effect
- Unit
The following is a list of default implementations for types that are provided in this library. Since the generation typeclass is defined on your side, you can choose a subset of the provided implementations.
In the future the following implementations may be added:
- Uncurried Functions
- Native tuples
- Nonempty Arrays
|
||
PureScript | TypeScript | |
---|---|---|
Ref |
Number |
number |
Def |
|
|
|
||
PureScript | TypeScript | |
Ref |
String |
string |
Def |
|
|
|
||
PureScript | TypeScript | |
Ref |
Boolean |
boolean |
Def |
|
|
|
||
PureScript | TypeScript | |
Ref |
Array String |
ReadonlyArray<string> |
Ref |
Unit -> Array a |
<A>() => ReadonlyArray<A> |
Def |
|
|
|
||
PureScript | TypeScript | |
Ref |
Int |
import('../Prim').Int |
Def |
|
type Int = {
readonly __brand: unique symbol;
} |
|
||
PureScript | TypeScript | |
Ref |
Maybe a |
import('../Data.Maybe').Maybe<A> |
Def |
data Maybe a
= Just a
| Nothing |
type Maybe<A> = {
readonly __brand: unique symbol;
readonly __arg1: A;
} |
|
||
PureScript | TypeScript | |
Ref |
Either a b |
import('../Data.Either').Either<A, B> |
Def |
data Either a b
= Left a
| Right b |
type Either<A, B> = {
readonly __brand: unique symbol;
readonly __arg1: A;
readonly __arg2: B;
} |
|
||
PureScript | TypeScript | |
Ref |
Tuple a b |
import('../Data.Tuple').Tuple<A, B> |
Def |
data Tuple a b
= Tuple a b |
type Tuple<A, B> = {
readonly __brand: unique symbol;
readonly __arg1: A;
readonly __arg2: B;
} |
From the nullable library.
|
||
PureScript | TypeScript | |
Ref |
Nullable a |
import('../Data.Nullable').Nullable<A> |
Def |
foreign import data Nullable
:: Type -> Type |
export type Nullable<A> = null | A |
From the untagged-union library.
|
||
PureScript | TypeScript | |
Ref |
OneOf a b |
import('../Untagged.Union').OneOf<A, B> |
Def |
foreign import data OneOf
:: Type -> Type -> Type |
export type OneOf<A, B> = A | B |
Records are represented as TypeScript records with readonly fields. |
||
PureScript | TypeScript | |
Ref |
{ name :: String
, loggedIn :: Boolean
} |
{
readonly name: string;
readonly loggedIn: boolean;
} |
Def |
|
|
From the variant library. Variant types are represented as TypeScript tagged unions. |
||
PureScript | TypeScript | |
Ref |
Variant
( done :: String
, counting :: Number
, init :: Unit
) |
| {
readonly type: 'done';
readonly value: string;
}
| {
readonly type: 'counting';
readonly value: number;
}
| {
readonly type: 'init';
readonly value: void;
} |
Def |
foreign import data Variant
:: Row Type -> Type |
|
From the variant-encodings library. Flat encoded Variants are represented as TypeScript tagged unions. |
||
PureScript | TypeScript | |
Ref |
VariantEncFlat "kind"
( one :: {name :: String, size :: Number}
, two :: {hobbies :: Array String}
) |
| {
readonly kind: 'one';
readonly name: string;
readonly size: number;
}
| {
readonly kind: 'two';
readonly hobbies: Array<string>;
} |
Def |
foreign import data VariantEncFlat
:: Symbol -> Row (Row Type) -> Type |
|
From the variant-encodings library. Variants with custom nested encoding are represented as TypeScript tagged unions. |
||
PureScript | TypeScript | |
Ref |
VariantEncNested "kind" "payload"
( one :: Number
, two :: String
) |
| {
readonly kind: 'one';
readonly payload: number;
}
| {
readonly kind: 'two';
readonly payload: string;
} |
Def |
foreign import data VariantEncNested
:: Symbol -> Symbol -> Row Type -> Type |
|
From the variant-encodings library. Variants with custom nested encoding are represented as TypeScript tagged unions. |
||
PureScript | TypeScript | |
Ref |
VariantEncNested "kind" "payload"
( one :: String
, two :: Number
) |
| {
readonly kind: 'one';
readonly payload: string;
}
| {
readonly kind: 'two';
readonly payload: number;
} |
Def |
foreign import data VariantEncNested
:: Symbol -> Symbol -> Row Type -> Type |
|
Functions are represented as TypeScript curried functions. |
||
PureScript | TypeScript | |
Ref |
Number -> String -> Boolean |
(_: number) => (_: string) => boolean |
Ref |
forall a b c. a -> b -> c |
<A>(_: A) =>
<B, C>(_: B) =>
C |
Def |
|
|
From the aff-promise library. Promises are represented as TypeScript Promises. Note that in most cases it makes sense to treat them as |
||
PureScript | TypeScript | |
Ref |
Promise a |
Promise<A> |
Def |
foreign import data Promise :: Type -> Type |
|
Effects are represented as TypeScript functions. |
||
PureScript | TypeScript | |
Ref |
Effect a |
<A>() => A |
Def |
foreign import data Effect
:: Type -> Type |
|
|
||
PureScript | TypeScript | |
Ref |
Unit |
void |
Def |
foreign import data Unit
:: Type |
|