This newtype wrapper can be used to derive default instances for classes taking an argument of kind Type.
Instances6GEnum, GEq, GShow, Uniplate, GMonoid, GSemigroup
(Generic a, GEq a, Enum' (Rep a)) => GEnum (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.DefaultThe Enum class in
baseis slightly different; it comprises toEnum and fromEnum. Generics.Deriving.Enum provides functions toEnumDefault and fromEnumDefault.(Generic a, GEq' (Rep a)) => GEq (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.Default(Generic a, GShow' (Rep a)) => GShow (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.DefaultFor example, with this type:
newtype TestShow = TestShow Bool deriving (GShow) via (Default Bool)gshow for
TestShowwould produce the same string as gshow for Bool.In this example,
TestShowrequires no Generic instance, as the constraint on gshowsPrec fromDefault BoolisGeneric Bool.In general, when using a newtype wrapper, the instance can be derived via the wrapped type, as here (via
Default Boolrather thanDefault TestShow).(Generic a, Uniplate' (Rep a) a, Context' (Rep a) a) => Uniplate (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.Default(Generic a, GMonoid' (Rep a)) => GMonoid (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.Default(Generic a, GSemigroup' (Rep a)) => GSemigroup (Default a)Defined in generic-deriving-1.14.6 · Generics.Deriving.DefaultSemigroups often have many sensible implementations of
Data.Semigroup.<>/ gsappend, and therefore no sensible default. Indeed, there is no GSemigroup' instance for representations of sum types.In other cases, one may wish to use the existing wrapper newtypes in
base, such as the following (using First):newtype FirstSemigroup = FirstSemigroup Bool deriving stock (Eq, Show) deriving (GSemigroup) via (First Bool)