File: frame-encode.hs

package info (click to toggle)
haskell-http2 5.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 55,180 kB
  • sloc: haskell: 8,657; makefile: 5
file content (24 lines) | stat: -rw-r--r-- 537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE OverloadedStrings #-}

module Main where

import Data.Aeson
import Data.Aeson.Encode.Pretty (encodePretty)
import qualified Data.ByteString.Lazy.Char8 as BL
import System.Environment (getArgs)

import Case

main :: IO ()
main = do
    args <- getArgs
    xs <- getContents
    if not (null args) -- "-w"
        then printWire xs
        else printJSON xs

printWire :: String -> IO ()
printWire = print . sourceToWire . read

printJSON :: String -> IO ()
printJSON = BL.putStrLn . encodePretty . toJSON . wireToCase . read