diff options
Diffstat (limited to 'src/Data/JLD/Expansion.hs')
-rw-r--r-- | src/Data/JLD/Expansion.hs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/Data/JLD/Expansion.hs b/src/Data/JLD/Expansion.hs index beb10a3..983c126 100644 --- a/src/Data/JLD/Expansion.hs +++ b/src/Data/JLD/Expansion.hs | |||
@@ -39,7 +39,7 @@ import Data.Foldable.WithIndex (ifoldlM, iforM_) | |||
39 | import Data.RDF (parseIRI) | 39 | import Data.RDF (parseIRI) |
40 | import Data.Set qualified as S (insert, member) | 40 | import Data.Set qualified as S (insert, member) |
41 | import Data.Text qualified as T (elem, toLower) | 41 | import Data.Text qualified as T (elem, toLower) |
42 | import Data.Vector qualified as V (catMaybes, concat, cons, filter, fromList, mapMaybeM, maximum, modify, null, singleton, snoc, toList) | 42 | import Data.Vector qualified as V (catMaybes, concat, cons, filter, fromList, mapMaybeM, maximum, modify, null, snoc, toList) |
43 | import Data.Vector.Algorithms.Merge qualified as V | 43 | import Data.Vector.Algorithms.Merge qualified as V |
44 | import Text.URI (URI) | 44 | import Text.URI (URI) |
45 | 45 | ||
@@ -190,16 +190,16 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
190 | } | 190 | } |
191 | case maybeExpandedStringValue of | 191 | case maybeExpandedStringValue of |
192 | Just expandedStringValue | 192 | Just expandedStringValue |
193 | | jldeEnvFrameExpansion -> pure <. Just <. Array <. V.singleton <| String expandedStringValue | 193 | | jldeEnvFrameExpansion -> pure <. Just <. Array <. pure <| String expandedStringValue |
194 | | otherwise -> pure <. Just <| String expandedStringValue | 194 | | otherwise -> pure <. Just <| String expandedStringValue |
195 | Nothing -> pure <| Just Null | 195 | Nothing -> pure <| Just Null |
196 | -- | 196 | -- |
197 | Object (KM.null -> True) | jldeEnvFrameExpansion -> do | 197 | Object (KM.null -> True) | jldeEnvFrameExpansion -> do |
198 | pure <. Just <. Array <. V.singleton <| Object mempty | 198 | pure <. Just <. Array <. pure <| Object mempty |
199 | -- | 199 | -- |
200 | Array (allStrings -> Just arrayValue) | jldeEnvFrameExpansion && not (V.null arrayValue) -> do | 200 | Array (allStrings -> Just arrayValue) | jldeEnvFrameExpansion && not (V.null arrayValue) -> do |
201 | Just <. Array <. V.concat <. V.toList <$> forM arrayValue \item -> do | 201 | Just <. Array <. V.concat <. V.toList <$> forM arrayValue \item -> do |
202 | V.singleton <. maybe Null String <$> eo1314ExpandIriAC item \params -> | 202 | pure <. maybe Null String <$> eo1314ExpandIriAC item \params -> |
203 | params | 203 | params |
204 | { eiParamsDocumentRelative = True | 204 | { eiParamsDocumentRelative = True |
205 | , eiParamsVocab = False | 205 | , eiParamsVocab = False |
@@ -233,7 +233,7 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
233 | -- 13.4.4.4. | 233 | -- 13.4.4.4. |
234 | Array (allStrings -> Just arrayValue) -> | 234 | Array (allStrings -> Just arrayValue) -> |
235 | Array <. V.concat <. V.toList <$> forM arrayValue \item -> do | 235 | Array <. V.concat <. V.toList <$> forM arrayValue \item -> do |
236 | V.singleton <. maybe Null String <$> eo1314ExpandIriTC item \params -> | 236 | pure <. maybe Null String <$> eo1314ExpandIriTC item \params -> |
237 | params | 237 | params |
238 | { eiParamsDocumentRelative = True | 238 | { eiParamsDocumentRelative = True |
239 | , eiParamsVocab = True | 239 | , eiParamsVocab = True |
@@ -264,7 +264,7 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
264 | -- 13.4.6.4. | 264 | -- 13.4.6.4. |
265 | gets <| eo1314StateResult .> KM.lookup (show KeywordIncluded) .> \case | 265 | gets <| eo1314StateResult .> KM.lookup (show KeywordIncluded) .> \case |
266 | Just (Array includedValue) -> Just <. Array <| includedValue <> expandedValue | 266 | Just (Array includedValue) -> Just <. Array <| includedValue <> expandedValue |
267 | Just includedValue -> Just <. Array <| V.singleton includedValue <> expandedValue | 267 | Just includedValue -> Just <. Array <| pure includedValue <> expandedValue |
268 | Nothing -> Just <| Array expandedValue | 268 | Nothing -> Just <| Array expandedValue |
269 | -- 13.4.7. | 269 | -- 13.4.7. |
270 | KeywordValue -> do | 270 | KeywordValue -> do |
@@ -277,9 +277,9 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
277 | -- 13.4.7.2. | 277 | -- 13.4.7.2. |
278 | _ | value == Null || valueIsScalar value -> do | 278 | _ | value == Null || valueIsScalar value -> do |
279 | if jldeEnvFrameExpansion | 279 | if jldeEnvFrameExpansion |
280 | then pure <. Array <| V.singleton value | 280 | then pure <. Array <| pure value |
281 | else pure value | 281 | else pure value |
282 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <. Array <| V.singleton value | 282 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <. Array <| pure value |
283 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure value | 283 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure value |
284 | -- | 284 | -- |
285 | _ -> throwError InvalidValueObjectValue | 285 | _ -> throwError InvalidValueObjectValue |
@@ -291,7 +291,7 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
291 | -- 13.4.8. | 291 | -- 13.4.8. |
292 | KeywordLanguage -> case value of | 292 | KeywordLanguage -> case value of |
293 | String stringValue | 293 | String stringValue |
294 | | jldeEnvFrameExpansion -> pure <. Just <. Array <. V.singleton <. String <| T.toLower stringValue | 294 | | jldeEnvFrameExpansion -> pure <. Just <. Array <. pure <. String <| T.toLower stringValue |
295 | | otherwise -> pure <. Just <. String <| T.toLower stringValue | 295 | | otherwise -> pure <. Just <. String <| T.toLower stringValue |
296 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <| Just value | 296 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <| Just value |
297 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure <| Just value | 297 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure <| Just value |
@@ -301,7 +301,7 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
301 | | JLD1_0 <- jldExpansionEnvProcessingMode -> pure Nothing | 301 | | JLD1_0 <- jldExpansionEnvProcessingMode -> pure Nothing |
302 | | otherwise -> case value of | 302 | | otherwise -> case value of |
303 | String ((`elem` ["ltr", "rtl"]) -> True) | 303 | String ((`elem` ["ltr", "rtl"]) -> True) |
304 | | jldeEnvFrameExpansion -> pure <. Just <. Array <| V.singleton value | 304 | | jldeEnvFrameExpansion -> pure <. Just <. Array <| pure value |
305 | | otherwise -> pure <| Just value | 305 | | otherwise -> pure <| Just value |
306 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <| Just value | 306 | Object (KM.null -> True) | jldeEnvFrameExpansion -> pure <| Just value |
307 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure <| Just value | 307 | Array (all valueIsString -> True) | jldeEnvFrameExpansion -> pure <| Just value |
@@ -319,7 +319,7 @@ eo1314ExpandKeywordItem inputType key keyword value = do | |||
319 | expandedValue <- eo1314ExpandAC jldeEnvActiveProperty value id | 319 | expandedValue <- eo1314ExpandAC jldeEnvActiveProperty value id |
320 | case expandedValue of | 320 | case expandedValue of |
321 | Array _ -> pure <| Just expandedValue | 321 | Array _ -> pure <| Just expandedValue |
322 | _ -> pure <. Just <. Array <| V.singleton expandedValue | 322 | _ -> pure <. Just <. Array <| pure expandedValue |
323 | -- 13.4.12. | 323 | -- 13.4.12. |
324 | KeywordSet -> Just <$> eo1314ExpandAC jldeEnvActiveProperty value id | 324 | KeywordSet -> Just <$> eo1314ExpandAC jldeEnvActiveProperty value id |
325 | -- 13.4.13. | 325 | -- 13.4.13. |
@@ -491,7 +491,7 @@ eo1314ExpandNonKeywordItem key expandedProperty value = do | |||
491 | let maybeExistingValues = expandedIndexKey >>= (`KM.lookup` item) | 491 | let maybeExistingValues = expandedIndexKey >>= (`KM.lookup` item) |
492 | 492 | ||
493 | indexPropertyValues = | 493 | indexPropertyValues = |
494 | V.singleton (Object reExpandedIndex) | 494 | pure (Object reExpandedIndex) |
495 | |> case maybeExistingValues of | 495 | |> case maybeExistingValues of |
496 | Just (Array existingValues) -> (<> existingValues) | 496 | Just (Array existingValues) -> (<> existingValues) |
497 | Just existingValue -> (`V.snoc` existingValue) | 497 | Just existingValue -> (`V.snoc` existingValue) |
@@ -526,7 +526,7 @@ eo1314ExpandNonKeywordItem key expandedProperty value = do | |||
526 | , expandedIndex /= show KeywordNone -> do | 526 | , expandedIndex /= show KeywordNone -> do |
527 | let types = case KM.lookup (show KeywordType) item of | 527 | let types = case KM.lookup (show KeywordType) item of |
528 | Just existingType -> V.cons expandedIndex <| valueToArray existingType | 528 | Just existingType -> V.cons expandedIndex <| valueToArray existingType |
529 | Nothing -> V.singleton expandedIndex | 529 | Nothing -> pure expandedIndex |
530 | pure <. KM.insert (show KeywordType) (Array types) <| item | 530 | pure <. KM.insert (show KeywordType) (Array types) <| item |
531 | -- 13.8.3.7.6. | 531 | -- 13.8.3.7.6. |
532 | | otherwise -> pure item | 532 | | otherwise -> pure item |
@@ -755,7 +755,7 @@ expandObject maybePropertyContext value = do | |||
755 | | Just resultType <- KM.lookup (show KeywordType) result -> | 755 | | Just resultType <- KM.lookup (show KeywordType) result -> |
756 | eoNormalizeObject | 756 | eoNormalizeObject |
757 | <| if valueIsNotArray resultType && resultType /= Null | 757 | <| if valueIsNotArray resultType && resultType /= Null |
758 | then KM.insert (show KeywordType) (Array <| V.singleton resultType) result | 758 | then KM.insert (show KeywordType) (Array <| pure resultType) result |
759 | else result | 759 | else result |
760 | -- 17. | 760 | -- 17. |
761 | | KM.member (show KeywordList) result || KM.member (show KeywordSet) result -> do | 761 | | KM.member (show KeywordList) result || KM.member (show KeywordSet) result -> do |
@@ -793,7 +793,7 @@ expandArrayItem item = do | |||
793 | -- 5.2.3. | 793 | -- 5.2.3. |
794 | Array a -> pure <| V.filter (/= Null) a | 794 | Array a -> pure <| V.filter (/= Null) a |
795 | Null -> pure mempty | 795 | Null -> pure mempty |
796 | _ -> pure <| V.singleton item'' | 796 | _ -> pure <| pure item'' |
797 | 797 | ||
798 | -- | 798 | -- |
799 | 799 | ||