data-default
A brilliant little package
It has taken me a while to properly appreciate data-default
, but I am getting there. It is deceptively simple.
[Beware, Haddocks don’t always deal gracefully with packages re-exporting things from other packages. In this case the Default
class is actually defined in data-default-class
where you can see its definition clearly, unlike in data-default
(currently).]
Default
allows you to nominate defaults for your types, allowing them to be deployed with the drop of a def
. If your type Foo
supports generics you can let the class work out the default,
and use it in situations where a Foo
is needed,
or maybe:
This works best where you have a type with an obvious canonical value, such as a configuration with an obvious default.
Got an issue with any of this? Please share or drop me a line (see below).