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:
parent
31b325c101
commit
c42ebf27e3
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user