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'