diff --git a/ChangeLog.md b/ChangeLog.md index 1d25de7..c4b7359 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,11 @@ ## 1.4 +* Support GHC >= 9.6 +* Use `buildVariantExtractor` in `Codec.Winery.Query.con` +* Require mtl >= 2.3 + +## 1.4 + * Added an instance for `NonEmpty` * Removed the instance for `Option` * Added `withSchema` diff --git a/src/Codec/Winery/Class.hs b/src/Codec/Winery/Class.hs index d9a5f65..2243298 100644 --- a/src/Codec/Winery/Class.hs +++ b/src/Codec/Winery/Class.hs @@ -70,7 +70,8 @@ import Barbies.Constraints import Barbies.TH import Control.Applicative import Control.Exception -import Control.Monad.Reader +import Control.Monad +import Control.Monad.Fix import qualified Data.ByteString as B import qualified Data.ByteString.FastBuilder as BB import qualified Data.ByteString.Lazy as BL @@ -117,6 +118,9 @@ import GHC.Float (castWord32ToFloat, castWord64ToDouble) import GHC.Natural import GHC.Generics import GHC.TypeLits +#if __GLASGOW_HASKELL__ >= 906 + hiding (SChar) +#endif -- | Serialisable datatype -- @@ -1104,4 +1108,4 @@ buildRecordExtractor = buildExtractor . btraverse (fmap Identity) -- | Collect extractors for record fields bextractors :: forall b. (ConstraintsB b, AllB Serialise b, FieldNamesB b) => b Subextractor bextractors = bmapC @Serialise (extractField . getConst) bfieldNames -{-# INLINABLE bextractors #-} \ No newline at end of file +{-# INLINABLE bextractors #-} diff --git a/src/Codec/Winery/Query.hs b/src/Codec/Winery/Query.hs index ba299b6..ea3ed71 100644 --- a/src/Codec/Winery/Query.hs +++ b/src/Codec/Winery/Query.hs @@ -28,6 +28,7 @@ import Codec.Winery.Internal import Data.Typeable import qualified Data.Text as T import qualified Data.Vector as V +import qualified Data.HashMap.Strict as HM -- | Query is a transformation between 'Extractor's. -- Like jq, this returns a list of values. @@ -71,7 +72,7 @@ field name = Query $ \d -> buildExtractor $ extractFieldBy d name -- | Takes a variant and returns a value when the constructor matches. con :: Typeable a => T.Text -> Query a a -con name = Query $ \d -> buildExtractor $ extractConstructorBy (d, name, id) (pure []) +con name = Query $ \d -> buildVariantExtractor $ HM.singleton name d -- | Propagate values if the supplied 'Query' doesn't return False. select :: Query a Bool -> Query a a diff --git a/winery.cabal b/winery.cabal index 25709e2..dfefc00 100644 --- a/winery.cabal +++ b/winery.cabal @@ -1,6 +1,6 @@ cabal-version: 2.0 name: winery -version: 1.4 +version: 1.5 synopsis: A compact, well-typed seralisation format for Haskell values description: <> @@ -50,7 +50,7 @@ library , hashable , HUnit , megaparsec >=7.0.0 - , mtl + , mtl >= 2.3 , prettyprinter ^>= 1.7 , prettyprinter-ansi-terminal , scientific