Skip to content

Monomorphize kinds of Error{,WithoutStackTrace}, introduce PolyError#554

Merged
RyanGlScott merged 2 commits intomasterfrom
T89-part-two
Feb 18, 2023
Merged

Monomorphize kinds of Error{,WithoutStackTrace}, introduce PolyError#554
RyanGlScott merged 2 commits intomasterfrom
T89-part-two

Conversation

@RyanGlScott
Copy link
Copy Markdown
Collaborator

Previously, we had generalized the argument kind to Error in commit 077aee5 to permit passing things to Error besides Symbols. Back then, there was no way to show things at the type level, nor was there a way to manipulate Symbols in any meaningful fashion, so this seemed like a reasonable choice.

Nowadays, however, the story is different. There is a type-level Show_ function, and the API for manipulating Symbols is nearly as expressive as the API for manipulating Strings. What's more, making Error's argument kind more general introduces ambiguity-related issues when deriving Enum instances with OverloadedStrings enabled, as observed in #89.

In light of this, I have changed the API such that:

  • The kind of the argument to Error (as well as the related ErrorWithoutStackTrace function) is now Symbol. In this sense, this patch reverts 077aee5.
  • There is now a new Data.Singletons.Base.PolyError module that provides a PolyError function. PolyError provides a kind-polymorphic Error interface much like what the previous type of Error was, so any existing code that relied on the argument of Error being kind-polymorphic can be migrated over to use PolyError.

Resolves #89 (hopefully for good this time).

Previously, we had generalized the argument kind to `Error` in commit
077aee5 to permit passing things to `Error`
besides `Symbol`s. Back then, there was no way to `show` things at the type
level, nor was there a way to manipulate `Symbol`s in any meaningful fashion,
so this seemed like a reasonable choice.

Nowadays, however, the story is different. There is a type-level `Show_`
function, and the API for manipulating `Symbol`s is nearly as expressive as the
API for manipulating `String`s.  What's more, making `Error`'s argument kind
more general introduces ambiguity-related issues when deriving `Enum` instances
with `OverloadedStrings` enabled, as observed in #89.

In light of this, I have changed the API such that:

* The kind of the argument to `Error` (as well as the related
  `ErrorWithoutStackTrace` function) is now `Symbol`.  In this sense, this patch
  reverts 077aee5.
* There is now a new `Data.Singletons.Base.PolyError` module that provides a
  `PolyError` function. `PolyError` provides a kind-polymorphic `Error`
  interface much like what the previous type of `Error` was, so any existing
  code that relied on the argument of `Error` being kind-polymorphic can be
  migrated over to use `PolyError`.

Resolves #89 (hopefully for good this time).
Copy link
Copy Markdown

@amesgen amesgen left a comment

Choose a reason for hiding this comment

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

I think this is looking great, thanks for such a quick and thorough resolution!

@RyanGlScott RyanGlScott merged commit e89070a into master Feb 18, 2023
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.

Extended error reporting

2 participants