1

I know I can do the following from a command prompt:

$ runghc WC < quux.txt

How do I do this in WinGHCi? I know I have to first load the file like this:

Prelude> :load WC

But then what? This doesn't work:

*Main> WC < quux.txt

<interactive>:1:1: Not in scope: data constructor `WC'

<interactive>:1:6: Not in scope: `quux'

<interactive>:1:11: Not in scope: `txt'
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
  • 1
    possible duplicate of [How do you route stdin from a file to a function when running GHCI](http://stackoverflow.com/questions/1735386/how-do-you-route-stdin-from-a-file-to-a-function-when-running-ghci) – hammar Jul 27 '11 at 20:55

1 Answers1

4

Look at the IO routines provided:

http://www.haskell.org/tutorial/io.html

Another place to look is:

http://book.realworldhaskell.org/read/io.html

I think you need to write your program differently. WC should be parameterized by the file handle. Then you can do wc (openFile "quux.txt" ReadMode) at GHCi. Then you define your main function as main = wc stdin to keep the input redirection at the command prompt working.

Jules
  • 6,318
  • 2
  • 29
  • 40