create 'Ordering' type
This commit is contained in:
parent
77dfc8b182
commit
b0023afe8c
15 changed files with 158 additions and 117 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// A simple, hacked-together recursive parser for types.
|
||||
|
||||
import { Bool, Char, Double, Int, UUID, Type, Unit } from "../primitives/primitive_types.js";
|
||||
import { Bool, Char, Double, Int, UUID, Type, Unit, Ordering } from "../primitives/primitive_types.js";
|
||||
import { Dynamic } from "../primitives/primitive_types.js";
|
||||
import { getHumanReadableName } from "../primitives/symbol.js";
|
||||
import { getSymbol } from "../primitives/type.js";
|
||||
|
|
@ -21,16 +21,17 @@ export const makeTypeParser = ({
|
|||
extraInfixOperators=[],
|
||||
}) => {
|
||||
const primitives = new Map([
|
||||
['Int', Int],
|
||||
['Double', Double],
|
||||
['Bool', Bool],
|
||||
['Char', Char],
|
||||
['String', lsType(_ => Char)],
|
||||
['Module', lsType(_ => Dynamic)],
|
||||
['Unit', Unit],
|
||||
['Type', Type],
|
||||
['Dynamic', Dynamic],
|
||||
['UUID', UUID],
|
||||
['Int' , Int ],
|
||||
['Double' , Double ],
|
||||
['Bool' , Bool ],
|
||||
['Char' , Char ],
|
||||
['String' , lsType(_ => Char) ],
|
||||
['Module' , lsType(_ => Dynamic)],
|
||||
['Unit' , Unit ],
|
||||
['Type' , Type ],
|
||||
['Dynamic' , Dynamic ],
|
||||
['UUID' , UUID ],
|
||||
['Ordering', Ordering ],
|
||||
|
||||
...TYPE_VARS.map(type => [getHumanReadableName(getSymbol(type)), type]),
|
||||
|
||||
|
|
@ -38,21 +39,21 @@ export const makeTypeParser = ({
|
|||
]);
|
||||
|
||||
const bracketOperators = new Map([
|
||||
['(', [')', null]],
|
||||
['[', [']', lsType]],
|
||||
['(', [')', null ]],
|
||||
['[', [']', lsType ]],
|
||||
['{', ['}', setType]],
|
||||
|
||||
...extraBracketOperators,
|
||||
]);
|
||||
|
||||
const infixOperators = new Map([
|
||||
['+', sumType],
|
||||
['|', sumType],
|
||||
['⨯', prodType],
|
||||
['*', prodType],
|
||||
['→', fnType],
|
||||
['->', fnType],
|
||||
['⇒', dictType],
|
||||
['+' , sumType ],
|
||||
['|' , sumType ],
|
||||
['⨯' , prodType],
|
||||
['*' , prodType],
|
||||
['→' , fnType ],
|
||||
['->', fnType ],
|
||||
['⇒' , dictType],
|
||||
['=>', dictType],
|
||||
|
||||
...extraInfixOperators,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue