On Mon, Jan 21, 2013 at 03:54:39PM +0000, Dato Simó wrote: > On Mon, Jan 21, 2013 at 11:26 +0100, Iustin Pop <[email protected]> wrote: > > > - First I wanted to just re-specify the default values, getting them > > > from somewhere; but it seems the corresponding field accessors are > > > not exported from Ganeti.THH (and perhaps they shouldn't be, > > > indeed). > > > The field accessors for sure are exported, but most probably with > > different names, and not from Ganeti.THH, but rather directly from > > Ganeti.OpCodes: > > > *Ganeti.OpCodes> :i OpInstanceCreate > > data OpCode > > = ... > > | OpInstanceCreate {opInstanceName :: String, > > opForceVariant :: Bool, > > opWaitForSync :: Bool, > > opNameCheck :: Bool, > > > So not p* - those are helper names. > > Just to clarify, what I wanted to do was something like: > > opShutdownTimeout = fieldDefault pShutdownTimeout > > The accesor I was referring to was "fieldDefault", in this case.
The problem with this would be that it would leak both the field accessor and the parameter definitions; this is "bad" as in would promote the technical details of how we build the opcodes to the users of opcodes (both of these are related to THH). Acceptable, but not ideal… What I would like to have, but not sure yet how clean/easy it would be, would be to provide either a fully-defined opcode where the non-default fields are 'undefined' or even 'error "Programmer error: uninitialised field"', but this would fail at runtime, or a function which only takes the non-default arguments (would fail at compile time, but would be a bit uglier to sort out which parameters come where). thanks, iustin
