add enum type (generalization of sum-type)
This commit is contained in:
parent
8653bb99c6
commit
0b262daf7f
6 changed files with 102 additions and 7 deletions
|
|
@ -15,8 +15,8 @@ export const constructorRight = right => ({t: "R", v: right});
|
|||
// sum-type -> (leftType -> resultType, rightType -> resultType) -> resultType
|
||||
export const match = sum => handlers =>
|
||||
sum.t === "L"
|
||||
? handlers.left(sum.v)
|
||||
: handlers.right(sum.v);
|
||||
? handlers.l(sum.v)
|
||||
: handlers.r(sum.v);
|
||||
|
||||
export const ModuleSum = {l:[
|
||||
// binary type constructor
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue