From 80b57094613b3f6db0c742446a1555867d2f30f4 Mon Sep 17 00:00:00 2001 From: Dmitrii Kovanikov Date: Sat, 12 Oct 2019 16:04:21 +0300 Subject: [PATCH] Prepare for 1.2.0.0 release (#234) --- CHANGELOG.md | 29 +++++++++++++++++++++--- src/Toml/Bi/Combinators.hs | 26 ++++++++++++++++----- src/Toml/Bi/Map.hs | 45 ++++++++++++++++++++++--------------- src/Toml/Bi/Monad.hs | 2 ++ src/Toml/Generic.hs | 7 ++++++ src/Toml/Parser/Item.hs | 6 +++-- src/Toml/Parser/Key.hs | 2 ++ src/Toml/Parser/Validate.hs | 2 ++ stack.yaml | 7 +----- 9 files changed, 92 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1dbd45..28d9e8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,15 +3,38 @@ tomland uses [PVP Versioning][1]. The changelog is available [on GitHub][2]. -## Unreleased: 1.2.0.0 +## 1.2.0.0 — Oct 12, 2019 -* [#215](https://github.com/kowainik/tomland/issues/215): - Move benchmarks to separate repository [toml-benchmarks](https://github.com/kowainik/toml-benchmarks) (by [@kutyel](https://github.com/kutyel)) * [#216](https://github.com/kowainik/tomland/issues/216): Refactor TOML parser significantly. Check for some validation errors. (by [@chshersh](https://github.com/chshersh)) * [#213](https://github.com/kowainik/tomland/issues/213): Support GHC-8.8.1. + (by [@vrom911](https://github.com/vrom911)) +* [#226](https://github.com/kowainik/tomland/issues/226): + Add `dimatch` combinator for better support of sum types. + (by [@Nimor111](https://github.com/Nimor111)) +* [#219](https://github.com/kowainik/tomland/issues/219): + Add INLINE pragmas to code. + (by [@willbasky](https://github.com/willbasky)) +* [#204](https://github.com/kowainik/tomland/issues/204): + Implement bidirectional codecs to work with `ByteString` as array of bytes. + (by [@crtschin](https://github.com/crtschin)) +* [#201](https://github.com/kowainik/tomland/issues/201): + Implement `set` and `hashSet` combinators for array of tables. + (by [@SanchayanMaity](https://github.com/SanchayanMaity)) +* [#215](https://github.com/kowainik/tomland/issues/215): + Move benchmarks to separate repository + [toml-benchmarks](https://github.com/kowainik/toml-benchmarks). + (by [@kutyel](https://github.com/kutyel)) +* [#209](https://github.com/kowainik/tomland/issues/209): + Bump up `parser-combinators` to `1.2.0`. + (by [@vrom911](https://github.com/vrom911)) +* [#198](https://github.com/kowainik/tomland/issues/198): + Improve test generators. + (by [@gabrielelana](https://github.com/gabrielelana) + , [@chshersh](https://github.com/chshersh) + ) ## 1.1.0.1 — Jul 10, 2019 diff --git a/src/Toml/Bi/Combinators.hs b/src/Toml/Bi/Combinators.hs index e7ae0c73..f0c0501b 100644 --- a/src/Toml/Bi/Combinators.hs +++ b/src/Toml/Bi/Combinators.hs @@ -147,7 +147,10 @@ word :: Key -> TomlCodec Word word = match _Word {-# INLINE word #-} --- | Codec for word8 values. +{- | Codec for word8 values. + +@since 1.2.0.0 +-} word8 :: Key -> TomlCodec Word8 word8 = match _Word8 {-# INLINE word8 #-} @@ -207,12 +210,18 @@ lazyByteString :: Key -> TomlCodec BL.ByteString lazyByteString = match _LByteString {-# INLINE lazyByteString #-} --- | Codec for positive integer array values as 'ByteString'. +{- | Codec for positive integer array values as 'ByteString'. + +@since 1.2.0.0 +-} byteStringArray :: Key -> TomlCodec ByteString byteStringArray = match _ByteStringArray {-# INLINE byteStringArray #-} --- | Codec for positive integer array values as lazy 'ByteString'. +{- | Codec for positive integer array values as lazy 'ByteString'. + +@since 1.2.0.0 +-} lazyByteStringArray :: Key -> TomlCodec BL.ByteString lazyByteStringArray = match _LByteStringArray {-# INLINE lazyByteStringArray #-} @@ -344,12 +353,19 @@ list codec key = Codec nonEmptyCodec :: TomlCodec (NonEmpty a) nonEmptyCodec = nonEmpty codec key --- | 'Codec' for set of values. Represented in TOML as array of tables. +{- | 'Codec' for set of values. Represented in TOML as array of tables. + +@since 1.2.0.0 +-} set :: forall a . Ord a => TomlCodec a -> Key -> TomlCodec (Set a) set codec key = dimap S.toList S.fromList (list codec key) {-# INLINE set #-} --- | 'Codec' for HashSet of values. Represented in TOML as array of tables. +{- | 'Codec' for HashSet of values. Represented in TOML as array of tables. + +@since 1.2.0.0 +-} + hashSet :: forall a . (Hashable a, Eq a) => TomlCodec a -> Key -> TomlCodec (HashSet a) hashSet codec key = dimap HS.toList HS.fromList (list codec key) {-# INLINE hashSet #-} diff --git a/src/Toml/Bi/Map.hs b/src/Toml/Bi/Map.hs index 2ddf1ff8..753b2b77 100644 --- a/src/Toml/Bi/Map.hs +++ b/src/Toml/Bi/Map.hs @@ -21,20 +21,6 @@ module Toml.Bi.Map , wrongConstructor , prettyBiMapError - -- * Helpers for BiMap and AnyValue - , mkAnyValueBiMap - , _TextBy - , _LTextText - , _NaturalInteger - , _StringText - , _ReadString - , _BoundedInteger - , _EnumBoundedText - , _ByteStringArray - , _LByteStringArray - , _ByteStringText - , _LByteStringText - -- * Some predefined bi mappings , _Array , _Bool @@ -55,11 +41,24 @@ module Toml.Bi.Map , _Float , _ByteString , _LByteString + , _ByteStringArray + , _LByteStringArray + , _NonEmpty , _Set , _IntSet , _HashSet - , _NonEmpty + -- * Helpers for BiMap and AnyValue + , mkAnyValueBiMap + , _TextBy + , _LTextText + , _NaturalInteger + , _StringText + , _ReadString + , _BoundedInteger + , _EnumBoundedText + , _ByteStringText + , _LByteStringText , _Left , _Right , _EnumBounded @@ -412,7 +411,7 @@ _BoundedInteger = BiMap (Right . toInteger) eitherBounded in Left $ ArbitraryError msg | otherwise = Right (fromIntegral n) -{- | Helper bimap for 'EnumBounded' and 'Data.Text.Text'. +{- | Helper bimap for '_EnumBounded' and 'Data.Text.Text'. @since 1.1.1.0 -} @@ -452,6 +451,8 @@ _Word = _BoundedInteger >>> _Integer {- | 'Word8' bimap for 'AnyValue'. Usually used as 'Toml.Bi.Combinators.word8' combinator. + +@since 1.2.0.0 -} _Word8 :: TomlBiMap Word8 AnyValue _Word8 = _BoundedInteger >>> _Integer @@ -499,12 +500,20 @@ _LByteString :: TomlBiMap BL.ByteString AnyValue _LByteString = _LByteStringText >>> _Text {-# INLINE _LByteString #-} --- | 'ByteString' bimap for 'AnyValue' encoded as a list of non-negative integers. +{- | 'ByteString' bimap for 'AnyValue' encoded as a list of non-negative integers. +Usually used as 'Toml.Bi.Combinators.byteStringArray' combinator. + +@since 1.2.0.0 +-} _ByteStringArray :: TomlBiMap ByteString AnyValue _ByteStringArray = iso BS.unpack BS.pack >>> _Array _Word8 {-# INLINE _ByteStringArray #-} --- | Lazy 'ByteString' bimap for 'AnyValue' encoded as a list of non-negative integers. +{- | Lazy 'ByteString' bimap for 'AnyValue' encoded as a list of non-negative integers. +Usually used as 'Toml.Bi.Combinators.lazyByteStringArray' combinator. + +@since 1.2.0.0 +-} _LByteStringArray :: TomlBiMap BL.ByteString AnyValue _LByteStringArray = iso BL.unpack BL.pack >>> _Array _Word8 {-# INLINE _LByteStringArray #-} diff --git a/src/Toml/Bi/Monad.hs b/src/Toml/Bi/Monad.hs index 96f80dd8..7a7369a2 100644 --- a/src/Toml/Bi/Monad.hs +++ b/src/Toml/Bi/Monad.hs @@ -250,6 +250,8 @@ exampleCodec = dimatch matchFoo Foo (Toml.int "foo") \<|\> dimatch matchBar (uncurry Bar) (Toml.table barCodec "bar") @ + +@since 1.2.0.0 -} dimatch :: (Functor r, Alternative w) diff --git a/src/Toml/Generic.hs b/src/Toml/Generic.hs index cb198b9f..084c31c1 100644 --- a/src/Toml/Generic.hs +++ b/src/Toml/Generic.hs @@ -233,6 +233,8 @@ typeName = show $ typeRep (Proxy @a) -- Generic typeclasses ---------------------------------------------------------------------------- +{- | Helper class to derive TOML codecs generically. +-} class GenericCodec (f :: k -> Type) where genericTomlCodec :: GenericOptions -> TomlCodec (f p) @@ -291,6 +293,7 @@ class HasItemCodec a where instance HasItemCodec Bool where hasItemCodec = Left Toml._Bool instance HasItemCodec Int where hasItemCodec = Left Toml._Int instance HasItemCodec Word where hasItemCodec = Left Toml._Word +-- | @since 1.2.0.0 instance HasItemCodec Word8 where hasItemCodec = Left Toml._Word8 instance HasItemCodec Integer where hasItemCodec = Left Toml._Integer instance HasItemCodec Natural where hasItemCodec = Left Toml._Natural @@ -326,6 +329,8 @@ class HasCodec a where instance HasCodec Bool where hasCodec = Toml.bool instance HasCodec Int where hasCodec = Toml.int instance HasCodec Word where hasCodec = Toml.word +-- | @since 1.2.0.0 +instance HasCodec Word8 where hasCodec = Toml.word8 instance HasCodec Integer where hasCodec = Toml.integer instance HasCodec Natural where hasCodec = Toml.natural instance HasCodec Double where hasCodec = Toml.double @@ -351,11 +356,13 @@ instance HasItemCodec a => HasCodec (NonEmpty a) where Left prim -> Toml.arrayNonEmptyOf prim Right codec -> Toml.nonEmpty codec +-- | @since 1.2.0.0 instance (Ord a, HasItemCodec a) => HasCodec (Set a) where hasCodec = case hasItemCodec @a of Left prim -> Toml.arraySetOf prim Right codec -> Toml.set codec +-- | @since 1.2.0.0 instance (Hashable a, Eq a, HasItemCodec a) => HasCodec (HashSet a) where hasCodec = case hasItemCodec @a of Left prim -> Toml.arrayHashSetOf prim diff --git a/src/Toml/Parser/Item.hs b/src/Toml/Parser/Item.hs index aaf628bb..8397f107 100644 --- a/src/Toml/Parser/Item.hs +++ b/src/Toml/Parser/Item.hs @@ -2,6 +2,8 @@ represents either key-value pair or table name. This data type serves the purpose to be the intermediate representation of parsing a TOML file which will be assembled to TOML AST later. + +@since 1.2.0.0 -} module Toml.Parser.Item @@ -33,8 +35,8 @@ import Toml.Type (AnyValue) * Inline table * Inline array of tables -Knowing a list of 'TomlItem's, it's possible to construct 'TOML' from this -information. +Knowing a list of 'TomlItem's, it's possible to construct 'Toml.Type.TOML.TOML' +from this information. -} data TomlItem = TableName !Key diff --git a/src/Toml/Parser/Key.hs b/src/Toml/Parser/Key.hs index ef6d4361..9be394db 100644 --- a/src/Toml/Parser/Key.hs +++ b/src/Toml/Parser/Key.hs @@ -1,4 +1,6 @@ {- | Parsers for keys and table names. + +@since 1.2.0.0 -} module Toml.Parser.Key diff --git a/src/Toml/Parser/Validate.hs b/src/Toml/Parser/Validate.hs index 8671455b..a7d7ba0a 100644 --- a/src/Toml/Parser/Validate.hs +++ b/src/Toml/Parser/Validate.hs @@ -2,6 +2,8 @@ 'Toml.Parser.Item.tomlP' parser into 'TOML'. This approach allows to keep parser fast and simple and delegate the process of creating tree structure to a separate function. + +@since 1.2.0.0 -} module Toml.Parser.Validate diff --git a/stack.yaml b/stack.yaml index 526bfb08..2246a053 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,6 +1 @@ -resolver: nightly-2019-09-29 - -extra-deps: - - tasty-silver-3.1.13 - - regex-tdfa-1.3.0 # for tasty-silver - - toml-parser-0.1.0.0 +resolver: nightly-2019-10-10