rename function
This commit is contained in:
parent
97b4e83379
commit
e892ade34d
8 changed files with 26 additions and 19 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { fnType, prodType } from "../type_registry.js";
|
||||
import { Function } from "../metacircular.js";
|
||||
import { Function, Type } from "../metacircular.js";
|
||||
|
||||
// In JS, all products are encoded in the same way:
|
||||
const constructor = left => right => ({left, right});
|
||||
|
|
@ -8,15 +8,17 @@ const getRight = product => product.right;
|
|||
|
||||
// Given two types A and B, create the type (A × B).
|
||||
export const makeProductType = (leftType, rightType) => {
|
||||
const productType = prodType(leftType, rightType);
|
||||
const pType = prodType(leftType, rightType);
|
||||
|
||||
const leftFnType = fnType({in: productType, out: leftType});
|
||||
const rightFnType = fnType({in: productType, out: rightType});
|
||||
const leftFnType = fnType({in: pType, out: leftType});
|
||||
const rightFnType = fnType({in: pType, out: rightType});
|
||||
|
||||
const constructorBoundType = fnType({in: rightType, out: productType});
|
||||
const constructorBoundType = fnType({in: rightType, out: pType});
|
||||
const constructorType = fnType({in: leftType , out: constructorBoundType});
|
||||
|
||||
return [
|
||||
{i: pType, t: Type},
|
||||
|
||||
{i: getLeft , t: leftFnType},
|
||||
{i: getRight , t: rightFnType},
|
||||
{i: leftFnType , t: Function},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue