Skip to content

Conversation

@JackKelly-Bellroy
Copy link
Contributor

This seems like a good idea (see #175), but I'd want someone who really understands the guts to confirm that.



-- | Change the type of an 'Expr' without using @CAST()@, if the
-- Haskell type can be safely coerced.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it follows that if the Haskell types can be safely coerced then the DB types can be safely coerced. Could you not have a newtype which uses a different DBType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's sound only if you ever newtype-derive DBType instances. If that's true then it might not pull its weight: either it'll sound safer than it is, or we'll have to call it something like sometimesButNotAlwaysSafeCoerceExpr. Or use some constraint that indicates that it's specifically a newtype and not just Coercible. (e.g. the one in generic-data.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimesButNotAlwaysSafe is exactly what unsafe means though. unsafe just means that there is some pre-condition that we couldn't express in the types so you should be careful when using it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's my point. It's slightly less unsafe but still unsafe, which makes me doubt if it's enough of an improvement over unsafeCoerceExpr to include. I might just close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants