On Tue, Jan 22, 2013 at 05:17:23PM +0000, Dato Simó wrote: > On Mon, Jan 21, 2013 at 11:26 +0100, Iustin Pop <[email protected]> wrote: > > > - So then I tried to just hard-code the values: how do you suggest I > > > handle the NonNegative case? Would it be okay to just export > > > forceNonNegative from OpParams.hs? > > > Hmmm, that I was hoping to avoid. Please do so for now, but add a FIXME > > both in your code and near the export, as this shouldn't be done. > > I wasn't looking properly at mkNonNegative before. Given that > forceNonNegative just errors out if the conversion fails, I think I'll > dispense with exporting it, and just use: > > [OpInstanceFailover { ... > , opShutdownTimeout = fromJust $ mkNonNegative > C.defaultShutdownTimeout > ... > > which has the same effect, if that's ok. > > And for optional fields: > > [OpInstanceReplaceDisks { ... > , opIallocator = mkNonEmpty "hail" > > (Though perhaps `Just . fromJust $ mkNonEmpty "hail"` would be better, if we > want to insist in visible failures.)
Hmm… this works but only by accident: Maybe is the monad in which mkNonNegative/mkNonEmpty represent success/failure, but it's (unrelated) also the data type in which optional fields are denoting presence/failure. I like your hackish solution, I don't like that you can actually do it :P Please definitely add FIXMEs where you do this, it needs to be sorted out… thanks, iustin
