File: Transcode.hs

package info (click to toggle)
haskell-base64-bytestring 1.0.0.1-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 124 kB
  • sloc: haskell: 555; python: 9; makefile: 3
file content (16 lines) | stat: -rw-r--r-- 540 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import qualified Data.ByteString as B
import System.Environment
import Data.ByteString.Base64

main = do
  (kind:files) <- getArgs
  let xcode bs = case kind of
            "decode" -> case decode bs of
                          Left err -> putStrLn err
                          Right p -> B.putStr p
            "decodeLenient" -> B.putStr (decodeLenient bs)
            "encode" -> B.putStr (encode bs)
            "read" -> B.putStr bs
  case files of
    [] -> B.getContents >>= xcode
    fs -> mapM_ (\f -> B.readFile f >>= xcode) fs