Skip to content

Linear coerce

Should there exist a

linearCoerce :: Coercible a b => a %m -> b

As coerce is primitive, linearCoerce cannot be defined "safely".

I think multiplicity polymorphic function is more convenient with current LinearTypes design / state of implementation, but it could also be Coercible a b => a %1 -> b.

The coerce itself could be generalized, but I'm not sure whether that would break something (even if it's defined explicitly as forall a b m. Coercible a b => a %m -> b, so the possible TypeApplications are still in right order), as additional multiplicity may be ambiguous somewhere.

(Note: linear unsafeCoerce can be written by a user using UnsafeEquality.)

Edited by Oleg Grenrus