aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2023-01-05 17:29:17 +0530
committerAkshay Nair <phenax5@gmail.com>2023-01-05 17:29:17 +0530
commit35419c2bf7444c2ba32172ee0a6c00d88913598c (patch)
treee401aec5cbd8501b3974bff1a47778848e5a8962
parent5f5ea35c634cd97710eb953f930cc4d468c948ce (diff)
downloadts-types-lang-35419c2bf7444c2ba32172ee0a6c00d88913598c.tar.gz
ts-types-lang-35419c2bf7444c2ba32172ee0a6c00d88913598c.zip
feat: runtime ready yo
Diffstat (limited to '')
-rw-r--r--src/index.ts21
-rw-r--r--src/runtime.ts6
2 files changed, 9 insertions, 18 deletions
diff --git a/src/index.ts b/src/index.ts
index accde98..87eea0b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -13,27 +13,22 @@ export interface Program<Effs extends Effect, ExitCode extends number = 0> {
exitCode: ExitCode,
}
-export interface Kind<Inp = unknown, Out = unknown> {
+export interface Kind1<Inp = unknown, Out = unknown> {
input: Inp
return: Out
}
-export interface WriteFileC extends Kind<string> {
- return: WriteFile<"./somefile.txt", this['input']>
-}
-
-export interface ChainIO<Eff extends EffectAtom, Fn extends Kind> extends EffectAtom {
+export interface ChainIO<Eff extends EffectAtom, Fn extends Kind1> extends EffectAtom {
input: Eff
chainTo: Fn
}
+export interface PrintK extends Kind1<string> {
+ return: Print<this['input']>
+}
+
export type main = Program<[
[1, 2, 3] extends infer Res ? Print<Res> : never,
- Print<"bye bye">,
- ReadFile<"./.gitignore">,
-
- ChainIO<
- ReadFile<"./default.nix">,
- WriteFileC
- >,
+ Print<`wow: ${string} -> ${'helo'}`>,
+ ChainIO<ReadFile<"./default.nix">, PrintK>,
]>
diff --git a/src/runtime.ts b/src/runtime.ts
index d03e7a9..8174118 100644
--- a/src/runtime.ts
+++ b/src/runtime.ts
@@ -70,7 +70,6 @@ const evalAccumulator = (effNode: Node, node: Node) => {
const name = effTyp.getSymbol()?.getName()
switch (name) {
- case 'PrintString':
case 'Print':
console.log(...effTyp.getTypeArguments().map(typeToString));
return null
@@ -90,7 +89,6 @@ const evalAccumulator = (effNode: Node, node: Node) => {
case 'ChainIO':
const inputTyp = effTyp.getProperty('input')?.getTypeAtLocation(node)
const chainToKind = effTyp.getProperty('chainTo')?.getTypeAtLocation(node)
- console.log('wow')
const [hashRes] = inputTyp ? accumulateResults(inputTyp, node) : []
const chainRes = `(${typeToString(chainToKind)} & { input: ${RESULT_TYPE_NAME}[${JSON.stringify(hashRes)}]['output'] })['return']`
@@ -113,8 +111,6 @@ if (typeRefNode) {
const exitCodeTy = getPropertyType(typeRefNode, 'exitCode')
const effectTypes = getPropertyType(typeRefNode, 'effects')
if (effectTypes?.isTuple()) {
- console.log('Effects to run', effectTypes?.getTupleElements().map(eff => typeToString(eff)))
-
const effectNodes = entryPoint.getChildrenOfKind(SyntaxKind.TypeReference)
.flatMap(n => n.getChildrenOfKind(SyntaxKind.TupleType))
.flatMap(tt => tt.getChildrenOfKind(SyntaxKind.SyntaxList))
@@ -124,7 +120,7 @@ if (typeRefNode) {
effectNodes.flatMap(n => evalAccumulator(n, typeRefNode))
}
- console.log('Exited with code', exitCodeTy?.getLiteralValue())
+ process.exit(exitCodeTy?.getLiteralValue() as number)
} else {
const ty = typeChecker.getTypeAtLocation(typeRefNode)
console.log(typeToString(ty))