diff -Nru haskell-contravariant-0.4/CHANGELOG.markdown haskell-contravariant-0.4.4/CHANGELOG.markdown --- haskell-contravariant-0.4/CHANGELOG.markdown 2013-02-05 22:24:34.000000000 +0000 +++ haskell-contravariant-0.4.4/CHANGELOG.markdown 2013-08-20 14:16:27.000000000 +0000 @@ -1,3 +1,11 @@ +0.4.4 +----- +* Fixed compatibility with GHC 7.7 and tightened `Safe` Haskell support. + +0.4.1 +----- +* Added `Day` convolution under `Data.Functor.Contravariant.Day`. + 0.3 --- * Added `Backwards` and `Reverse` instances for `transformers` 0.3 diff -Nru haskell-contravariant-0.4/Data/Functor/Contravariant/Day.hs haskell-contravariant-0.4.4/Data/Functor/Contravariant/Day.hs --- haskell-contravariant-0.4/Data/Functor/Contravariant/Day.hs 1970-01-01 00:00:00.000000000 +0000 +++ haskell-contravariant-0.4.4/Data/Functor/Contravariant/Day.hs 2013-08-20 14:16:27.000000000 +0000 @@ -0,0 +1,194 @@ +{-# LANGUAGE CPP #-} +{-# LANGUAGE ExistentialQuantification #-} +{-# LANGUAGE Rank2Types #-} +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707 +{-# LANGUAGE DeriveDataTypeable #-} +#endif +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ <= 707 +{-# LANGUAGE KindSignatures #-} +#endif +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 +{-# LANGUAGE Trustworthy #-} +#endif +----------------------------------------------------------------------------- +-- | +-- Copyright : (C) 2013 Edward Kmett, Gershom Bazerman and Derek Elkins +-- License : BSD-style (see the file LICENSE) +-- +-- Maintainer : Edward Kmett +-- Stability : provisional +-- Portability : portable +-- +-- The Day convolution of two contravariant functors is a contravariant +-- functor. +-- +-- +---------------------------------------------------------------------------- + +module Data.Functor.Contravariant.Day + ( Day(..) + , day + , runDay + , assoc, disassoc + , swapped + , intro1, intro2 + , day1, day2 + , diag + , trans1, trans2 + ) where + +import Control.Applicative +import Data.Functor.Contravariant +import Data.Proxy +import Data.Tuple (swap) +#ifdef __GLASGOW_HASKELL__ +import Data.Typeable +#endif + +-- | The Day convolution of two contravariant functors. +data Day f g a = forall b c. Day (f b) (g c) (a -> (b, c)) +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 707 + deriving Typeable +#endif + +-- | Construct the Day convolution +-- +-- @ +-- 'day1' ('day' f g) = f +-- 'day2' ('day' f g) = g +-- @ +day :: f a -> g b -> Day f g (a, b) +day fa gb = Day fa gb id + +#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 707 +instance (Typeable1 f, Typeable1 g) => Typeable1 (Day f g) where + typeOf1 tfga = mkTyConApp dayTyCon [typeOf1 (fa tfga), typeOf1 (ga tfga)] + where fa :: t f (g :: * -> *) a -> f a + fa = undefined + ga :: t (f :: * -> *) g a -> g a + ga = undefined + +dayTyCon :: TyCon +#if MIN_VERSION_base(4,4,0) +dayTyCon = mkTyCon3 "contravariant" "Data.Functor.Contravariant.Day" "Day" +#else +dayTyCon = mkTyCon "Data.Functor.Contravariant.Day.Day" +#endif + +#endif + +instance Contravariant (Day f g) where + contramap f (Day fb gc abc) = Day fb gc (abc . f) + +-- | Break apart the Day convolution of two contravariant functors. +runDay :: (Contravariant f, Contravariant g) => Day f g a -> (f a, g a) +runDay (Day fb gc abc) = + ( contramap (fst . abc) fb + , contramap (snd . abc) gc + ) + +-- | Day convolution provides a monoidal product. The associativity +-- of this monoid is witnessed by 'assoc' and 'disassoc'. +-- +-- @ +-- 'assoc' . 'disassoc' = 'id' +-- 'disassoc' . 'assoc' = 'id' +-- 'contramap' f '.' 'assoc' = 'assoc' '.' 'contramap' f +-- @ +assoc :: Day f (Day g h) a -> Day (Day f g) h a +assoc (Day fb (Day gd he cde) abc) = Day (Day fb gd id) he $ \a -> + case cde <$> abc a of + (b, (d, e)) -> ((b, d), e) + +-- | Day convolution provides a monoidal product. The associativity +-- of this monoid is witnessed by 'assoc' and 'disassoc'. +-- +-- @ +-- 'assoc' . 'disassoc' = 'id' +-- 'disassoc' . 'assoc' = 'id' +-- 'contramap' f '.' 'disassoc' = 'disassoc' '.' 'contramap' f +-- @ +disassoc :: Day (Day f g) h a -> Day f (Day g h) a +disassoc (Day (Day fd ge bde) hc abc) = Day fd (Day ge hc id) $ \a -> + case abc a of + (b, c) -> case bde b of + (d, e) -> (d, (e, c)) + +-- | The monoid for Day convolution /in Haskell/ is symmetric. +-- +-- @ +-- 'contramap' f '.' 'swapped' = 'swapped' '.' 'contramap' f +-- @ +swapped :: Day f g a -> Day g f a +swapped (Day fb gc abc) = Day gc fb (swap . abc) + +-- | Proxy serves as the unit of Day convolution. +-- +-- @ +-- 'day1' '.' 'intro1' = 'id' +-- 'contramap' f '.' 'intro1' = 'intro1' '.' 'contramap' f +-- @ +intro1 :: f a -> Day Proxy f a +intro1 fa = Day Proxy fa $ \a -> ((),a) + +-- | Proxy serves as the unit of Day convolution. +-- +-- @ +-- 'day2' '.' 'intro2' = 'id' +-- 'contramap' f '.' 'intro2' = 'intro2' '.' 'contramap' f +-- @ +intro2 :: f a -> Day f Proxy a +intro2 fa = Day fa Proxy $ \a -> (a,()) + +-- | In Haskell we can do general purpose elimination, but in a more general setting +-- it is only possible to eliminate the unit. +-- +-- @ +-- 'day1' '.' 'intro1' = 'id' +-- 'day1' = 'fst' '.' 'runDay' +-- 'contramap' f '.' 'day1' = 'day1' '.' 'contramap' f +-- @ +day1 :: Contravariant f => Day f g a -> f a +day1 (Day fb _ abc) = contramap (fst . abc) fb + +-- | In Haskell we can do general purpose elimination, but in a more general setting +-- it is only possible to eliminate the unit. +-- @ +-- 'day2' '.' 'intro2' = 'id' +-- 'day2' = 'snd' '.' 'runDay' +-- 'contramap' f '.' 'day2' = 'day2' '.' 'contramap' f +-- @ +day2 :: Contravariant g => Day f g a -> g a +day2 (Day _ gc abc) = contramap (snd . abc) gc + +-- | Diagonalize the Day convolution: +-- +-- @ +-- 'day1' '.' 'diag' = 'id' +-- 'day2' '.' 'diag' = 'id' +-- 'runDay '.' 'diag' = \a -> (a,a) +-- 'contramap' f . 'diag' = 'diag' . 'contramap' f +-- @ + +diag :: f a -> Day f f a +diag fa = Day fa fa $ \a -> (a,a) + +-- | Apply a natural transformation to the left-hand side of a Day convolution. +-- +-- This respects the naturality of the natural transformation you supplied: +-- +-- @ +-- 'contramap' f '.' 'trans1' fg = 'trans1' fg '.' 'contramap' f +-- @ +trans1 :: (forall x. f x -> g x) -> Day f h a -> Day g h a +trans1 fg (Day fb hc abc) = Day (fg fb) hc abc + +-- | Apply a natural transformation to the right-hand side of a Day convolution. +-- +-- This respects the naturality of the natural transformation you supplied: +-- +-- @ +-- 'contramap' f '.' 'trans2' fg = 'trans2' fg '.' 'contramap' f +-- @ +trans2 :: (forall x. g x -> h x) -> Day f g a -> Day f h a +trans2 gh (Day fb gc abc) = Day fb (gh gc) abc diff -Nru haskell-contravariant-0.4/Data/Functor/Contravariant.hs haskell-contravariant-0.4.4/Data/Functor/Contravariant.hs --- haskell-contravariant-0.4/Data/Functor/Contravariant.hs 2013-02-05 22:24:34.000000000 +0000 +++ haskell-contravariant-0.4.4/Data/Functor/Contravariant.hs 2013-08-20 14:16:27.000000000 +0000 @@ -1,3 +1,19 @@ +{-# LANGUAGE CPP #-} +#ifdef __GLASGOW_HASKELL__ +{-# LANGUAGE DeriveDataTypeable #-} +#if __GLASGOW_HASKELL__ >= 702 +#if MIN_VERSION_transformers(0,3,0) +#if MIN_VERSION_tagged(0,6,1) +{-# LANGUAGE Safe #-} +#else +{-# LANGUAGE Trustworthy #-} +#endif +#else +{-# LANGUAGE Trustworthy #-} +#endif +#endif +#endif + ----------------------------------------------------------------------------- -- | -- Module : Data.Functor.Contravariant @@ -44,6 +60,9 @@ import Data.Functor.Reverse import Data.Proxy import Prelude hiding ((.),id) +#ifdef __GLASGOW_HASKELL__ +import Data.Typeable +#endif -- | Any instance should be subject to the following laws: -- @@ -92,6 +111,11 @@ contramap _ Proxy = Proxy newtype Predicate a = Predicate { getPredicate :: a -> Bool } +#ifdef __GLASGOW_HASKELL__ + deriving Typeable +#endif + + -- | A 'Predicate' is a 'Contravariant' 'Functor', because 'contramap' can -- apply its function argument to the input of the predicate. @@ -100,6 +124,9 @@ -- | Defines a total ordering on a type as per 'compare' newtype Comparison a = Comparison { getComparison :: a -> a -> Ordering } +#ifdef __GLASGOW_HASKELL__ + deriving Typeable +#endif -- | A 'Comparison' is a 'Contravariant' 'Functor', because 'contramap' can -- apply its function argument to each input to each input to the @@ -113,6 +140,10 @@ -- | Define an equivalence relation newtype Equivalence a = Equivalence { getEquivalence :: a -> a -> Bool } +#ifdef __GLASGOW_HASKELL__ + deriving Typeable +#endif + -- | Equivalence relations are 'Contravariant', because you can -- apply the contramapped function to each input to the equivalence -- relation. @@ -125,6 +156,9 @@ -- | Dual function arrows. newtype Op a b = Op { getOp :: b -> a } +#ifdef __GLASGOW_HASKELL__ + deriving Typeable +#endif instance Category Op where id = Op id diff -Nru haskell-contravariant-0.4/contravariant.cabal haskell-contravariant-0.4.4/contravariant.cabal --- haskell-contravariant-0.4/contravariant.cabal 2013-02-05 22:24:34.000000000 +0000 +++ haskell-contravariant-0.4.4/contravariant.cabal 2013-08-20 14:16:27.000000000 +0000 @@ -1,6 +1,6 @@ name: contravariant category: Control, Data -version: 0.4 +version: 0.4.4 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE @@ -9,9 +9,9 @@ stability: provisional homepage: http://github.com/ekmett/contravariant/ bug-reports: http://github.com/ekmett/contravariant/issues -copyright: Copyright (C) 2007-2011 Edward A. Kmett -synopsis: Haskell 98 contravariant functors -description: Haskell 98 contravariant functors +copyright: Copyright (C) 2007-2013 Edward A. Kmett +synopsis: Contravariant functors +description: Contravariant functors build-type: Simple extra-source-files: .travis.yml @@ -30,4 +30,5 @@ exposed-modules: Data.Functor.Contravariant Data.Functor.Contravariant.Compose + Data.Functor.Contravariant.Day ghc-options: -Wall diff -Nru haskell-contravariant-0.4/debian/changelog haskell-contravariant-0.4.4/debian/changelog --- haskell-contravariant-0.4/debian/changelog 2013-06-11 23:34:36.000000000 +0000 +++ haskell-contravariant-0.4.4/debian/changelog 2014-01-01 03:57:51.000000000 +0000 @@ -1,8 +1,25 @@ -haskell-contravariant (0.4-2~ppa1) precise; urgency=low +haskell-contravariant (0.4.4-1~ppa1) precise; urgency=low * Backport from Debian unstable + * Specify my PPA version of libghc-tagged-dev - -- Francois Marier Wed, 12 Jun 2013 11:34:28 +1200 + -- Francois Marier Wed, 01 Jan 2014 16:56:58 +1300 + +haskell-contravariant (0.4.4-1) unstable; urgency=medium + + [ Joachim Breitner ] + * Adjust watch file to new hackage layout + + [ Clint Adams ] + * New upstream version. + + -- Clint Adams Wed, 25 Dec 2013 20:23:33 -0500 + +haskell-contravariant (0.4.1-1) unstable; urgency=low + + * New upstream version. + + -- Clint Adams Tue, 11 Jun 2013 12:00:06 -0400 haskell-contravariant (0.4-2) unstable; urgency=low diff -Nru haskell-contravariant-0.4/debian/control haskell-contravariant-0.4.4/debian/control --- haskell-contravariant-0.4/debian/control 2013-06-11 23:34:24.000000000 +0000 +++ haskell-contravariant-0.4.4/debian/control 2014-01-01 03:56:57.000000000 +0000 @@ -3,13 +3,12 @@ Priority: extra Maintainer: Debian Haskell Group Uploaders: Iulian Udrea -DM-Upload-Allowed: yes Build-Depends: debhelper (>= 9) , cdbs , haskell-devscripts (>= 0.8.15) , ghc , ghc-prof - , libghc-tagged-dev (>> 0.4.4) + , libghc-tagged-dev (>= 0.7) , libghc-tagged-dev (<< 1) , libghc-tagged-prof , libghc-transformers-dev (>> 0.3) @@ -18,7 +17,7 @@ Build-Depends-Indep: ghc-doc , libghc-tagged-doc , libghc-transformers-doc -Standards-Version: 3.9.4 +Standards-Version: 3.9.5 Homepage: http://hackage.haskell.org/package/contravariant Vcs-Darcs: http://darcs.debian.org/pkg-haskell/haskell-contravariant Vcs-Browser: http://darcs.debian.org/cgi-bin/darcsweb.cgi?r=pkg-haskell/haskell-contravariant diff -Nru haskell-contravariant-0.4/debian/patches/no-transformers-compat.diff haskell-contravariant-0.4.4/debian/patches/no-transformers-compat.diff --- haskell-contravariant-0.4/debian/patches/no-transformers-compat.diff 2013-04-06 14:33:00.000000000 +0000 +++ haskell-contravariant-0.4.4/debian/patches/no-transformers-compat.diff 2013-12-26 01:24:06.000000000 +0000 @@ -1,6 +1,6 @@ --- a/contravariant.cabal +++ b/contravariant.cabal -@@ -25,8 +25,7 @@ +@@ -25,8 +25,7 @@ library build-depends: base < 5, tagged >= 0.4.4 && < 1, diff -Nru haskell-contravariant-0.4/debian/watch haskell-contravariant-0.4.4/debian/watch --- haskell-contravariant-0.4/debian/watch 2012-10-13 11:22:48.000000000 +0000 +++ haskell-contravariant-0.4.4/debian/watch 2013-12-26 01:23:24.000000000 +0000 @@ -1,5 +1,2 @@ version=3 -opts="downloadurlmangle=s|archive/([\w\d_-]+)/([\d\.]+)/|archive/$1/$2/$1-$2.tar.gz|,\ -filenamemangle=s|(.*)/$|contravariant-$1.tar.gz|" \ - http://hackage.haskell.org/packages/archive/contravariant \ - ([\d\.]*\d)/ +http://hackage.haskell.org/package/contravariant/distro-monitor .*-([0-9\.]+).(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))