From 11d0fb47c292a0ca25a9c377499d2b221d97a5cb Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 26 May 2023 07:40:13 +0200 Subject: Init --- src/Data/JLD/Options.hs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/Data/JLD/Options.hs (limited to 'src/Data/JLD/Options.hs') 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 @@ +module Data.JLD.Options ( + Document (..), + ContextCache, + DocumentCache, + JLDVersion (..), + DocumentLoader (..), + hoistDocumentLoader, +) where + +import Data.JLD.Prelude + +import Data.Aeson (Object, Value) +import Text.Show (Show (..)) +import Text.URI (URI) + +data Document = Document + { documentUri :: URI + , documentContent :: Object + } + deriving (Show, Eq) + +type ContextCache = Map Text Value + +type DocumentCache = Map Text Document + +newtype DocumentLoader e m = DocumentLoader {runDocumentLoader :: URI -> m (Either e Value)} + +instance Show (DocumentLoader e m) where + show _ = "DocumentLoader" + +data JLDVersion = JLD1_0 | JLD1_1 deriving (Show, Eq) + +hoistDocumentLoader :: (forall a. m a -> n a) -> DocumentLoader e m -> DocumentLoader e n +hoistDocumentLoader map' (DocumentLoader loader) = DocumentLoader <| loader .> map' -- cgit v1.2.3-54-g00ecf