capslocker.hs 有以下代码:
import Control.Monad
import Data.Char
main = forever $ do
putStr "Give me some input: "
l <- getLine
putStrLn $ map toUpper l
haiku.txt 有以下内容:
I'm a lil' teapot
What's with that airplane food, huh?
It's so small, tasteless
在终端中,我能够做到:
optimight@optimight:~$ cat haiku.txt
I'm a lil' teapot
What's with that airplane food, huh?
It's so small, tasteless
还有这个:
optimight@optimight:~$ cat haiku.txt | ./capslocker
Give me some input: I'M A LIL' TEAPOT
Give me some input: WHAT'S WITH THAT AIRPLANE FOOD, HUH?
Give me some input: IT'S SO SMALL, TASTELESS
Give me some input: capslocker: <stdin>: hGetLine: end of file
如何在 emacs23 - haskell 模式下测试相同的(如在终端中所做的)?请指导。
请注意,在 emacs - haskell 模式下,我尝试了以下操作:
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load "/home/optimight/capslocker.hs"
[1 of 1] Compiling Main ( /home/optimight/capslocker.hs, interpreted )
Ok, modules loaded: Main.
*Main> cat haiku.txt | ./capslocker
<interactive>:3:15: parse error on input `|'
*Main>