Open arthurxavierx opened 3 years ago
Is there a way to prevent this outside of the library code? This is a feature in the internal code, we get free coercion.
Basically coerce is not part of our contract so if someone makes a runtime error using it I don't really care.
Hm.
We could have:
newtype SqlExpr a
type role SqlExpr nominal
veryUnsafeCoerceSqlExpr :: SqlExpr a -> SqlExpr b
veryUnsafeCoerceSqlExpr = unsafeCoerce
unsafeCoerce
is safe in this sense, since we're explicitly blocking the normal coerce
behavior that would otherwise be used. Clients of the library need to write the scary name. And we can still use it internally. Is this an acceptable compromise?
that seems fine, we should probably be using veryUnsafeCoerceSqlExpr
everywhere anyways though I think we lose the fmap (f . coerce) == coerce . fmap f
rewrite rule
I think an INLINE
pragma on veryUnsafeCoerceSqlExpr
would work to get the rewrites firing again
It's now possible to write
which could cause unexpected runtime errors.