progress
This commit is contained in:
parent
6af72e525c
commit
145835ad5d
22 changed files with 153 additions and 90 deletions
|
|
@ -1,15 +1,15 @@
|
|||
import { prodType } from "./types.js";
|
||||
import { Type } from "../type.js";
|
||||
import { Type } from "../primitives/types.js";
|
||||
import { typedFnType } from "./types.js";
|
||||
import { makeGeneric } from "../generics/generics.js";
|
||||
import { sumType } from "./types.js";
|
||||
|
||||
const constructorLeft = left => ({variant: "L", value: left });
|
||||
const constructorRight = right => ({variant: "R", value: right});
|
||||
export const constructorLeft = left => ({variant: "L", value: left });
|
||||
export const constructorRight = right => ({variant: "R", value: right});
|
||||
|
||||
// signature:
|
||||
// sum-type -> (leftType -> resultType, rightType -> resultType) -> resultType
|
||||
const match = sum => handlers => sum.variant === "L"
|
||||
export const match = sum => handlers => sum.variant === "L"
|
||||
? handlers.left(sum.value)
|
||||
: handlers.right(sum.value);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue