
16 Jul
2013
16 Jul
'13
5:06 p.m.
On Tue, Jul 16, 2013 at 04:57:59PM -0400, Michael Orlitzky wrote:
This all works great, except that when there's 20 or so options, I duplicate a ton of code in the definition of OptionalCfg. Is there some pre-existing solution that will let me take a Cfg and create a new type with Cfg's fields wrapped in Maybe?
You can always try data Cfg f = Cfg { verbose :: f Bool } and set f to Maybe or Identity depending on what you use it for. It will be slightly notationally cumbersome to extract values from the Identity functor though. Tom