Marker for fields of HKD types
A common pattern for datatypes is to wrap every field in a type constructor:
data RequestHeaders_ f = RequestHeaders {
requestTimeout :: f (Maybe Timeout)
, requestCompression :: f (Maybe CompressionId)
, ..
}The downside of such an approach is that if we don't need that type
constructor, we must instantiate f to Identity, which results in
syntactic overhead.
(See also
The Haskell Unfolder episode 14: Higher-kinded types.)
The HKD family is designed to avoid this overhead:
data RequestHeaders_ f = RequestHeaders {
requestTimeout :: HKD f (Maybe Timeout)
, requestCompression :: HKD f (Maybe CompressionId)
, ..
}There are then two valid choices for f:
Undecorated:
HKD Undecorated xis simply equal tox. This avoids the overhead mentioned above.DecoratedWith
f, for somef:HKD (DecoratedWith f) xis equal tof x.
This explicit distinction between Undecorated and DecoratedWith is the main difference between the approach in this module and other libraries that provide similar functionality.
Instances2HKD
type HKD Undecorated x = xDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.Util.HKDtype HKD (DecoratedWith f) x = f xDefined in grpc-spec-1.0.0 · Network.GRPC.Spec.Util.HKD