[Haskell-cafe] Config Files and monoids

Sven Panne svenpanne at gmail.com
Fri May 25 13:58:58 UTC 2018


2018-05-24 23:00 GMT+02:00 Olaf Klinke <olf at aatal-apotheke.de>:

> [...] 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-31914a71fc67
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180525/52637c02/attachment.html>


More information about the Haskell-Cafe mailing list