上手haskell没有不痛苦的!

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没有不痛苦的!)