on master help sign in
Merge remote-tracking branch 'origin/master' into newer-conduit
commit1bafb517b6c2793472ddfc3c428dcc29f4dc3449 authorMichael Snoyman <michael@snoyman.com> dateSun 14 Jan 2018, 14:47 (9 years ago) parente5310ceff9e968
4 files changed+16−5
ChangeLog.md+4 Data/Yaml/Parser.hs+8−1 exe/json2yaml.hs+3−3 yaml.cabal+1−1
ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 0.8.26
2+
3+* Add `Semigroup` instance [#123](https://github.com/snoyberg/yaml/pull/123)
4+
15## 0.8.25.2
26
37* Use `throwM` instead of `monadThrow`
Data/Yaml/Parser.hs+8−1
@@ -18,6 +18,9 @@ import qualified Data.Map as Map
1818#if !MIN_VERSION_base(4,8,0)
1919import Data.Monoid (Monoid (..))
2020#endif
21+#if !MIN_VERSION_base(4,11,0)
22+import Data.Semigroup (Semigroup(..))
23+#endif
2124import Data.Text (Text, pack, unpack)
2225import Data.Text.Encoding (decodeUtf8)
2326import Data.Text.Read (signed, decimal)
@@ -36,9 +39,13 @@ instance Applicative YamlParser where
3639instance Alternative YamlParser where
3740 empty = fail "empty"
3841 (<|>) = mplus
42+instance Semigroup (YamlParser a) where
43+ (<>) = mplus
3944instance Monoid (YamlParser a) where
4045 mempty = fail "mempty"
41− mappend = mplus
46+#if !MIN_VERSION_base(4,11,0)
47+ mappend = (<>)
48+#endif
4249instance Monad YamlParser where
4350 return = pure
4451 YamlParser f >>= g = YamlParser $ \am ->
exe/json2yaml.hs+3−3
@@ -1,4 +1,3 @@
1−import Control.Monad (when)
21import qualified Data.Aeson as J
32import qualified Data.ByteString as S
43import qualified Data.ByteString.Lazy as L
@@ -9,8 +8,9 @@ import qualified Data.Yaml as Y
98main :: IO ()
109main = do
1110 args <- getArgs
12− when (length args > 2) $ error "Usage: json2yaml [in] [out]"
13− let (input:output:_) = args ++ repeat "-"
11+ (input, output) <- case args ++ replicate (2 - length args) "-" of
12+ [i, o] -> return (i, o)
13+ _ -> fail "Usage: json2yaml [in] [out]"
1414 mval <- fmap J.decode $
1515 case input of
1616 "-" -> L.getContents
yaml.cabal+1−1
@@ -1,5 +1,5 @@
11name: yaml
2−version: 0.8.25.2
2+version: 0.8.26
33license: BSD3
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>, Anton Ageev <antage@gmail.com>,Kirill Simonov