{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE TemplateHaskell #-} module Text.Heterocephalus.Parse ( module Text.Heterocephalus.Parse , module Text.Heterocephalus.Parse.Control , module Text.Heterocephalus.Parse.Doc , module Text.Heterocephalus.Parse.Option ) where import Text.Heterocephalus.Parse.Control (Content(..), parseLineControl) import Text.Heterocephalus.Parse.Doc (Doc(..), parseDocFromControls) import Text.Heterocephalus.Parse.Option (ParseOptions(..), createParseOptions, defaultParseOptions) docFromString :: ParseOptions -> String -> [Doc] docFromString :: ParseOptions -> String -> [Doc] docFromString opts :: ParseOptions opts s :: String s = case ParseOptions -> String -> Either String [Doc] parseDoc ParseOptions opts String s of Left s' :: String s' -> String -> [Doc] forall a. HasCallStack => String -> a error String s' Right d :: [Doc] d -> [Doc] d parseDoc :: ParseOptions -> String -> Either String [Doc] parseDoc :: ParseOptions -> String -> Either String [Doc] parseDoc opts :: ParseOptions opts s :: String s = do [Control] controls <- ParseOptions -> String -> Either String [Control] parseLineControl ParseOptions opts String s case [Control] -> Either ParseError [Doc] parseDocFromControls [Control] controls of Left parseError :: ParseError parseError -> String -> Either String [Doc] forall a b. a -> Either a b Left (String -> Either String [Doc]) -> String -> Either String [Doc] forall a b. (a -> b) -> a -> b $ ParseError -> String forall a. Show a => a -> String show ParseError parseError Right docs :: [Doc] docs -> [Doc] -> Either String [Doc] forall a b. b -> Either a b Right [Doc] docs