Has uses DefaultSignatures to provide a default implementation based on HasField and Dep.
It would be nice to support deriving that same instance suing DerivingVia and an auxiliary newtype. That way is more explicit, at the cost of more verbosity.
It would look like this:
newtype TheDefaultFieldName env = TheDefaultFieldName env
instance (Dep r_, HasField (DefaultFieldName r_) (env_ m) u, Coercible u (r_ m))
=> Has r_ m (TheDefaultFieldName (env_ m)) where
dep (TheDefaultFieldName env) = coerce . getField @(DefaultFieldName r_) $ env
And be used like
deriving via (TheDefaultFieldName (EnvHKD I m)) instance Has Controller m (EnvHKD I m)
Has
usesDefaultSignatures
to provide a default implementation based onHasField
andDep
.It would be nice to support deriving that same instance suing
DerivingVia
and an auxiliary newtype. That way is more explicit, at the cost of more verbosity.It would look like this:
And be used like