packages feed

salak-yaml 0.2.9 → 0.2.9.1

raw patch · 3 files changed

+19/−4 lines, 3 filesdep ~salakPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: salak

API changes (from Hackage documentation)

Files

salak-yaml.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name: salak-yaml-version: 0.2.9+version: 0.2.9.1 license: BSD3 license-file: LICENSE copyright: (c) 2018 Daniel YU@@ -27,7 +27,7 @@         conduit >=1.3.1.1 && <1.4,         libyaml >=0.1.1.0 && <0.2,         mtl >=2.2.2 && <2.3,-        salak ==0.2.9,+        salak ==0.2.9.*,         text >=1.2.3.1 && <1.3  test-suite spec@@ -46,5 +46,5 @@         hspec ==2.*,         libyaml >=0.1.1.0 && <0.2,         mtl >=2.2.2 && <2.3,-        salak ==0.2.9,+        salak ==0.2.9.*,         text >=1.2.3.1 && <1.3
src/Salak/Yaml.hs view
@@ -1,6 +1,16 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RecordWildCards  #-} {-# LANGUAGE TupleSections    #-}+-- |+-- Module:      Salak.Yaml+-- Copyright:   (c) 2019 Daniel YU+-- License:     BSD3+-- Maintainer:  leptonyu@gmail.com+-- Stability:   experimental+-- Portability: portable+--+-- Yaml support for "Salak". Yaml alias and anchor is not supported.+-- module Salak.Yaml(     YAML(..)   , loadYaml@@ -14,9 +24,11 @@ import           Salak.Load import           Text.Libyaml +-- | Load Yaml loadYaml :: MonadIO m => FilePath -> LoadSalakT m () loadYaml file = loadFile file $ \i s -> liftIO $ runConduitRes (decodeFileMarked file .| loadYAML i s) +-- | YAML notation for `loadYaml` data YAML = YAML  instance HasLoad YAML where@@ -29,6 +41,7 @@     go (MarkedEvent EventSequenceStart{}  _ _) = goSeq 0 s     go (MarkedEvent EventSequenceEnd      _ _) = return emptySource     go (MarkedEvent EventMappingStart{}  _ ee) = goMap ee s+    go (MarkedEvent (EventAlias a)       _ ee) = ge ee $ "alias " ++ a ++ " not supported by salak"     go _ = loadYAML i s     goSeq j s1 = do       s' <- loadYAML i emptySource@@ -42,7 +55,7 @@         Just (MarkedEvent (EventScalar a _ _ _) _ ee') ->           updateSources (simpleSelectors $ decodeUtf8 a) (loadYAML i) s1 >>= goMap ee'         Just (MarkedEvent EventMappingEnd _ _) -> return s1-        Just e -> ge (yamlStartMark e) "suppose scalar and mapping end"+        Just e -> ge (yamlStartMark e) ("suppose scalar and mapping end, but is " ++ show (yamlEvent e))     ge YamlMark{..} e = liftIO $ throwIO $ YamlException $ "(" ++ show yamlLine ++ "," ++ show yamlColumn ++ ")" ++ e  
test/Spec.hs view
@@ -15,6 +15,7 @@ import           Test.Hspec import           Test.QuickCheck +main :: IO () main = hspec spec  spec :: Spec@@ -50,6 +51,7 @@  instance FromProp Conf +jsonProperty :: SpecWith () jsonProperty = do   context "load json" $ do     it "salak.yml" $ do