2019-07-31 20:25:10 +00:00
|
|
|
{-# OPTIONS_GHC -Wall #-}
|
2019-07-31 18:19:22 +00:00
|
|
|
module Main where
|
|
|
|
|
2019-07-31 20:25:10 +00:00
|
|
|
import Control.Category ((>>>))
|
|
|
|
import Control.Monad.Fail (fail)
|
|
|
|
import Data.Attoparsec.Text (Parser)
|
|
|
|
import Data.Foldable (traverse_)
|
|
|
|
import Data.Text (Text)
|
|
|
|
import Language.Haskell.Exts.Pretty
|
|
|
|
import Prelude hiding (fail)
|
|
|
|
import qualified Data.Attoparsec.Text as Parser
|
2019-07-31 18:19:22 +00:00
|
|
|
import qualified Data.Text.IO as Text
|
2019-07-31 20:25:10 +00:00
|
|
|
import qualified GraphQL.Internal.Syntax.AST as GraphQL
|
|
|
|
import qualified GraphQL.Internal.Syntax.Parser as GraphQL.Parser
|
|
|
|
import qualified Language.GraphQL.Reflection as GraphQL
|
2019-07-31 18:19:22 +00:00
|
|
|
|
|
|
|
main :: IO ()
|
2019-08-08 14:40:05 +00:00
|
|
|
main = run
|
2019-07-31 18:19:22 +00:00
|
|
|
|
2019-08-08 14:40:05 +00:00
|
|
|
run :: IO ()
|
|
|
|
run = parseContents >>= (GraphQL.schemaDocument >>> traverse_ (prettyPrint >>> putStrLn))
|
2019-07-31 18:19:22 +00:00
|
|
|
|
2019-08-08 14:40:05 +00:00
|
|
|
parseContents :: IO GraphQL.SchemaDocument
|
|
|
|
parseContents = do
|
|
|
|
txt <- Text.getContents
|
2019-07-31 20:25:10 +00:00
|
|
|
parse GraphQL.Parser.schemaDocument txt
|
2019-07-31 18:19:22 +00:00
|
|
|
|
2019-07-31 20:25:10 +00:00
|
|
|
parse :: Parser a -> Text -> IO a
|
|
|
|
parse p = Parser.parseOnly p >>> either fail pure
|