Merge branch 'master' of rosencrantz:/srv/git/telml
Getty Ritter
9 years ago
| 1 |
{-# LANGUAGE OverloadedStrings #-}
|
| 2 |
|
| 3 |
module Main where
|
| 4 |
|
| 5 |
import Data.Aeson (Value(..), encode, object, (.=))
|
| 6 |
import qualified Data.ByteString.Lazy.Char8 as BS
|
| 7 |
import Data.Maybe (fromJust)
|
| 8 |
import Data.TeLML
|
| 9 |
import Data.Vector (fromList)
|
| 10 |
import qualified Data.Text as T
|
| 11 |
import qualified Data.Text.IO as T
|
| 12 |
|
| 13 |
telmlToValue :: Fragment -> Value
|
| 14 |
telmlToValue (Chunk t) = String t
|
| 15 |
telmlToValue (Tag t ts) = object
|
| 16 |
[ "name" .= String t
|
| 17 |
, "contents" .= Array (fromList (map telmlToValue ts))
|
| 18 |
]
|
| 19 |
|
| 20 |
main = do
|
| 21 |
contents <- T.getContents
|
| 22 |
BS.putStrLn . encode . map telmlToValue . fromJust . parse $ contents
|
1 | |
-- Initial telml.cabal generated by cabal init. For further documentation,
|
2 | |
-- see http://haskell.org/cabal/users-guide/
|
3 | |
|
4 | 1 |
name: telml
|
5 | 2 |
version: 0.1.0.0
|
6 | |
-- synopsis:
|
7 | |
-- description:
|
| 3 |
synopsis: foo
|
| 4 |
description: foo
|
8 | 5 |
license: BSD3
|
9 | 6 |
license-file: LICENSE
|
10 | 7 |
author: Getty Ritter
|
11 | 8 |
maintainer: gdritter@galois.com
|
12 | |
-- copyright:
|
| 9 |
copyright: ©2015
|
13 | 10 |
category: Data
|
14 | 11 |
build-type: Simple
|
15 | |
-- extra-source-files:
|
16 | 12 |
cabal-version: >=1.10
|
17 | 13 |
|
18 | 14 |
library
|
19 | 15 |
exposed-modules: Data.TeLML
|
20 | 16 |
other-modules: Data.TeLML.Parser
|
21 | |
-- other-extensions:
|
22 | 17 |
build-depends: base >=4.7 && <4.8, text, attoparsec
|
23 | |
-- hs-source-dirs:
|
24 | 18 |
default-language: Haskell2010
|
| 19 |
|
| 20 |
executable from-telml
|
| 21 |
main-is: Main.hs
|
| 22 |
hs-source-dirs: src
|
| 23 |
build-depends: base >=4.7 && <4.8, aeson, telml, vector, text, bytestring
|
| 24 |
default-language: Haskell2010
|