From 68566ca5a376f8508fdd1c5eff3155cde7929850 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Mon, 12 Feb 2024 10:05:02 +0100 Subject: refactor `Query` --- app/Query/Type.hs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 app/Query/Type.hs (limited to 'app/Query/Type.hs') diff --git a/app/Query/Type.hs b/app/Query/Type.hs new file mode 100644 index 0000000..d27106f --- /dev/null +++ b/app/Query/Type.hs @@ -0,0 +1,62 @@ +module Query.Type + ( module Query.Field, + module Query.Record, + Collection, + Comparison (..), + EmbedClause (..), + EmbedClauses, + FieldSelector (..), + JoinClause (..), + JoinClauses, + JoinType (..), + Query (..), + WhereClause (..), + ) +where + +import Data.List.NonEmpty qualified as N +import Query.Field +import Query.Record + +data Query + = Select + FieldSelector + Collection + (JoinClauses FilePath) + (EmbedClauses FilePath) + (Maybe WhereClause) + +data FieldSelector + = All + | Only (N.NonEmpty Field) + deriving (Show) + +type Collection = FilePath + +type JoinClauses a = [JoinClause a] + +data JoinClause a + = JoinClause JoinType a (Maybe WhereClause) + deriving (Show) + +data JoinType + = JoinLeft + | JoinRight + | JoinFull + deriving (Show) + +type EmbedClauses a = [EmbedClause a] + +data EmbedClause a + = EmbedClause a (Maybe WhereClause) + deriving (Show) + +data WhereClause + = And [WhereClause] + | Or [WhereClause] + | Where Comparison + deriving (Show) + +data Comparison + = Eq Field Field + deriving (Show) -- cgit v1.2.3