mirror of
https://github.com/github/semantic.git
synced 2025-01-01 11:46:14 +03:00
📝 parseWith & parsePairWith’s parameters.
This commit is contained in:
parent
3dd91ec21a
commit
7433b7e6b1
@ -40,9 +40,9 @@ parse parser blob = send (Parse parser blob pure)
|
|||||||
-- | 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)
|
||||||
=> Map.Map Language (SomeParser c ann)
|
=> Map.Map Language (SomeParser c ann) -- ^ The set of parsers to select from.
|
||||||
-> (forall term . c term => term ann -> m a)
|
-> (forall term . c term => term ann -> m a) -- ^ A function to run on the parsed term. Note that the term is abstract, but constrained by @c@, allowing you to do anything @c@ allows, and requiring that all the input parsers produce terms supporting @c@.
|
||||||
-> Blob
|
-> Blob -- ^ The blob to parse.
|
||||||
-> m a
|
-> m a
|
||||||
parseWith parsers with blob = case Map.lookup (blobLanguage blob) parsers of
|
parseWith parsers with blob = case Map.lookup (blobLanguage blob) parsers of
|
||||||
Just (SomeParser parser) -> parse parser blob >>= with
|
Just (SomeParser parser) -> parse parser blob >>= with
|
||||||
@ -51,9 +51,9 @@ parseWith parsers with blob = case Map.lookup (blobLanguage blob) parsers of
|
|||||||
-- | Parse a 'BlobPair' with one of the provided parsers, and run an action on the abstracted term pair.
|
-- | Parse a 'BlobPair' with one of the provided parsers, and run an action on the abstracted term pair.
|
||||||
parsePairWith
|
parsePairWith
|
||||||
:: (Carrier sig m, Member (Error SomeException) sig, Member Parse sig)
|
:: (Carrier sig m, Member (Error SomeException) sig, Member Parse sig)
|
||||||
=> Map.Map Language (SomeParser c ann)
|
=> Map.Map Language (SomeParser c ann) -- ^ The set of parsers to select from.
|
||||||
-> (forall term . c term => These (term ann) (term ann) -> m a)
|
-> (forall term . c term => These (term ann) (term ann) -> m a) -- ^ A function to run on the parsed terms. Note that the terms are abstract, but constrained by @c@, allowing you to do anything @c@ allows, and requiring that all the input parsers produce terms supporting @c@.
|
||||||
-> BlobPair
|
-> BlobPair -- ^ The blob pair to parse.
|
||||||
-> m a
|
-> m a
|
||||||
parsePairWith parsers with blobPair = case Map.lookup (languageForBlobPair blobPair) parsers of
|
parsePairWith parsers with blobPair = case Map.lookup (languageForBlobPair blobPair) parsers of
|
||||||
Just (SomeParser parser) -> traverse (parse parser) blobPair >>= with . runJoin
|
Just (SomeParser parser) -> traverse (parse parser) blobPair >>= with . runJoin
|
||||||
|
Loading…
Reference in New Issue
Block a user