18 lines
497 B
JavaScript
18 lines
497 B
JavaScript
import { assignFn } from "../generics/generics.js";
|
|
|
|
export const newDynamic = i => t => ({i, t});
|
|
|
|
export const getInst = lnk => lnk.i;
|
|
export const getType = lnk => lnk.t;
|
|
|
|
export const apply = input => fun => {
|
|
const inputType = getType(input)
|
|
const funType = getType(fun);
|
|
const outputType = assignFn(funType, inputType);
|
|
|
|
const inputValue = getInst(input);
|
|
const funValue = getInst(fun);
|
|
const outputValue = funValue(inputValue);
|
|
|
|
return newDynamic(outputValue, outputType);
|
|
};
|