diff options
author | Volpeon <github@volpeon.ink> | 2023-05-26 07:40:13 +0200 |
---|---|---|
committer | Volpeon <github@volpeon.ink> | 2023-05-26 07:40:13 +0200 |
commit | 11d0fb47c292a0ca25a9c377499d2b221d97a5cb (patch) | |
tree | e729e2a4508763b3073b7eae9a56bc9c6a9ca0f7 /src/Data/JLD/Model | |
download | hs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.tar.gz hs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.tar.bz2 hs-jsonld-11d0fb47c292a0ca25a9c377499d2b221d97a5cb.zip |
Init
Diffstat (limited to 'src/Data/JLD/Model')
-rw-r--r-- | src/Data/JLD/Model/ActiveContext.hs | 44 | ||||
-rw-r--r-- | src/Data/JLD/Model/Direction.hs | 13 | ||||
-rw-r--r-- | src/Data/JLD/Model/GraphObject.hs | 22 | ||||
-rw-r--r-- | src/Data/JLD/Model/IRI.hs | 46 | ||||
-rw-r--r-- | src/Data/JLD/Model/InverseContext.hs | 5 | ||||
-rw-r--r-- | src/Data/JLD/Model/Keyword.hs | 135 | ||||
-rw-r--r-- | src/Data/JLD/Model/Language.hs | 6 | ||||
-rw-r--r-- | src/Data/JLD/Model/ListObject.hs | 24 | ||||
-rw-r--r-- | src/Data/JLD/Model/NodeObject.hs | 21 | ||||
-rw-r--r-- | src/Data/JLD/Model/TermDefinition.hs | 43 | ||||
-rw-r--r-- | src/Data/JLD/Model/URI.hs | 13 | ||||
-rw-r--r-- | src/Data/JLD/Model/ValueObject.hs | 27 |
12 files changed, 399 insertions, 0 deletions
diff --git a/src/Data/JLD/Model/ActiveContext.hs b/src/Data/JLD/Model/ActiveContext.hs new file mode 100644 index 0000000..5423036 --- /dev/null +++ b/src/Data/JLD/Model/ActiveContext.hs | |||
@@ -0,0 +1,44 @@ | |||
1 | module Data.JLD.Model.ActiveContext ( ActiveContext (..), newActiveContext, lookupTerm, containsProtectedTerm,) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Direction (Direction) | ||
6 | import Data.JLD.Model.InverseContext (InverseContext) | ||
7 | import Data.JLD.Model.Language (Language) | ||
8 | import Data.JLD.Model.TermDefinition (TermDefinition (..)) | ||
9 | |||
10 | import Data.Map.Strict qualified as M (lookup) | ||
11 | import Data.RDF (IRIRef) | ||
12 | import Text.URI (URI) | ||
13 | |||
14 | data ActiveContext = ActiveContext | ||
15 | { activeContextTerms :: Map Text TermDefinition | ||
16 | , activeContextBaseIri :: Maybe IRIRef | ||
17 | , activeContextBaseUrl :: Maybe URI | ||
18 | , activeContextInverseContext :: InverseContext | ||
19 | , activeContextPreviousContext :: Maybe ActiveContext | ||
20 | , activeContextVocabularyMapping :: Maybe Text | ||
21 | , activeContextDefaultLanguage :: Maybe Language | ||
22 | , activeContextDefaultBaseDirection :: Maybe Direction | ||
23 | } | ||
24 | deriving (Eq, Show) | ||
25 | |||
26 | newActiveContext :: (ActiveContext -> ActiveContext) -> ActiveContext | ||
27 | newActiveContext fn = | ||
28 | fn | ||
29 | ActiveContext | ||
30 | { activeContextTerms = mempty | ||
31 | , activeContextBaseIri = Nothing | ||
32 | , activeContextBaseUrl = Nothing | ||
33 | , activeContextInverseContext = mempty | ||
34 | , activeContextPreviousContext = Nothing | ||
35 | , activeContextVocabularyMapping = Nothing | ||
36 | , activeContextDefaultLanguage = Nothing | ||
37 | , activeContextDefaultBaseDirection = Nothing | ||
38 | } | ||
39 | |||
40 | lookupTerm :: Text -> ActiveContext -> Maybe TermDefinition | ||
41 | lookupTerm key ActiveContext{..} = M.lookup key activeContextTerms | ||
42 | |||
43 | containsProtectedTerm :: ActiveContext -> Bool | ||
44 | containsProtectedTerm = activeContextTerms .> any termDefinitionProtectedFlag | ||
diff --git a/src/Data/JLD/Model/Direction.hs b/src/Data/JLD/Model/Direction.hs new file mode 100644 index 0000000..2ed8e87 --- /dev/null +++ b/src/Data/JLD/Model/Direction.hs | |||
@@ -0,0 +1,13 @@ | |||
1 | module Data.JLD.Model.Direction (Direction (..)) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Text.Show (Show (..)) | ||
6 | |||
7 | data Direction = LTR | RTL | NoDirection | ||
8 | deriving (Eq, Ord) | ||
9 | |||
10 | instance Show Direction where | ||
11 | show LTR = "ltr" | ||
12 | show RTL = "rtl" | ||
13 | show NoDirection = "none" | ||
diff --git a/src/Data/JLD/Model/GraphObject.hs b/src/Data/JLD/Model/GraphObject.hs new file mode 100644 index 0000000..3db9e6b --- /dev/null +++ b/src/Data/JLD/Model/GraphObject.hs | |||
@@ -0,0 +1,22 @@ | |||
1 | module Data.JLD.Model.GraphObject (isGraphObject, isNotGraphObject, toGraphObject) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Keyword (Keyword (..), isKeyword) | ||
6 | |||
7 | import Data.Aeson (Object, Value (..)) | ||
8 | import Data.Aeson.Key qualified as K (toText) | ||
9 | import Data.Aeson.KeyMap qualified as KM (keys, singleton, member) | ||
10 | import Data.Vector qualified as V (singleton) | ||
11 | |||
12 | isGraphObject :: Value -> Bool | ||
13 | isGraphObject (Object o) | ||
14 | | KM.member (show KeywordGraph) o = | ||
15 | all (`isKeyword` [KeywordGraph, KeywordId, KeywordIndex, KeywordContext]) (K.toText <$> KM.keys o) | ||
16 | isGraphObject _ = False | ||
17 | |||
18 | isNotGraphObject :: Value -> Bool | ||
19 | isNotGraphObject = isGraphObject .> not | ||
20 | |||
21 | toGraphObject :: Value -> Object | ||
22 | toGraphObject = V.singleton .> Array .> KM.singleton (show KeywordGraph) | ||
diff --git a/src/Data/JLD/Model/IRI.hs b/src/Data/JLD/Model/IRI.hs new file mode 100644 index 0000000..7c054eb --- /dev/null +++ b/src/Data/JLD/Model/IRI.hs | |||
@@ -0,0 +1,46 @@ | |||
1 | module Data.JLD.Model.IRI ( | ||
2 | CompactIRI (..), | ||
3 | compactIriPrefix, | ||
4 | compactIriSuffix, | ||
5 | isBlankIri, | ||
6 | endsWithGenericDelim, | ||
7 | parseCompactIri, | ||
8 | renderCompactIri, | ||
9 | ) where | ||
10 | |||
11 | import Data.JLD.Prelude | ||
12 | |||
13 | import Data.Char (isAlphaNum) | ||
14 | import Data.Text qualified as T (drop, findIndex, isPrefixOf, take, uncons, unsnoc) | ||
15 | |||
16 | data CompactIRI = CompactIRI Text Text | BlankIRI Text | ||
17 | deriving (Show, Eq) | ||
18 | |||
19 | compactIriPrefix :: CompactIRI -> Text | ||
20 | compactIriPrefix (CompactIRI prefix _) = prefix | ||
21 | compactIriPrefix (BlankIRI _) = "_" | ||
22 | |||
23 | compactIriSuffix :: CompactIRI -> Text | ||
24 | compactIriSuffix (CompactIRI _ suffix) = suffix | ||
25 | compactIriSuffix (BlankIRI suffix) = suffix | ||
26 | |||
27 | renderCompactIri :: CompactIRI -> Text | ||
28 | renderCompactIri iri = compactIriPrefix iri <> ":" <> compactIriSuffix iri | ||
29 | |||
30 | parseCompactIri :: Text -> Maybe CompactIRI | ||
31 | parseCompactIri value | ||
32 | | Just idx <- (+ 1) <$> T.findIndex (== ':') (T.drop 1 value) | ||
33 | , prefix <- T.take idx value | ||
34 | , suffix <- T.drop (idx + 1) value | ||
35 | , not ("/" `T.isPrefixOf` suffix) | ||
36 | , Just (prefixFirst, _) <- T.uncons prefix | ||
37 | , prefixFirst == '_' || isAlphaNum prefixFirst = | ||
38 | Just <| if prefix == "_" then BlankIRI suffix else CompactIRI prefix suffix | ||
39 | | otherwise = Nothing | ||
40 | |||
41 | isBlankIri :: Text -> Bool | ||
42 | isBlankIri = T.isPrefixOf "_:" | ||
43 | |||
44 | endsWithGenericDelim :: Text -> Bool | ||
45 | endsWithGenericDelim (T.unsnoc -> Just (_, c)) = c `elem` (":/?#[]@" :: String) | ||
46 | endsWithGenericDelim _ = False | ||
diff --git a/src/Data/JLD/Model/InverseContext.hs b/src/Data/JLD/Model/InverseContext.hs new file mode 100644 index 0000000..fe4b516 --- /dev/null +++ b/src/Data/JLD/Model/InverseContext.hs | |||
@@ -0,0 +1,5 @@ | |||
1 | module Data.JLD.Model.InverseContext (InverseContext) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | type InverseContext = Map (Text, Text, Text, Text) Text | ||
diff --git a/src/Data/JLD/Model/Keyword.hs b/src/Data/JLD/Model/Keyword.hs new file mode 100644 index 0000000..10835a9 --- /dev/null +++ b/src/Data/JLD/Model/Keyword.hs | |||
@@ -0,0 +1,135 @@ | |||
1 | module Data.JLD.Model.Keyword ( | ||
2 | Keyword (..), | ||
3 | parseKeyword, | ||
4 | isKeyword, | ||
5 | isNotKeyword, | ||
6 | allKeywords, | ||
7 | isKeywordLike, | ||
8 | ) where | ||
9 | |||
10 | import Data.JLD.Prelude hiding (show) | ||
11 | |||
12 | import Data.Char (isAlpha) | ||
13 | import Data.Foldable qualified as F | ||
14 | import Data.Text qualified as T (all, null, uncons) | ||
15 | import Text.Show (Show (..)) | ||
16 | |||
17 | data Keyword | ||
18 | = KeywordAny | ||
19 | | KeywordBase | ||
20 | | KeywordContainer | ||
21 | | KeywordContext | ||
22 | | KeywordDefault | ||
23 | | KeywordDirection | ||
24 | | KeywordEmbed | ||
25 | | KeywordExplicit | ||
26 | | KeywordFirst | ||
27 | | KeywordGraph | ||
28 | | KeywordId | ||
29 | | KeywordImport | ||
30 | | KeywordIncluded | ||
31 | | KeywordIndex | ||
32 | | KeywordJson | ||
33 | | KeywordLanguage | ||
34 | | KeywordList | ||
35 | | KeywordNest | ||
36 | | KeywordNone | ||
37 | | KeywordNull | ||
38 | | KeywordOmitDefault | ||
39 | | KeywordPrefix | ||
40 | | KeywordPreserve | ||
41 | | KeywordPropagate | ||
42 | | KeywordProtected | ||
43 | | KeywordRequireAll | ||
44 | | KeywordReverse | ||
45 | | KeywordSet | ||
46 | | KeywordType | ||
47 | | KeywordValue | ||
48 | | KeywordVersion | ||
49 | | KeywordVocab | ||
50 | deriving (Eq, Ord) | ||
51 | |||
52 | instance Show Keyword where | ||
53 | show = \case | ||
54 | KeywordAny -> "@any" | ||
55 | KeywordBase -> "@base" | ||
56 | KeywordContainer -> "@container" | ||
57 | KeywordContext -> "@context" | ||
58 | KeywordDefault -> "@default" | ||
59 | KeywordDirection -> "@direction" | ||
60 | KeywordEmbed -> "@embed" | ||
61 | KeywordExplicit -> "@explicit" | ||
62 | KeywordFirst -> "@first" | ||
63 | KeywordGraph -> "@graph" | ||
64 | KeywordId -> "@id" | ||
65 | KeywordImport -> "@import" | ||
66 | KeywordIncluded -> "@included" | ||
67 | KeywordIndex -> "@index" | ||
68 | KeywordJson -> "@json" | ||
69 | KeywordLanguage -> "@language" | ||
70 | KeywordList -> "@list" | ||
71 | KeywordNest -> "@nest" | ||
72 | KeywordNone -> "@none" | ||
73 | KeywordNull -> "@null" | ||
74 | KeywordOmitDefault -> "@omitDefault" | ||
75 | KeywordPrefix -> "@prefix" | ||
76 | KeywordPreserve -> "@preserve" | ||
77 | KeywordPropagate -> "@propagate" | ||
78 | KeywordProtected -> "@protected" | ||
79 | KeywordRequireAll -> "@requireAll" | ||
80 | KeywordReverse -> "@reverse" | ||
81 | KeywordSet -> "@set" | ||
82 | KeywordType -> "@type" | ||
83 | KeywordValue -> "@value" | ||
84 | KeywordVersion -> "@version" | ||
85 | KeywordVocab -> "@vocab" | ||
86 | |||
87 | parseKeyword :: Text -> Maybe Keyword | ||
88 | parseKeyword = \case | ||
89 | "@any" -> Just KeywordAny | ||
90 | "@base" -> Just KeywordBase | ||
91 | "@container" -> Just KeywordContainer | ||
92 | "@context" -> Just KeywordContext | ||
93 | "@default" -> Just KeywordDefault | ||
94 | "@direction" -> Just KeywordDirection | ||
95 | "@embed" -> Just KeywordEmbed | ||
96 | "@explicit" -> Just KeywordExplicit | ||
97 | "@first" -> Just KeywordFirst | ||
98 | "@graph" -> Just KeywordGraph | ||
99 | "@id" -> Just KeywordId | ||
100 | "@import" -> Just KeywordImport | ||
101 | "@included" -> Just KeywordIncluded | ||
102 | "@index" -> Just KeywordIndex | ||
103 | "@json" -> Just KeywordJson | ||
104 | "@language" -> Just KeywordLanguage | ||
105 | "@list" -> Just KeywordList | ||
106 | "@nest" -> Just KeywordNest | ||
107 | "@none" -> Just KeywordNone | ||
108 | "@null" -> Just KeywordNull | ||
109 | "@omitDefault" -> Just KeywordOmitDefault | ||
110 | "@prefix" -> Just KeywordPrefix | ||
111 | "@preserve" -> Just KeywordPreserve | ||
112 | "@propagate" -> Just KeywordPropagate | ||
113 | "@protected" -> Just KeywordProtected | ||
114 | "@requireAll" -> Just KeywordRequireAll | ||
115 | "@reverse" -> Just KeywordReverse | ||
116 | "@set" -> Just KeywordSet | ||
117 | "@type" -> Just KeywordType | ||
118 | "@value" -> Just KeywordValue | ||
119 | "@version" -> Just KeywordVersion | ||
120 | "@vocab" -> Just KeywordVocab | ||
121 | _ -> Nothing | ||
122 | |||
123 | isKeyword :: Foldable f => Text -> f Keyword -> Bool | ||
124 | isKeyword (parseKeyword -> Just keyword) (F.elem keyword -> True) = True | ||
125 | isKeyword _ _ = False | ||
126 | |||
127 | isNotKeyword :: Foldable f => Text -> f Keyword -> Bool | ||
128 | isNotKeyword s = isKeyword s .> not | ||
129 | |||
130 | allKeywords :: Foldable f => f Text -> f Keyword -> Bool | ||
131 | allKeywords values keywords = all (`isKeyword` keywords) values | ||
132 | |||
133 | isKeywordLike :: Text -> Bool | ||
134 | isKeywordLike (T.uncons -> Just ('@', res)) = not (T.null res) && T.all isAlpha res | ||
135 | isKeywordLike _ = False | ||
diff --git a/src/Data/JLD/Model/Language.hs b/src/Data/JLD/Model/Language.hs new file mode 100644 index 0000000..c24994e --- /dev/null +++ b/src/Data/JLD/Model/Language.hs | |||
@@ -0,0 +1,6 @@ | |||
1 | module Data.JLD.Model.Language (Language (..)) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | data Language = Language Text | NoLanguage | ||
6 | deriving (Show, Eq) | ||
diff --git a/src/Data/JLD/Model/ListObject.hs b/src/Data/JLD/Model/ListObject.hs new file mode 100644 index 0000000..8dda349 --- /dev/null +++ b/src/Data/JLD/Model/ListObject.hs | |||
@@ -0,0 +1,24 @@ | |||
1 | module Data.JLD.Model.ListObject (isListObject, isNotListObject, toListObject) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Keyword (Keyword (..)) | ||
6 | |||
7 | import Data.Aeson (Value (..)) | ||
8 | import Data.Aeson.KeyMap qualified as KM | ||
9 | import Data.Vector qualified as V | ||
10 | |||
11 | isListObject :: Value -> Bool | ||
12 | isListObject (Object o) = | ||
13 | KM.member (show KeywordList) o | ||
14 | && ( KM.size o == 1 | ||
15 | || (KM.size o == 2 && KM.member (show KeywordIndex) o) | ||
16 | ) | ||
17 | isListObject _ = False | ||
18 | |||
19 | isNotListObject :: Value -> Bool | ||
20 | isNotListObject = isListObject .> not | ||
21 | |||
22 | toListObject :: Value -> Value | ||
23 | toListObject value@(Array _) = Object <| KM.singleton (show KeywordList) value | ||
24 | toListObject value = Object <| KM.singleton (show KeywordList) (Array <| V.singleton value) | ||
diff --git a/src/Data/JLD/Model/NodeObject.hs b/src/Data/JLD/Model/NodeObject.hs new file mode 100644 index 0000000..d0bb4c5 --- /dev/null +++ b/src/Data/JLD/Model/NodeObject.hs | |||
@@ -0,0 +1,21 @@ | |||
1 | module Data.JLD.Model.NodeObject (isNodeObject, isNotNodeObject) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Keyword (Keyword (..)) | ||
6 | |||
7 | import Data.Aeson (Value (..)) | ||
8 | import Data.Aeson.Key qualified as K | ||
9 | import Data.Aeson.KeyMap qualified as KM | ||
10 | |||
11 | isNodeObject :: Value -> Bool | ||
12 | isNodeObject (Object o) = | ||
13 | ( not (KM.member (show KeywordValue) o) | ||
14 | && not (KM.member (show KeywordList) o) | ||
15 | && not (KM.member (show KeywordSet) o) | ||
16 | ) | ||
17 | || (KM.keys o == ([KeywordContext, KeywordGraph] <&> show .> K.fromText)) | ||
18 | isNodeObject _ = False | ||
19 | |||
20 | isNotNodeObject :: Value -> Bool | ||
21 | isNotNodeObject = isNodeObject .> not | ||
diff --git a/src/Data/JLD/Model/TermDefinition.hs b/src/Data/JLD/Model/TermDefinition.hs new file mode 100644 index 0000000..5f39eee --- /dev/null +++ b/src/Data/JLD/Model/TermDefinition.hs | |||
@@ -0,0 +1,43 @@ | |||
1 | module Data.JLD.Model.TermDefinition (TermDefinition (..), newTermDefinition) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Direction (Direction) | ||
6 | import Data.JLD.Model.Language (Language) | ||
7 | |||
8 | import Data.Aeson (Value) | ||
9 | import Text.URI (URI) | ||
10 | |||
11 | data TermDefinition = TermDefinition | ||
12 | { termDefinitionIriMapping :: Maybe Text | ||
13 | , termDefinitionPrefixFlag :: Bool | ||
14 | , termDefinitionProtectedFlag :: Bool | ||
15 | , termDefinitionReversePropertyFlag :: Bool | ||
16 | , termDefinitionBaseUrl :: Maybe URI | ||
17 | , termDefinitionLocalContext :: Maybe Value | ||
18 | , termDefinitionContainerMapping :: Set Text | ||
19 | , termDefinitionIndexMapping :: Maybe Text | ||
20 | , termDefinitionNestValue :: Maybe Text | ||
21 | , termDefinitionTypeMapping :: Maybe Text | ||
22 | , termDefinitionDirectionMapping :: Maybe Direction | ||
23 | , termDefinitionLanguageMapping :: Maybe Language | ||
24 | } | ||
25 | deriving (Show, Eq) | ||
26 | |||
27 | newTermDefinition :: Bool -> (TermDefinition -> TermDefinition) -> TermDefinition | ||
28 | newTermDefinition protectedFlag fn = | ||
29 | fn | ||
30 | TermDefinition | ||
31 | { termDefinitionIriMapping = Nothing | ||
32 | , termDefinitionPrefixFlag = False | ||
33 | , termDefinitionProtectedFlag = protectedFlag | ||
34 | , termDefinitionReversePropertyFlag = False | ||
35 | , termDefinitionBaseUrl = Nothing | ||
36 | , termDefinitionLocalContext = Nothing | ||
37 | , termDefinitionContainerMapping = mempty | ||
38 | , termDefinitionIndexMapping = Nothing | ||
39 | , termDefinitionNestValue = Nothing | ||
40 | , termDefinitionTypeMapping = Nothing | ||
41 | , termDefinitionDirectionMapping = Nothing | ||
42 | , termDefinitionLanguageMapping = Nothing | ||
43 | } | ||
diff --git a/src/Data/JLD/Model/URI.hs b/src/Data/JLD/Model/URI.hs new file mode 100644 index 0000000..07cf8a9 --- /dev/null +++ b/src/Data/JLD/Model/URI.hs | |||
@@ -0,0 +1,13 @@ | |||
1 | module Data.JLD.Model.URI (parseUri, uriToIri) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.RDF (IRIRef, parseIRI) | ||
6 | import Text.Megaparsec (MonadParsec (..), Parsec, runParser) | ||
7 | import Text.URI (URI, parser, render) | ||
8 | |||
9 | parseUri :: Text -> Maybe URI | ||
10 | parseUri = runParser (parser <* eof :: Parsec Void Text URI) "" .> either (const Nothing) Just | ||
11 | |||
12 | uriToIri :: URI -> Maybe IRIRef | ||
13 | uriToIri = render .> parseIRI .> either (const Nothing) Just | ||
diff --git a/src/Data/JLD/Model/ValueObject.hs b/src/Data/JLD/Model/ValueObject.hs new file mode 100644 index 0000000..79bd94f --- /dev/null +++ b/src/Data/JLD/Model/ValueObject.hs | |||
@@ -0,0 +1,27 @@ | |||
1 | module Data.JLD.Model.ValueObject (isValueObject, isValueObject', isNotValueObject, isNotValueObject', valueObjectValue) where | ||
2 | |||
3 | import Data.JLD.Prelude | ||
4 | |||
5 | import Data.JLD.Model.Keyword (Keyword (..), isNotKeyword) | ||
6 | |||
7 | import Data.Aeson (Object, Value (..)) | ||
8 | import Data.Aeson.Key qualified as K | ||
9 | import Data.Aeson.KeyMap qualified as KM | ||
10 | |||
11 | isValueObject :: Value -> Bool | ||
12 | isValueObject (Object o) = isValueObject' o | ||
13 | isValueObject _ = False | ||
14 | |||
15 | isValueObject' :: Object -> Bool | ||
16 | isValueObject' = KM.member (show KeywordValue) | ||
17 | |||
18 | isNotValueObject :: Value -> Bool | ||
19 | isNotValueObject (Object o) = isNotValueObject' o | ||
20 | isNotValueObject _ = False | ||
21 | |||
22 | isNotValueObject' :: Object -> Bool | ||
23 | isNotValueObject' = KM.keys .> fmap K.toText .> any (`isNotKeyword` [KeywordType, KeywordValue, KeywordDirection, KeywordLanguage, KeywordIndex]) | ||
24 | |||
25 | valueObjectValue :: Value -> Maybe Value | ||
26 | valueObjectValue (Object o) = KM.lookup (show KeywordValue) o | ||
27 | valueObjectValue _ = Nothing | ||