punchcard icon indicating copy to clipboard operation
punchcard copied to clipboard

monadic step functions

Open sam-goodwin opened this issue 6 years ago • 3 comments

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(...)
}

sam-goodwin avatar May 23 '19 22:05 sam-goodwin

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

joaomilho avatar Sep 02 '21 15:09 joaomilho

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?

sam-goodwin avatar Sep 03 '21 20:09 sam-goodwin

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.

joaomilho avatar Sep 05 '21 18:09 joaomilho