Skip to content

Unable to coerce with flipped Coercible context

coerce' :: Coercible a b => b -> a
coerce' = coerce

doesn't compile, forcing workarounds like:

coerce' :: forall a b. Coercible a b => b -> a
coerce' = coerce (id :: a -> a)

This arises in practice in several places in the profunctors package and lens.

https://github.com/ekmett/profunctors/blob/1c3508e5274a0ed03765c569596a8fda8817ed56/src/Data/Profunctor/Unsafe.hs#L188

http://hackage.haskell.org/package/lens-4.8/docs/src/Control-Lens-Internal-Coerce.html#coerce%27

Ideally we'd be able to retire coerce' entirely and just use coerce in those contexts.

The tricky part is of course avoiding infinite loops once you add symmetry.

Trac metadata
Trac field Value
Version 7.10.1-rc2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information