sam-goodwin / punchcard

Type-safe AWS infrastructure.
Apache License 2.0
507 stars 20 forks source link

generalize enumerables and event sources #16

Closed sam-goodwin closed 5 years ago

sam-goodwin commented 5 years ago

There's a lot of redundancy in the enumerable implementations: https://github.com/sam-goodwin/punchcard/tree/master/packages/punchcard/lib/enumerable

Can we extract out the common bits into something like a Functor?

Also, the run method is statically mapped to the event type, e.g. SQSEvent, maybe we can model event sources generically, e.g. Queue implements Source<SQSEvent> which exposes subscribe(sink: Sink<SQSEvent>)?

sam-goodwin commented 5 years ago

Modeled a nice Functor-like thing-o in this commit: https://github.com/sam-goodwin/punchcard/commit/a656da447a7cdca6608e4dde56f239568ecd3d5a

Feels right.

sam-goodwin commented 5 years ago

Another pass: https://github.com/sam-goodwin/punchcard/commit/1f39fe995c26f2460f835aca7e9502e01b472e36

I wonder how difficult it would be to integrate with these guy's Functor: https://github.com/gcanti/fp-ts