I've currently wrote a program to use on a .txt file but whenever i try to run it i get the error:
开发者_高级运维cat quux.txt | ./wordCount
<interactive>:1:14: parse error on input `|'
Am i typing in my code wrong to work it on the ghc or?
You can't use shell syntax in ghci. You should type the command into the shell instead.
In ghci you can do
:!<shell command>
To execute a command in the shell e.g.
Prelude> :!pwd
/home/me
You seem to be thinking GHCi is a shell, it isn't. There is no piping and no cat
in GHCi.
Once you compile your program just do what you showed in a bash shell:
$ cat rotate.hs | ./rotate
ainm = od
c -< etContentsg
etl sl = inesl c
sw = apm ordsw sl
sr = apm map( ot)r sw
utStrLnp $ nlinesu $ apm nwordsu sr
otr w = ropd 1 w ++ aket 1 w
精彩评论