Removed `from-telml` executable, which bloated dependencies for little reason
Getty Ritter
10 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.TeLML
|
| 8 | |
import Data.Vector (fromList)
|
| 9 | |
import qualified Data.Text as T
|
| 10 | |
|
| 11 | |
telmlToValue :: Fragment -> Value
|
| 12 | |
telmlToValue (Text t) = String (T.pack t)
|
| 13 | |
telmlToValue (Tag t ts) = object
|
| 14 | |
[ "name" .= String (T.pack t)
|
| 15 | |
, "contents" .= arr (map (arr . map telmlToValue) ts)
|
| 16 | |
]
|
| 17 | |
where arr = Array . fromList
|
| 18 | |
|
| 19 | |
fromRight (Right x) = x
|
| 20 | |
fromRight _ = undefined
|
| 21 | |
|
| 22 | |
main = do
|
| 23 | |
r <- fmap parse getContents
|
| 24 | |
case r of
|
| 25 | |
Right x -> BS.putStrLn . encode . map telmlToValue $ x
|
| 26 | |
Left err -> putStrLn err
|
| 1 | 1 |
name: telml
|
| 2 | 2 |
version: 0.1.0.0
|
| 3 | |
synopsis: foo
|
| 4 | |
description: foo
|
| 3 |
synopsis: A lightweight TeX-like markup format.
|
| 4 |
description: A lightweight TeX-like markup format.
|
| 5 | 5 |
license: BSD3
|
| 6 | 6 |
license-file: LICENSE
|
| 7 | 7 |
author: Getty Ritter
|
| 8 | 8 |
maintainer: gdritter@galois.com
|
| 9 | |
copyright: ©2015
|
| 9 |
copyright: ©2015 Getty Ritter
|
| 10 | 10 |
category: Data
|
| 11 | 11 |
build-type: Simple
|
| 12 | 12 |
cabal-version: >=1.10
|
|
| 14 | 14 |
library
|
| 15 | 15 |
exposed-modules: Data.TeLML
|
| 16 | 16 |
other-modules: Data.TeLML.Parser, Data.TeLML.Type
|
| 17 | |
build-depends: base >=4.7 && <4.9, deepseq
|
| 17 |
build-depends: base >=4.7 && <4.9,
|
| 18 |
deepseq >=1.4 && <2
|
| 18 | 19 |
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
|