!/0,     Safe (c) Evgeny PoberezkinMITevgeny@poberezkin.com experimental non-portableSafe /=?@ACXk,interact. typeclass with polymorphic stateful function H to interactively evaluate input lines and print responses (see below).interactFunction passed to ! 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).BSpecific behaviour depends on function type (see instances above).Examples:Prints sums of entered numbers: Madder :: Int -> State Int Int adder x = modify (+ x) >> get replState adder 0or with plain state function Zadder :: Int -> Int -> (Int, Int) adder x s = let s' = s + x in (s', s') replState adder 0Above can be done with  (see below): replFold (+) 0Ibut replState is more flexible - state and output can be different types.interact/ typeclass with polymorphic stateless function H to interactively evaluate input lines and print responses (see below).interactFunction passed to ! will be called with values from stdin (!s or " 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 (! or # instance, possibly wrapped in $ or %*, one value at a time or as a lazy list) .BSpecific 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: gsqrSqrt :: [Double] -> [Double] sqrSqrt [] = [] sqrSqrt (x:xs) = x^2 : sqrt x : sqrSqrt xs repl sqrSqrtinteractSame as  with (a -> b)? function but the first argument is the value that will cause  to exit.interactSame as  with (a -> State s b)? function but the first argument is the value that will cause  to exit.interactq combines the entered values with the accumulated value using provided function and prints the resulting values.interactSame as 6 but the first argument is the value that will cause  to exit.interactreturn & to exit, string in & is printed interactreturn ' to exit interact! s do not use  'read'/'show' interactCtrl-D to exitinteract'stdin'/'stdout' values as lazy listsinteract'stdin'/'stdout' !s as lazy listsinteractreturn & to exit, string in & is printedinteractreturn ' to exitinteract! s do not use  'read'/'show'interactCtrl-D to exitinteract'stdin'/'stdout' !s as lazy listsinteract5plain state function with argument and result of any  'Read'/'Show' typesinteractplain state function with !s as argument and result(      !"#$%&$'($)*$+,$-.$-/$+01'interact-0.1.0.0-50sSLf6QoqKB2BdIuk46GKSystem.IO.InteractPaths_interact ReplState replStateReplreplrepl' replState'replFold replFold' $fReplaEither $fReplaMaybe$fRepl[]Either $fRepl[]Maybe $fRepl[][]$fReplab $fRepl[][]0 $fRepl[][]1$fReplStateaStateTs$fReplStateaStateTs0$fReplState[]StateTs$fReplState[]StateTs0$fReplState[]StateTs1$fReplStateaStateTs1$fReplState[]StateTs2$fReplStatea->s$fReplState[]->sversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileNamebaseGHC.BaseStringGHC.ReadReadGHC.ShowShow GHC.MaybeMaybe Data.EitherEitherLeftNothing