Skip to content

Commit

Permalink
Support GHC 9.4 (#422)
Browse files Browse the repository at this point in the history
* Support GHC 9.4

* Fix stack build

* Remove transformers dependancy

* Use newer cabal on CI

* Use CPP to remove Eq constraint for newer hashable

* Fic 8.4.4 build
  • Loading branch information
vrom911 authored Mar 7, 2023
1 parent bb6311e commit 37f1646
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @chshersh @vrom911
* @vrom911
13 changes: 9 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
cabal: ["3.4"]
cabal: ["3.8"]
ghc:
- "8.4.4"
- "8.6.5"
- "8.8.4"
- "8.10.7"
- "9.0.2"
- "9.2.4"
- "9.2.7"
- "9.4.4"
exclude:
- os: macOS-latest
ghc: 9.2.7
- os: macOS-latest
ghc: 9.0.2
- os: macOS-latest
Expand All @@ -36,6 +39,8 @@ jobs:
- os: macOS-latest
ghc: 8.4.4

- os: windows-latest
ghc: 9.2.7
- os: windows-latest
ghc: 9.0.2
- os: windows-latest
Expand Down Expand Up @@ -93,8 +98,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["2.5"]
ghc: ["8.10.4"]
stack: ["2.9"]
ghc: ["9.2.6"]

steps:
- uses: actions/checkout@v3
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
`tomland` uses [PVP Versioning][1].
The changelog is available [on GitHub][2].

## Unreleased

* [#412](https://github.com/kowainik/tomland/issues/412):
Support GHC-9.4.4.
* Upgrade `mtl` and `validation-selective` upper boundary.
* Remove `transformers` dependency.

## 1.3.3.2 – Oct 5, 2022

* [#395](https://github.com/kowainik/tomland/issues/395):
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
![palm](https://user-images.githubusercontent.com/4276606/51088259-7a777000-176e-11e9-9d76-6be4023c0ac3.png)

[![GitHub CI](https://github.com/kowainik/tomland/workflows/CI/badge.svg)](https://github.com/kowainik/tomland/actions)
[![AppVeyor CI](https://ci.appveyor.com/api/projects/status/github/kowainik/tomland?branch=main&svg=true)](https://ci.appveyor.com/project/kowainik/tomland)
[![Hackage](https://img.shields.io/hackage/v/tomland.svg?logo=haskell)](https://hackage.haskell.org/package/tomland)
[![Stackage LTS](http://stackage.org/package/tomland/badge/lts)](http://stackage.org/lts/package/tomland)
[![Stackage Nightly](http://stackage.org/package/tomland/badge/nightly)](http://stackage.org/nightly/package/tomland)
[![MPL-2.0 license](https://img.shields.io/badge/license-MPL--2.0-blue.svg)](https://github.com/kowainik/tomland/blob/main/LICENSE)

> “A library is like an island in the middle of a vast sea of ignorance,
Expand Down
16 changes: 12 additions & 4 deletions src/Toml/Codec/BiMap/Conversion.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE GADTs #-}

{- |
Expand Down Expand Up @@ -427,7 +428,14 @@ values and 'AnyValue' as an array. Usually used as the
@since 0.5.0
-}
_HashSet :: (Eq a, Hashable a) => TomlBiMap a AnyValue -> TomlBiMap (HS.HashSet a) AnyValue
_HashSet
#if MIN_VERSION_hashable(1,4,0)
:: (Hashable a)
#else
:: (Eq a, Hashable a)
#endif
=> TomlBiMap a AnyValue
-> TomlBiMap (HS.HashSet a) AnyValue
_HashSet bi = iso HS.toList HS.fromList >>> _Array bi
{-# INLINE _HashSet #-}

Expand Down Expand Up @@ -624,7 +632,7 @@ _KeyInt = BiMap
_Left :: (Show l, Show r) => TomlBiMap (Either l r) l
_Left = prism Left $ \case
Left l -> Right l
x -> wrongConstructor "Left" x
x -> wrongConstructor "Left" x

{- | 'BiMap' for 'Either' and its 'Right' part.
Expand All @@ -633,7 +641,7 @@ _Left = prism Left $ \case
_Right :: (Show l, Show r) => TomlBiMap (Either l r) r
_Right = prism Right $ \case
Right r -> Right r
x -> wrongConstructor "Right" x
x -> wrongConstructor "Right" x

{- | 'BiMap' for 'Maybe' and its 'Just' part.
Expand All @@ -642,4 +650,4 @@ _Right = prism Right $ \case
_Just :: Show r => TomlBiMap (Maybe r) r
_Just = prism Just $ \case
Just r -> Right r
x -> wrongConstructor "Just" x
x -> wrongConstructor "Just" x
13 changes: 11 additions & 2 deletions src/Toml/Codec/Combinator/Map.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE TupleSections #-}

Expand Down Expand Up @@ -74,8 +75,8 @@ import Prelude hiding (map)
import Control.Applicative (empty)
import Control.Monad (forM_)
import Control.Monad.State (gets, modify)
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap)
import Data.Hashable (Hashable)
import Data.IntMap.Strict (IntMap)
import Data.List.NonEmpty (NonEmpty (..))
import Data.Map.Strict (Map)
Expand All @@ -87,7 +88,7 @@ import Toml.Codec.BiMap (BiMap (..), TomlBiMap)
import Toml.Codec.Code (execTomlCodec)
import Toml.Codec.Combinator.Common (whenLeftBiMapError)
import Toml.Codec.Types (Codec (..), TomlCodec, TomlEnv, TomlState (..))
import Toml.Type.Key (pattern (:||), Key)
import Toml.Type.Key (Key, pattern (:||))
import Toml.Type.TOML (TOML (..), insertTable, insertTableArrays)

import qualified Data.HashMap.Strict as HashMap
Expand Down Expand Up @@ -237,7 +238,11 @@ If there's no key with the name @"myHashMap"@ then empty 'HashMap' is returned.
-}
hashMap
:: forall k v
#if MIN_VERSION_hashable(1,4,0)
. (Hashable k)
#else
. (Eq k, Hashable k)
#endif
=> TomlCodec k -- ^ Codec for 'HashMap' keys
-> TomlCodec v -- ^ Codec for 'HashMap' values
-> Key -- ^ TOML key where 'HashMap' is stored
Expand All @@ -261,7 +266,11 @@ key2 = "value2"
-}
tableHashMap
:: forall k v
#if MIN_VERSION_hashable(1,4,0)
. (Hashable k)
#else
. (Eq k, Hashable k)
#endif
=> TomlBiMap Key k
-- ^ Bidirectional converter between TOML 'Key's and 'HashMap' keys
-> (Key -> TomlCodec v)
Expand Down
19 changes: 17 additions & 2 deletions src/Toml/Codec/Combinator/Set.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{-# LANGUAGE CPP #-}

{- |
Module : Toml.Codec.Combinator.Set
Copyright : (c) 2018-2022 Kowainik
Expand Down Expand Up @@ -152,7 +154,11 @@ tomland decode error: Key foo is not found
@since 0.5.0
-}
arrayHashSetOf
:: (Hashable a, Eq a)
#if MIN_VERSION_hashable(1,4,0)
:: (Hashable a)
#else
:: (Eq a, Hashable a)
#endif
=> TomlBiMap a AnyValue
-> Key
-> TomlCodec (HashSet a)
Expand Down Expand Up @@ -222,6 +228,15 @@ Decodes to an empty 'HashSet' in case of the missing field in @TOML@.
@since 1.2.0.0
-}
hashSet :: forall a . (Hashable a, Eq a) => TomlCodec a -> Key -> TomlCodec (HashSet a)
hashSet
:: forall a
#if MIN_VERSION_hashable(1,4,0)
. (Hashable a)
#else
. (Eq a, Hashable a)
#endif
=> TomlCodec a
-> Key
-> TomlCodec (HashSet a)
hashSet codec key = dimap HS.toList HS.fromList (list codec key)
{-# INLINE hashSet #-}
15 changes: 13 additions & 2 deletions src/Toml/Codec/Generic.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
Expand Down Expand Up @@ -586,7 +587,12 @@ instance (Ord a, HasItemCodec a) => HasCodec (Set a) where
{-# INLINE hasCodec #-}

-- | @since 1.2.0.0
instance (Hashable a, Eq a, HasItemCodec a) => HasCodec (HashSet a) where
#if MIN_VERSION_hashable(1,4,0)
instance (Hashable a, HasItemCodec a)
#else
instance (Hashable a, Eq a, HasItemCodec a)
#endif
=> HasCodec (HashSet a) where
hasCodec = case hasItemCodec @a of
Left prim -> Toml.arrayHashSetOf prim
Right codec -> Toml.hashSet codec
Expand Down Expand Up @@ -624,7 +630,12 @@ fieldName =
@since 1.3.0.0
-}
instance (Hashable k, Eq k, HasCodec k, HasCodec v) => HasCodec (HashMap k v) where
#if MIN_VERSION_hashable(1,4,0)
instance (Hashable k, HasCodec k, HasCodec v)
#else
instance (Hashable k, Eq k, HasCodec k, HasCodec v)
#endif
=> HasCodec (HashMap k v) where
hasCodec = Toml.hashMap (hasCodec @k "key") (hasCodec @v "val")
{-# INLINE hasCodec #-}

Expand Down
1 change: 1 addition & 0 deletions src/Toml/Codec/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

{- |
Expand Down
9 changes: 2 additions & 7 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
resolver: lts-17.5
resolver: lts-20.12

extra-deps:
- hashable-1.3.1.0

flags:
tomland:
build-readme: true
build-play-tomland: true
- validation-selective-0.2.0.0
12 changes: 10 additions & 2 deletions test/Test/Toml/Gen.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# OPTIONS_GHC -fno-warn-orphans #-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE PatternSynonyms #-}
Expand Down Expand Up @@ -258,7 +259,14 @@ genFloat = Gen.float (Range.constant (-10000.0) 10000.0)
genSet :: Ord a => Gen a -> Gen (Set a)
genSet genA = fromList <$> genList genA

genHashSet :: (Eq a, Hashable a) => Gen a -> Gen (HashSet a)
genHashSet
#if MIN_VERSION_hashable(1,4,0)
:: (Hashable a)
#else
:: (Eq a, Hashable a)
#endif
=> Gen a
-> Gen (HashSet a)
genHashSet genA = fromList <$> genList genA

genNonEmpty :: Gen a -> Gen (NonEmpty a)
Expand Down Expand Up @@ -387,7 +395,7 @@ genArray = Gen.recursive Gen.choice

-- filters

-- | Discards strings that end with \
-- | Discards strings that end with @\@
genNotEscape :: Gen Text -> Gen Text
genNotEscape gen = gen >>= \t ->
if | Text.null t -> pure t
Expand Down
7 changes: 6 additions & 1 deletion test/Test/Toml/Parser/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ import Data.Time (Day, LocalTime (..), TimeOfDay (..), TimeZone, ZonedTime (..),
minutesToTimeZone)
import Test.Hspec (Expectation)
import Test.Hspec.Megaparsec (shouldFailOn, shouldParse)
import Text.Megaparsec (Parsec, ShowErrorComponent, Stream, parse)
import Text.Megaparsec (Parsec, ShowErrorComponent, parse)
#if __GLASGOW_HASKELL__ <= 804
import Text.Megaparsec (Stream)
#endif
#if MIN_VERSION_megaparsec(9,0,0)
import Text.Megaparsec.Stream (TraversableStream, VisualStream)
#endif
Expand All @@ -58,7 +61,9 @@ import Toml.Type.UValue (UValue (..))

parseX
:: ( ShowErrorComponent e
#if __GLASGOW_HASKELL__ <= 804
, Stream s
#endif
#if MIN_VERSION_megaparsec(9,0,0)
, VisualStream s
, TraversableStream s
Expand Down
12 changes: 6 additions & 6 deletions tomland.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ license: MPL-2.0
license-file: LICENSE
author: Dmitrii Kovanikov, Veronika Romashkina
maintainer: Kowainik <xrom.xkov@gmail.com>
copyright: 2018-2022 Kowainik
copyright: 2018-2023 Kowainik
category: TOML, Text, Configuration
build-type: Simple
extra-doc-files: README.md
Expand All @@ -39,7 +39,8 @@ tested-with: GHC == 8.4.4
GHC == 8.8.4
GHC == 8.10.7
GHC == 9.0.2
GHC == 9.2.4
GHC == 9.2.7
GHC == 9.4.4

source-repository head
type: git
Expand All @@ -56,7 +57,7 @@ flag build-play-tomland
manual: True

common common-options
build-depends: base >= 4.11 && < 4.17
build-depends: base >= 4.11 && < 4.18

ghc-options: -Wall
-Wcompat
Expand Down Expand Up @@ -135,13 +136,12 @@ library
, deepseq ^>= 1.4
, hashable >= 1.3.1.0 && < 1.5
, megaparsec >= 7.0.5 && < 9.4
, mtl ^>= 2.2
, mtl >= 2.2 && < 2.4
, parser-combinators >= 1.1.0 && < 1.4
, text >= 1.2 && < 2.1
, time >= 1.8 && < 1.14
, transformers >= 0.5 && < 0.7
, unordered-containers ^>= 0.2.7
, validation-selective ^>= 0.1.0
, validation-selective >= 0.1.0 && < 0.3

executable readme
import: common-options
Expand Down

0 comments on commit 37f1646

Please sign in to comment.