module Data.Binding.Hobbits.PatternParser (parsePattern) where
import Language.Haskell.TH
import qualified Language.Haskell.Exts.Parser as Meta
import qualified Language.Haskell.Meta.Parse as Meta
import qualified Language.Haskell.Meta.Parse as Sloppy
import qualified Language.Haskell.Meta.Syntax.Translate as Translate
import qualified Language.Haskell.Exts.Extension as Exts
parsePatternExtensions =
map Exts.EnableExtension $ Exts.ViewPatterns : Sloppy.myDefaultExtensions
parsePattern :: String -> String -> Either String Pat
parsePattern fn =
fmap Translate.toPat . Meta.parseResultToEither .
Meta.parsePatWithMode (Sloppy.myDefaultParseMode
{Meta.parseFilename = fn,
Meta.extensions = parsePatternExtensions })