Skip to content

Commit f61830a

Browse files
committed
Move prelude out of compiler, improve many imports
1 parent c018fc2 commit f61830a

File tree

9 files changed

+48
-59
lines changed

9 files changed

+48
-59
lines changed

src/language/compiling/semantics.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
type ElaboratedSemanticGraph,
1313
type ObjectNode,
1414
} from '../semantics.js'
15+
import { prelude } from '../semantics/prelude.js'
1516
import type { SemanticGraph } from '../semantics/semantic-graph.js'
1617
import { keywordHandlers } from './semantics/keywords.js'
17-
import { prelude } from './semantics/prelude.js'
1818

1919
const elaborationSuite = testCases(
2020
(input: Atom | Molecule) =>

src/language/compiling/semantics/keyword-handlers/apply-handler.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@ import { either, type Either } from '../../../../adts.js'
22
import type { ElaborationError } from '../../../errors.js'
33
import {
44
asSemanticGraph,
5+
containsAnyUnelaboratedNodes,
56
isFunctionNode,
67
readApplyExpression,
78
type Expression,
8-
} from '../../../semantics.js'
9-
import {
109
type ExpressionContext,
1110
type KeywordHandler,
12-
} from '../../../semantics/expression-elaboration.js'
13-
import {
14-
containsAnyUnelaboratedNodes,
1511
type SemanticGraph,
16-
} from '../../../semantics/semantic-graph.js'
12+
} from '../../../semantics.js'
1713

1814
export const applyKeywordHandler: KeywordHandler = (
1915
expression: Expression,

src/language/compiling/semantics/keyword-handlers/check-handler.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,14 @@ import type { ElaborationError } from '../../../errors.js'
33
import {
44
asSemanticGraph,
55
isFunctionNode,
6+
lookupPropertyOfObjectNode,
67
readCheckExpression,
8+
stringifySemanticGraphForEndUser,
79
type Expression,
8-
} from '../../../semantics.js'
9-
import {
1010
type ExpressionContext,
1111
type KeywordHandler,
12-
} from '../../../semantics/expression-elaboration.js'
13-
import { lookupPropertyOfObjectNode } from '../../../semantics/object-node.js'
14-
import {
15-
stringifySemanticGraphForEndUser,
1612
type SemanticGraph,
17-
} from '../../../semantics/semantic-graph.js'
13+
} from '../../../semantics.js'
1814

1915
export const checkKeywordHandler: KeywordHandler = (
2016
expression: Expression,

src/language/compiling/semantics/keyword-handlers/function-handler.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@ import { either, option, type Either } from '../../../../adts.js'
22
import type { ElaborationError } from '../../../errors.js'
33
import {
44
asSemanticGraph,
5+
elaborateWithContext,
56
makeFunctionNode,
7+
makeObjectNode,
68
readFunctionExpression,
79
serialize,
810
types,
11+
updateValueAtKeyPathInSemanticGraph,
912
type Expression,
13+
type ExpressionContext,
1014
type FunctionExpression,
1115
type FunctionNode,
12-
} from '../../../semantics.js'
13-
import {
14-
elaborateWithContext,
15-
type ExpressionContext,
1616
type KeywordHandler,
17-
} from '../../../semantics/expression-elaboration.js'
18-
import { makeObjectNode } from '../../../semantics/object-node.js'
19-
import {
20-
updateValueAtKeyPathInSemanticGraph,
2117
type SemanticGraph,
22-
} from '../../../semantics/semantic-graph.js'
18+
} from '../../../semantics.js'
2319

2420
export const functionKeywordHandler: KeywordHandler = (
2521
expression: Expression,

src/language/compiling/semantics/keyword-handlers/lookup-handler.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,22 @@ import type {
44
InvalidExpressionError,
55
} from '../../../errors.js'
66
import {
7+
applyKeyPathToSemanticGraph,
8+
isObjectNode,
9+
keyPathToMolecule,
710
makeLookupExpression,
11+
makeObjectNode,
12+
prelude,
813
readFunctionExpression,
914
readLookupExpression,
15+
stringifyKeyPathForEndUser,
1016
type Expression,
11-
type KeyPath,
12-
} from '../../../semantics.js'
13-
import {
1417
type ExpressionContext,
18+
type KeyPath,
1519
type KeywordHandler,
16-
} from '../../../semantics/expression-elaboration.js'
17-
import {
18-
keyPathToMolecule,
19-
stringifyKeyPathForEndUser,
20-
} from '../../../semantics/key-path.js'
21-
import {
22-
isObjectNode,
23-
makeObjectNode,
2420
type ObjectNode,
25-
} from '../../../semantics/object-node.js'
26-
import {
27-
applyKeyPathToSemanticGraph,
2821
type SemanticGraph,
29-
} from '../../../semantics/semantic-graph.js'
30-
import { prelude } from '../prelude.js'
22+
} from '../../../semantics.js'
3123

