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

Error composition #2

Open
bbarker opened this issue Jun 8, 2020 · 1 comment
Open

Error composition #2

bbarker opened this issue Jun 8, 2020 · 1 comment

Comments

@bbarker
Copy link
Owner

bbarker commented Jun 8, 2020

Currently error composition is left as an exercise to the user :-).

Things to try:

  • Look into Plucky as a possible way to handle error composition.
@bbarker
Copy link
Owner Author

bbarker commented Jun 20, 2020

Also think about IsA relationships:

Brandon Barker Jun 18th at 6:07 PM
errorCallException looks like a handy function to use for non-fatal exceptions (or non-errors I guess) if you don't want to worry about modeling exception types too much ... yes?

parsonsmatt:haskell_logo_purple: 1 day ago
you describe a venn diagram with no overlap

parsonsmatt:haskell_logo_purple: 1 day ago
the only really useful t hing you can do with it is throw it to hook into the GHC Exception machinery

parsonsmatt:haskell_logo_purple: 1 day ago
for anything that you want to ever be handled by anyone (aside from killing the process), you should use a real type (eg not String).

Brandon Barker 1 day ago
Yeah; i've been using some functions that essentially convert SomeException to something more refined, and just wanted something extra to bridge the gap from String to SomeException

Brandon Barker 1 day ago
Vaguely related ... I've been wondering if somehow overhauling exceptions to basically just implement Is-A relationships could be a nice way to make exception handling far less complicated. The downside is that you might need orphan instances for users to decide when a certain error is an instance of a given error type ... though I haven't thought much on it

Brandon Barker 1 day ago
Maybe people already do this a lot

parsonsmatt:haskell_logo_purple: 1 day ago
this is what plucky does and it does work out nicely

parsonsmatt:haskell_logo_purple: 1 day ago
However, what you're talking about is essentially how GHC's exception machinery works. It's the only part of Haskell that uses subtyping a la OOP extensively.

Brandon Barker 1 day ago
I'll have to take a closer look at plucky - my first thought when looking at it was that it might have been more complicated than what I had in mind

parsonsmatt:haskell_logo_purple: 1 day ago
eg the class methods you might define on an IsA class would be like

class Is a b where
  put :: a -> b
  get :: b -> Maybe a

And this is nearly exactly how the Exception class looks:

class Exception e where
  toException :: e -> SomeException
  fromException :: SomeException -> Maybe e
  displayException :: e -> String

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

1 participant