diff options
Diffstat (limited to 'src/Data/JLD/Options.hs')
-rw-r--r-- | src/Data/JLD/Options.hs | 34 |
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 @@ | |||
1 | module Data.JLD.Options ( | ||
2 | Document (..), | ||
3 | ContextCache, | ||
4 | DocumentCache, | ||
5 | JLDVersion (..), | ||
6 | DocumentLoader (..), | ||
7 | hoistDocumentLoader, | ||
8 | ) where | ||
9 | |||
10 | import Data.JLD.Prelude | ||
11 | |||
12 | import Data.Aeson (Object, Value) | ||
13 | import Text.Show (Show (..)) | ||
14 | import Text.URI (URI) | ||
15 | |||
16 | data Document = Document | ||
17 | { documentUri :: URI | ||
18 | , documentContent :: Object | ||
19 | } | ||
20 | deriving (Show, Eq) | ||
21 | |||
22 | type ContextCache = Map Text Value | ||
23 | |||
24 | type DocumentCache = Map Text Document | ||
25 | |||
26 | newtype DocumentLoader e m = DocumentLoader {runDocumentLoader :: URI -> m (Either e Value)} | ||
27 | |||
28 | instance Show (DocumentLoader e m) where | ||
29 | show _ = "DocumentLoader" | ||
30 | |||
31 | data JLDVersion = JLD1_0 | JLD1_1 deriving (Show, Eq) | ||
32 | |||
33 | hoistDocumentLoader :: (forall a. m a -> n a) -> DocumentLoader e m -> DocumentLoader e n | ||
34 | hoistDocumentLoader map' (DocumentLoader loader) = DocumentLoader <| loader .> map' | ||