-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor in progress * Fixing imports and missing references * add Fail effect * fix imports Co-authored-by: Jonathan Cubides <[email protected]>
- Loading branch information
1 parent
a6ac12c
commit d70cbc6
Showing
5 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 @@ | ||
-- | An effect similar to Polysemy Fail but wihout an error message | ||
module Juvix.Prelude.Effect.Fail where | ||
|
||
import Juvix.Prelude.Base | ||
|
||
data Fail m a = Fail | ||
|
||
makeSem ''Fail | ||
|
||
-- | Run a 'Fail' effect purely. | ||
runFail :: | ||
Sem (Fail ': r) a -> | ||
Sem r (Maybe a) | ||
runFail = fmap (^? _Right) . runError @() . reinterpret (\Fail -> throw ()) | ||
{-# INLINE runFail #-} | ||
|
||
failMaybe :: Member Fail r => Maybe a -> Sem r a | ||
failMaybe = \case | ||
Nothing -> fail | ||
Just x -> return x |
This file contains 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