aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts42
1 files changed, 6 insertions, 36 deletions
diff --git a/src/index.ts b/src/index.ts
index aad0c00..7ee4461 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,47 +1,17 @@
-export interface EffectAtom<T = unknown> { output: T }
-export type Effect = EffectAtom[]
-
-export interface PutString<_ extends string> extends EffectAtom { }
-export interface Print<_ extends any> extends EffectAtom { }
-export interface Debug<_ extends string, T> extends EffectAtom<T> { }
-
-export interface WriteFile<_Path extends string, _Content extends string> extends EffectAtom { }
-export interface ReadFile<_Path extends string> extends EffectAtom<string> { }
-
-export interface GetEnv<_Name extends string> extends EffectAtom<string> { }
-export interface GetArgs extends EffectAtom<string[]> { }
-
-export interface ReadLine extends EffectAtom<string> { }
-
-export interface JsExpr<_Expr extends string> extends EffectAtom<any> { }
-
-export interface Program<Effs extends Effect, ExitCode extends number = 0> {
- effects: Effs,
- exitCode: ExitCode,
-}
-
-export interface Kind1<Inp = unknown, Out = unknown> {
- input: Inp
- return: Out
-}
-
-export interface ChainIO<Eff extends EffectAtom, Fn extends Kind1> extends EffectAtom {
- input: Eff
- chainTo: Fn
-}
+import { Program, Print, PutString, Bind, Debug, Kind1, GetEnv, JsExpr, ReadFile, GetArgs, ReadLine } from './stdlib'
interface PrintK<Label extends string = ""> extends Kind1<unknown> {
return: Debug<Label, this['input']>
}
export type main = Program<[
- ChainIO<GetArgs, PrintK>,
+ Bind<GetArgs, PrintK>,
[1, 2, 3] extends infer Res ? Print<Res> : never,
- ChainIO<GetEnv<"NODE_ENV">, PrintK>,
- ChainIO<JsExpr<"{ boobaa: [5 * 3, 5 * 2] }">, PrintK>,
+ Bind<GetEnv<"NODE_ENV">, PrintK>,
+ Bind<JsExpr<"{ boobaa: [5 * 3, 5 * 2] }">, PrintK>,
// ChainIO<ReadLine, WithInputK>,
- ChainIO<ReadFile<"./default.nix">, PrintK>,
+ Bind<ReadFile<"./default.nix">, PrintK>,
PutString<"Your name? ">,
- // ChainIO<ReadLine, PrintK<"Hello,">>,
+ Bind<ReadLine, PrintK<"Hello,">>,
]>