-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Some monad transformers and typeclasses for abstraction of global dependencies. -- -- Some monad transformers and typeclasses abstracting global -- dependencies, like Text in- and output (incl. here-strings, pipes, -- recorders and file-redirections on a per-function scope), process -- spawning, time and random number retrieval. Later also: Filesystem -- access, database access, authentication and privilege escalation -- (passing-through IO actions). @package chatty @version 0.6 -- | Provides typeclasses for clocks and randomizer environments module System.Chatty.Misc -- | Typeclass for all monads that know the time class (Functor m, Monad m) => ChClock m where mgetstamp = fmap (flip diffUTCTime (UTCTime (fromGregorian 1970 1 1) (secondsToDiffTime 0))) mutctime mutctime :: ChClock m => m UTCTime mgetstamp :: ChClock m => m NominalDiffTime -- | Typeclass for all monads that may provide random numbers class Monad m => ChRandom m mrandom :: (ChRandom m, Random r) => m r mrandomR :: (ChRandom m, Random r) => (r, r) -> m r instance ChRandom IO instance ChClock IO module Text.Chatty.Templates -- | Returns a TypeQ from a name strToType :: Name -> Q Type -- | Provides handle-closing. module Text.Chatty.Finalizer -- | Class for all handle-finalizing monads. Required for file -- redirections. class Monad m => ChFinalizer m where mqfhs = foldr ((>>) . mqfh) (return ()) mqfh :: ChFinalizer m => Handle -> m () mqfhs :: ChFinalizer m => [Handle] -> m () mfin :: ChFinalizer m => m () -- | Handle-closing transformer newtype HandleCloserT m a HandleCloser :: ([Handle] -> m (a, [Handle])) -> HandleCloserT m a runHandleCloserT :: HandleCloserT m a -> [Handle] -> m (a, [Handle]) -- | Run function with handle closer withLazyIO :: (MonadIO m, Functor m) => HandleCloserT m a -> m a instance MonadIO m => ChFinalizer (HandleCloserT m) instance MonadIO m => MonadIO (HandleCloserT m) instance Monad m => Functor (HandleCloserT m) instance MonadTrans HandleCloserT instance Monad m => Monad (HandleCloserT m) -- | Provides a typeclass for all monads that may scan text. module Text.Chatty.Scanner -- | A typeclass for all monads that may read input. class Monad m => ChScanner m where mscanh = return Nothing mscan1 :: ChScanner m => m Char mscanL :: ChScanner m => m String mscannable :: ChScanner m => m Bool mscanh :: ChScanner m => m (Maybe Handle) mready :: ChScanner m => m Bool -- | HereStringT holds a given string and uses it as input for the function -- (much like here-strings in the shell) newtype HereStringT m a HereString :: (String -> m (a, String)) -> HereStringT m a runHereStringT :: HereStringT m a -> String -> m (a, String) -- | QuietT does not convey any input (much like <devnull in the -- shell) newtype QuietT m a Quiet :: m a -> QuietT m a runQuietT :: QuietT m a -> m a -- | InRedirT redirects all input to a given handle (much like <filename -- in the shell) newtype InRedirT m a InRedir :: (Handle -> m (a, Handle)) -> InRedirT m a runInRedirT' :: InRedirT m a -> Handle -> m (a, Handle) -- | InRedirT on an IO monad type InRedir = InRedirT (HandleCloserT IO) -- | Run InRedirT with handle runInRedirT :: Functor m => InRedirT m a -> Handle -> m a -- | Run InRedir with handle runInRedir :: InRedir a -> Handle -> IO a -- | Run InRedirT with a filename runInRedirFT :: (Functor m, MonadIO m, ChFinalizer m) => InRedirT m a -> FilePath -> m a -- | Run InRedir with a filename runInRedirF :: InRedir a -> FilePath -> IO a -- | Line-scanning alternative to mscan1/L mscanLn :: ChScanner m => m String -- | Scan a fixed number of chars mscanN :: ChScanner m => Int -> m String -- | Redirection source that does not provide any output data EmptyI EmptyI :: EmptyI -- | Class for all primitive redirection sources. class RedirectionSource t mt a r | t -> mt, t a -> r (.<.) :: (RedirectionSource t mt a r, ChFinalizer m, Functor m, MonadIO m, ChScanner (mt m)) => mt m a -> t -> m r -- | Class for all Here-Documents class RedirectionHeredoc t mt a r | t -> mt, t a -> r (.<<.) :: (RedirectionHeredoc t mt a r, Functor m, ChScanner (mt m)) => mt m a -> t -> m r instance RedirectionHeredoc String HereStringT a a instance RedirectionSource Handle InRedirT a a instance RedirectionSource FilePath InRedirT a a instance RedirectionSource EmptyI QuietT a a instance ChFinalizer m => ChFinalizer (InRedirT m) instance Monad m => Functor (InRedirT m) instance MonadIO m => ChScanner (InRedirT m) instance MonadIO m => MonadIO (InRedirT m) instance MonadTrans InRedirT instance Monad m => Monad (InRedirT m) instance Functor m => Functor (QuietT m) instance Monad m => ChScanner (QuietT m) instance MonadTrans QuietT instance Monad m => Monad (QuietT m) instance ChFinalizer m => ChFinalizer (HereStringT m) instance MonadIO m => MonadIO (HereStringT m) instance Monad m => ChScanner (HereStringT m) instance Monad m => Functor (HereStringT m) instance MonadTrans HereStringT instance Monad m => Monad (HereStringT m) instance Monad m => ChScanner (StateT String m) instance ChScanner IO -- | Provides a typeclass for buffered scanners as well as a buffering -- monad transformer. module Text.Chatty.Scanner.Buffered -- | Typeclass for all buffered ChScanners. class ChScanner m => ChBufferedScanner m mpeek1 :: ChBufferedScanner m => m Char mprepend :: ChBufferedScanner m => String -> m () -- | Typeclass for all BufferedScanners with support for pushing -- and popping. class ChBufferedScanner m => ChStackBufferedScanner m mpush :: ChStackBufferedScanner m => m () mpop :: ChStackBufferedScanner m => m () -- | A buffering MonadScanner transformer that lets you use -- mpeek1 and mprepend everywhere. newtype ScannerBufferT m a ScannerBuffer :: ([String] -> m (a, [String])) -> ScannerBufferT m a runScannerBufferT :: ScannerBufferT m a -> [String] -> m (a, [String]) instance ChScanner m => ChStackBufferedScanner (ScannerBufferT m) instance ChScanner m => ChBufferedScanner (ScannerBufferT m) instance MonadIO m => MonadIO (ScannerBufferT m) instance ChScanner m => ChScanner (ScannerBufferT m) instance Monad m => Functor (ScannerBufferT m) instance MonadTrans ScannerBufferT instance Monad m => Monad (ScannerBufferT m) instance Monad m => ChBufferedScanner (HereStringT m) instance Monad m => ChBufferedScanner (StateT String m) -- | Provides a typeclass for all monads that may print text. module Text.Chatty.Printer -- | A typeclass for all monads that may output strings. class Monad m => ChPrinter m where mnoecho = mprint mflush = return () mnomask = mprint mprint :: ChPrinter m => String -> m () mnoecho :: ChPrinter m => String -> m () mflush :: ChPrinter m => m () mnomask :: ChPrinter m => String -> m () -- | DeafT discards all output (much like >/dev/null in the shell) newtype DeafT m a Deaf :: m a -> DeafT m a runDeafT :: DeafT m a -> m a -- | Redirects all output to a given handle (much like >filename in the -- shell) newtype OutRedirT m a OutRedir :: (Handle -> m (a, Handle)) -> OutRedirT m a runOutRedirT' :: OutRedirT m a -> Handle -> m (a, Handle) -- | OutRedirT on a blank IO monad type OutRedir = OutRedirT IO -- | Run OutRedirT with a Handle runOutRedirT :: Functor m => OutRedirT m a -> Handle -> m a -- | Run OutRedir with a Handle runOutRedir :: OutRedir a -> Handle -> IO a -- | Run OutRedirT with a FilePath runOutRedirFT :: (Functor m, MonadIO m) => OutRedirT m a -> FilePath -> IOMode -> m a -- | Run OutRedir with a FilePath runOutRedirF :: OutRedir a -> FilePath -> IOMode -> IO a -- | Catches all output (much like VAR=$(...) in the shell) newtype RecorderT m a Recorder :: ([String] -> m (a, [String])) -> RecorderT m a runRecorderT' :: RecorderT m a -> [String] -> m (a, [String]) -- | RecorderT on the Identity type Recorder = RecorderT Identity -- | The recorder state. Use this together with replay, -- replayM or replay_. newtype Replayable Replayable :: [String] -> Replayable -- | Replay a recorder state inside a Monad. replayM :: Monad m => m Replayable -> m String -- | Replay a recorder state in a pure context. replay :: Replayable -> String -- | Replay the current recorder state without leaving the recorder. replay_ :: Monad m => RecorderT m String -- | Run Recorder and also return its state. runRecorder :: Recorder a -> (a, Replayable) -- | Run RecorderT and also return its state. runRecorderT :: (Functor m, Monad m) => RecorderT m a -> m (a, Replayable) -- | Line-terminating alternative to mprint mprintLn :: ChPrinter m => String -> m () -- | Line-terminating alternative to mnomask mnomaskLn :: ChPrinter m => String -> m () -- | Redirection target that discards input. data DiscardO DiscardO :: DiscardO -- | Redirection target that records input. data RecordO RecordO :: RecordO -- | Class for all redirection targets. class RedirectionTarget t mt a r | t -> mt, t a -> r where .>>. = (.>.) (.>.) :: (RedirectionTarget t mt a r, Functor m, MonadIO m, ChPrinter (mt m)) => mt m a -> t -> m r (.>>.) :: (RedirectionTarget t mt a r, Functor m, MonadIO m, ChPrinter (mt m)) => mt m a -> t -> m r instance RedirectionTarget Handle OutRedirT a a instance RedirectionTarget FilePath OutRedirT a a instance RedirectionTarget RecordO RecorderT a (a, Replayable) instance RedirectionTarget DiscardO DeafT a a instance Show Replayable instance MonadIO m => MonadIO (RecorderT m) instance Monad m => Functor (RecorderT m) instance Monad m => ChPrinter (RecorderT m) instance MonadTrans RecorderT instance Monad m => Monad (RecorderT m) instance Monad m => Functor (OutRedirT m) instance MonadIO m => ChPrinter (OutRedirT m) instance MonadIO m => MonadIO (OutRedirT m) instance MonadTrans OutRedirT instance Monad m => Monad (OutRedirT m) instance Monad m => ChPrinter (DeafT m) instance MonadIO m => MonadIO (DeafT m) instance Functor m => Functor (DeafT m) instance MonadTrans DeafT instance Monad m => Monad (DeafT m) instance Monad m => ChPrinter (StateT String m) instance ChPrinter IO -- | Provides a typeclass for process spawning. module System.Chatty.Spawn -- | Class for all (real or pseudo) process-spawning monads. class Monad m => ChSpawn m mspw :: ChSpawn m => String -> [String] -> Either Handle String -> m (Int, String, [Handle]) mah :: ChSpawn m => String -> m Bool -- | Spawn process spawn :: (ChFinalizer m, ChScanner m, ChPrinter m, ChSpawn m, Functor m) => String -> [String] -> m Int instance ChSpawn IO -- | Provides a MonadSpawn overlay that may catch specific spawn calls and -- handle them itself. module System.Chatty.Spawn.Overlay -- | MonadSpawn overlay. Carries a map of own command implementations that -- are called instead of the actual ones. newtype SpawnOverlayT m a SpawnOverlay :: ([(String, [String] -> String -> m (Int, String))] -> m (a, [(String, [String] -> String -> m (Int, String))])) -> SpawnOverlayT m a runSpawnOverlayT :: SpawnOverlayT m a -> [(String, [String] -> String -> m (Int, String))] -> m (a, [(String, [String] -> String -> m (Int, String))]) instance ChSpawn m => ChSpawn (SpawnOverlayT m) instance Monad m => Functor (SpawnOverlayT m) instance MonadIO m => MonadIO (SpawnOverlayT m) instance MonadTrans SpawnOverlayT instance Monad m => Monad (SpawnOverlayT m) -- | Provides builtins for some common commands. module System.Chatty.Spawn.Builtins -- | Use builtins if possible. withBuiltins :: (Functor m, ChSpawn m) => SpawnOverlayT m a -> m a -- | Provides a printer class that offers several channels. module Text.Chatty.Channel.Printer -- | Typeclass for all printers that offer several channels. class (ChPrinter m, Eq c) => ChChannelPrinter c m where cbracket c m = cstart c >> m >>= \ a -> cfin c >> return a cprint c s = cbracket c $ mprint s cbracket :: ChChannelPrinter c m => c -> m a -> m a cstart :: ChChannelPrinter c m => c -> m () cfin :: ChChannelPrinter c m => c -> m () cprint :: ChChannelPrinter c m => c -> String -> m () cthis :: ChChannelPrinter c m => m c -- | Catches all output on multiple channels. newtype ArchiverT c m a Archiver :: (([(c, [String])], [c]) -> m (a, ([(c, [String])], [c]))) -> ArchiverT c m a runArchiverT' :: ArchiverT c m a -> ([(c, [String])], [c]) -> m (a, ([(c, [String])], [c])) type IntArchiverT = ArchiverT Int type BoolArchiverT = ArchiverT Bool type HandleArchiverT = ArchiverT Handle runArchiverT :: (Eq c, Monad m) => c -> ArchiverT c m a -> m (a, [(c, Replayable)]) -- | Forwards output only on a specific channel. newtype FilterT c m a Filter :: ((c, [c]) -> m (a, [c])) -> FilterT c m a runFilterT :: FilterT c m a -> (c, [c]) -> m (a, [c]) type IntFilterT = FilterT Int type BoolFilterT = FilterT Bool type HandleFilterT = FilterT Handle -- | Joins all output regardless of its channel. newtype JoinerT m a Joiner :: m a -> JoinerT m a runJoinerT :: JoinerT m a -> m a instance (Eq c, ChPrinter m) => ChChannelPrinter c (JoinerT m) instance ChPrinter m => ChPrinter (JoinerT m) instance Functor m => Functor (JoinerT m) instance MonadIO m => MonadIO (JoinerT m) instance MonadTrans JoinerT instance Monad m => Monad (JoinerT m) instance (Eq c, ChPrinter m) => ChChannelPrinter c (FilterT c m) instance (Eq c, ChPrinter m) => ChPrinter (FilterT c m) instance Monad m => Functor (FilterT c m) instance MonadIO m => MonadIO (FilterT c m) instance MonadTrans (FilterT c) instance Monad m => Monad (FilterT c m) instance (Eq c, Monad m) => ChChannelPrinter c (ArchiverT c m) instance (Eq c, Monad m) => ChPrinter (ArchiverT c m) instance Monad m => Functor (ArchiverT c m) instance MonadIO m => MonadIO (ArchiverT c m) instance MonadTrans (ArchiverT c) instance Monad m => Monad (ArchiverT c m) -- | Provides a printer class that may broadcast to all channels that -- fulfill a condition. module Text.Chatty.Channel.Broadcast -- | Typeclass for all channel printers that may broadcast to all channels -- that fulfill a condition. class ChChannelPrinter c m => ChBroadcaster c m bprint :: ChBroadcaster c m => (c -> m Bool) -> String -> m () -- | Typeclass for all broadcaster that may embrace sections class ChBroadcaster c m => ChBroadcasterBracket c m where bbracket f m = bstart f >> m >>= \ a -> bfin f >> return a bbracket :: ChBroadcasterBracket c m => (c -> m Bool) -> m a -> m a bstart :: ChBroadcasterBracket c m => (c -> m Bool) -> m () bfin :: ChBroadcasterBracket c m => (c -> m Bool) -> m () -- | Provides an extended printer class that supports colours. module Text.Chatty.Extended.Printer -- | Typeclass for all printers that support colourized output. class ChPrinter m => ChExtendedPrinter m where ebracket c m = do { estart c; a <- m; efin; return a } eprint c = ebracket c . mprint eprintLn c s = eprint c s >> mprintLn "" enomask c = ebracket c . mnomask enomaskLn c s = enomask c s >> mprintLn "" ebracket :: ChExtendedPrinter m => Colour -> m a -> m a eprint :: ChExtendedPrinter m => Colour -> String -> m () eprintLn :: ChExtendedPrinter m => Colour -> String -> m () enomask :: ChExtendedPrinter m => Colour -> String -> m () enomaskLn :: ChExtendedPrinter m => Colour -> String -> m () estart :: ChExtendedPrinter m => Colour -> m () efin :: ChExtendedPrinter m => m () -- | Colour tone. data Tone Green :: Tone Red :: Tone Yellow :: Tone Blue :: Tone Black :: Tone White :: Tone Cyan :: Tone Magenta :: Tone -- | Colour brightness data Colour Dull :: Tone -> Colour Vivid :: Tone -> Colour expandClr :: ChExtendedPrinter m => String -> m () -- | Provides generic string expansion module Text.Chatty.Expansion -- | Typeclass for all string-expanding monads. class Monad e => ChExpand e expand :: ChExpand e => String -> e String newtype NullExpanderT m a NullExpander :: m a -> NullExpanderT m a runNullExpanderT :: NullExpanderT m a -> m a withExpansion :: Monad m => NullExpanderT m a -> m a instance Monad m => ChExpand (NullExpanderT m) instance MonadIO m => MonadIO (NullExpanderT m) instance Functor m => Functor (NullExpanderT m) instance MonadTrans NullExpanderT instance Monad m => Monad (NullExpanderT m) module Text.Chatty.Expansion.Vars -- | Some environment variable data EnvVar -- | Not set. NotSet :: EnvVar -- | An embeddable string. Literal :: String -> EnvVar -- | Something we can show. Scalar :: a -> EnvVar -- | Array of that Array :: [EnvVar] -> EnvVar -- | Environment storage and variable expander. newtype ExpanderT m a Expander :: ([(String, EnvVar)] -> m (a, [(String, EnvVar)])) -> ExpanderT m a runExpanderT :: ExpanderT m a -> [(String, EnvVar)] -> m (a, [(String, EnvVar)]) -- | Run this function inside a blank environment. localEnvironment :: Functor m => ExpanderT m a -> m a -- | Run this function in a locally modifiable, but not exported -- environment forkEnvironment :: (Functor m, Monad m, MonadIO m) => ExpanderT m a -> m a -- | Export this local environment. exportAll :: (Monad m, MonadIO m) => ExpanderT m () -- | Expand $variables expandVars :: (Monad m, Functor m, ChExpanderEnv m) => String -> m String -- | Is alphanumeric? isAnum :: Char -> Bool -- | Typeclass for all environment storages. class Monad ee => ChExpanderEnv ee mgetv :: ChExpanderEnv ee => String -> ee EnvVar mputv :: ChExpanderEnv ee => String -> EnvVar -> ee () instance ChExpanderEnv IO instance Monad m => ChExpanderEnv (ExpanderT m) instance ChExpand m => ChExpand (ExpanderT m) instance ChExpand IO instance Monad m => Functor (ExpanderT m) instance MonadIO m => MonadIO (ExpanderT m) instance MonadTrans ExpanderT instance Monad m => Monad (ExpanderT m) instance Show EnvVar module Text.Chatty.Expansion.History newtype HistoryT m a History :: ([String] -> m (a, [String])) -> HistoryT m a runHistoryT :: HistoryT m a -> [String] -> m (a, [String]) class Monad he => ChHistoryEnv he mcounth :: ChHistoryEnv he => he Int mgeth :: ChHistoryEnv he => Int -> he String mputh :: ChHistoryEnv he => String -> he () expandHist :: ChHistoryEnv h => String -> h String withHistory :: Monad m => HistoryT m a -> m a instance ChExpand m => ChExpand (HistoryT m) instance Monad m => ChHistoryEnv (HistoryT m) instance Monad m => Functor (HistoryT m) instance MonadIO m => MonadIO (HistoryT m) instance MonadTrans HistoryT instance Monad m => Monad (HistoryT m) -- | Provides an ChExtendedPrinter that handles colours using HTML -- output. module Text.Chatty.Extended.HTML -- | An ChExtendedPrinter for HTML output. newtype HtmlPrinterT m a HtmlPrinter :: m a -> HtmlPrinterT m a runHtmlPrinterT :: HtmlPrinterT m a -> m a -- | Convert the given character to its HTML representation. maskHtml :: Char -> String -- | Convert the given colour to its CSS representation. hexColour :: Colour -> [Char] instance (Functor m, ChExpand m) => ChExpand (HtmlPrinterT m) instance ChPrinter m => ChExtendedPrinter (HtmlPrinterT m) instance ChPrinter m => ChPrinter (HtmlPrinterT m) instance MonadIO m => MonadIO (HtmlPrinterT m) instance Functor m => Functor (HtmlPrinterT m) instance MonadTrans HtmlPrinterT instance Monad m => Monad (HtmlPrinterT m) -- | Provides a ChExtendedPrinter that handles colours using -- standardized ANSI codes. module Text.Chatty.Extended.ANSI -- | A ChExtendedPrinter that uses ANSI colour codes. newtype AnsiPrinterT m a AnsiPrinter :: ([Colour] -> m (a, [Colour])) -> AnsiPrinterT m a runAnsiPrinterT :: AnsiPrinterT m a -> [Colour] -> m (a, [Colour]) -- | Convert Chatty's colour intensity to ansi-terminal's one mkColourInt :: Colour -> ColorIntensity -- | Convert Chatty's colour tone to ansi-terminal's one mkColourCode :: Colour -> Color instance (Functor m, ChExpand m) => ChExpand (AnsiPrinterT m) instance ChPrinter m => ChExtendedPrinter (AnsiPrinterT m) instance ChPrinter m => ChPrinter (AnsiPrinterT m) instance MonadIO m => MonadIO (AnsiPrinterT m) instance Monad m => Functor (AnsiPrinterT m) instance MonadTrans AnsiPrinterT instance Monad m => Monad (AnsiPrinterT m) -- | Declares serveral templates for comfortable instance derivation module Text.Chatty.Interactor.Templates -- | Automatically derives a ChScanner instance for you. mkScanner :: Name -> Q [Dec] -- | Automatically derives a ChPrinter instance for you. mkPrinter :: Name -> Q [Dec] -- | Automatically derives a ChFinalizer instance for you. mkFinalizer :: Name -> Q [Dec] -- | Automatically derives a ChExpand instance for you. mkExpander :: Name -> Q [Dec] -- | Automatically derives an ChExpanderEnv instance for you mkExpanderEnv :: Name -> Q [Dec] -- | Automatically derives a ChHistoryEnv instance for you mkHistoryEnv :: Name -> Q [Dec] -- | mkInteractor takes a type name and a list of typeclass derivers and -- applies them all. mkInteractor :: InteractorMaker i => Name -> i -- | Automatically derives a ChSpawn instance for you. mkSpawn :: Name -> Q [Dec] -- | Automatically derives a ChRandom instance for you. mkRandom :: Name -> Q [Dec] -- | Automatically derives a ChClock instance for you. mkClock :: Name -> Q [Dec] -- | Automatically derives all chatty typeclasses for you. mkChatty :: Name -> Q [Dec] -- | Automatically derives a ChChannelPrinter instance for you. mkChannelPrinter :: Name -> Name -> Q [Dec] -- | Automatically derives ChChannelPrinter instances for Int, -- Bool and Handle channels. mkDefCP :: Name -> Q [Dec] -- | Automatically derives all chatty typeclasses that are sensible for an -- ArchiverT. mkArchiver :: Name -> Q [Dec] -- | Automatically derives an ChExtendedPrinter instance for you. mkExtendedPrinter :: Name -> Q [Dec] -- | Automatically derives a ChBufferedScanner instance for you. mkBufferedScanner :: Name -> Q [Dec] instance InteractorMaker i => InteractorMaker ((Name -> Q [Dec]) -> i) instance InteractorMaker (Q [Dec]) -- | Provides a bunch of derived instances for the various typeclasses. module Text.Chatty.Interactor -- | IgnorantT ignores all output and does not provide any input. type IgnorantT m = QuietT (DeafT m) -- | Ignorant is IgnorantT on the identity type Ignorant = IgnorantT Identity -- | ChattyT simulates a console, actually taking input as a string and -- recording output. type ChattyT m = HereStringT (RecorderT m) -- | Chatty is ChattyT on the identity type Chatty = ChattyT Identity -- | Run IgnorantT (does not take anything) runIgnorantT :: Monad m => IgnorantT m a -> m a -- | Run Ignorant (does not take anything) runIgnorant :: Ignorant a -> a -- | Run ChattyT. Takes input as a string and returns (result, remaining -- input, output). runChattyT :: (Monad m, Functor m) => ChattyT m a -> String -> m (a, String, Replayable) -- | Run Chatty. Takes input as a string and returns (result, remaining -- input, output). runChatty :: Chatty a -> String -> (a, String, Replayable) -- | Connect the output of some function to the input of another one. -- Compare with a pipe (cmd1 | cmd2). (.|.) :: (Monad m, Functor m) => RecorderT m a -> HereStringT m b -> m b -- | Runs the second function and feeds its output as an argument to the -- first one. Compare with process expansion ($(cmd)). (.<$.) :: (Functor m, Monad m) => (String -> m b) -> RecorderT m a -> m b instance ChClock m0 => ChClock (JoinerT m0) instance ChRandom m0 => ChRandom (JoinerT m0) instance ChSpawn m0 => ChSpawn (JoinerT m0) instance ChFinalizer m0 => ChFinalizer (JoinerT m0) instance ChHistoryEnv m0 => ChHistoryEnv (JoinerT m0) instance ChExpanderEnv m0 => ChExpanderEnv (JoinerT m0) instance ChExpand m0 => ChExpand (JoinerT m0) instance ChScanner m0 => ChScanner (JoinerT m0) instance ChClock m0 => ChClock (HandleFilterT m0) instance ChRandom m0 => ChRandom (HandleFilterT m0) instance ChSpawn m0 => ChSpawn (HandleFilterT m0) instance ChFinalizer m0 => ChFinalizer (HandleFilterT m0) instance ChHistoryEnv m0 => ChHistoryEnv (HandleFilterT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HandleFilterT m0) instance ChExpand m0 => ChExpand (HandleFilterT m0) instance ChScanner m0 => ChScanner (HandleFilterT m0) instance ChClock m0 => ChClock (BoolFilterT m0) instance ChRandom m0 => ChRandom (BoolFilterT m0) instance ChSpawn m0 => ChSpawn (BoolFilterT m0) instance ChFinalizer m0 => ChFinalizer (BoolFilterT m0) instance ChHistoryEnv m0 => ChHistoryEnv (BoolFilterT m0) instance ChExpanderEnv m0 => ChExpanderEnv (BoolFilterT m0) instance ChExpand m0 => ChExpand (BoolFilterT m0) instance ChScanner m0 => ChScanner (BoolFilterT m0) instance ChClock m0 => ChClock (IntFilterT m0) instance ChRandom m0 => ChRandom (IntFilterT m0) instance ChSpawn m0 => ChSpawn (IntFilterT m0) instance ChFinalizer m0 => ChFinalizer (IntFilterT m0) instance ChHistoryEnv m0 => ChHistoryEnv (IntFilterT m0) instance ChExpanderEnv m0 => ChExpanderEnv (IntFilterT m0) instance ChExpand m0 => ChExpand (IntFilterT m0) instance ChScanner m0 => ChScanner (IntFilterT m0) instance ChClock m0 => ChClock (HandleArchiverT m0) instance ChRandom m0 => ChRandom (HandleArchiverT m0) instance ChSpawn m0 => ChSpawn (HandleArchiverT m0) instance ChFinalizer m0 => ChFinalizer (HandleArchiverT m0) instance ChHistoryEnv m0 => ChHistoryEnv (HandleArchiverT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HandleArchiverT m0) instance ChExpand m0 => ChExpand (HandleArchiverT m0) instance ChScanner m0 => ChScanner (HandleArchiverT m0) instance ChClock m0 => ChClock (BoolArchiverT m0) instance ChRandom m0 => ChRandom (BoolArchiverT m0) instance ChSpawn m0 => ChSpawn (BoolArchiverT m0) instance ChFinalizer m0 => ChFinalizer (BoolArchiverT m0) instance ChHistoryEnv m0 => ChHistoryEnv (BoolArchiverT m0) instance ChExpanderEnv m0 => ChExpanderEnv (BoolArchiverT m0) instance ChExpand m0 => ChExpand (BoolArchiverT m0) instance ChScanner m0 => ChScanner (BoolArchiverT m0) instance ChClock m0 => ChClock (IntArchiverT m0) instance ChRandom m0 => ChRandom (IntArchiverT m0) instance ChSpawn m0 => ChSpawn (IntArchiverT m0) instance ChFinalizer m0 => ChFinalizer (IntArchiverT m0) instance ChHistoryEnv m0 => ChHistoryEnv (IntArchiverT m0) instance ChExpanderEnv m0 => ChExpanderEnv (IntArchiverT m0) instance ChExpand m0 => ChExpand (IntArchiverT m0) instance ChScanner m0 => ChScanner (IntArchiverT m0) instance ChSpawn m0 => ChSpawn (ScannerBufferT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (ScannerBufferT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (ScannerBufferT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (ScannerBufferT m0) instance ChClock m0 => ChClock (ScannerBufferT m0) instance ChRandom m0 => ChRandom (ScannerBufferT m0) instance ChFinalizer m0 => ChFinalizer (ScannerBufferT m0) instance ChHistoryEnv m0 => ChHistoryEnv (ScannerBufferT m0) instance ChExpanderEnv m0 => ChExpanderEnv (ScannerBufferT m0) instance ChExpand m0 => ChExpand (ScannerBufferT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (ScannerBufferT m0) instance ChPrinter m0 => ChPrinter (ScannerBufferT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (HistoryT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (HistoryT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (HistoryT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HistoryT m0) instance ChClock m0 => ChClock (HistoryT m0) instance ChRandom m0 => ChRandom (HistoryT m0) instance ChSpawn m0 => ChSpawn (HistoryT m0) instance ChFinalizer m0 => ChFinalizer (HistoryT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (HistoryT m0) instance ChPrinter m0 => ChPrinter (HistoryT m0) instance ChBufferedScanner m0 => ChBufferedScanner (HistoryT m0) instance ChScanner m0 => ChScanner (HistoryT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (NullExpanderT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (NullExpanderT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (NullExpanderT m0) instance ChClock m0 => ChClock (NullExpanderT m0) instance ChRandom m0 => ChRandom (NullExpanderT m0) instance ChSpawn m0 => ChSpawn (NullExpanderT m0) instance ChFinalizer m0 => ChFinalizer (NullExpanderT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (NullExpanderT m0) instance ChPrinter m0 => ChPrinter (NullExpanderT m0) instance ChBufferedScanner m0 => ChBufferedScanner (NullExpanderT m0) instance ChScanner m0 => ChScanner (NullExpanderT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (AnsiPrinterT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (AnsiPrinterT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (AnsiPrinterT m0) instance ChClock m0 => ChClock (AnsiPrinterT m0) instance ChRandom m0 => ChRandom (AnsiPrinterT m0) instance ChSpawn m0 => ChSpawn (AnsiPrinterT m0) instance ChFinalizer m0 => ChFinalizer (AnsiPrinterT m0) instance ChHistoryEnv m0 => ChHistoryEnv (AnsiPrinterT m0) instance ChExpanderEnv m0 => ChExpanderEnv (AnsiPrinterT m0) instance ChBufferedScanner m0 => ChBufferedScanner (AnsiPrinterT m0) instance ChScanner m0 => ChScanner (AnsiPrinterT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (HtmlPrinterT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (HtmlPrinterT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (HtmlPrinterT m0) instance ChClock m0 => ChClock (HtmlPrinterT m0) instance ChRandom m0 => ChRandom (HtmlPrinterT m0) instance ChSpawn m0 => ChSpawn (HtmlPrinterT m0) instance ChFinalizer m0 => ChFinalizer (HtmlPrinterT m0) instance ChHistoryEnv m0 => ChHistoryEnv (HtmlPrinterT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HtmlPrinterT m0) instance ChBufferedScanner m0 => ChBufferedScanner (HtmlPrinterT m0) instance ChScanner m0 => ChScanner (HtmlPrinterT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (SpawnOverlayT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (SpawnOverlayT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (SpawnOverlayT m0) instance ChClock m0 => ChClock (SpawnOverlayT m0) instance ChRandom m0 => ChRandom (SpawnOverlayT m0) instance ChFinalizer m0 => ChFinalizer (SpawnOverlayT m0) instance ChHistoryEnv m0 => ChHistoryEnv (SpawnOverlayT m0) instance ChExpanderEnv m0 => ChExpanderEnv (SpawnOverlayT m0) instance ChExpand m0 => ChExpand (SpawnOverlayT m0) instance ChBufferedScanner m0 => ChBufferedScanner (SpawnOverlayT m0) instance ChScanner m0 => ChScanner (SpawnOverlayT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (SpawnOverlayT m0) instance ChPrinter m0 => ChPrinter (SpawnOverlayT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (InRedirT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (InRedirT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (InRedirT m0) instance ChClock m0 => ChClock (InRedirT m0) instance ChRandom m0 => ChRandom (InRedirT m0) instance ChSpawn m0 => ChSpawn (InRedirT m0) instance ChHistoryEnv m0 => ChHistoryEnv (InRedirT m0) instance ChExpanderEnv m0 => ChExpanderEnv (InRedirT m0) instance ChExpand m0 => ChExpand (InRedirT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (InRedirT m0) instance ChPrinter m0 => ChPrinter (InRedirT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (QuietT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (QuietT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (QuietT m0) instance ChClock m0 => ChClock (QuietT m0) instance ChRandom m0 => ChRandom (QuietT m0) instance ChSpawn m0 => ChSpawn (QuietT m0) instance ChHistoryEnv m0 => ChHistoryEnv (QuietT m0) instance ChExpanderEnv m0 => ChExpanderEnv (QuietT m0) instance ChExpand m0 => ChExpand (QuietT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (QuietT m0) instance ChPrinter m0 => ChPrinter (QuietT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (HereStringT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (HereStringT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (HereStringT m0) instance ChClock m0 => ChClock (HereStringT m0) instance ChRandom m0 => ChRandom (HereStringT m0) instance ChSpawn m0 => ChSpawn (HereStringT m0) instance ChHistoryEnv m0 => ChHistoryEnv (HereStringT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HereStringT m0) instance ChExpand m0 => ChExpand (HereStringT m0) instance ChExtendedPrinter m0 => ChExtendedPrinter (HereStringT m0) instance ChPrinter m0 => ChPrinter (HereStringT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (ExpanderT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (ExpanderT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (ExpanderT m0) instance ChHistoryEnv m0 => ChHistoryEnv (ExpanderT m0) instance ChClock m0 => ChClock (ExpanderT m0) instance ChRandom m0 => ChRandom (ExpanderT m0) instance ChSpawn m0 => ChSpawn (ExpanderT m0) instance ChFinalizer m0 => ChFinalizer (ExpanderT m0) instance ChPrinter m0 => ChPrinter (ExpanderT m0) instance ChBufferedScanner m0 => ChBufferedScanner (ExpanderT m0) instance ChScanner m0 => ChScanner (ExpanderT m0) instance ChChannelPrinter Handle m0 => ChChannelPrinter Handle (HandleCloserT m0) instance ChChannelPrinter Bool m0 => ChChannelPrinter Bool (HandleCloserT m0) instance ChChannelPrinter Int m0 => ChChannelPrinter Int (HandleCloserT m0) instance ChClock m0 => ChClock (HandleCloserT m0) instance ChRandom m0 => ChRandom (HandleCloserT m0) instance ChSpawn m0 => ChSpawn (HandleCloserT m0) instance ChHistoryEnv m0 => ChHistoryEnv (HandleCloserT m0) instance ChExpanderEnv m0 => ChExpanderEnv (HandleCloserT m0) instance ChExpand m0 => ChExpand (HandleCloserT m0) instance ChPrinter m0 => ChPrinter (HandleCloserT m0) instance ChBufferedScanner m0 => ChBufferedScanner (HandleCloserT m0) instance ChScanner m0 => ChScanner (HandleCloserT m0) instance ChClock m0 => ChClock (OutRedirT m0) instance ChRandom m0 => ChRandom (OutRedirT m0) instance ChSpawn m0 => ChSpawn (OutRedirT m0) instance ChHistoryEnv m0 => ChHistoryEnv (OutRedirT m0) instance ChExpanderEnv m0 => ChExpanderEnv (OutRedirT m0) instance ChExpand m0 => ChExpand (OutRedirT m0) instance ChFinalizer m0 => ChFinalizer (OutRedirT m0) instance ChBufferedScanner m0 => ChBufferedScanner (OutRedirT m0) instance ChScanner m0 => ChScanner (OutRedirT m0) instance ChClock m0 => ChClock (DeafT m0) instance ChRandom m0 => ChRandom (DeafT m0) instance ChSpawn m0 => ChSpawn (DeafT m0) instance ChHistoryEnv m0 => ChHistoryEnv (DeafT m0) instance ChExpanderEnv m0 => ChExpanderEnv (DeafT m0) instance ChExpand m0 => ChExpand (DeafT m0) instance ChFinalizer m0 => ChFinalizer (DeafT m0) instance ChBufferedScanner m0 => ChBufferedScanner (DeafT m0) instance ChScanner m0 => ChScanner (DeafT m0) instance ChClock m0 => ChClock (RecorderT m0) instance ChRandom m0 => ChRandom (RecorderT m0) instance ChSpawn m0 => ChSpawn (RecorderT m0) instance ChHistoryEnv m0 => ChHistoryEnv (RecorderT m0) instance ChExpanderEnv m0 => ChExpanderEnv (RecorderT m0) instance ChExpand m0 => ChExpand (RecorderT m0) instance ChFinalizer m0 => ChFinalizer (RecorderT m0) instance ChBufferedScanner m0 => ChBufferedScanner (RecorderT m0) instance ChScanner m0 => ChScanner (RecorderT m0) -- | Provides in-haskell implementations for some standard functions module System.Chatty.Commands -- | Like cat on the command line. Accepts a list of filenames. -- Simple pass-through, if none are provided. cat :: (ChScanner m, ChPrinter m, MonadIO m, Functor m, ChFinalizer m) => [String] -> m () -- | Like cat, but reverses the line order. tac :: (ChFinalizer m, ChScanner m, ChPrinter m, MonadIO m, Functor m) => [String] -> m () -- | Pass-through, simultanously writing all input to a given file. tee :: (ChScanner m, ChPrinter m, MonadIO m, Functor m) => String -> m () -- | Prints the given string, after expanding it. echo :: (ChPrinter m, ChExpand m) => String => m () -- | Mode for wc. data WcMode CountChars :: WcMode CountLines :: WcMode CountWords :: WcMode -- | Count characters, lines or words of the input. wc :: (ChScanner m, ChPrinter m, MonadIO m, Functor m) => WcMode -> m () -- | Change to given directory. cd :: MonadIO m => String -> m () -- | Print current working directory. pwd :: (MonadIO m, ChPrinter m) => m () -- | List directory contents of the given directories (current one, if -- empty list). ls :: (MonadIO m, ChPrinter m) => [String] -> m () -- | Filters only the first n lines of the input. head :: (ChScanner m, ChPrinter m, MonadIO m, Functor m) => Int -> m () -- | FIlters only the last n lines of the input. tail :: (ChScanner m, ChPrinter m, MonadIO m, Functor m) => Int -> m ()