I realized in coercible-utils #14 that the inference-enhancing effects of the O type are only needed for some of the arguments. For the rest, things can be left much freer. That suggests a modification here as well:
class Isomorphic n o where
packI :: o -> n
default packI :: (Generic n, GNewtype (Rep n), O n ~ GO (Rep n), o ~ O n) => o -> n
packI = to . gpack
unpackI :: n -> o
default unpackI :: (Generic n, GNewtype (Rep n), O n ~ GO (Rep n), o ~ O n) => n -> o
unpackI = gunpack . from
class Isomorphic n (O n) => Newtype n where
type O n :: *
type O n = GO (Rep n)
pack :: Newtype n => O n -> n
pack = packI
unpack :: Newtype n => n -> O n
unpack = unpackI
Now you can use Isomorphic, rather than Newtype, for the type variables that are already constrained by the type of the packer the user passes in.
I realized in coercible-utils #14 that the inference-enhancing effects of the
Otype are only needed for some of the arguments. For the rest, things can be left much freer. That suggests a modification here as well:Now you can use
Isomorphic, rather thanNewtype, for the type variables that are already constrained by the type of the packer the user passes in.