aboutsummaryrefslogtreecommitdiffstats
path: root/src/Data/JLD/Options.hs
diff options
context:
space:
mode:
authorVolpeon <github@volpeon.ink>2023-05-26 07:40:13 +0200
committerVolpeon <github@volpeon.ink>2023-05-26 07:40:13 +0200
commit11d0fb47c292a0ca25a9c377499d2b221d97a5cb (patch)
treee729e2a4508763b3073b7eae9a56bc9c6a9ca0f7 /src/Data/JLD/Options.hs
downloadhs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.tar.gz
hs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.tar.bz2
hs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.zip
Init
Diffstat (limited to 'src/Data/JLD/Options.hs')
-rw-r--r--src/Data/JLD/Options.hs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Data/JLD/Options.hs b/src/Data/JLD/Options.hs
new file mode 100644
index 0000000..d6ec51d
--- /dev/null
+++ b/src/Data/JLD/Options.hs
@@ -0,0 +1,34 @@
1module Data.JLD.Options (
2 Document (..),
3 ContextCache,
4 DocumentCache,
5 JLDVersion (..),
6 DocumentLoader (..),
7 hoistDocumentLoader,
8) where
9
10import Data.JLD.Prelude
11
12import Data.Aeson (Object, Value)
13import Text.Show (Show (..))
14import Text.URI (URI)
15
16data Document = Document
17 { documentUri :: URI
18 , documentContent :: Object
19 }
20 deriving (Show, Eq)
21
22type ContextCache = Map Text Value
23
24type DocumentCache = Map Text Document
25
26newtype DocumentLoader e m = DocumentLoader {runDocumentLoader :: URI -> m (Either e Value)}
27
28instance Show (DocumentLoader e m) where
29 show _ = "DocumentLoader"
30
31data JLDVersion = JLD1_0 | JLD1_1 deriving (Show, Eq)
32
33hoistDocumentLoader :: (forall a. m a -> n a) -> DocumentLoader e m -> DocumentLoader e n
34hoistDocumentLoader map' (DocumentLoader loader) = DocumentLoader <| loader .> map'