Learn / Write your own language, store or protocol
Bundle custom operations into a Language
Language.make groups operations into named families. Build a JavaScript implementation table, then use Language.complete to check that it covers every operation in the language.
ts
import { Schema } from 'effect'
import * as Language from '@doeixd/metakit/language'
import * as Operation from '@doeixd/metakit/operation'
const flagsOr = Operation.define({ id: 'flags.or', args: [Schema.Int, Schema.Int], returns: Schema.Int })
const Permissions = Language.make({ flags: { or: flagsOr } })
const serverImpls = Operation.implementations(
'server',
Operation.implement(flagsOr, (a, b) => a | b),
)
const checked = Language.complete(Permissions, serverImpls)checked is the same table as serverImpls. Pass it to each evaluation as { foreign: checked }, or once to an Effect program with Interpreter.withForeign(checked) from @doeixd/metakit/interpreter. Omit the flagsOr implementation and Language.complete reports a missing binding for flags.or@1. Build a partial table with Operation.implementations alone. To bind a function named with Operation.derived, list its .implementation so evaluation checks contracts such as where. Give a checked function an operation name.
- Use
sql(language, dialect)from@doeixd/metakit/language/sqlto check the language's default SQL lowerings. Pass a table from@doeixd/metakit/operation/sqlas the third argument to check that table. - Use
Language.describe(language)to compare the operation signatures known to the client and server. - Use
lawObligations(language, tables)from@doeixd/metakit/conformanceto list the laws your implementations must demonstrate.