1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
module Data.JLD.Model.ActiveContext (ActiveContext (..), newActiveContext, lookupTerm, containsProtectedTerm) where
import Data.JLD.Prelude
import Data.JLD.Model.Direction (Direction)
import Data.JLD.Model.InverseContext (InverseContext)
import Data.JLD.Model.Language (Language)
import Data.JLD.Model.TermDefinition (TermDefinition (..))
import Data.Map.Strict qualified as M (lookup)
import Data.RDF (IRIRef)
import Text.URI (URI)
data ActiveContext = ActiveContext
{ activeContextTerms :: Map Text TermDefinition
, activeContextBaseIri :: Maybe IRIRef
, activeContextBaseUrl :: Maybe URI
, activeContextInverseContext :: Maybe InverseContext
, activeContextPreviousContext :: Maybe ActiveContext
, activeContextVocabularyMapping :: Maybe Text
, activeContextDefaultLanguage :: Maybe Language
, activeContextDefaultBaseDirection :: Maybe Direction
}
deriving (Eq, Show)
newActiveContext :: (ActiveContext -> ActiveContext) -> ActiveContext
newActiveContext fn =
fn
ActiveContext
{ activeContextTerms = mempty
, activeContextBaseIri = Nothing
, activeContextBaseUrl = Nothing
, activeContextInverseContext = Nothing
, activeContextPreviousContext = Nothing
, activeContextVocabularyMapping = Nothing
, activeContextDefaultLanguage = Nothing
, activeContextDefaultBaseDirection = Nothing
}
lookupTerm :: Text -> ActiveContext -> Maybe TermDefinition
lookupTerm key ActiveContext{..} = M.lookup key activeContextTerms
containsProtectedTerm :: ActiveContext -> Bool
containsProtectedTerm = activeContextTerms .> any termDefinitionProtectedFlag
|