adjunctions 3.2 → 3.2.1
raw patch · 13 files changed
+142/−37 lines, 13 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- .travis.yml +19/−0
- CHANGELOG.markdown +4/−0
- HLint.hs +4/−0
- LICENSE +1/−1
- adjunctions.cabal +5/−2
- src/Control/Comonad/Trans/Adjoint.hs +6/−3
- src/Control/Monad/Trans/Adjoint.hs +6/−3
- src/Control/Monad/Trans/Contravariant/Adjoint.hs +4/−0
- src/Control/Monad/Trans/Conts.hs +5/−2
- src/Data/Functor/Adjunction.hs +30/−26
- src/Data/Functor/Contravariant/Adjunction.hs +15/−0
- travis/cabal-apt-install +27/−0
- travis/config +16/−0
.travis.yml view
@@ -1,4 +1,20 @@ language: haskell++before_install:+ # Uncomment whenever hackage is down.+ # - mkdir -p ~/.cabal && cp travis/config ~/.cabal/config && cabal update+ - cabal update++ # Try installing some of the build-deps with apt-get for speed.+ - travis/cabal-apt-install $mode++install:+ - cabal configure $mode+ - cabal build++script:+ - $script && hlint src --cpp-define HLINT+ notifications: irc: channels:@@ -6,3 +22,6 @@ skip_join: true template: - "\x0313adjunctions\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"++env:+ - mode="--enable-tests" script="cabal test --show-details=always"
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+3.2.1+-----+* Marked modules appropriately `Trustworthy`.+ 3.2 --- * Updated to `representable-functors` 3.1, which changed the API for contravariant representable functors.
+ HLint.hs view
@@ -0,0 +1,4 @@+import "hint" HLint.Default++ignore "Warning: Avoid lambda"+
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2011 Edward Kmett+Copyright 2011-2013 Edward Kmett All rights reserved.
adjunctions.cabal view
@@ -1,6 +1,6 @@ name: adjunctions category: Data Structures, Adjunctions-version: 3.2+version: 3.2.1 license: BSD3 cabal-version: >= 1.6 license-file: LICENSE@@ -9,7 +9,7 @@ stability: provisional homepage: http://github.com/ekmett/adjunctions/ bug-reports: http://github.com/ekmett/adjunctions/issues-copyright: Copyright (C) 2011 Edward A. Kmett+copyright: Copyright (C) 2011-2013 Edward A. Kmett synopsis: Adjunctions description: Adjunctions build-type: Simple@@ -18,6 +18,9 @@ .gitignore .travis.yml .vim.custom+ travis/cabal-apt-install+ travis/config+ HLint.hs CHANGELOG.markdown README.markdown
src/Control/Comonad/Trans/Adjoint.hs view
@@ -1,8 +1,11 @@-{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- |--- Module : Control.Comonad.Trans.Adjoint--- Copyright : (C) 2011 Edward Kmett+-- Copyright : (C) 2011-2013 Edward Kmett -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>
src/Control/Monad/Trans/Adjoint.hs view
@@ -1,8 +1,11 @@-{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- |--- Module : Control.Monad.Trans.Adjoint--- Copyright : (C) 2011 Edward Kmett+-- Copyright : (C) 2011-2013 Edward Kmett -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>
src/Control/Monad/Trans/Contravariant/Adjoint.hs view
@@ -1,4 +1,8 @@ {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Monad.Trans.Contravariant.Adjoint
src/Control/Monad/Trans/Conts.hs view
@@ -1,8 +1,11 @@ {-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif ----------------------------------------------------------------------------- -- |--- Module : Control.Monad.Trans.Conts--- Copyright : (C) 2011 Edward Kmett+-- Copyright : (C) 2011-2013 Edward Kmett -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>
src/Data/Functor/Adjunction.hs view
@@ -3,10 +3,14 @@ , FunctionalDependencies , UndecidableInstances #-} +{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif+ ------------------------------------------------------------------------------------------- -- |--- Module : Data.Functor.Adjunction--- Copyright : 2008-2011 Edward Kmett+-- Copyright : 2008-2013 Edward Kmett -- License : BSD -- -- Maintainer : Edward Kmett <ekmett@gmail.com>@@ -14,7 +18,7 @@ -- Portability : rank 2 types, MPTCs, fundeps -- --------------------------------------------------------------------------------------------module Data.Functor.Adjunction +module Data.Functor.Adjunction ( Adjunction(..) , tabulateAdjunction , indexAdjunction@@ -23,7 +27,7 @@ , unabsurdL, absurdL , cozipL, uncozipL , extractL, duplicateL- , splitL, unsplitL + , splitL, unsplitL ) where import Control.Applicative@@ -47,8 +51,8 @@ -- | An adjunction between Hask and Hask. ----- Minimal definition: both 'unit' and 'counit' or both 'leftAdjunct' --- and 'rightAdjunct', subject to the constraints imposed by the +-- Minimal definition: both 'unit' and 'counit' or both 'leftAdjunct'+-- and 'rightAdjunct', subject to the constraints imposed by the -- default definitions that the following laws should hold. -- -- > unit = leftAdjunct id@@ -56,13 +60,13 @@ -- > leftAdjunct f = fmap f . unit -- > rightAdjunct f = counit . fmap f ----- Any implementation is required to ensure that 'leftAdjunct' and --- 'rightAdjunct' witness an isomorphism from @Nat (f a, b)@ to +-- Any implementation is required to ensure that 'leftAdjunct' and+-- 'rightAdjunct' witness an isomorphism from @Nat (f a, b)@ to -- @Nat (a, g b)@ -- -- > rightAdjunct unit = id--- > leftAdjunct counit = id -class (Functor f, Representable u) => +-- > leftAdjunct counit = id+class (Functor f, Representable u) => Adjunction f u | f -> u, u -> f where unit :: a -> u (f a) counit :: f (u a) -> a@@ -74,17 +78,17 @@ leftAdjunct f = fmap f . unit rightAdjunct f = counit . fmap f --- | Every right adjoint is representable by its left adjoint +-- | Every right adjoint is representable by its left adjoint -- applied to a unit element--- --- Use this definition and the primitives in --- Data.Functor.Representable to meet the requirements of the +--+-- Use this definition and the primitives in+-- Data.Functor.Representable to meet the requirements of the -- superclasses of Representable. tabulateAdjunction :: Adjunction f u => (f () -> b) -> u b tabulateAdjunction f = leftAdjunct f () --- | This definition admits a default definition for the --- 'index' method of 'Index", one of the superclasses of +-- | This definition admits a default definition for the+-- 'index' method of 'Index", one of the superclasses of -- Representable. indexAdjunction :: Adjunction f u => u b -> f a -> b indexAdjunction = rightAdjunct . const@@ -104,7 +108,7 @@ duplicateL :: Adjunction f u => f a -> f (f a) duplicateL as = as <$ as --- | A right adjoint functor admits an intrinsic +-- | A right adjoint functor admits an intrinsic -- notion of zipping zipR :: Adjunction f u => (u a, u b) -> u (a, b) zipR = leftAdjunct (rightAdjunct fst &&& rightAdjunct snd)@@ -116,7 +120,7 @@ absurdL :: Void -> f Void absurdL = absurd --- | A left adjoint must be inhabited, or we can derive bottom. +-- | A left adjoint must be inhabited, or we can derive bottom. unabsurdL :: Adjunction f u => f Void -> Void unabsurdL = rightAdjunct absurd @@ -140,27 +144,27 @@ leftAdjunct f = Identity . f . Identity rightAdjunct f = runIdentity . f . runIdentity -instance Adjunction f g => +instance Adjunction f g => Adjunction (IdentityT f) (IdentityT g) where unit = IdentityT . leftAdjunct IdentityT counit = rightAdjunct runIdentityT . runIdentityT -instance Adjunction w m => +instance Adjunction w m => Adjunction (EnvT e w) (ReaderT e m) where unit = ReaderT . flip fmap EnvT . flip leftAdjunct counit (EnvT e w) = rightAdjunct (flip runReaderT e) w -instance Adjunction m w => +instance Adjunction m w => Adjunction (WriterT s m) (TracedT s w) where- unit = TracedT . leftAdjunct (\ma s -> WriterT (fmap (\a -> (a, s)) ma)) + unit = TracedT . leftAdjunct (\ma s -> WriterT (fmap (\a -> (a, s)) ma)) counit = rightAdjunct (\(t, s) -> ($s) <$> runTracedT t) . runWriterT -instance (Adjunction f g, Adjunction f' g') => +instance (Adjunction f g, Adjunction f' g') => Adjunction (Compose f' f) (Compose g g') where- unit = Compose . leftAdjunct (leftAdjunct Compose) + unit = Compose . leftAdjunct (leftAdjunct Compose) counit = rightAdjunct (rightAdjunct getCompose) . getCompose -instance (Adjunction f g, Adjunction f' g') => +instance (Adjunction f g, Adjunction f' g') => Adjunction (Coproduct f f') (Product g g') where unit a = Pair (leftAdjunct left a) (leftAdjunct right a) counit = coproduct (rightAdjunct fstP) (rightAdjunct sndP)@@ -168,7 +172,7 @@ fstP (Pair x _) = x sndP (Pair _ x) = x -instance Adjunction f u => +instance Adjunction f u => Adjunction (Free f) (Cofree u) where unit a = return a :< tabulateAdjunction (\k -> leftAdjunct (wrap . flip unsplitL k) a) counit (Pure a) = extract a
src/Data/Functor/Contravariant/Adjunction.hs view
@@ -1,4 +1,19 @@ {-# LANGUAGE Rank2Types, MultiParamTypeClasses, FunctionalDependencies, UndecidableInstances #-}+{-# LANGUAGE CPP #-}+#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE Trustworthy #-}+#endif+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) 2011-2013 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : MPTCs+--+----------------------------------------------------------------------------+ module Data.Functor.Contravariant.Adjunction ( Adjunction(..) , contrarepAdjunction
+ travis/cabal-apt-install view
@@ -0,0 +1,27 @@+#! /bin/bash+set -eu++APT="sudo apt-get -q -y"+CABAL_INSTALL_DEPS="cabal install --only-dependencies --force-reinstall"++$APT update+$APT install dctrl-tools++# Find potential system packages to satisfy cabal dependencies+deps()+{+ local M='^\([^ ]\+\)-[0-9.]\+ (.*$'+ local G=' -o ( -FPackage -X libghc-\L\1\E-dev )'+ local E="$($CABAL_INSTALL_DEPS "$@" --dry-run -v 2> /dev/null \+ | sed -ne "s/$M/$G/p" | sort -u)"+ grep-aptavail -n -sPackage \( -FNone -X None \) $E | sort -u+}++$APT install $(deps "$@") libghc-quickcheck2-dev # QuickCheck is special+$CABAL_INSTALL_DEPS "$@" # Install the rest via Hackage++if ! $APT install hlint ; then+ $APT install $(deps hlint)+ cabal install hlint+fi+
+ travis/config view
@@ -0,0 +1,16 @@+-- This provides a custom ~/.cabal/config file for use when hackage is down that should work on unix+--+-- This is particularly useful for travis-ci to get it to stop complaining+-- about a broken build when everything is still correct on our end.+--+-- This uses Luite Stegeman's mirror of hackage provided by his 'hdiff' site instead+--+-- To enable this, uncomment the before_script in .travis.yml++remote-repo: hdiff.luite.com:http://hdiff.luite.com/packages/archive+remote-repo-cache: ~/.cabal/packages+world-file: ~/.cabal/world+build-summary: ~/.cabal/logs/build.log+remote-build-reporting: anonymous+install-dirs user+install-dirs global