module Text.Chatty.Interactor where
import Text.Chatty.Printer
import Text.Chatty.Scanner
import Text.Chatty.Finalizer
import Text.Chatty.Expansion
import Text.Chatty.Expansion.Vars
import Text.Chatty.Expansion.History
import Text.Chatty.Extended.HTML
import Text.Chatty.Extended.ANSI
import Text.Chatty.Channel.Printer
import System.Chatty.Misc
import Text.Chatty.Interactor.Templates
import System.Chatty.Spawn
import System.Chatty.Spawn.Overlay
import Control.Monad
import Control.Monad.Trans.Class
import Control.Monad.Identity
import System.IO
mkInteractor ''RecorderT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock
mkInteractor ''DeafT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock
mkInteractor ''OutRedirT mkScanner mkFinalizer mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock
mkInteractor ''HandleCloserT mkScanner mkPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''ExpanderT mkScanner mkPrinter mkFinalizer mkSpawn mkRandom mkClock mkHistoryEnv mkDefCP
mkInteractor ''HereStringT mkPrinter mkExtendedPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''QuietT mkPrinter mkExtendedPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''InRedirT mkPrinter mkExtendedPrinter mkExpander mkExpanderEnv mkHistoryEnv mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''SpawnOverlayT mkPrinter mkExtendedPrinter mkScanner mkExpander mkExpanderEnv mkHistoryEnv mkFinalizer mkRandom mkClock mkDefCP
mkInteractor ''HtmlPrinterT mkScanner mkExpanderEnv mkHistoryEnv mkFinalizer mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''AnsiPrinterT mkScanner mkExpanderEnv mkHistoryEnv mkFinalizer mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''NullExpanderT mkScanner mkPrinter mkExtendedPrinter mkFinalizer mkSpawn mkRandom mkClock mkDefCP
mkInteractor ''HistoryT mkScanner mkPrinter mkExtendedPrinter mkFinalizer mkSpawn mkRandom mkClock mkExpanderEnv mkDefCP
mkInteractor ''IntArchiverT mkArchiver
mkInteractor ''BoolArchiverT mkArchiver
mkInteractor ''HandleArchiverT mkArchiver
mkInteractor ''IntFilterT mkArchiver
mkInteractor ''BoolFilterT mkArchiver
mkInteractor ''HandleFilterT mkArchiver
mkInteractor ''JoinerT mkArchiver
type IgnorantT m = QuietT (DeafT m)
type Ignorant = IgnorantT Identity
type ChattyT m = HereStringT (RecorderT m)
type Chatty = ChattyT Identity
runIgnorantT :: Monad m => IgnorantT m a -> m a
runIgnorantT = runDeafT . runQuietT
runIgnorant :: Ignorant a -> a
runIgnorant = runIdentity . runIgnorantT
runChattyT :: (Monad m,Functor m) => ChattyT m a -> String -> m (a,String,Replayable)
runChattyT m input = fmap (\((a,u),r) -> (a,u,r)) $ runRecorderT $ runHereStringT m input
runChatty :: Chatty a -> String -> (a,String,Replayable)
runChatty m = runIdentity . runChattyT m
(.|.) :: (Monad m,Functor m) => RecorderT m a -> HereStringT m b -> m b
m1 .|. m2 = do
(_,r) <- runRecorderT m1
fmap fst $ runHereStringT m2 (replay r)
(.<$.) :: (Functor m,Monad m) => (String -> m b) -> RecorderT m a -> m b
m1 .<$. m2 = do
(_,r) <- runRecorderT m2
m1 $ replay r