aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Main.hs2
-rw-r--r--astore.cabal64
-rw-r--r--json2sql.cabal60
-rw-r--r--src/Store.hs6
-rw-r--r--src/Store/Debug.hs (renamed from app/Debug.hs)2
-rw-r--r--src/Store/Exception.hs (renamed from app/Exception.hs)2
-rw-r--r--src/Store/Query.hs (renamed from app/Query.hs)20
-rw-r--r--src/Store/Query/Field.hs (renamed from app/Query/Field.hs)2
-rw-r--r--src/Store/Query/Parser.hs (renamed from app/Query/Parser.hs)6
-rw-r--r--src/Store/Query/Printer.hs (renamed from app/Query/Printer.hs)8
-rw-r--r--src/Store/Query/Record.hs (renamed from app/Query/Record.hs)6
-rw-r--r--src/Store/Query/Type.hs (renamed from app/Query/Type.hs)10
-rw-r--r--src/Store/Store.hs (renamed from app/Store.hs)2
13 files changed, 100 insertions, 90 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 7bf67ba..5574afa 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -5,7 +5,7 @@ where
import Data.Aeson qualified as J
import Data.ByteString.Lazy.Char8 qualified as LB
-import Query qualified as Q
+import Store qualified as Q
import System.Directory (setCurrentDirectory)
import Text.Printf (printf)
diff --git a/astore.cabal b/astore.cabal
new file mode 100644
index 0000000..fa9b4ea
--- /dev/null
+++ b/astore.cabal
@@ -0,0 +1,64 @@
+cabal-version: 3.4
+name: astore
+version: 0.1.0.0
+license: Apache-2.0
+license-file: LICENSE
+maintainer: aforemny@posteo.de
+author: Alexander Foremny
+build-type: Simple
+extra-doc-files: CHANGELOG.md
+
+library
+ exposed-modules:
+ Store
+
+ hs-source-dirs: src
+ other-modules: Store.Debug
+ Store.Exception
+ Store.Query
+ Store.Query.Field
+ Store.Query.Parser
+ Store.Query.Printer
+ Store.Query.Record
+ Store.Query.Type
+ Store.Store
+ default-language: GHC2021
+ default-extensions:
+ AllowAmbiguousTypes BlockArguments GeneralizedNewtypeDeriving
+ OverloadedRecordDot OverloadedStrings ViewPatterns
+
+ ghc-options:
+ -Wall -fno-warn-incomplete-patterns -fno-warn-name-shadowing
+
+ build-depends:
+ aeson,
+ base,
+ bytestring,
+ containers,
+ directory,
+ exceptions,
+ filepath,
+ gitlib,
+ gitlib-libgit2,
+ megaparsec,
+ mtl,
+ parser-combinators,
+ tagged,
+ text,
+ unliftio,
+ unliftio-core,
+ unordered-containers,
+ utf8-string,
+ vector
+
+executable astore
+ main-is: Main.hs
+ hs-source-dirs: app
+ default-language: GHC2021
+ default-extensions: OverloadedStrings
+ build-depends:
+ aeson,
+ astore,
+ base,
+ bytestring,
+ directory
diff --git a/json2sql.cabal b/json2sql.cabal
deleted file mode 100644
index 1cfd4da..0000000
--- a/json2sql.cabal
+++ /dev/null
@@ -1,60 +0,0 @@
-cabal-version: 3.4
-name: json2sql
-version: 0.1.0.0
--- synopsis:
--- description:
-license: Apache-2.0
-license-file: LICENSE
-author: Alexander Foremny
-maintainer: aforemny@posteo.de
--- copyright:
-build-type: Simple
-extra-doc-files: CHANGELOG.md
--- extra-source-files:
-
-executable json2sql
- ghc-options:
- -Wall
- -fno-warn-incomplete-patterns
- -fno-warn-name-shadowing
- main-is: Main.hs
- other-modules:
- Debug
- Exception
- Query
- Query.Field
- Query.Parser
- Query.Printer
- Query.Record
- Query.Type
- Store
- -- other-extensions:
- build-depends: base ^>=4.16.4.0,
- aeson,
- bytestring,
- containers,
- directory,
- exceptions,
- filepath,
- gitlib,
- gitlib-libgit2,
- megaparsec,
- mtl,
- parser-combinators,
- tagged,
- text,
- unliftio,
- unliftio-core,
- unordered-containers,
- utf8-string,
- vector
- hs-source-dirs: app
- default-language: GHC2021
- default-extensions:
- AllowAmbiguousTypes
- BlockArguments
- GeneralizedNewtypeDeriving
- OverloadedRecordDot
- OverloadedStrings
- ViewPatterns
-
diff --git a/src/Store.hs b/src/Store.hs
new file mode 100644
index 0000000..f7562f5
--- /dev/null
+++ b/src/Store.hs
@@ -0,0 +1,6 @@
+module Store
+ ( module Store.Query,
+ )
+where
+
+import Store.Query
diff --git a/app/Debug.hs b/src/Store/Debug.hs
index 3499e02..5e0b704 100644
--- a/app/Debug.hs
+++ b/src/Store/Debug.hs
@@ -1,4 +1,4 @@
-module Debug
+module Store.Debug
( debug,
)
where
diff --git a/app/Exception.hs b/src/Store/Exception.hs
index 0cccf5b..245780c 100644
--- a/app/Exception.hs
+++ b/src/Store/Exception.hs
@@ -1,4 +1,4 @@
-module Exception
+module Store.Exception
( DecodeException (DecodeException),
DuplicateField (DuplicateField),
ParseError (ParseError),
diff --git a/app/Query.hs b/src/Store/Query.hs
index 140d0f1..b63b176 100644
--- a/app/Query.hs
+++ b/src/Store/Query.hs
@@ -1,5 +1,5 @@
-module Query
- ( module Query.Type,
+module Store.Query
+ ( module Store.Query.Type,
query,
)
where
@@ -12,12 +12,12 @@ import Data.List (foldl', isSuffixOf)
import Data.List.NonEmpty qualified as N
import Data.Maybe (fromMaybe)
import Data.Vector qualified as V
-import Exception (DecodeException (DecodeException))
-import Query.Parser ()
-import Query.Printer ()
-import Query.Record
-import Query.Type
-import Store qualified as S
+import Store.Exception (DecodeException (DecodeException))
+import Store.Query.Parser ()
+import Store.Query.Printer ()
+import Store.Query.Record
+import Store.Query.Type
+import Store.Store qualified as S
import System.FilePath ((</>))
query :: Query -> IO [J.Value]
@@ -38,7 +38,7 @@ query (Select fs c js es w) = do
=<< ls c
)
es
- pure $ map (Query.select fs) $ where_ w $ embeds es' $ joins js' c'
+ pure $ map (Store.Query.select fs) $ where_ w $ embeds es' $ joins js' c'
where
ls c =
filter (not . (isSuffixOf "/"))
@@ -118,7 +118,7 @@ join vss (JoinClause JoinFull js w) =
select :: FieldSelector -> Records J.Value -> J.Value
select All vs = disjointUnions (map toValue vs)
-select (Only fs) vs = Query.Record.select (N.toList fs) vs
+select (Only fs) vs = Store.Query.Record.select (N.toList fs) vs
where_ :: Maybe WhereClause -> [Records J.Value] -> [Records J.Value]
where_ w = filter (satisfies w)
diff --git a/app/Query/Field.hs b/src/Store/Query/Field.hs
index cdb977a..69a0983 100644
--- a/app/Query/Field.hs
+++ b/src/Store/Query/Field.hs
@@ -1,4 +1,4 @@
-module Query.Field
+module Store.Query.Field
( Field (..),
toString,
prefix,
diff --git a/app/Query/Parser.hs b/src/Store/Query/Parser.hs
index f2012e2..93e408c 100644
--- a/app/Query/Parser.hs
+++ b/src/Store/Query/Parser.hs
@@ -1,6 +1,6 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
-module Query.Parser () where
+module Store.Query.Parser () where
import Control.Exception (throw)
import Control.Monad (void)
@@ -10,8 +10,8 @@ import Data.List.NonEmpty qualified as N
import Data.String (IsString (fromString))
import Data.Text qualified as T
import Data.Void (Void)
-import Exception (ParseError (ParseError))
-import Query.Type
+import Store.Exception (ParseError (ParseError))
+import Store.Query.Type
import Text.Megaparsec qualified as P
import Text.Megaparsec.Char qualified as P
import Text.Megaparsec.Char.Lexer qualified as P
diff --git a/app/Query/Printer.hs b/src/Store/Query/Printer.hs
index e43b7d0..5692ba8 100644
--- a/app/Query/Printer.hs
+++ b/src/Store/Query/Printer.hs
@@ -1,12 +1,12 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}
-module Query.Printer () where
+module Store.Query.Printer () where
import Data.List (intercalate)
import Data.List.NonEmpty qualified as N
import Data.Maybe (catMaybes, mapMaybe)
-import Query.Field
-import Query.Type
+import Store.Query.Field
+import Store.Query.Type
instance Show Query where
show (Select fs c js es w) =
@@ -24,7 +24,7 @@ instance Show Query where
showFieldSelector All = "*"
showFieldSelector (Only (N.toList -> fs)) =
intercalate ", " (map showField fs)
- showField = Query.Field.toString
+ showField = Store.Query.Field.toString
showCollection c = c
showJoinClauses js = case map showJoinClause js of
[] -> Nothing
diff --git a/app/Query/Record.hs b/src/Store/Query/Record.hs
index b1b3329..71461d5 100644
--- a/app/Query/Record.hs
+++ b/src/Store/Query/Record.hs
@@ -1,4 +1,4 @@
-module Query.Record
+module Store.Query.Record
( Record (..),
fromValue,
toValue,
@@ -19,8 +19,8 @@ import Data.List (foldl')
import Data.List.NonEmpty qualified as N
import Data.Maybe (fromMaybe, mapMaybe)
import Data.Text qualified as T
-import Exception (DuplicateField (DuplicateField))
-import Query.Field
+import Store.Exception (DuplicateField (DuplicateField))
+import Store.Query.Field
import Prelude hiding (lookup)
data Record a
diff --git a/app/Query/Type.hs b/src/Store/Query/Type.hs
index d27106f..5aa0e36 100644
--- a/app/Query/Type.hs
+++ b/src/Store/Query/Type.hs
@@ -1,6 +1,6 @@
-module Query.Type
- ( module Query.Field,
- module Query.Record,
+module Store.Query.Type
+ ( module Store.Query.Field,
+ module Store.Query.Record,
Collection,
Comparison (..),
EmbedClause (..),
@@ -15,8 +15,8 @@ module Query.Type
where
import Data.List.NonEmpty qualified as N
-import Query.Field
-import Query.Record
+import Store.Query.Field
+import Store.Query.Record
data Query
= Select
diff --git a/app/Store.hs b/src/Store/Store.hs
index 3a899b6..7917449 100644
--- a/app/Store.hs
+++ b/src/Store/Store.hs
@@ -1,4 +1,4 @@
-module Store
+module Store.Store
( withStore,
listDirectory,
readFile,