json-autotype

Safe HaskellNone
LanguageHaskell2010

Main

Contents

Synopsis

Command line flags

data HFlag_suggest

Constructors

HFlagC_suggest 

Instances

data HFlag_test

Constructors

HFlagC_test 

Instances

data HFlag_debug

Constructors

HFlagC_debug 

Instances

myTrace :: String -> IO ()

Works like Debug.trace when the --debug flag is enabled, and does nothing otherwise.

report :: Text -> IO ()

Report an error to error output.

fatal :: Text -> IO ()

Report an error and terminate the program.

extractTypeFromJSONFile :: FilePath -> IO (Maybe (FilePath, Type, Value))

Extracts type from JSON file, along with the original Value. In order to facilitate dealing with failures, it returns a triple of FilePath, extracted Type, and a JSON Value.

preprocess :: ByteString -> ByteString

Perform preprocessing of JSON input to drop initial pragma.

dropPragma :: ByteString -> ByteString

Drop initial pragma.

typeChecking :: Type -> [FilePath] -> [Value] -> IO [FilePath]

Type checking all input files with given type, and return a list of filenames for files that passed the check.

generateHaskellFromJSONs :: [FilePath] -> FilePath -> IO ()

Take a set of JSON input filenames, Haskell output filename, and generate module parsing these JSON files.

main :: IO ()

Initialize flags, and run generateHaskellFromJSONs.