newtype 0.2.2.0 → 0.2.2.1
raw patch · 4 files changed
+35/−60 lines, 4 filesdep −transformersdep ~basesetup-changednew-uploader
Dependencies removed: transformers
Dependency ranges changed: base
Files
- CHANGES.md +6/−4
- Control/Newtype.hs +6/−41
- Setup.hs +0/−5
- newtype.cabal +23/−10
CHANGES.md view
@@ -1,9 +1,11 @@-See also https://pvp.haskell.org/faq+## 0.2.2.1 -## 0.2.2.0 *(minor)*+ - Drop support for GHC 7.+ - Tested with GHC 8.0 - 9.14. - - Provide safe `Coercible`-based default-methods for `pack`/`unpack`- ([#1](https://github.com/haskell-hvr/newtype/pull/1))+## 0.2.2.0++ - Provide safe coerceible based default-methods for pack/unpack ## 0.2.1.0 *(minor)*
Control/Newtype.hs view
@@ -1,13 +1,11 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-}-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE DefaultSignatures #-}-#endif -{-# OPTIONS_GHC -fno-warn-unused-imports #-}+{-# OPTIONS_GHC -Wno-unused-imports #-} {- | Module : Control.Newtype@@ -42,60 +40,37 @@ import Control.Applicative import Control.Arrow++import Data.Coerce import Data.Fixed import Data.Functor.Compose import Data.Functor.Identity import Data.Monoid import Data.Ord -#if !MIN_VERSION_base(4,7,0)--- necessary evil for 'Newtype Fixed'-import Unsafe.Coerce (unsafeCoerce)-#else-import Data.Coerce-#endif- -- | Given a @newtype@ @n@, we will always have the same unwrapped type @o@, meaning we can represent this with a fundep @n -> o@. -- -- Any instance of this class just needs to let 'pack' equal to the newtype's constructor, and let 'unpack' destruct the @newtype@ with pattern matching. ----- Starting with @newtype-0.2.2.0@, default method implementations are provided using "Data.Coerce" for GHC 7.8 (i.e. @base-4.7.0.0@) and later, i.e.:+-- Starting with @base-4.7.0.0@ / GHC 7.8 default method implementations are provided using "Data.Coerce", i.e.: -- -- @--- 'pack' = 'coerce'+-- 'pack' = 'coerce' -- 'unpack' = 'coerce' -- @ -- -- When omitting the method definitions with GHC 7.4 and 7.6 a compile error will be triggered.------ Consequently, if your code relies on these default methods make sure to state------ > build-depends: newtype ^>= 0.2.2.0------ In your @.cabal@ package description. class Newtype n o | n -> o where pack :: o -> n unpack :: n -> o -#if __GLASGOW_HASKELL__ >= 704 default pack :: Coercible o n => o -> n pack = coerce default unpack :: Coercible n o => n -> o unpack = coerce-#endif -#if __GLASGOW_HASKELL__ >= 704 && !MIN_VERSION_base(4,7,0)--- Hack: We define a dummy 'Coercible' class to force a--- missing-instance compile error when methods are not explicitly--- defined-class Coercible o n--coerce :: a -> b-coerce = undefined-#endif- {- TODO: for newtype-0.3 This would be nice, but it breaks in odd ways with GHC < 7.@@ -202,37 +177,27 @@ -- | @since 0.2.1.0 instance Newtype (Fixed a) Integer where-#if MIN_VERSION_base(4,7,0) pack = MkFixed unpack (MkFixed x) = x-#else- -- 'Fixed' is a newtype, but its constructor wasn't exported before base-4.7.0- pack = unsafeCoerce- unpack = unsafeCoerce-#endif -- | @since 0.2.1.0 instance Newtype (Dual a) a where pack = Dual unpack (Dual a) = a -#if MIN_VERSION_base(4,8,0) -- | __NOTE__: Type & instance only available with @base ≥ 4.8.0@ -- -- @since 0.2.1.0 instance Newtype (Alt f a) (f a) where pack = Alt unpack (Alt x) = x-#endif -#if MIN_VERSION_base(4,6,0) -- | __NOTE__: Type & instance only available with @base ≥ 4.6.0@ -- -- @since 0.2.1.0 instance Newtype (Down a) a where pack = Down unpack (Down a) = a-#endif -- | @since 0.2.1.0 instance Newtype (Identity a) a where
Setup.hs view
@@ -1,7 +1,2 @@- import Distribution.Simple---- main = defaultMain
newtype.cabal view
@@ -1,18 +1,34 @@ cabal-version: 1.12 build-type: Simple name: newtype-version: 0.2.2.0+version: 0.2.2.1 license: BSD3 license-file: LICENSE author: Herbert Valerio Riedel, Darius Jahandarie, Conor McBride-maintainer: hvr@gnu.org+maintainer: Andreas Abel category: Control bug-reports: https://github.com/hvr/newtype/issues synopsis: A typeclass and set of functions for working with newtypes. description: Per Conor McBride, the 'Newtype' typeclass represents the packing and unpacking of a @newtype@, and allows you to operate under that @newtype@ with functions such as 'ala'. See "Control.Newtype" for documentation and examples. +tested-with:+ GHC == 9.14.1+ GHC == 9.12.2+ GHC == 9.10.3+ GHC == 9.8.4+ GHC == 9.6.7+ GHC == 9.4.8+ GHC == 9.2.8+ GHC == 9.0.2+ GHC == 8.10.7+ GHC == 8.8.4+ GHC == 8.6.5+ GHC == 8.4.4+ GHC == 8.2.2+ GHC == 8.0.2+ extra-source-files: CHANGES.md source-repository head@@ -22,9 +38,7 @@ library exposed-modules: Control.Newtype - build-depends: base >= 4.5 && < 4.14- if !impl(ghc >= 8.0)- build-depends: transformers >= 0.2.2.0 && < 0.6+ build-depends: base >= 4.9 && < 5 default-language: Haskell2010 other-extensions:@@ -32,10 +46,9 @@ FlexibleInstances FunctionalDependencies MultiParamTypeClasses+ Trustworthy TypeFamilies - if impl(ghc >= 7.2)- default-extensions: Trustworthy- if impl(ghc >= 7.10) { ghc-options: -fno-warn-trustworthy-safe }-- ghc-options: -Wall+ ghc-options:+ -Wall+ -Wno-trustworthy-safe