Exporting more low level APIs.

This commit is contained in:
Kazu Yamamoto
2013-09-16 09:56:08 +09:00
parent 5750673e0e
commit 45751e3926
5 changed files with 61 additions and 23 deletions

View File

@@ -9,20 +9,22 @@ import GHC
----------------------------------------------------------------
-- | Try the left 'Ghc' action. If 'IOException' occurs, try
-- the right 'Ghc' action.
(||>) :: Ghc a -> Ghc a -> Ghc a
x ||> y = x `gcatch` (\(_ :: IOException) -> y)
(|||>) :: GhcMonad m => m a -> m a -> m a
x |||> y = x `gcatch` (\(_ :: IOException) -> y)
----------------------------------------------------------------
{-| Go to the next 'Ghc' monad by throwing 'AltGhcgoNext'.
-}
-- | Go to the next 'Ghc' monad by throwing 'AltGhcgoNext'.
goNext :: Ghc a
goNext = liftIO . throwIO $ userError "goNext"
{-| Run any one 'Ghc' monad.
-}
-- | Run any one 'Ghc' monad.
runAnyOne :: [Ghc a] -> Ghc a
runAnyOne = foldr (||>) goNext
----------------------------------------------------------------
-- | Try the left 'GhcMonad' action. If 'IOException' occurs, try
-- the right 'GhcMonad' action.
(|||>) :: GhcMonad m => m a -> m a -> m a
x |||> y = x `gcatch` (\(_ :: IOException) -> y)