Closed samhh closed 1 year ago
A discovery worth documenting (https://github.com/unsplash/unsplash-web/pull/10389#discussion_r1280540272).
getCodecFromMappedNullaryTag builds a codec from:
getCodecFromMappedNullaryTag
a -> b
b -> m a
[a]
This is strikingly similar to inverseMap:
inverseMap
Enum a
The biggest difference is that in the former a is the member tag whereas in the latter it'd (typically) be the sum itself.
a
Finding the common ground between these could substantially reduce the boilerplate needed to write these mapped codecs.
I suppose it's getCodecFromPrimitiveMappedNullaryTag?
getCodecFromPrimitiveMappedNullaryTag
A discovery worth documenting (https://github.com/unsplash/unsplash-web/pull/10389#discussion_r1280540272).
getCodecFromMappedNullaryTag
builds a codec from:a -> b
b -> m a
[a]
This is strikingly similar to
inverseMap
:a -> b
b -> m a
Enum a
The biggest difference is that in the former
a
is the member tag whereas in the latter it'd (typically) be the sum itself.Finding the common ground between these could substantially reduce the boilerplate needed to write these mapped codecs.