1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 17:04:47 +03:00

Define a helper to select a parser for the given language.

This commit is contained in:
Rob Rix 2019-10-23 12:11:50 -04:00
parent 31b325c101
commit c42ebf27e3
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -3,6 +3,7 @@ module Control.Effect.Parse
( -- * Parse effect ( -- * Parse effect
Parse(..) Parse(..)
, parse , parse
, parserForLanguage
, parseWith , parseWith
, parsePairWith , parsePairWith
) where ) where
@ -37,6 +38,11 @@ parse :: (Member Parse sig, Carrier sig m)
parse parser blob = send (Parse parser blob pure) parse parser blob = send (Parse parser blob pure)
-- | Select a parser for the given language.
parserForLanguage :: Map.Map Language (SomeParser c ann) -> Language -> Maybe (SomeParser c ann)
parserForLanguage = flip Map.lookup
-- | Parse a 'Blob' with one of the provided parsers, and run an action on the abstracted term. -- | Parse a 'Blob' with one of the provided parsers, and run an action on the abstracted term.
parseWith parseWith
:: (Carrier sig m, Member (Error SomeException) sig, Member Parse sig) :: (Carrier sig m, Member (Error SomeException) sig, Member Parse sig)