-
-
Notifications
You must be signed in to change notification settings - Fork 2
[#7] Custom Errors for runEIO #13
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
Open
JonathanLorimer
wants to merge
7
commits into
kowainik:main
Choose a base branch
from
JonathanLorimer:runEIO-custom-type-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2733cdc
add custom type error
JonathanLorimer 1c0732b
move custom error logic to separate file
JonathanLorimer 638ec82
added doctests
JonathanLorimer 9c971c5
add unsafeLiftIO
JonathanLorimer bb05040
add tests
JonathanLorimer 08b15a1
add tests to GHA
JonathanLorimer da57e96
make the doctests pass
JonathanLorimer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,4 @@ jobs: | |
|
|
||
| - name: Test | ||
| run: | | ||
| echo 'No tests' | ||
| cabal test | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| {-# LANGUAGE DataKinds #-} | ||
| {-# LANGUAGE TypeFamilies #-} | ||
| {-# LANGUAGE TypeOperators #-} | ||
| {-# LANGUAGE UndecidableInstances #-} | ||
|
|
||
| module EIO.TypeErrors | ||
| (DisallowUnhandledExceptions) | ||
| where | ||
|
|
||
| import Data.Kind (Type, Constraint) | ||
| import GHC.TypeLits | ||
|
|
||
| type family DisallowUnhandledExceptions (excepts :: [Type]) :: Constraint where | ||
| DisallowUnhandledExceptions '[] = () | ||
| DisallowUnhandledExceptions excepts = | ||
| TypeError | ||
| ( 'Text "The 'runEIO' handler requires that all exceptions in 'EIO' to be handled." | ||
| ':$$: 'Text "The action 'runEIO' is applied to throws the following unhandled exceptions:" | ||
|
Comment on lines
+17
to
+18
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to keep the text as similar to your suggestion as possible. |
||
| ':$$: ShowTypeList excepts | ||
| ) | ||
|
|
||
| type family ShowTypeList (xs :: [Type]) :: ErrorMessage where | ||
| ShowTypeList '[] = 'Text "" | ||
| ShowTypeList (x ': xs) = 'Text " • " ':<>: ('ShowType x) ':$$: (ShowTypeList xs) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| module Main (main) where | ||
|
|
||
| import EIO | ||
|
|
||
| import System.FilePath.Glob (glob) | ||
| import Test.DocTest (doctest) | ||
|
|
||
| main :: IO () | ||
| main = do | ||
| sourceFiles <- glob "src/**/*.hs" | ||
| doctest | ||
| $ "-XInstanceSigs" | ||
| : "-XNoImplicitPrelude" | ||
| : "-XOverloadedStrings" | ||
| : "-XScopedTypeVariables" | ||
| : "-XTypeApplications" | ||
| : "-XDerivingStrategies" | ||
| : "-XGeneralizedNewtypeDeriving" | ||
| : "-XQualifiedDo" | ||
| : sourceFiles |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you don't mind me adding these. I like to use
nix-shellto pull in all the project dependencies (such as ghc, and cabal) and useghcidfor development. I didn't want to clutter up anyone else's workflow so I added the files I use to .gitignore. If this is annoying I can just stage my files more carefully and remove this.