haskell太怪了,上手很痛苦!
module Main where
import System.Environment(getArgs)
import qualified Data.ByteString as B (readFile, writeFile, map)
main = do
args <- getArgs
case args of
[from, out, direction] ->
if direction == "exe2txt"
then do
s <- B.readFile from
let s1 = B.map (/x->x+1) s
B.writeFile out s1
else if direction == "txt2exe"
then do
s <- B.readFile from
let s1 = B.map (/x->x-1) s
B.writeFile out s1
else do Prelude.putStrLn "usage: hs20101004-1.exe from out direction"
otherwise ->
Prelude.putStrLn "usage: hs20101004-1.exe from out direction"
为什么case里面不能case呢?
本文分享了一个使用Haskell语言实现文件内容转换的实际案例,包括从可执行文件转为文本文件及反之的操作,并探讨了Haskell语法中的一些疑惑。

4420

被折叠的 条评论
为什么被折叠?



