-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A class for types with a default value.
--
-- An alternative to data-default package, that provides a lot of
-- additional instances for Default type class.
--
-- Default type class provides a default value (def) of
-- a type. In case when a particluar type has an instance for
-- Monoid, then the default value should be mempty,
-- otherwise it can cause a great deal of confusion.
--
-- One must understand, that Default type class, has no axioms
-- associated with it. Its purpose is to minimize:
--
--
-- - Number of imports.
-- - Number of introduced definitions that are part of an API.
-- - Complexity of building more complicated "default values" out of
-- simpler "default values".
-- - Cognitive overhead. (Reduction of cognitive overhead is partially
-- a consequence of reducing above issues.)
--
--
-- As one may notice, most of the listed problems, that Default
-- type class tries to solve, to various degrees of success, are for
-- human benefit, and not theoretically founded. Because of this, please
-- always try hard to define sensible instances of Default. Most
-- importantly, document what def means for particular type, and
-- always check that def is sensible, by testing it on a real
-- world sample of human beings, one is not a big enough sample.
--
-- That said, using Default may not always be a good idea. If it
-- breaks people's mental model, or theoretical models with real axioms,
-- then just don't use it.
@package data-default-extra
@version 0.0.1
-- | Create Default instances using GHC Generics. For more
-- information see:
--
--
module Data.Default.Generic
-- | Derive implementation of def by using GHC Generics.
genericDef :: (Generic a, GDefault (Rep a)) => a
-- | Simple derivation of def definition that handles only product
-- types, but not sum types. In case of sum types it is better to provide
-- hand written instances for Default.
class GDefault f
gdef :: GDefault f => f a
instance Data.Default.Generic.GDefault GHC.Generics.U1
instance Data.Default.Class.Default a => Data.Default.Generic.GDefault (GHC.Generics.K1 i a)
instance Data.Default.Generic.GDefault a => Data.Default.Generic.GDefault (GHC.Generics.M1 i c a)
instance (Data.Default.Generic.GDefault a, Data.Default.Generic.GDefault b) => Data.Default.Generic.GDefault (a GHC.Generics.:*: b)
-- | A class for types with a default value.
module Data.Default
-- | A class for types with a default value.
class Default a
-- | The default value for this type.
def :: Default a => a
-- | The default value for type a.
defOf :: Default a => proxy a -> a