newtype-generics 0.5.0.1 → 0.5.1
raw patch · 3 files changed
+137/−30 lines, 3 filesdep +transformersPVP ok
version bump matches the API change (PVP)
Dependencies added: transformers
API changes (from Hackage documentation)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Fixed.Fixed a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Functor.Compose.Compose f g a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Functor.Identity.Identity a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Monoid.Alt f a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Monoid.Dual a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Ord.Down a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.First a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.Last a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.Max a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.Min a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.Option a)
+ Control.Newtype: instance Control.Newtype.Newtype (Data.Semigroup.WrappedMonoid m)
Files
- CHANGELOG.md +1/−0
- Control/Newtype.hs +134/−29
- newtype-generics.cabal +2/−1
CHANGELOG.md view
@@ -1,2 +1,3 @@+* 0.5.1 - Add more instances from base * 0.5.0.1 - Compatibility with GHC 8.2.1 * 0.5 - Relax types of underF and overF to allow different input & output funtors
Control/Newtype.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, TypeFamilies #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-}@@ -47,9 +48,19 @@ , overF ) where -import Data.Monoid import Control.Applicative import Control.Arrow+import Data.Functor.Compose+import Data.Functor.Identity+#if MIN_VERSION_base(4,7,0)+import Data.Fixed+#endif+import Data.Monoid+import Data.Ord+#if MIN_VERSION_base(4,9,0)+import qualified Data.Semigroup+import Data.Semigroup (Min(..), Max(..), WrappedMonoid(..), Option(..))+#endif import GHC.Generics {-import Generics.Deriving-} @@ -157,6 +168,81 @@ => (o -> n) -> (f o -> g o') -> (f n -> g n') overF _ f = fmap pack . f . fmap unpack +-- Instances from Control.Applicative++instance Newtype (WrappedMonad m a) where+ type O (WrappedMonad m a) = m a+ pack = WrapMonad+ unpack (WrapMonad a) = a++instance Newtype (WrappedArrow a b c) where+ type O (WrappedArrow a b c) = a b c+ pack = WrapArrow+ unpack (WrapArrow a) = a++instance Newtype (ZipList a) where+ type O (ZipList a) = [a]+ pack = ZipList+ unpack (ZipList a) = a++-- Instances from Control.Arrow++instance Newtype (Kleisli m a b) where+ type O (Kleisli m a b) = a -> m b+ pack = Kleisli+ unpack (Kleisli a) = a++instance Newtype (ArrowMonad a b) where+ type O (ArrowMonad a b) = a () b+ pack = ArrowMonad+ unpack (ArrowMonad a) = a++#if MIN_VERSION_base(4,7,0)+-- Instances from Data.Fixed++-- | @since 0.5.1+instance Newtype (Fixed a) where+ type O (Fixed a) = Integer+ pack = MkFixed+ unpack (MkFixed x) = x+#endif++-- Instances from Data.Functor.Compose++-- | @since 0.5.1+instance Newtype (Compose f g a) where+ type O (Compose f g a) = f (g a)+ pack = Compose+ unpack (Compose x) = x++-- Instances from Data.Functor.Const++instance Newtype (Const a x) where+ type O (Const a x) = a+ pack = Const+ unpack (Const a) = a++-- Instances from Data.Functor.Identity++-- | @since 0.5.1+instance Newtype (Identity a) where+ type O (Identity a) = a+ pack = Identity+ unpack (Identity a) = a++-- Instances from Data.Monoid++-- | @since 0.5.1+instance Newtype (Dual a) where+ type O (Dual a) = a+ pack = Dual+ unpack (Dual a) = a++instance Newtype (Endo a) where+ type O (Endo a) = (a -> a)+ pack = Endo+ unpack (Endo a) = a+ instance Newtype All where type O All = Bool pack = All@@ -187,40 +273,59 @@ pack = Last unpack (Last a) = a -instance Newtype (Endo a) where- type O (Endo a) = (a -> a)- pack = Endo- unpack (Endo a) = a+#if MIN_VERSION_base(4,8,0)+-- | @since 0.5.1+instance Newtype (Alt f a) where+ type O (Alt f a) = f a+ pack = Alt+ unpack (Alt x) = x+#endif -instance Newtype (ZipList a) where- type O (ZipList a) = [a]- pack = ZipList- unpack (ZipList a) = a+-- Instances from Data.Ord -instance Newtype (Const a x) where- type O (Const a x) = a- pack = Const- unpack (Const a) = a+-- | @since 0.5.1+instance Newtype (Down a) where+ type O (Down a) = a+ pack = Down+ unpack (Down a) = a -instance Newtype (Kleisli m a b) where- type O (Kleisli m a b) = a -> m b- pack = Kleisli- unpack (Kleisli a) = a -instance Newtype (WrappedMonad m a) where- type O (WrappedMonad m a) = m a- pack = WrapMonad- unpack (WrapMonad a) = a+#if MIN_VERSION_base(4,9,0)+-- Instances from Data.Semigroup -instance Newtype (WrappedArrow a b c) where- type O (WrappedArrow a b c) = a b c- pack = WrapArrow- unpack (WrapArrow a) = a+-- | @since 0.5.1+instance Newtype (Min a) where+ type O (Min a) = a+ pack = Min+ unpack (Min a) = a -instance Newtype (ArrowMonad a b) where- type O (ArrowMonad a b) = a () b- pack = ArrowMonad- unpack (ArrowMonad a) = a+-- | @since 0.5.1+instance Newtype (Max a) where+ type O (Max a) = a+ pack = Max+ unpack (Max a) = a +-- | @since 0.5.1+instance Newtype (Data.Semigroup.First a) where+ type O (Data.Semigroup.First a) = a+ pack = Data.Semigroup.First+ unpack (Data.Semigroup.First a) = a +-- | @since 0.5.1+instance Newtype (Data.Semigroup.Last a) where+ type O (Data.Semigroup.Last a) = a+ pack = Data.Semigroup.Last+ unpack (Data.Semigroup.Last a) = a +-- | @since 0.5.1+instance Newtype (WrappedMonoid m) where+ type O (WrappedMonoid m) = m+ pack = WrapMonoid+ unpack (WrapMonoid m) = m++-- | @since 0.5.1+instance Newtype (Option a) where+ type O (Option a) = Maybe a+ pack = Option+ unpack (Option x) = x+#endif
newtype-generics.cabal view
@@ -1,5 +1,5 @@ Name: newtype-generics-Version: 0.5.0.1+Version: 0.5.1 Synopsis: A typeclass and set of functions for working with newtypes, with generics support. Description: Per Conor McBride, the Newtype typeclass represents the packing and unpacking of a newtype, and allows you to operatate under that newtype with functions such as ala.@@ -24,6 +24,7 @@ Library Exposed-modules: Control.Newtype Build-depends: base >= 4.6 && < 4.11+ , transformers -- Other-modules: -- Build-tools: Ghc-options: -Wall