Using io-choice.

This commit is contained in:
Kazu Yamamoto
2012-02-16 14:44:20 +09:00
parent d373966625
commit f3725127bc
7 changed files with 37 additions and 53 deletions

25
GHCChoice.hs Normal file
View 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