From 504dc557cc041f7427f8b717cf3f7f5e7524f467 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 12 Feb 2024 05:34:29 +0100 Subject: `combine` -> `join` --- app/Main.hs | 28 +++++++++++++--------------- 1 file 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] -- cgit v1.2.3