
31 Mar
2013
31 Mar
'13
8:29 p.m.
On Mon, Apr 1, 2013 at 6:26 AM, Ovidiu D
1. Make f behave lazy Its input list is made of lines read from stdin and I want it to process lines one by one as they are entered by the user.
Eschewing laziness (which adds only complexity in this case), here's something that'll work, if a little ugly: import System.Exit f :: String -> IO () f "exit" = exitSuccess f a = putStrLn $ "you entered: " ++ a main = do s <- getLine f s main Going down this path would involve IORef's, among others from the "sin bin". Something more pure and haskell-y would typically involve an analysis of the DSL abstract syntax and state space and implementation using a combination of State and Free monads. -- Kim-Ee