
25 May
2018
25 May
'18
9:58 a.m.
2018-05-24 23:00 GMT+02:00 Olaf Klinke
[...] I'm struggling to make the concept of monoidal configuration work when there is no sensible default configuration. Suppose my configuration type is
data Config = Config {foo :: Bool, bar :: Int}
with no reasonable default, e.g.
emptyConfig = Config { foo = error "you did not specify option foo", bar = error "you did not specify option bar" } [...]
I find the approach in https://medium.com/@jonathangfischoff/the-partial-options-monoid-pattern-319... quite straightforward, without any need for higher-kinded stuff, generics or lenses: Just distinguish between partial and non-partial options, and make a Monoid instance only for the partial ones. Cheers, S.