gdritter repos telml / 3f70608
Added from-telml application Getty Ritter 9 years ago
2 changed file(s) with 31 addition(s) and 9 deletion(s). Collapse all Expand all
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
41 name: telml
52 version: 0.1.0.0
6 -- synopsis:
7 -- description:
3 synopsis: foo
4 description: foo
85 license: BSD3
96 license-file: LICENSE
107 author: Getty Ritter
118 maintainer: gdritter@galois.com
12 -- copyright:
9 copyright: ©2015
1310 category: Data
1411 build-type: Simple
15 -- extra-source-files:
1612 cabal-version: >=1.10
1713
1814 library
1915 exposed-modules: Data.TeLML
2016 other-modules: Data.TeLML.Parser
21 -- other-extensions:
2217 build-depends: base >=4.7 && <4.8, text, attoparsec
23 -- hs-source-dirs:
2418 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