diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-02-12 05:34:29 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-02-12 05:34:29 +0100 |
commit | 504dc557cc041f7427f8b717cf3f7f5e7524f467 (patch) | |
tree | df7823aa19c27fd91b686bcb97c9db714ac3fae1 /app | |
parent | 9e79b37ce9f6f863d50659d1c51620d544cc5b5c (diff) |
`combine` -> `join`
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/app/Main.hs b/app/Main.hs index c0618ae..4eedc97 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -230,9 +230,9 @@ instance IsString Query where F.Qualified <$> (fieldPart <* P.string ".") <*> (N.map T.pack <$> PN.sepBy1 fieldPart (P.string ".")), - do - F.Unqualified - <$> (N.map T.pack <$> PN.sepBy1 fieldPart (P.string ".")) + do + F.Unqualified + <$> (N.map T.pack <$> PN.sepBy1 fieldPart (P.string ".")) ] fieldPart :: P.Parsec Void String String @@ -273,7 +273,7 @@ query (Select fs c js es w) = do =<< ls c ) es - pure $ map (select fs) $ where_ w $ embed es' $ combine c' js' + pure $ map (select fs) $ where_ w $ embed es' $ join c' js' where ls c = filter (not . (isSuffixOf "/")) @@ -309,18 +309,16 @@ embed es vss = embed' vss es ) ess --- TODO rename `join` - -- TODO use fold -combine :: +join :: R.Records J.Value -> JoinClauses (R.Records J.Value) -> [R.Records J.Value] -combine vs js = combine' (map (: []) vs) js +join vs js = join' (map (: []) vs) js where - combine' vss [] = vss - combine' vss (JoinClause JoinLeft js w : jss) = - combine' + join' vss [] = vss + join' vss (JoinClause JoinLeft js w : jss) = + join' ( concatMap ( \vs -> case filter (satisfies w) $ map (\j -> vs ++ [j]) js of [] -> [vs] @@ -329,8 +327,8 @@ combine vs js = combine' (map (: []) vs) js vss ) jss - combine' vss (JoinClause JoinRight js w : jss) = - combine' + join' vss (JoinClause JoinRight js w : jss) = + join' ( concatMap ( \j -> case filter (satisfies w) $ map (\vs -> vs ++ [j]) vss of [] -> [[j]] @@ -339,8 +337,8 @@ combine vs js = combine' (map (: []) vs) js js ) jss - combine' vss (JoinClause JoinFull js w : jss) = - combine' + join' vss (JoinClause JoinFull js w : jss) = + join' ( concatMap ( \vs -> case filter (satisfies w) $ map (\j -> vs ++ [j]) js of [] -> [vs] |