wrapped 0.1.0.0 → 0.1.0.1
raw patch · 3 files changed
+36/−9 lines, 3 filesdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base
API changes (from Hackage documentation)
- Data.Wrapped: instance (GHC.Base.Applicative f, GHC.Base.Monoid m) => GHC.Base.Monoid (Data.Wrapped.Wrapped1 GHC.Base.Applicative f m)
+ Data.Wrapped: instance (GHC.Base.Applicative f, GHC.Base.Monoid a) => GHC.Base.Monoid (Data.Wrapped.Wrapped1 GHC.Base.Applicative f a)
Files
- CHANGELOG.md +4/−0
- src/Data/Wrapped.hs +29/−6
- wrapped.cabal +3/−3
CHANGELOG.md view
@@ -1,3 +1,7 @@ # 0.1.0.0 Initial version.++# 0.1.0.1++* Extend support back to GHC 8.0.
src/Data/Wrapped.hs view
@@ -14,7 +14,7 @@ -- | Provides 'Wrapped' and 'Wrapped1' types to hold @DerivingVia@ instances. -{-# LANGUAGE DerivingVia #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -31,17 +31,24 @@ Wrapped(..), Wrapped1(..) -- ** Wrapped 'Generic' -- $Wrapped_Generic- , GSemigroup(..), GMonoid(..)+ -- ** Wrapped 'IsList' -- $Wrapped_IsList+ -- ** Wrapped 'Foldable' -- $Wrapped_Foldable++ -- * Internals+ , GSemigroup(..), GMonoid(..) ) where import Control.Applicative (liftA2) import qualified Data.Foldable as F (toList) import Data.Function (on) import Data.Kind (Constraint, Type)+#if !MIN_VERSION_base(4, 11, 0)+import Data.Semigroup (Semigroup(..))+#endif import GHC.Exts (IsList(Item)) import qualified GHC.Exts as Exts (IsList(..)) import GHC.Generics@@ -128,6 +135,9 @@ -- mix this with a `Semigroup` instance from another source. instance (Generic a, GSemigroup (Rep a), GMonoid (Rep a)) => Monoid (Wrapped Generic a) where+#if !MIN_VERSION_base(4, 11, 0)+ mappend = (<>)+#endif mempty = Wrapped $ to gmempty -- $Wrapped_IsList@@ -155,7 +165,11 @@ -- and may then assume that 'IsList' and 'Foldable' give the same instances. -- | Just forwarding the instance; not meant to be used for deriving.-deriving newtype instance IsList a => IsList (Wrapped IsList a)+instance IsList a => IsList (Wrapped IsList a) where+ type Item (Wrapped IsList a) = Exts.Item a+ fromList = Wrapped . Exts.fromList+ fromListN n = Wrapped . Exts.fromListN n+ toList = Exts.toList . unWrapped -- | Equality of the results of 'Exts.toList'. instance (IsList a, Eq (Item a)) => Eq (Wrapped IsList a) where@@ -181,7 +195,7 @@ -- See above for a description of how this differs from @'Wrapped' 'IsList'@. -- | Just forwarding the instance; not meant to be used for deriving.-deriving newtype instance Foldable f => Foldable (Wrapped1 Foldable f)+deriving instance Foldable f => Foldable (Wrapped1 Foldable f) -- | Equality of the results of 'F.toList'. instance (Foldable f, Eq a) => Eq (Wrapped1 Foldable f a) where@@ -201,7 +215,16 @@ (<>) = fmap Wrapped1 . (liftA2 (<>) `on` unWrapped1) -- | Provide 'mappend' by 'liftA2' and 'mempty' by @'pure' 'mempty'@.-instance (Applicative f, Monoid m) => Monoid (Wrapped1 Applicative f m) where+instance ( Applicative f+ , Monoid a+#if !MIN_VERSION_base(4, 11, 0)+ , Semigroup a+#endif+ )+ => Monoid (Wrapped1 Applicative f a) where+#if !MIN_VERSION_base(4, 11, 0)+ mappend = (<>)+#endif mempty = Wrapped1 (pure mempty) -- | Forwarding instance for 'Functor'.@@ -210,4 +233,4 @@ -- as a superclass, then it needs to have a 'Functor' instance. There's not -- much point in providing a Generics-based one, though because @DeriveFunctor@ -- exists. So, just forward the underlying type's instance.-deriving newtype instance Functor f => Functor (Wrapped1 Generic1 f)+deriving instance Functor f => Functor (Wrapped1 Generic1 f)
wrapped.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: e0afcb2bfa2caf82798dcda573c47f1043922eedabf3601cddf74ddf9e49e42e+-- hash: 4500c6c26363d1ccde6c149d7a5f8f073bbb8b95f173c1625140478ff5f9ae8f name: wrapped-version: 0.1.0.0+version: 0.1.0.1 synopsis: Provides a single standardized place to hang DerivingVia instances. description: This exports the newtypes 'Wrapped' and 'Wrapped1', which are meant to hold typeclass implementations derived from other classes (most frequently,@@ -39,5 +39,5 @@ hs-source-dirs: src build-depends:- base >=4.12 && <4.16+ base >=4.9 && <4.16 default-language: Haskell2010