diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-02-12 05:39:19 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-02-12 05:39:19 +0100 |
commit | 33faca6f99dc207e81497297c205a1ff29ae2f33 (patch) | |
tree | a73ecda14cf14b5ff3e0c21d92f8f388fec57ff0 /app/Main.hs | |
parent | 504dc557cc041f7427f8b717cf3f7f5e7524f467 (diff) |
dissolve `unique`
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/app/Main.hs b/app/Main.hs index 4eedc97..e7d62bf 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -374,20 +374,7 @@ satisfies :: Maybe WhereClause -> R.Records J.Value -> Bool satisfies Nothing _ = True satisfies (Just (And ws)) vs = all (\w -> satisfies (Just w) vs) ws satisfies (Just (Or ws)) vs = any (\w -> satisfies (Just w) vs) ws -satisfies (Just (Where p)) vs = satisfy p vs - -satisfy :: Comparison -> R.Records J.Value -> Bool -satisfy (Eq f g) vs = unique f vs == unique g vs - -data DuplicateField' = DuplicateField' - deriving (Show) - -instance Exception DuplicateField' - -unique :: F.Field -> R.Records J.Value -> J.Value -unique f as = case mapMaybe (R.lookup f) as of - [v] -> v - (_ : _) -> throw DuplicateField' +satisfies (Just (Where (Eq f g))) vs = R.lookups f vs == R.lookups g vs query' :: Query -> IO () query' q = mapM_ (LB.putStrLn . J.encode) =<< query q |