-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e450a15
commit 97bce50
Showing
7 changed files
with
229 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Masque.Ejectors where | ||
|
||
import Control.Monad.Error.Class | ||
import Control.Monad.Trans.Either | ||
import Data.Unique | ||
|
||
import Masque.Monte | ||
import Masque.Objects | ||
|
||
-- | Run an action, catching a single specified ejector. If caught, the | ||
-- ejector's payload will be run through the given handler action. | ||
catchEjector :: Unique -> Monte Obj -> (Obj -> Monte Obj) -> Monte Obj | ||
catchEjector u action handler = catchError action $ \err -> | ||
case err of | ||
Ejecting u' obj | u == u' -> handler obj | ||
_ -> left err | ||
|
||
-- | Like Monte m`throw.eject(ej, problem)`. | ||
throwEject :: Obj -> Obj -> Monte () | ||
throwEject ej problem = left $ case ej of | ||
EjectorObj u -> Ejecting u problem | ||
_ -> Exception problem |
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
Oops, something went wrong.