-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | instantly create REPL from any function -- -- This module provides functions to create interactive REPLs: -- -- -- -- Each line you enter is read into the argument type and sent to -- the function, with the result printed @package interact @version 0.2.0.0 -- | This module provides functions to instantly create interactive REPL, -- similar to Prelude interact but with line-by-line processing: -- -- -- -- Each line you enter is read into the argument type and sent to -- the function, with the result printed. module System.IO.Interact -- | Repl typeclass with polymorphic stateless function repl -- to interactively evaluate input lines and print responses (see below). class Repl a b -- | Function passed to repl will be called with values from -- stdin (Strings or Read instances, one value at a -- time or as a lazy list depending on the type of the function) and -- should return value to be printed to stdout (String or -- Show instance, possibly wrapped in Maybe or -- Either, one value at a time or as a lazy list) . -- -- Specific behaviour depends on function type (see instances above). -- -- Examples: -- -- Print square roots of the entered numbers: -- --
--   repl (sqrt :: Double -> Double)
--   
-- -- Reverse entered strings: -- --
--   repl (reverse :: String -> String)
--   
-- -- Prints both squares and square roots: -- --
--   sqrSqrt :: [Double] -> [Double]
--   sqrSqrt [] = []
--   sqrSqrt (x:xs) = x^2 : sqrt x : sqrSqrt xs
--   repl sqrSqrt
--   
repl :: Repl a b => (a -> b) -> IO () -- | Same as repl with (a -> b) function but the first -- argument is the value that will cause repl' to exit. repl' :: (Eq a, Read a, Show b) => a -> (a -> b) -> IO () -- | pRepl is repl with prompt -- -- Example: -- --
--   pRepl ">" (sqrt :: Double -> Double)
--   
pRepl :: Repl a b => String -> (a -> b) -> IO () pRepl' :: forall a b. (Eq a, Read a, Show b) => String -> a -> (a -> b) -> IO () -- | ReplState typeclass with polymorphic stateful function -- replState to interactively evaluate input lines and print -- responses (see below). class ReplState a b s | b -> s -- | Function passed to replState will be called with values from -- stdin and previous state (depending on type, via State monad or -- as the first argument) and should return value to be printed to -- stdout and the new state (either via State monad or as a -- tuple). -- -- Specific behaviour depends on function type (see instances above). -- -- Examples: -- -- Prints sums of entered numbers: -- --
--   adder :: Int -> State Int Int
--   adder x = modify (+ x) >> get
--   replState adder 0
--   
-- -- or with plain state function -- --
--   adder :: Int -> Int -> (Int, Int)
--   adder x s = let s' = s + x in (s', s')
--   replState adder 0
--   
-- -- Above can be done with replFold (see below): -- --
--   replFold (+) 0
--   
-- -- but replState is more flexible - state and output can be different -- types. replState :: ReplState a b s => (a -> b) -> s -> IO () -- | Same as replState with (a -> State s b) function -- but the first argument is the value that will cause replState' -- to exit. replState' :: (Eq a, Read a, Show b) => a -> (a -> State s b) -> s -> IO () -- | replState with prompt defined by the first argument pReplState :: ReplState a b s => String -> (a -> b) -> s -> IO () -- | replState' with prompt pReplState' :: forall a b s. (Eq a, Read a, Show b) => String -> a -> (a -> State s b) -> s -> IO () -- | replFold combines the entered values with the accumulated value -- using provided function and prints the resulting values. replFold :: (Read a, Show b) => (b -> a -> b) -> b -> IO () -- | Same as replFold but the first argument is the value that will -- cause replFold' to exit. replFold' :: (Eq a, Read a, Show b) => a -> (b -> a -> b) -> b -> IO () -- | replFold with prompt pReplFold :: (Read a, Show b) => String -> (b -> a -> b) -> b -> IO () -- | replFold' with prompt pReplFold' :: (Eq a, Read a, Show b) => String -> a -> (b -> a -> b) -> b -> IO () instance System.IO.Interact.ReplState GHC.Base.String (s -> (GHC.Base.String, s)) s instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.ReplState a (s -> (b, s)) s instance System.IO.Interact.ReplState [GHC.Base.String] (Control.Monad.Trans.State.Lazy.State s [GHC.Base.String]) s instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.ReplState a (Control.Monad.Trans.State.Lazy.State s b) s instance System.IO.Interact.ReplState GHC.Base.String (Control.Monad.Trans.State.Lazy.State s GHC.Base.String) s instance System.IO.Interact.ReplState GHC.Base.String (Control.Monad.Trans.State.Lazy.State s (GHC.Maybe.Maybe GHC.Base.String)) s instance System.IO.Interact.ReplState GHC.Base.String (Control.Monad.Trans.State.Lazy.State s (Data.Either.Either GHC.Base.String GHC.Base.String)) s instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.ReplState a (Control.Monad.Trans.State.Lazy.State s (GHC.Maybe.Maybe b)) s instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.ReplState a (Control.Monad.Trans.State.Lazy.State s (Data.Either.Either GHC.Base.String b)) s instance System.IO.Interact.Repl [GHC.Base.String] [GHC.Base.String] instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.Repl [a] [b] instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.Repl a b instance System.IO.Interact.Repl GHC.Base.String GHC.Base.String instance System.IO.Interact.Repl GHC.Base.String (GHC.Maybe.Maybe GHC.Base.String) instance System.IO.Interact.Repl GHC.Base.String (Data.Either.Either GHC.Base.String GHC.Base.String) instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.Repl a (GHC.Maybe.Maybe b) instance (GHC.Read.Read a, GHC.Show.Show b) => System.IO.Interact.Repl a (Data.Either.Either GHC.Base.String b)