3
capslocker.hs有下面的代碼:如何使用emacs-haskell模式將一個程序的輸出管道輸出到另一個程序的輸入(capslocker)?
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
在終端中,我能夠做到:
[email protected]:~$ cat haiku.txt
I'm a lil' teapot
What's with that airplane food, huh?
It's so small, tasteless
而這個:
[email protected]:~$ 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 - 哈斯克爾模式,我曾嘗試以下操作:
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>
另一種無用的貓......'./capslocker
2012-08-03 23:57:55
@DanielWagner:先生,我是一個絕對的初學者。只要通過LYAH好。貓可以正確使用的實際場景是什麼? – Optimight 2012-08-04 00:19:33
不是一個真正的Haskell的東西,但是... [「貓的目的是連接(或'連接')文件。如果它只有一個文件,連接它沒有任何東西是浪費時間,並且花費你一個過程。「](http://partmaps.org/era/unix/award.html) – 2012-08-04 00:27:38