packages feed

ogma-language-jsonspec 1.5.0 → 1.6.0

raw patch · 3 files changed

+33/−14 lines, 3 filesdep +mtldep ~bytestringdep ~megaparsecdep ~ogma-specPVP ok

version bump matches the API change (PVP)

Dependencies added: mtl

Dependency ranges changed: bytestring, megaparsec, ogma-spec, text

API changes (from Hackage documentation)

+ Language.JSONSpec.Parser: except :: Monad m => Either e a -> ExceptT e m a
- Language.JSONSpec.Parser: parseJSONSpec :: (String -> Either String a) -> JSONFormat -> Value -> Either String (Spec a)
+ Language.JSONSpec.Parser: parseJSONSpec :: (String -> IO (Either String a)) -> JSONFormat -> Value -> IO (Either String (Spec a))

Files

CHANGELOG.md view
@@ -1,5 +1,12 @@ # Revision history for ogma-language-jsonspec +## [1.6.0] - 2025-01-21++* Version bump 1.6.0 (#208).+* Add repository information to cabal package (#148).+* Add version bounds to all dependencies (#119).+* Extend JSON spec parser to use an IO action to parse properties (#197).+ ## [1.5.0] - 2024-11-21  * Version bump 1.5.0 (#178).
ogma-language-jsonspec.cabal view
@@ -32,8 +32,9 @@ build-type:          Simple  name:                ogma-language-jsonspec-version:             1.5.0+version:             1.6.0 homepage:            https://github.com/nasa/ogma+bug-reports:         https://github.com/nasa/ogma/issues license:             OtherLicense license-file:        LICENSE.pdf author:              Ivan Perez, Alwyn Goodloe@@ -57,6 +58,11 @@ -- exactly what we publish, unmodified by anyone external to our project. x-curation: uncurated +source-repository head+  type:     git+  location: git@github.com:nasa/ogma.git+  subdir:   ogma-language-jsonspec+ library    exposed-modules:@@ -66,11 +72,12 @@       base                   >= 4.11.0.0 && < 5     , aeson                  >= 2.0.0.0  && < 2.2     , jsonpath               >= 0.3      && < 0.4-    , text-    , megaparsec-    , bytestring+    , text                   >= 1.2.3.1  && < 2.1+    , megaparsec             >= 8.0.0    && < 9.10+    , mtl                    >= 2.2.2    && < 2.4+    , bytestring             >= 0.10.8.2 && < 0.13 -    , ogma-spec              >= 1.5.0 && < 1.6+    , ogma-spec              >= 1.6.0 && < 1.7    hs-source-dirs:     src
src/Language/JSONSpec/Parser.hs view
@@ -33,6 +33,7 @@ module Language.JSONSpec.Parser where  -- External imports+import           Control.Monad.Except  (ExceptT (..), runExceptT) import           Data.Aeson            (FromJSON (..), Value (..), decode, (.:)) import           Data.Aeson.Key        (toString) import qualified Data.Aeson.KeyMap     as M@@ -107,9 +108,9 @@              , jfiRequirementExpr = jfi12              } -parseJSONSpec :: (String -> Either String a) -> JSONFormat -> Value -> Either String (Spec a)-parseJSONSpec parseExpr jsonFormat value = do-  jsonFormatInternal <- parseJSONFormat jsonFormat+parseJSONSpec :: (String -> IO (Either String a)) -> JSONFormat -> Value -> IO (Either String (Spec a))+parseJSONSpec parseExpr jsonFormat value = runExceptT $ do+  jsonFormatInternal <- except $ parseJSONFormat jsonFormat    let values :: [Value]       values = maybe [] (`executeJSONPath` value) (jfiInternalVars jsonFormatInternal)@@ -131,7 +132,7 @@                    , internalVariableExpr    = varExpr                    } -  internalVariableDefs <- mapM internalVarDef values+  internalVariableDefs <- except $ mapM internalVarDef values    let values :: [Value]       values = maybe [] (`executeJSONPath` value) (jfiExternalVars jsonFormatInternal)@@ -150,7 +151,7 @@                    , externalVariableType    = varType                    } -  externalVariableDefs <- mapM externalVarDef values+  externalVariableDefs <- except $ mapM externalVarDef values    let values :: [Value]       values = executeJSONPath (jfiRequirements jsonFormatInternal) value@@ -158,14 +159,14 @@       -- requirementDef :: Value -> Either String (Requirement a)       requirementDef value = do         let msg = "Requirement name"-        reqId <- valueToString msg =<< (listToEither msg (executeJSONPath (jfiRequirementId jsonFormatInternal) value))+        reqId <- except $ valueToString msg =<< (listToEither msg (executeJSONPath (jfiRequirementId jsonFormatInternal) value))          let msg = "Requirement expression"-        reqExpr <- valueToString msg =<< (listToEither msg (executeJSONPath (jfiRequirementExpr jsonFormatInternal) value))-        reqExpr' <- parseExpr reqExpr+        reqExpr <- except $ valueToString msg =<< (listToEither msg (executeJSONPath (jfiRequirementExpr jsonFormatInternal) value))+        reqExpr' <- ExceptT $ parseExpr reqExpr          let msg = "Requirement description"-        reqDesc <- maybe (Right "") (\e -> valueToString msg =<< (listToEither msg (executeJSONPath e value))) (jfiRequirementDesc jsonFormatInternal)+        reqDesc <- except $ maybe (Right "") (\e -> valueToString msg =<< (listToEither msg (executeJSONPath e value))) (jfiRequirementDesc jsonFormatInternal)          return $ Requirement                    { requirementName        = reqId@@ -198,3 +199,7 @@ showErrorsM Nothing          = Right Nothing showErrorsM (Just (Left s))  = Left (show s) showErrorsM (Just (Right x)) = Right (Just x)++-- | Wrap an 'Either' value in an @ExceptT m@ monad.+except :: Monad m => Either e a -> ExceptT e m a+except = ExceptT . return