diff --git a/package-lock.json b/package-lock.json index 160a6b3..6923b6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "please-prototype", "version": "0.0.0", "dependencies": { + "@matt.kantor/either": "^1.0.0", + "@matt.kantor/option": "^1.0.0", "kleur": "^4.1.5" }, "bin": { @@ -18,6 +20,36 @@ "typescript": "^5.6.2" } }, + "node_modules/@matt.kantor/either": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@matt.kantor/either/-/either-1.0.0.tgz", + "integrity": "sha512-Abvg2BkwpQKUIAN5wSnTheBTcNR4dWeRS6E3j6Ra9NbftMfF+fTPtdNGDrtaRT3lTfGnkbhELeLGwd3iokHlpA==", + "license": "MIT", + "dependencies": { + "@matt.kantor/either-tag-symbol": "*" + } + }, + "node_modules/@matt.kantor/either-tag-symbol": { + "version": "9007199254740991.9007199254740991.9007199254740991", + "resolved": "https://registry.npmjs.org/@matt.kantor/either-tag-symbol/-/either-tag-symbol-9007199254740991.9007199254740991.9007199254740991.tgz", + "integrity": "sha512-gcsznH1E+z2Or7+bdt3DgvXLgUajDM/zUvS5cmLDIOeYQkeveZTlYnY9dS1Zp6tZU5jQEvd1zUOeYfJhVYa5eA==", + "license": "MIT" + }, + "node_modules/@matt.kantor/option": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@matt.kantor/option/-/option-1.0.0.tgz", + "integrity": "sha512-EzMyjqjQ9L+s4KLBLrMRooZlJSz3cj1sK9rRHz7ZfPCt0GJak4ZkARTimSzkS2R6wEaOvJXJH7frlf/y0kHt0g==", + "license": "MIT", + "dependencies": { + "@matt.kantor/option-tag-symbol": "*" + } + }, + "node_modules/@matt.kantor/option-tag-symbol": { + "version": "9007199254740991.9007199254740991.9007199254740991", + "resolved": "https://registry.npmjs.org/@matt.kantor/option-tag-symbol/-/option-tag-symbol-9007199254740991.9007199254740991.9007199254740991.tgz", + "integrity": "sha512-SfSHY47RmrQn7Dm6L9Tx4bmUzef4xDmOcQeFtgK5e/3NG/oWzNB6vZkDyBy7rDiBgk5o2Z99HutcEvDX9xTrfg==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.7.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.8.tgz", diff --git a/package.json b/package.json index 099d42e..1bde3e2 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ "typescript": "^5.6.2" }, "dependencies": { + "@matt.kantor/either": "^1.0.0", + "@matt.kantor/option": "^1.0.0", "kleur": "^4.1.5" } } diff --git a/src/adts.ts b/src/adts.ts deleted file mode 100644 index e34e68a..0000000 --- a/src/adts.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as eitherUtilities from './adts/either-utilities.js' -import * as eitherAdt from './adts/either.js' -import * as optionUtilities from './adts/option-utilities.js' -import * as optionAdt from './adts/option.js' - -export type { Either } from './adts/either.js' -export type { Option } from './adts/option.js' -export const either = { ...eitherAdt, ...eitherUtilities } -export const option = { ...optionAdt, ...optionUtilities } diff --git a/src/adts/either-utilities.ts b/src/adts/either-utilities.ts deleted file mode 100644 index 91edf79..0000000 --- a/src/adts/either-utilities.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { makeLeft, makeRight, match, type Either, type Left } from './either.js' - -export const flatMap = ( - either: Either, - f: (value: RightValue) => Either, -): Either => - match(either, { - left: makeLeft, - right: f, - }) - -export const isLeft = ( - either: Either, -): either is Left => - match(either, { left: _ => true, right: _ => false }) - -export const map = ( - either: Either, - f: (value: RightValue) => NewRightValue, -): Either => - match(either, { - left: makeLeft, - right: value => makeRight(f(value)), - }) - -export const mapLeft = ( - either: Either, - f: (value: LeftValue) => NewLeftValue, -): Either => - match(either, { - left: value => makeLeft(f(value)), - right: makeRight, - }) - -export const tryCatch = ( - operation: () => RightValue, -): Either => { - try { - return makeRight(operation()) - } catch (error) { - return makeLeft(error) - } -} diff --git a/src/adts/either.ts b/src/adts/either.ts deleted file mode 100644 index 7938490..0000000 --- a/src/adts/either.ts +++ /dev/null @@ -1,37 +0,0 @@ -const eitherTag = Symbol('either') -export type Either = Right | Left - -export type Left = { - readonly [eitherTag]: 'left' - readonly value: Value -} - -export type Right = { - readonly [eitherTag]: 'right' - readonly value: Value -} - -export const makeLeft = (value: Value): Left => ({ - [eitherTag]: 'left', - value, -}) - -export const makeRight = (value: Value): Right => ({ - [eitherTag]: 'right', - value, -}) - -export const match = ( - adt: Either, - cases: { - left: (value: LeftValue) => LeftResult - right: (value: RightValue) => RightResult - }, -): LeftResult | RightResult => { - switch (adt[eitherTag]) { - case 'left': - return cases[adt[eitherTag]](adt.value) - case 'right': - return cases[adt[eitherTag]](adt.value) - } -} diff --git a/src/adts/option-utilities.ts b/src/adts/option-utilities.ts deleted file mode 100644 index c816083..0000000 --- a/src/adts/option-utilities.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { makeSome, match, none, type None, type Option } from './option.js' - -export const filter = ( - option: Option, - predicate: (value: Value) => value is NarrowedValue, -): Option => - flatMap(option, value => fromPredicate(value, predicate)) - -export const fromPredicate = ( - value: InputValue, - predicate: (value: InputValue) => value is Value, -): Option => (predicate(value) ? makeSome(value) : none) - -export const flatMap = ( - option: Option, - f: (value: Value) => Option, -): Option => match(option, { none: () => none, some: f }) - -export const isNone = (option: Option): option is None => - match(option, { none: () => true, some: _ => false }) - -export const map = ( - option: Option, - f: (value: Value) => NewValue, -): Option => - match(option, { - none: (): Option => none, - some: value => makeSome(f(value)), - }) diff --git a/src/adts/option.ts b/src/adts/option.ts deleted file mode 100644 index 24dede1..0000000 --- a/src/adts/option.ts +++ /dev/null @@ -1,33 +0,0 @@ -const optionTag = Symbol('option') -export type Option = None | Some - -export type None = { - readonly [optionTag]: 'none' -} - -export type Some = { - readonly [optionTag]: 'some' - readonly value: Value -} - -export const none: None = { [optionTag]: 'none' } - -export const makeSome = (value: Value): Some => ({ - [optionTag]: 'some', - value, -}) - -export const match = ( - adt: Option, - cases: { - none: () => NoneResult - some: (value: Value) => SomeResult - }, -): NoneResult | SomeResult => { - switch (adt[optionTag]) { - case 'none': - return cases[adt[optionTag]]() - case 'some': - return cases[adt[optionTag]](adt.value) - } -} diff --git a/src/end-to-end.test.ts b/src/end-to-end.test.ts index bbe9acd..ce35da1 100644 --- a/src/end-to-end.test.ts +++ b/src/end-to-end.test.ts @@ -1,5 +1,5 @@ +import either, { type Either } from '@matt.kantor/either' import assert from 'node:assert' -import { either, type Either } from './adts.js' import { compile } from './language/compiling.js' import type { Atom, Molecule } from './language/parsing.js' import { parse } from './language/parsing/parser.js' diff --git a/src/language/cli/input.ts b/src/language/cli/input.ts index 410ffe4..b0805fd 100644 --- a/src/language/cli/input.ts +++ b/src/language/cli/input.ts @@ -1,5 +1,5 @@ +import either, { type Either } from '@matt.kantor/either' import { parseArgs } from 'util' -import { either, type Either } from '../../adts.js' import { type JsonValueForbiddingSymbolicKeys } from '../parsing.js' export type InvalidJsonError = { diff --git a/src/language/cli/output.ts b/src/language/cli/output.ts index b4a9c16..3c15219 100644 --- a/src/language/cli/output.ts +++ b/src/language/cli/output.ts @@ -1,5 +1,5 @@ +import either, { type Either } from '@matt.kantor/either' import { parseArgs } from 'util' -import { either, type Either } from '../../adts.js' import { type SyntaxTree } from '../parsing/syntax-tree.js' import { unparse, type Notation } from '../unparsing.js' import { prettyJson } from '../unparsing/pretty-json.js' diff --git a/src/language/cli/please.ts b/src/language/cli/please.ts index 3fc24fd..cd47d4a 100644 --- a/src/language/cli/please.ts +++ b/src/language/cli/please.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' import { compile } from '../compiling.js' import type { Atom, Molecule } from '../parsing.js' import { parse } from '../parsing/parser.js' diff --git a/src/language/compiling/compiler.test.ts b/src/language/compiling/compiler.test.ts index cd52eb7..7aae3ba 100644 --- a/src/language/compiling/compiler.test.ts +++ b/src/language/compiling/compiler.test.ts @@ -1,5 +1,5 @@ +import either, { type Either } from '@matt.kantor/either' import assert from 'node:assert' -import { either, type Either } from '../../adts.js' import { withPhantomData } from '../../phantom-data.js' import { testCases } from '../../test-utilities.test.js' import type { ElaborationError } from '../errors.js' diff --git a/src/language/compiling/compiler.ts b/src/language/compiling/compiler.ts index f11a923..490f357 100644 --- a/src/language/compiling/compiler.ts +++ b/src/language/compiling/compiler.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { CompilationError } from '../errors.js' import type { JsonValueForbiddingSymbolicKeys } from '../parsing.js' import { canonicalize } from '../parsing.js' diff --git a/src/language/compiling/semantics.test.ts b/src/language/compiling/semantics.test.ts index 3db73b3..6f4c86d 100644 --- a/src/language/compiling/semantics.test.ts +++ b/src/language/compiling/semantics.test.ts @@ -1,5 +1,6 @@ +import either, { type Either } from '@matt.kantor/either' +import option from '@matt.kantor/option' import assert from 'node:assert' -import { either, option, type Either } from '../../adts.js' import { withPhantomData } from '../../phantom-data.js' import { testCases } from '../../test-utilities.test.js' import type { Writable } from '../../utility-types.js' diff --git a/src/language/compiling/semantics/keyword-handlers/apply-handler.ts b/src/language/compiling/semantics/keyword-handlers/apply-handler.ts index 555abc4..2ff3208 100644 --- a/src/language/compiling/semantics/keyword-handlers/apply-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/apply-handler.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../../errors.js' import { asSemanticGraph, diff --git a/src/language/compiling/semantics/keyword-handlers/check-handler.ts b/src/language/compiling/semantics/keyword-handlers/check-handler.ts index 556a86b..3c3c93d 100644 --- a/src/language/compiling/semantics/keyword-handlers/check-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/check-handler.ts @@ -1,4 +1,5 @@ -import { either, option, type Either } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option from '@matt.kantor/option' import type { ElaborationError } from '../../../errors.js' import { asSemanticGraph, diff --git a/src/language/compiling/semantics/keyword-handlers/function-handler.ts b/src/language/compiling/semantics/keyword-handlers/function-handler.ts index e8679f7..141807d 100644 --- a/src/language/compiling/semantics/keyword-handlers/function-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/function-handler.ts @@ -1,4 +1,5 @@ -import { either, option, type Either } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option from '@matt.kantor/option' import type { ElaborationError } from '../../../errors.js' import { asSemanticGraph, diff --git a/src/language/compiling/semantics/keyword-handlers/lookup-handler.ts b/src/language/compiling/semantics/keyword-handlers/lookup-handler.ts index b62e3ab..a04d733 100644 --- a/src/language/compiling/semantics/keyword-handlers/lookup-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/lookup-handler.ts @@ -1,4 +1,5 @@ -import { either, option, type Either, type Option } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option, { type Option } from '@matt.kantor/option' import type { ElaborationError, InvalidExpressionError, diff --git a/src/language/compiling/semantics/keyword-handlers/runtime-handler.ts b/src/language/compiling/semantics/keyword-handlers/runtime-handler.ts index ec0ca1d..cca10a2 100644 --- a/src/language/compiling/semantics/keyword-handlers/runtime-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/runtime-handler.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../../errors.js' import { asSemanticGraph, diff --git a/src/language/compiling/semantics/keyword-handlers/todo-handler.ts b/src/language/compiling/semantics/keyword-handlers/todo-handler.ts index 96ff8ba..ad48d9e 100644 --- a/src/language/compiling/semantics/keyword-handlers/todo-handler.ts +++ b/src/language/compiling/semantics/keyword-handlers/todo-handler.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../../errors.js' import { makeObjectNode, diff --git a/src/language/parsing/parser.ts b/src/language/parsing/parser.ts index 93cac67..9e90504 100644 --- a/src/language/parsing/parser.ts +++ b/src/language/parsing/parser.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ParseError } from '../errors.js' import { type SyntaxTree, syntaxTreeParser } from './syntax-tree.js' diff --git a/src/language/parsing/syntax-tree.ts b/src/language/parsing/syntax-tree.ts index 33a58f7..eca9d37 100644 --- a/src/language/parsing/syntax-tree.ts +++ b/src/language/parsing/syntax-tree.ts @@ -1,4 +1,4 @@ -import { option, type Option } from '../../adts.js' +import option, { type Option } from '@matt.kantor/option' import { parser, type Parser } from '../../parsing.js' import { withPhantomData, type WithPhantomData } from '../../phantom-data.js' import type { diff --git a/src/language/runtime/evaluator.test.ts b/src/language/runtime/evaluator.test.ts index cb34ace..80357ab 100644 --- a/src/language/runtime/evaluator.test.ts +++ b/src/language/runtime/evaluator.test.ts @@ -1,5 +1,5 @@ +import either, { type Either } from '@matt.kantor/either' import assert from 'node:assert' -import { either, type Either } from '../../adts.js' import { withPhantomData } from '../../phantom-data.js' import { testCases } from '../../test-utilities.test.js' import type { ElaborationError } from '../errors.js' diff --git a/src/language/runtime/evaluator.ts b/src/language/runtime/evaluator.ts index ecb63e7..cd7e8c7 100644 --- a/src/language/runtime/evaluator.ts +++ b/src/language/runtime/evaluator.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { RuntimeError } from '../errors.js' import type { JsonValueForbiddingSymbolicKeys } from '../parsing.js' import { canonicalize } from '../parsing.js' diff --git a/src/language/runtime/keywords.ts b/src/language/runtime/keywords.ts index 65ee21e..27a8110 100644 --- a/src/language/runtime/keywords.ts +++ b/src/language/runtime/keywords.ts @@ -1,5 +1,6 @@ +import either from '@matt.kantor/either' +import option, { type Option } from '@matt.kantor/option' import { parseArgs } from 'util' -import { either, option, type Option } from '../../adts.js' import { writeOutput } from '../cli/output.js' import { keywordHandlers as compilerKeywordHandlers } from '../compiling.js' import type { Atom } from '../parsing.js' diff --git a/src/language/semantics/expression-elaboration.ts b/src/language/semantics/expression-elaboration.ts index dd23586..1214f29 100644 --- a/src/language/semantics/expression-elaboration.ts +++ b/src/language/semantics/expression-elaboration.ts @@ -1,4 +1,5 @@ -import { either, option, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option from '@matt.kantor/option' import { withPhantomData, type WithPhantomData } from '../../phantom-data.js' import type { Writable } from '../../utility-types.js' import type { ElaborationError, InvalidSyntaxTreeError } from '../errors.js' @@ -158,23 +159,20 @@ const handleObjectNodeWhichMayBeAExpression = ( context: ExpressionContext, ): Either => { const { 0: possibleKeyword, ...possibleArguments } = node - return option.match(option.fromPredicate(possibleKeyword, isKeyword), { - none: () => - /^@[^@]/.test(possibleKeyword) - ? either.makeLeft({ - kind: 'unknownKeyword', - message: `unknown keyword: \`${possibleKeyword}\``, - }) - : either.makeRight({ - ...node, - 0: unescapeKeywordSigil(possibleKeyword), - }), - some: keyword => - context.keywordHandlers[keyword]( - makeObjectNode({ ...possibleArguments, 0: keyword }), + return isKeyword(possibleKeyword) + ? context.keywordHandlers[possibleKeyword]( + makeObjectNode({ ...possibleArguments, 0: possibleKeyword }), context, - ), - }) + ) + : /^@[^@]/.test(possibleKeyword) + ? either.makeLeft({ + kind: 'unknownKeyword', + message: `unknown keyword: \`${possibleKeyword}\``, + }) + : either.makeRight({ + ...node, + 0: unescapeKeywordSigil(possibleKeyword), + }) } const handleAtomWhichMayNotBeAKeyword = ( diff --git a/src/language/semantics/expressions/apply-expression.ts b/src/language/semantics/expressions/apply-expression.ts index b7acecd..dc62309 100644 --- a/src/language/semantics/expressions/apply-expression.ts +++ b/src/language/semantics/expressions/apply-expression.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../errors.js' import type { Molecule } from '../../parsing.js' import { isExpression } from '../expression.js' diff --git a/src/language/semantics/expressions/check-expression.ts b/src/language/semantics/expressions/check-expression.ts index d7d33f8..4af79b3 100644 --- a/src/language/semantics/expressions/check-expression.ts +++ b/src/language/semantics/expressions/check-expression.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../errors.js' import type { Molecule } from '../../parsing.js' import { isExpression } from '../expression.js' diff --git a/src/language/semantics/expressions/expression-utilities.ts b/src/language/semantics/expressions/expression-utilities.ts index 5ebb41b..4edaed9 100644 --- a/src/language/semantics/expressions/expression-utilities.ts +++ b/src/language/semantics/expressions/expression-utilities.ts @@ -1,4 +1,5 @@ -import { either, option, type Either, type Option } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option, { type Option } from '@matt.kantor/option' import type { ElaborationError } from '../../errors.js' import type { Atom, Molecule } from '../../parsing.js' import type { ExpressionContext } from '../expression-elaboration.js' diff --git a/src/language/semantics/expressions/function-expression.ts b/src/language/semantics/expressions/function-expression.ts index bbf802e..96fd5d4 100644 --- a/src/language/semantics/expressions/function-expression.ts +++ b/src/language/semantics/expressions/function-expression.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../errors.js' import type { Atom, Molecule } from '../../parsing.js' import { isExpression } from '../expression.js' diff --git a/src/language/semantics/expressions/lookup-expression.ts b/src/language/semantics/expressions/lookup-expression.ts index 9acf0b0..241ddb6 100644 --- a/src/language/semantics/expressions/lookup-expression.ts +++ b/src/language/semantics/expressions/lookup-expression.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError, InvalidExpressionError } from '../../errors.js' import type { Molecule } from '../../parsing.js' import { isExpression } from '../expression.js' diff --git a/src/language/semantics/expressions/runtime-expression.ts b/src/language/semantics/expressions/runtime-expression.ts index d1edffc..f9ccf09 100644 --- a/src/language/semantics/expressions/runtime-expression.ts +++ b/src/language/semantics/expressions/runtime-expression.ts @@ -1,4 +1,4 @@ -import { either, type Either } from '../../../adts.js' +import either, { type Either } from '@matt.kantor/either' import type { ElaborationError } from '../../errors.js' import type { Molecule } from '../../parsing.js' import { isExpression } from '../expression.js' diff --git a/src/language/semantics/function-node.ts b/src/language/semantics/function-node.ts index 0016b7b..5b0d506 100644 --- a/src/language/semantics/function-node.ts +++ b/src/language/semantics/function-node.ts @@ -1,4 +1,5 @@ -import { either, type Either, type Option } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import { type Option } from '@matt.kantor/option' import type { Writable } from '../../utility-types.js' import type { DependencyUnavailable, diff --git a/src/language/semantics/key-path.ts b/src/language/semantics/key-path.ts index d35109f..6c2743c 100644 --- a/src/language/semantics/key-path.ts +++ b/src/language/semantics/key-path.ts @@ -1,4 +1,4 @@ -import { either } from '../../adts.js' +import either from '@matt.kantor/either' import type { Atom, Molecule } from '../parsing.js' import { unparse } from '../unparsing.js' import { inlinePlz } from '../unparsing/inline-plz.js' diff --git a/src/language/semantics/object-node.ts b/src/language/semantics/object-node.ts index 41f8be3..7f554d7 100644 --- a/src/language/semantics/object-node.ts +++ b/src/language/semantics/object-node.ts @@ -1,4 +1,5 @@ -import { either, option, type Either, type Option } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option, { type Option } from '@matt.kantor/option' import type { Writable } from '../../utility-types.js' import type { UnserializableValueError } from '../errors.js' import type { Atom, Molecule } from '../parsing.js' diff --git a/src/language/semantics/prelude.ts b/src/language/semantics/prelude.ts index ba016ea..dd22c1e 100644 --- a/src/language/semantics/prelude.ts +++ b/src/language/semantics/prelude.ts @@ -1,4 +1,5 @@ -import { either, option, type Either } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option from '@matt.kantor/option' import type { DependencyUnavailable, Panic } from '../errors.js' import type { Atom } from '../parsing.js' import { isFunctionNode, makeFunctionNode } from './function-node.js' diff --git a/src/language/semantics/semantic-graph.ts b/src/language/semantics/semantic-graph.ts index 990ca89..3787bb8 100644 --- a/src/language/semantics/semantic-graph.ts +++ b/src/language/semantics/semantic-graph.ts @@ -1,4 +1,5 @@ -import { either, option, type Either, type Option } from '../../adts.js' +import either, { type Either } from '@matt.kantor/either' +import option, { type Option } from '@matt.kantor/option' import { withPhantomData, type WithPhantomData } from '../../phantom-data.js' import type { InvalidExpressionError, diff --git a/src/language/semantics/type-system/prelude-types.ts b/src/language/semantics/type-system/prelude-types.ts index 23e64a3..606bfa6 100644 --- a/src/language/semantics/type-system/prelude-types.ts +++ b/src/language/semantics/type-system/prelude-types.ts @@ -1,4 +1,4 @@ -import { option as optionAdt } from '../../../adts.js' +import optionAdt from '@matt.kantor/option' import { makeFunctionType, makeObjectType, diff --git a/src/language/semantics/type-system/type-formats.ts b/src/language/semantics/type-system/type-formats.ts index 070a6a7..f2373dc 100644 --- a/src/language/semantics/type-system/type-formats.ts +++ b/src/language/semantics/type-system/type-formats.ts @@ -1,5 +1,5 @@ -import { option } from '../../../adts.js' -import type { None, Some } from '../../../adts/option.js' +import type { None, Some } from '@matt.kantor/option' +import option from '@matt.kantor/option' import type { Atom } from '../../parsing.js' export type FunctionType = { diff --git a/src/language/unparsing.ts b/src/language/unparsing.ts index 5a31b51..0414312 100644 --- a/src/language/unparsing.ts +++ b/src/language/unparsing.ts @@ -1,4 +1,4 @@ -import type { Either } from '../adts.js' +import type { Either } from '@matt.kantor/either' import type { UnserializableValueError } from './errors.js' import type { Atom, Molecule } from './parsing.js' import type { Notation } from './unparsing/unparsing-utilities.js' diff --git a/src/language/unparsing/inline-plz.ts b/src/language/unparsing/inline-plz.ts index 4d936c5..04f6687 100644 --- a/src/language/unparsing/inline-plz.ts +++ b/src/language/unparsing/inline-plz.ts @@ -1,6 +1,6 @@ +import type { Right } from '@matt.kantor/either' +import either, { type Either } from '@matt.kantor/either' import kleur from 'kleur' -import { either, type Either } from '../../adts.js' -import type { Right } from '../../adts/either.js' import type { UnserializableValueError } from '../errors.js' import type { Atom, Molecule } from '../parsing.js' import { unquotedAtomParser } from '../parsing/atom.js' diff --git a/src/language/unparsing/pretty-json.ts b/src/language/unparsing/pretty-json.ts index 61e6946..81f372f 100644 --- a/src/language/unparsing/pretty-json.ts +++ b/src/language/unparsing/pretty-json.ts @@ -1,6 +1,6 @@ +import type { Right } from '@matt.kantor/either' +import either from '@matt.kantor/either' import kleur from 'kleur' -import { either } from '../../adts.js' -import type { Right } from '../../adts/either.js' import type { Atom, Molecule } from '../parsing.js' import { indent, type Notation } from './unparsing-utilities.js' diff --git a/src/language/unparsing/pretty-plz.ts b/src/language/unparsing/pretty-plz.ts index ea961b9..51dbeaa 100644 --- a/src/language/unparsing/pretty-plz.ts +++ b/src/language/unparsing/pretty-plz.ts @@ -1,6 +1,6 @@ +import type { Right } from '@matt.kantor/either' +import either, { type Either } from '@matt.kantor/either' import kleur from 'kleur' -import { either, type Either } from '../../adts.js' -import type { Right } from '../../adts/either.js' import type { UnserializableValueError } from '../errors.js' import type { Atom, Molecule } from '../parsing.js' import { unquotedAtomParser } from '../parsing/atom.js' diff --git a/src/language/unparsing/unparsing-utilities.ts b/src/language/unparsing/unparsing-utilities.ts index ba0cebe..654e4be 100644 --- a/src/language/unparsing/unparsing-utilities.ts +++ b/src/language/unparsing/unparsing-utilities.ts @@ -1,4 +1,4 @@ -import { type Either } from '../../adts.js' +import { type Either } from '@matt.kantor/either' import type { UnserializableValueError } from '../errors.js' import type { Atom, Molecule } from '../parsing.js' diff --git a/src/parsing/combinators.ts b/src/parsing/combinators.ts index 7f5a82b..3e40916 100644 --- a/src/parsing/combinators.ts +++ b/src/parsing/combinators.ts @@ -1,4 +1,4 @@ -import { either } from '../adts.js' +import either from '@matt.kantor/either' import { nothing } from './constructors.js' import type { AlwaysSucceedingParser, Parser, Success } from './parser.js' diff --git a/src/parsing/constructors.ts b/src/parsing/constructors.ts index d6ebeb4..b761cdc 100644 --- a/src/parsing/constructors.ts +++ b/src/parsing/constructors.ts @@ -1,4 +1,4 @@ -import { either } from '../adts.js' +import either from '@matt.kantor/either' import type { AlwaysSucceedingParser, Parser } from './parser.js' export const anySingleCharacter: Parser = input => { diff --git a/src/parsing/parser.ts b/src/parsing/parser.ts index dac9446..240e776 100644 --- a/src/parsing/parser.ts +++ b/src/parsing/parser.ts @@ -1,5 +1,4 @@ -import type { Either } from '../adts.js' -import type { Right } from '../adts/either.js' +import type { Either, Right } from '@matt.kantor/either' export type Success = { readonly remainingInput: string