2007-07-05から1日間の記事一覧

モナドは相変わらずわからないががんばってるよ。

以下の3つは全て同じ意味。a.txtをb.txtにコピーし"OK"を出力 $ runghc -e 'main=readFile "a.txt">>= \s ->writeFile "b.txt" s>>putStrLn "OK"' OK $ runghc -e 'main=readFile "a.txt">>= writeFile "b.txt">>putStrLn "OK"' OK $ runghc -e 'main=do{s<…

ghcで漢字を扱う。

ソースコード中には漢字が書けない。(コメントを除く) $ echo -e "abc\n漢字十を表示する\n123" > a.txt $ runghc -e 'main=do{c<-readFile "a.txt";putStr c}' abc 漢字十を表示する 123 $ runghc -e 'main=do{c<-readFile "a.txt";putStrLn$concat$lines…