I’m trying to write a urlview clone in Haskell. The program reads a message (piped via STDIN), extracts all URLs and asks the user to select one of them.
After reading the message, STDIN obviously reaches EOF. In Python, I reset STDIN like this
message = sys.stdin.read()
sys.stdin = open('/dev/tty')
selected_index = raw_input('Which URL to open? ')
How would I achieve the same in Haskell?
As far as I know there is no way to “re-assign” the built-in
stdinin Haskell, but you can otherwise open a new handle to/dev/tty. A direct translation of your Python code would be something like