sam-goodwin / punchcard

Type-safe AWS infrastructure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

monadic step functions

sam-goodwin opened this issue · comments

commented

I'm wondering if we can build a functional/monadic interface for AWS Step Functions:

Sources for inspiration:

  • https://github.com/gcanti/fp-ts: Functional Programming in TypeScript
    • Maybe the Free Monad?
    • Their v2 discussion is also interesting. In particular: their plan to implement do-notation with generators once this change is merged and they are statically typed.
  • Maybe redux-saga's free-monad'ish implementation could be used for building up an AST description of the step function flow.
// a rough sketch of what it may look like:
*function() {
  const runFunction = yield new Function(...);

  const choice = yield new Choice(...)

  return yield new Parallel(...)
}

Any progress on this idea, or perhaps some similar project elsewhere?

commented

No, I haven't been working on punchcard for a while but I'd love to circle back to this. I did try hooking into the typescript compiler to convert regular if-else, for, while syntax to step functions - that looked promising.

Do you have any ideas? Are you using punchcard or looking for somethings standalone/simpler?

I played with it but nothing in production. As far as I recall I had some issues around the decoding of enums, and went for zod instead.

But yeah, I would prefer something simple or just focused on making step fns type safe, it doesn't even be something that would parse "*" functions in do notation or anything like that, just plain good old types covering all states (choice, parallel, etc) and all of @aws-cdk/aws-stepfunctions-tasks.