Skip to content

Commit

Permalink
Prepare for 1.2.0.0 release (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
chshersh authored and vrom911 committed Oct 12, 2019
1 parent c026dc8 commit 80b5709
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 34 deletions.
29 changes: 26 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 21 additions & 5 deletions src/Toml/Bi/Combinators.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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 #-}
Expand Down Expand Up @@ -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 #-}
45 changes: 27 additions & 18 deletions src/Toml/Bi/Map.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
-}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 #-}
Expand Down
2 changes: 2 additions & 0 deletions src/Toml/Bi/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/Toml/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Toml/Parser/Item.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Toml/Parser/Key.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{- | Parsers for keys and table names.
@since 1.2.0.0
-}

module Toml.Parser.Key
Expand Down
2 changes: 2 additions & 0 deletions src/Toml/Parser/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 80b5709

Please sign in to comment.