diff --git a/ChangeLog.md b/ChangeLog.md index bfaef03..b5e520d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,7 @@ * Support GHC >= 9.6 * Use `buildVariantExtractor` in `Codec.Winery.Query.con` * Require mtl >= 2.3 +* Added an instance for `Solo` * Added `deserialiseOnly` * `extractConstructor`, `extractConstructorBy`, and `extractVoid` are now deprecated diff --git a/src/Codec/Winery/Class.hs b/src/Codec/Winery/Class.hs index 2243298..466a313 100644 --- a/src/Codec/Winery/Class.hs +++ b/src/Codec/Winery/Class.hs @@ -111,6 +111,7 @@ import qualified Data.Vector.Unboxed as UV import Prettyprinter hiding ((<>), SText, SChar) import Data.Time.Clock import Data.Time.Clock.POSIX +import Data.Tuple import Data.Typeable import Data.Void (Void) import Unsafe.Coerce @@ -1109,3 +1110,13 @@ buildRecordExtractor = buildExtractor . btraverse (fmap Identity) bextractors :: forall b. (ConstraintsB b, AllB Serialise b, FieldNamesB b) => b Subextractor bextractors = bmapC @Serialise (extractField . getConst) bfieldNames {-# INLINABLE bextractors #-} + +#if MIN_VERSION_base(4,15,0) +instance Serialise a => Serialise (Solo a) where + schemaGen = gschemaGenProduct + toBuilder = gtoBuilderProduct + extractor = gextractorProduct + decodeCurrent = gdecodeCurrentProduct + {-# INLINE toBuilder #-} + {-# INLINE decodeCurrent #-} +#endif diff --git a/src/Codec/Winery/Internal.hs b/src/Codec/Winery/Internal.hs index aa285dc..1ad0941 100644 --- a/src/Codec/Winery/Internal.hs +++ b/src/Codec/Winery/Internal.hs @@ -53,6 +53,7 @@ import qualified Data.ByteString.Internal as B import qualified Data.ByteString.Builder.Prim.Internal as BPI import Data.Bits import Data.String +import Data.Tuple import qualified Data.Vector.Unboxed as U import qualified Data.Vector as V import Data.Word