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>
答案 0 :(得分:4)
在ghci提示符下,您可以通过添加:!
前缀来调用shell命令。
*Main> :! cat haiku.txt | ./capslocker
它应该在emacs中工作相同。