3224
export const lookupKeywordHandler: KeywordHandler = (
3325
expression: Expression,

src/language/compiling/semantics/keyword-handlers/runtime-handler.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import {
99
replaceAllTypeParametersWithTheirConstraints,
1010
types,
1111
type Expression,
12-
} from '../../../semantics.js'
13-
import {
1412
type ExpressionContext,
1513
type KeywordHandler,
16-
} from '../../../semantics/expression-elaboration.js'
17-
import { type SemanticGraph } from '../../../semantics/semantic-graph.js'
14+
type SemanticGraph,
15+
} from '../../../semantics.js'
1816

1917
export const runtimeKeywordHandler: KeywordHandler = (
2018
expression: Expression,

src/language/compiling/semantics/keyword-handlers/todo-handler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { either, type Either } from '../../../../adts.js'
22
import type { ElaborationError } from '../../../errors.js'
3-
import type { Expression } from '../../../semantics.js'
43
import {
4+
makeObjectNode,
5+
type Expression,
56
type ExpressionContext,
67
type KeywordHandler,
7-
} from '../../../semantics/expression-elaboration.js'
8-
import { makeObjectNode } from '../../../semantics/object-node.js'
9-
import { type SemanticGraph } from '../../../semantics/semantic-graph.js'
8+
type SemanticGraph,
9+
} from '../../../semantics.js'
1010

1111
export const todoKeywordHandler: KeywordHandler = (
1212
_expression: Expression,

src/language/semantics.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export {
22
elaborate,
3+
elaborateWithContext,
34
type ElaboratedSemanticGraph,
45
type ExpressionContext,
56
type KeywordElaborationResult,
7+
type KeywordHandler,
68
type KeywordHandlers,
79
} from './semantics/expression-elaboration.js'
810
export { isExpression, type Expression } from './semantics/expression.js'
@@ -41,16 +43,26 @@ export {
4143
makeFunctionNode,
4244
type FunctionNode,
4345
} from './semantics/function-node.js'
44-
export { type KeyPath } from './semantics/key-path.js'
46+
export {
47+
keyPathToMolecule,
48+
stringifyKeyPathForEndUser,
49+
type KeyPath,
50+
} from './semantics/key-path.js'
4551
export { isKeyword, type Keyword } from './semantics/keyword.js'
4652
export {
4753
isObjectNode,
54+
lookupPropertyOfObjectNode,
4855
makeObjectNode,
4956
makeUnelaboratedObjectNode,
5057
type ObjectNode,
5158
} from './semantics/object-node.js'
59+
export { prelude } from './semantics/prelude.js'
5260
export {
61+
applyKeyPathToSemanticGraph,
62+
containsAnyUnelaboratedNodes,
5363
serialize,
64+
stringifySemanticGraphForEndUser,
65+
updateValueAtKeyPathInSemanticGraph,
5466
type Output,
5567
type SemanticGraph,
5668
} from './semantics/semantic-graph.js'

src/language/compiling/semantics/prelude.ts renamed to src/language/semantics/prelude.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
import { either, option, type Either } from '../../../adts.js'
2-
import type { DependencyUnavailable, Panic } from '../../errors.js'
3-
import type { Atom } from '../../parsing.js'
1+
import { either, option, type Either } from '../../adts.js'
2+
import type { DependencyUnavailable, Panic } from '../errors.js'
3+
import type { Atom } from '../parsing.js'
4+
import { isFunctionNode, makeFunctionNode } from './function-node.js'
5+
import { keyPathToMolecule } from './key-path.js'
46
import {
5-
isFunctionNode,
67
isObjectNode,
7-
makeFunctionNode,
8+
lookupPropertyOfObjectNode,
89
makeObjectNode,
910
makeUnelaboratedObjectNode,
10-
types,
1111
type ObjectNode,
12-
} from '../../semantics.js'
13-
import { keyPathToMolecule } from '../../semantics/key-path.js'
14-
import { lookupPropertyOfObjectNode } from '../../semantics/object-node.js'
12+
} from './object-node.js'
1513
import {
1614
containsAnyUnelaboratedNodes,
1715
isSemanticGraph,
1816
type SemanticGraph,
19-
} from '../../semantics/semantic-graph.js'
17+
} from './semantic-graph.js'
18+
import { types } from './type-system.js'
2019
import {
2120
makeFunctionType,
2221
makeObjectType,
2322
makeTypeParameter,
2423
makeUnionType,
2524
type FunctionType,
26-
} from '../../semantics/type-system/type-formats.js'
25+
} from './type-system/type-formats.js'
2726

2827
const handleUnavailableDependencies =
2928
(

0 commit comments

Comments
 (0)