From d144e1d0b45421d102751cdf584126810ab33ba5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Roman=20Smr=C5=BE?= <roman.smrz@seznam.cz>
Date: Wed, 30 Oct 2024 21:42:35 +0100
Subject: Create new Object, Storable and Storage modules

Changelog: API: Split Erebos.Storage into multiple modules
---
 src/Erebos/Object.hs   | 22 ++++++++++++++++++++++
 src/Erebos/Storable.hs | 39 +++++++++++++++++++++++++++++++++++++++
 src/Erebos/Storage.hs  | 27 +++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 src/Erebos/Object.hs
 create mode 100644 src/Erebos/Storable.hs
 create mode 100644 src/Erebos/Storage.hs

(limited to 'src')

diff --git a/src/Erebos/Object.hs b/src/Erebos/Object.hs
new file mode 100644
index 0000000..26ca09f
--- /dev/null
+++ b/src/Erebos/Object.hs
@@ -0,0 +1,22 @@
+{-|
+Description: Core Erebos objects and references
+
+Data types and functions for working with "raw" Erebos objects and references.
+-}
+
+module Erebos.Object (
+    Object, PartialObject, Object'(..),
+    serializeObject, deserializeObject, deserializeObjects,
+    ioLoadObject, ioLoadBytes,
+    storeRawBytes, lazyLoadBytes,
+
+    RecItem, RecItem'(..),
+
+    Ref, PartialRef, RefDigest,
+    refDigest,
+    readRef, showRef, showRefDigest,
+    refDigestFromByteString, hashToRefDigest,
+    copyRef, partialRef, partialRefFromDigest,
+) where
+
+import Erebos.Object.Internal
diff --git a/src/Erebos/Storable.hs b/src/Erebos/Storable.hs
new file mode 100644
index 0000000..15f43b3
--- /dev/null
+++ b/src/Erebos/Storable.hs
@@ -0,0 +1,39 @@
+{-|
+Description: Encoding custom types into Erebos objects
+
+Module provides the 'Storable' class for types that can be serialized to/from
+Erebos objects, along with various helpers, mostly for encoding using records.
+
+The 'Stored' wrapper for objects actually encoded and stored in some storage is
+defined here as well.
+-}
+
+module Erebos.Storable (
+    Storable(..), ZeroStorable(..),
+    StorableText(..), StorableDate(..), StorableUUID(..),
+
+    Store, StoreRec,
+    storeBlob, storeRec, storeZero,
+    storeEmpty, storeInt, storeNum, storeText, storeBinary, storeDate, storeUUID, storeRef, storeRawRef,
+    storeMbEmpty, storeMbInt, storeMbNum, storeMbText, storeMbBinary, storeMbDate, storeMbUUID, storeMbRef, storeMbRawRef,
+    storeZRef,
+    storeRecItems,
+
+    Load, LoadRec,
+    loadCurrentRef, loadCurrentObject,
+    loadRecCurrentRef, loadRecItems,
+
+    loadBlob, loadRec, loadZero,
+    loadEmpty, loadInt, loadNum, loadText, loadBinary, loadDate, loadUUID, loadRef, loadRawRef,
+    loadMbEmpty, loadMbInt, loadMbNum, loadMbText, loadMbBinary, loadMbDate, loadMbUUID, loadMbRef, loadMbRawRef,
+    loadTexts, loadBinaries, loadRefs, loadRawRefs,
+    loadZRef,
+
+    Stored,
+    fromStored, storedRef,
+    wrappedStore, wrappedLoad,
+    copyStored,
+    unsafeMapStored,
+) where
+
+import Erebos.Object.Internal
diff --git a/src/Erebos/Storage.hs b/src/Erebos/Storage.hs
new file mode 100644
index 0000000..3b2ce4a
--- /dev/null
+++ b/src/Erebos/Storage.hs
@@ -0,0 +1,27 @@
+{-|
+Description: Working with storage and heads
+
+Provides functions for opening 'Storage' backed either by disk or memory. For
+conveniance also function for working with 'Head's are reexported here.
+-}
+
+module Erebos.Storage (
+    Storage, PartialStorage,
+    openStorage, memoryStorage,
+    deriveEphemeralStorage, derivePartialStorage,
+
+    Head, HeadType(..),
+    HeadTypeID, mkHeadTypeID,
+    headId, headStorage, headRef, headObject, headStoredObject,
+    loadHeads, loadHead, reloadHead,
+    storeHead, replaceHead, updateHead, updateHead_,
+    loadHeadRaw, storeHeadRaw, replaceHeadRaw,
+
+    WatchedHead,
+    watchHead, watchHeadWith, unwatchHead,
+    watchHeadRaw,
+
+    MonadStorage(..),
+) where
+
+import Erebos.Object.Internal
-- 
cgit v1.2.3