coerce package:optics-core

This module defines operations to coerce the type parameters of optics to a representationally equal type. For example, if we have
newtype MkInt = MkInt Int
and
l :: Lens' S Int
then
coerceA @Int @MkInt l :: Lens' S MkInt
Lift coerce to the a parameter of an optic.
Lift coerce to the b parameter of an optic.
Lift coerce to the s parameter of an optic.
Lift coerce to the t parameter of an optic.
Data types that are representationally equal are isomorphic.
>>> view coerced 'x' :: Identity Char
Identity 'x'
Special case of coerced for trivial newtype wrappers.
>>> over (coerced1 @Identity) (++ "bar") (Identity "foo")
Identity "foobar"
Type-preserving version of coerced with type parameters rearranged for TypeApplications.
>>> newtype MkInt = MkInt Int deriving Show
>>> over (coercedTo @Int) (*3) (MkInt 2)
MkInt 6