Remove configuration step / depedency injection
Having the ability to handle type errors with a custom handler was a cool idea, but in practice I've never actually reached for it.
And so it seems like needless complexity. If it's so hard to initialize the library, it starts to make sense to reach for something heavier, especially in node.
I also think the dev/prod distinction was a cool idea, and could potentially remain but as an optional module. In practice the dev module is still extremely small and I've not ever opted for using the super lightweight prod version. It just adds to library initialization complexity.
Additionally, I'm finding myself using just yslashn
, or just taggy
for a particular file. And it'd be nice to not have to import static-sum-type
separately. It'd be nice for all the static-sum-type functions to be available on whatever module namespace.
I'm also not averse to adding methods to generated types that just dispatch to the sst function. It'd be pretty nice to do just do the following:
const yslashn = require('yslashn')
const Loaded = yslashn.maybe('Loaded')
Loaded.map( console.log )
// or
ylashn.map (Loaded) (console.log)
instead of:
const yslashn = require('static-sum-type/modules/yslashn')
const sst = require('static-sum-type/configs/dev/foldThrow')
const Loaded = yslashn.maybe('Loaded')
sst.map (Loaded) ( console.log )
But there's Rich Hickey in my ear advocating for simplicity. Perhaps fixing the import story alone is enough:
const yslashn = require('yslashn')
const { map } = require('static-sum-type')
const Loaded = yslashn.maybe('Loaded')
map (Loaded) ( console.log )
That's probably a good start.