You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lars Kuhtz edited this page Jan 29, 2015
·
1 revision
Ideas for an Configuration DSL
The DSL may include syntax for defining the configuration type, or it may cover only functions and instances
for an existing type. The former would require usage of Template Haskell, the latter could be done in plain
Haskell for instance through a free monad.
Elements of the configuration idiom for a type T:
the configuration type T itself
default value for T
validation function for T
instance ToJSON T
instance FromJSON (T -> T)
command line parsing function for T
possibly (in case of maybe) instance FromJSON T
possibly an arbitrary instance
possibly some test properties
Things that could be shared (or derived)
property names between ToJSON and FromJSON instances
property names could be derived from record field names
option names could be derived from property names or field names
command line help messages and config file documentation could be shared
ToJSON instance could be derived from T
FromJSON instances could be derived from the T (needs some parameters)
option parser could (mostly and often) be derived from T
essentially all of the above could be used in test properties
arbitrary instance could explicitly include the default value