module Language.Egison.Parser.Pattern.Mode.Haskell.TH
(
Expr
, parseExpr
, parseExprWithFixities
, toTH
)
where
import Control.Monad.Except ( MonadError )
import qualified Language.Haskell.TH.Syntax as TH
( Name
, Exp
)
import qualified Language.Haskell.Meta.Syntax.Translate
as TH
( toExp
, toName
)
import qualified Language.Haskell.Exts.Syntax as Haskell
( QName
, Name
, Exp
)
import qualified Language.Haskell.Exts.Parser as Haskell
( ParseMode )
import qualified Language.Egison.Syntax.Pattern
as Egison
( Expr )
import Language.Egison.Syntax.Pattern ( mapValueExpr
, mapVarName
, mapName
)
import Language.Egison.Parser.Pattern ( Errors )
import qualified Language.Egison.Parser.Pattern.Mode.Haskell
as HaskellMode
( Fixity
, parseExpr
, parseExprWithFixities
)
type Expr = Egison.Expr TH.Name TH.Name TH.Exp
toTH
:: Egison.Expr (Haskell.QName l1) (Haskell.Name l2) (Haskell.Exp l3) -> Expr
toTH = mapValueExpr TH.toExp . mapVarName TH.toName . mapName TH.toName
parseExpr
:: MonadError (Errors String) m => Haskell.ParseMode -> String -> m Expr
parseExpr mode = fmap toTH . HaskellMode.parseExpr mode
parseExprWithFixities
:: MonadError (Errors String) m
=> Haskell.ParseMode
-> [HaskellMode.Fixity]
-> String
-> m Expr
parseExprWithFixities mode fixities =
fmap toTH . HaskellMode.parseExprWithFixities mode fixities