diff options
author | Profpatsch <mail@profpatsch.de> | 2023-10-15T22·48+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-10-15T22·57+0000 |
commit | 81b790af1d8a49b52376c566183591396f60fb3e (patch) | |
tree | 33485e2676f6fe16f28f92e1f2ec74fc4cb43a41 /users/Profpatsch/my-prelude/src | |
parent | df43454dc5cea21d173df7385c3576318cb71211 (diff) |
feat(users/Profpatsch/whatcd-resolver): start checking musicbrainz r/6819
Ideally we can figure out how to search for single songs by grepping through musicbrainz. For this we kinda need the jsonld results, so this is a first step which visualizes the structure and makes it easy-ish to lazily traverse it. Change-Id: Ieca21674dee8e8c2dacbab4f2f15ccbe067da647 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9743 Reviewed-by: Profpatsch <mail@profpatsch.de> Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
Diffstat (limited to 'users/Profpatsch/my-prelude/src')
-rw-r--r-- | users/Profpatsch/my-prelude/src/Parse.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/users/Profpatsch/my-prelude/src/Parse.hs b/users/Profpatsch/my-prelude/src/Parse.hs index 5b6cca0fd26f..116b155f68a4 100644 --- a/users/Profpatsch/my-prelude/src/Parse.hs +++ b/users/Profpatsch/my-prelude/src/Parse.hs @@ -67,6 +67,16 @@ showContext (Context context) = context & fromMaybe [] & List.reverse & Text.int addContext :: Text -> Context -> Context addContext x (Context mxs) = Context (Just $ x : (mxs & fromMaybe [])) +mkParsePushContext :: Text -> ((Context, from) -> Either ErrorTree to) -> Parse from to +mkParsePushContext toPush f = Parse $ \(ctx, from) -> case f (ctx, from) of + Right to -> Success (addContext toPush ctx, to) + Left err -> Failure $ singleton err + +mkParseNoContext :: (from -> Either ErrorTree to) -> Parse from to +mkParseNoContext f = Parse $ \(ctx, from) -> case f from of + Right to -> Success (ctx, to) + Left err -> Failure $ singleton err + -- | Accept only exactly the given value exactly :: (Eq from) => (from -> Text) -> from -> Parse from from exactly errDisplay from = Parse $ \(ctx, from') -> |