Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show type representation of a, b when Deferrable (a ~ b) fails #29

Closed
Icelandjack opened this issue Apr 28, 2016 · 3 comments
Closed

Show type representation of a, b when Deferrable (a ~ b) fails #29

Icelandjack opened this issue Apr 28, 2016 · 3 comments

Comments

@Icelandjack
Copy link
Contributor

Icelandjack commented Apr 28, 2016

When (Typeable a, Typeable b) => Deferrable (a ~ b) fails our error is:

Nothing -> Left "deferred type equality: type mismatch"

but the user may want some information about the types (we already have their Typeable instances), so why not write:

Nothing   -> Left $
  printf "deferred type equality: type mismatch between ‘%s’ and ‘%s’" (showTr @a) (showTr @b)
  where
    showTr :: t. Typeable t => String
    showTr = show (typeRep @_ @t Proxy)
@Icelandjack
Copy link
Contributor Author

Couldn't you also accumulate the errors in Deferrable (a, b), Deferrable (a, b, c)

@ekmett
Copy link
Owner

ekmett commented Jul 28, 2016

The former sounds good to me. The latter sounds interesting and I'd happily take a patch that did it.

@ekmett
Copy link
Owner

ekmett commented Jul 28, 2016

I've implemented the former. The latter may require more thought, as the API would likely need to change to gain a good way to accumulate multiple messages.

@ekmett ekmett closed this as completed Jul 28, 2016
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

No branches or pull requests

2 participants