-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.ts
More file actions
28 lines (25 loc) · 971 Bytes
/
Copy pathfunction.ts
File metadata and controls
28 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Schema } from 'effect'
import { IdentExp, type IdentExpEncoded } from '../nodes/exps/ident'
import { BlockStmt, type BlockStmtEncoded } from '../nodes/stmts/block'
import { Environment, EnvironmentEncoded, environmentSchema } from '@/services/object/environment'
export interface FunctionObj {
readonly _tag: 'FunctionObj'
readonly params: readonly IdentExp[]
readonly body: BlockStmt
readonly env: Environment
}
export interface FunctionObjEncoded {
readonly _tag: 'FunctionObj'
readonly params: readonly IdentExpEncoded[]
readonly body: BlockStmtEncoded
readonly env: EnvironmentEncoded
}
export const functionObjSchema = Schema.TaggedStruct('FunctionObj', {
params: Schema.Array(
Schema.suspend((): Schema.Schema<IdentExp, IdentExpEncoded> => IdentExp),
),
body: Schema.suspend(
(): Schema.Schema<BlockStmt, BlockStmtEncoded> => BlockStmt,
),
env: Schema.suspend((): Schema.Schema<Environment, EnvironmentEncoded> => environmentSchema)
})