From ebc3ccadf21442dace5e7782f9e7726d0c149644 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 9 Feb 2024 07:19:24 +0100 Subject: Where, Cmp -> WhereClauses, WhereClause --- app/Main.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/Main.hs b/app/Main.hs index 4ccf455..dfee5e0 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -80,7 +80,7 @@ main = do [] data Query - = Select FieldSelector Collection [Join FilePath] Where + = Select FieldSelector Collection [Join FilePath] WhereClauses deriving (Show) data FieldSelector @@ -96,14 +96,14 @@ data Field type Collection = FilePath data Join a - = LeftJoin a Where - | RightJoin a Where - | FullJoin a Where + = LeftJoin a WhereClauses + | RightJoin a WhereClauses + | FullJoin a WhereClauses deriving (Show) -type Where = [Cmp] +type WhereClauses = [WhereClause] -data Cmp +data WhereClause = Eq Field Field deriving (Show) @@ -228,13 +228,13 @@ join' = foldl' merge (J.Object JM.empty) joinUnsafe :: [J.Value] -> J.Value joinUnsafe = foldl' mergeUnsafe (J.Object JM.empty) -where_ :: Where -> [[Record J.Value]] -> [[Record J.Value]] +where_ :: WhereClauses -> [[Record J.Value]] -> [[Record J.Value]] where_ ws vss = filter (satisfies ws) vss -satisfies :: [Cmp] -> [Record J.Value] -> Bool +satisfies :: WhereClauses -> [Record J.Value] -> Bool satisfies ws vs = all (\w -> satisfy w vs) ws -satisfy :: Cmp -> [Record J.Value] -> Bool +satisfy :: WhereClause -> [Record J.Value] -> Bool satisfy (Eq f f') vs = unique f vs == unique f' vs data DuplicateField' = DuplicateField' -- cgit v1.2.3