From 950eea3ba04e94cf3d5797f9b5d32b2621c89b55 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 13 Feb 2024 02:07:20 +0100 Subject: refactor library --- app/Query/Field.hs | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 app/Query/Field.hs (limited to 'app/Query/Field.hs') diff --git a/app/Query/Field.hs b/app/Query/Field.hs deleted file mode 100644 index cdb977a..0000000 --- a/app/Query/Field.hs +++ /dev/null @@ -1,32 +0,0 @@ -module Query.Field - ( Field (..), - toString, - prefix, - ) -where - -import Data.Aeson qualified as J -import Data.Aeson.Key qualified as JK -import Data.Aeson.KeyMap qualified as JM -import Data.List (intercalate) -import Data.List.NonEmpty qualified as N -import Data.Text qualified as T - -data Field - = Qualified Collection (N.NonEmpty T.Text) - | Unqualified (N.NonEmpty T.Text) - deriving (Show) - -toString :: Field -> String -toString (Qualified c ks) = intercalate "." (c : map T.unpack (N.toList ks)) -toString (Unqualified ks) = intercalate "." (map T.unpack (N.toList ks)) - -type Collection = FilePath - -prefix :: Field -> J.Value -> J.Value -prefix (Qualified c ks) = prefix' (T.pack c : N.toList ks) -prefix (Unqualified ks) = prefix' (N.toList ks) - -prefix' :: [T.Text] -> J.Value -> J.Value -prefix' ks v = - foldr ((J.Object .) . JM.singleton) v (map JK.fromText ks) -- cgit v1.2.3