Using io-choice.
This commit is contained in:
25
GHCChoice.hs
Normal file
25
GHCChoice.hs
Normal file
@@ -0,0 +1,25 @@
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
|
||||
module GHCChoice where
|
||||
|
||||
import Control.Exception
|
||||
import CoreMonad
|
||||
import Exception
|
||||
import GHC
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
(||>) :: Ghc a -> Ghc a -> Ghc a
|
||||
x ||> y = x `gcatch` (\(_ :: IOException) -> y)
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
{-| Go to the next 'Ghc' monad by throwing 'AltGhcgoNext'.
|
||||
-}
|
||||
goNext :: Ghc a
|
||||
goNext = liftIO . throwIO $ userError "goNext"
|
||||
|
||||
{-| Run any one 'Ghc' monad.
|
||||
-}
|
||||
runAnyOne :: [Ghc a] -> Ghc a
|
||||
runAnyOne = foldr (||>) goNext
|
||||
Reference in New Issue
Block a user