This is a simple question about reusing a piece of Haskell code

I had an interactive program which used a function of type

> prg  :: String -> String
> prg = 
>   {- for example -} \(c:cs) -> "first char = " ++ [c]

To run that program I used

> run :: IO ()
> run = interact prg

Now, I want to reuse that function in a shell program which will
execute the interactive function more than once (as an example, 
suppose that the shell program executes 'run' twice)

> main = run >> run

However, after the first run, stdin gets semi-closed, and the second 
run fails with an Illegal operation. 

I can solve the problem changing the definition of 'prg', but 
that's what I want to avoid

Is it possible to run an 'interact'ive program more than once?

Best regards, Jose Labra
http://lsi.uniovi.es/~labra




Reply via email to