{-# LANGUAGE Arrows #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}
module FRP.Rhine.ClSF.Except
( module FRP.Rhine.ClSF.Except
, module X
, safe, safely, Empty, exceptS, runMSFExcept, currentInput
)
where
import qualified Control.Category as Category
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Except as X
import Control.Monad.Trans.Reader
import Data.MonadicStreamFunction
import Control.Monad.Trans.MSF.Except hiding (try, once, once_, throwOn, throwOn', throwS)
import qualified Control.Monad.Trans.MSF.Except as MSFE
import FRP.Rhine.ClSF.Core
import FRP.Rhine.ClSF.Except.Util
throwS :: Monad m => ClSF (ExceptT e m) cl e a
throwS = arrMCl throwE
throw :: Monad m => e -> MSF (ExceptT e m) a b
throw = arrM_ . throwE
pass :: Monad m => MSF (ExceptT e m) a a
pass = Category.id
throwOn :: Monad m => e -> ClSF (ExceptT e m) cl Bool ()
throwOn e = proc b -> throwOn' -< (b, e)
throwOn' :: Monad m => ClSF (ExceptT e m) cl (Bool, e) ()
throwOn' = proc (b, e) -> if b
then throwS -< e
else returnA -< ()
throwOnCond :: Monad m => (a -> Bool) -> e -> ClSF (ExceptT e m) cl a a
throwOnCond cond e = proc a -> if cond a
then throwS -< e
else returnA -< a
throwOnCondM :: Monad m => (a -> m Bool) -> e -> ClSF (ExceptT e m) cl a a
throwOnCondM cond e = proc a -> do
b <- arrMCl (lift . cond) -< a
if b
then throwS -< e
else returnA -< a
throwMaybe :: Monad m => ClSF (ExceptT e m) cl (Maybe e) (Maybe a)
throwMaybe = proc me -> case me of
Nothing -> returnA -< Nothing
Just e -> throwS -< e
type ClSFExcept m cl a b e = MSFExcept (ReaderT (TimeInfo cl) m) a b e
type BehaviourFExcept m time a b e
= forall cl. time ~ Time cl => ClSFExcept m cl a b e
type BehaviorFExcept m time a b e = BehaviourFExcept m time a b e
runClSFExcept :: Monad m => ClSFExcept m cl a b e -> ClSF (ExceptT e m) cl a b
runClSFExcept = liftMSFPurer commuteExceptReader . runMSFExcept
try :: Monad m => ClSF (ExceptT e m) cl a b -> ClSFExcept m cl a b e
try = MSFE.try . liftMSFPurer commuteReaderExcept
once :: Monad m => (a -> m e) -> ClSFExcept m cl a b e
once f = MSFE.once $ lift . f
once_ :: Monad m => m e -> ClSFExcept m cl a b e
once_ = once . const
step :: Monad m => (a -> m (b, e)) -> ClSFExcept m cl a b e
step f = MSFE.step $ lift . f