profunctors 5.2.2 → 5.3
raw patch · 19 files changed
+223/−234 lines, 19 filesdep ~basedep ~semigroupsdep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, semigroups, transformers
API changes (from Hackage documentation)
+ Data.Profunctor.Unsafe: instance (Data.Profunctor.Unsafe.Profunctor p, Data.Profunctor.Unsafe.Profunctor q) => Data.Profunctor.Unsafe.Profunctor (Data.Bifunctor.Sum.Sum p q)
- Data.Profunctor.Unsafe: (#.) :: (Profunctor p, Coercible c b) => (b -> c) -> p a b -> p a c
+ Data.Profunctor.Unsafe: (#.) :: forall a b c q. (Profunctor p, Coercible c b) => q b c -> p a b -> p a c
- Data.Profunctor.Unsafe: (.#) :: (Profunctor p, Coercible b a) => p b c -> (a -> b) -> p a c
+ Data.Profunctor.Unsafe: (.#) :: forall a b c q. (Profunctor p, Coercible b a) => p b c -> q a b -> p a c
Files
- .hlint.yaml +54/−0
- .travis.yml +37/−41
- CHANGELOG.markdown +18/−0
- HLint.hs +0/−1
- profunctors.cabal +15/−5
- src/Data/Profunctor.hs +0/−6
- src/Data/Profunctor/Cayley.hs +3/−6
- src/Data/Profunctor/Choice.hs +0/−7
- src/Data/Profunctor/Closed.hs +10/−7
- src/Data/Profunctor/Composition.hs +3/−7
- src/Data/Profunctor/Mapping.hs +10/−0
- src/Data/Profunctor/Ran.hs +3/−7
- src/Data/Profunctor/Rep.hs +2/−4
- src/Data/Profunctor/Sieve.hs +0/−3
- src/Data/Profunctor/Strong.hs +0/−8
- src/Data/Profunctor/Traversing.hs +0/−2
- src/Data/Profunctor/Types.hs +10/−27
- src/Data/Profunctor/Unsafe.hs +48/−71
- src/Data/Profunctor/Yoneda.hs +10/−32
+ .hlint.yaml view
@@ -0,0 +1,54 @@+- extensions:+ - default: false # all extension are banned by default+ - name:+ - CPP+ - DeriveFunctor+ - FlexibleContexts+ - FlexibleInstances+ - FunctionalDependencies+ - GADTs+ - InstanceSigs+ - MultiParamTypeClasses+ - RankNTypes+ - ScopedTypeVariables+ - Trustworthy+ - TypeOperators+ - TypeFamilies+ - UndecidableInstances++- functions:+ - {name: unsafeCoerce, within: []} # banned++- ignore:+ name: Use const+ within:+ - Data.Profunctor.Types++- ignore:+ name: Avoid lambda+ within:+ - Data.Profunctor.Choice+ - Data.Profunctor.Traversing++- ignore:+ name: Use fmap+ within:+ - Data.Profunctor.Composition+ - Data.Profunctor.Strong+ - Data.Profunctor.Unsafe++- ignore:+ name: Avoid lambda+ within: Data.Profunctor.Strong++- ignore:+ name: Redundant lambda+ within: Data.Profunctor.Unsafe++- ignore:+ name: Collapse lambdas+ within: Data.Profunctor.Unsafe++- fixity: "infixr 9 #."+- fixity: "infixl 8 .#"+- fixity: "infixr 0 :->"
.travis.yml view
@@ -1,6 +1,6 @@ # This Travis job script has been generated by a script via #-# runghc make_travis_yml_2.hs '-o' '.travis.yml' '--irc-channel=irc.freenode.org#haskell-lens' '--no-no-tests-no-bench' '--no-installed' 'cabal.project'+# runghc make_travis_yml_2.hs '-o' '.travis.yml' '--ghc-head' '--irc-channel=irc.freenode.org#haskell-lens' '--no-no-tests-no-bench' '--no-unconstrained' 'cabal.project' # # For more information, see https://github.com/hvr/multi-ghc-travis #@@ -34,58 +34,44 @@ - rm -rfv $HOME/.cabal/packages/head.hackage -addons:- apt:- packages: &apt_packages- - ghc-ppa-tools- - hlint- matrix: include:- - compiler: "ghc-7.0.4"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.0.4], sources: [hvr-ghc]}}- - compiler: "ghc-7.2.2"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.2.2], sources: [hvr-ghc]}}- - compiler: "ghc-7.4.2"+ - compiler: "ghc-8.6.1"+ env: GHCHEAD=true+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.6.1], sources: [hvr-ghc]}}+ - compiler: "ghc-8.4.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.4.2], sources: [hvr-ghc]}}- - compiler: "ghc-7.6.3"+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}+ - compiler: "ghc-8.2.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.6.3], sources: [hvr-ghc]}}- - compiler: "ghc-7.8.4"+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.2.2], sources: [hvr-ghc]}}+ - compiler: "ghc-8.0.2" # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.8.4], sources: [hvr-ghc]}}+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-8.0.2], sources: [hvr-ghc]}} - compiler: "ghc-7.10.3" # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.10.3], sources: [hvr-ghc]}}- - compiler: "ghc-8.0.2"- # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-8.0.2], sources: [hvr-ghc]}}- - compiler: "ghc-8.2.2"+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.10.3], sources: [hvr-ghc]}}+ - compiler: "ghc-7.8.4" # env: TEST=--disable-tests BENCH=--disable-benchmarks- addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-8.2.2], sources: [hvr-ghc]}}- - compiler: "ghc-8.4.1"- env: GHCHEAD=true- addons: {apt: {packages: [*apt_packages,cabal-install-head,ghc-8.4.1], sources: [hvr-ghc]}}+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.2,ghc-7.8.4], sources: [hvr-ghc]}} - compiler: "ghc-head" env: GHCHEAD=true- addons: {apt: {packages: [*apt_packages,cabal-install-head,ghc-head], sources: [hvr-ghc]}}+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}} allow_failures:- - compiler: "ghc-7.0.4"- - compiler: "ghc-7.2.2"- - compiler: "ghc-8.4.1" - compiler: "ghc-head"+ - compiler: "ghc-8.6.1" before_install: - HC=${CC} - HCPKG=${HC/ghc/ghc-pkg} - unset CC+ - export HLINTVER=2.1.3+ - mkdir ~/.hlint+ - curl -L https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz | tar -xz --strip-components=1 -C ~/.hlint - ROOTDIR=$(pwd) - mkdir -p $HOME/.local/bin- - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"+ - "PATH=~/.hlint:/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH" - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') )) - echo $HCNUMVER @@ -95,7 +81,8 @@ - BENCH=${BENCH---enable-benchmarks} - TEST=${TEST---enable-tests} - HADDOCK=${HADDOCK-true}- - INSTALLED=${INSTALLED-true}+ - UNCONSTRAINED=${UNCONSTRAINED-true}+ - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false} - GHCHEAD=${GHCHEAD-false} - travis_retry cabal update -v - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"@@ -103,7 +90,8 @@ # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage - | if $GHCHEAD; then- sed -i.bak 's/-- allow-newer:.*/allow-newer: *:base, *:template-haskell, *:ghc, *:Cabal/' ${HOME}/.cabal/config+ sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config+ for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done echo 'repository head.hackage' >> ${HOME}/.cabal/config echo ' url: http://head.hackage.haskell.org/' >> ${HOME}/.cabal/config@@ -113,17 +101,22 @@ echo ' 8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config echo ' key-threshold: 3' >> ${HOME}/.cabal.config + grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'+ cabal new-update head.hackage -v fi - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$' - "printf 'packages: \".\"\\n' > cabal.project"- - cat cabal.project+ - touch cabal.project.local+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"+ - cat cabal.project || true+ - cat cabal.project.local || true - if [ -f "./configure.ac" ]; then (cd "." && autoreconf -i); fi - rm -f cabal.project.freeze - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all- - rm -rf "."/.ghc.environment.* "."/dist+ - rm -rf .ghc.environment.* "."/dist - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) # Here starts the actual work to be performed for the package under test;@@ -135,8 +128,10 @@ - cd ${DISTDIR} || false - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; - "printf 'packages: profunctors-*/*.cabal\\n' > cabal.project"- - cat cabal.project-+ - touch cabal.project.local+ - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"+ - cat cabal.project || true+ - cat cabal.project.local || true # build & run tests, build benchmarks - cabal new-build -w ${HC} ${TEST} ${BENCH} all@@ -149,7 +144,8 @@ - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi # hlint- - (cd profunctors-* && hlint src --cpp-define=HLINT)+ - hlint --version+ - (cd profunctors-* && hlint src) -# REGENDATA ["-o",".travis.yml","--irc-channel=irc.freenode.org#haskell-lens","--no-no-tests-no-bench","--no-installed","cabal.project"]+# REGENDATA ["-o",".travis.yml","--ghc-head","--irc-channel=irc.freenode.org#haskell-lens","--no-no-tests-no-bench","--no-unconstrained","cabal.project"] # EOF
CHANGELOG.markdown view
@@ -1,3 +1,21 @@+5.3 [2018.07.02]+----------------+* Generalize the types of `(#.)` and `(.#)`. Before, they were:++ ```haskell+ (#.) :: (Profunctor p, Coercible c b) => (b -> c) -> p a b -> p a c+ (.#) :: (Profunctor p, Coercible b a) => p b c -> (a -> b) -> p a c+ ```++ Now, they are:++ ```haskell+ (#.) :: (Profunctor p, Coercible c b) => q b c -> p a b -> p a c+ (.#) :: (Profunctor p, Coercible b a) => p b c -> q a b -> p a c+ ```+* Drop support for GHC < 7.8.+* Add a `Profunctor` instance for `Data.Bifunctor.Sum`.+ 5.2.2 [2018.01.18] ------------------ * Add `Semigroup` instances for `Closure` and `Tambara`
− HLint.hs
@@ -1,1 +0,0 @@-ignore "use const"
profunctors.cabal view
@@ -1,6 +1,6 @@ name: profunctors category: Control, Categories-version: 5.2.2+version: 5.3 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -12,16 +12,21 @@ copyright: Copyright (C) 2011-2015 Edward A. Kmett synopsis: Profunctors description: Profunctors.-tested-with: GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.1+tested-with: GHC == 7.8.4+ , GHC == 7.10.3+ , GHC == 8.0.2+ , GHC == 8.2.2+ , GHC == 8.4.3+ , GHC == 8.6.1 build-type: Simple extra-source-files: .ghci .gitignore+ .hlint.yaml .travis.yml .vim.custom README.markdown CHANGELOG.markdown- HLint.hs source-repository head type: git@@ -29,8 +34,8 @@ library build-depends:- base >= 4 && < 5,- base-orphans >= 0.4 && < 0.7,+ base >= 4.7 && < 5,+ base-orphans >= 0.4 && < 0.9, bifunctors >= 5.2 && < 6, comonad >= 4 && < 6, contravariant >= 1 && < 2,@@ -58,6 +63,10 @@ Data.Profunctor.Yoneda ghc-options: -Wall -O2++ if impl(ghc>=8.0)+ ghc-options: -Wno-trustworthy-safe+ hs-source-dirs: src default-language: Haskell2010@@ -66,5 +75,6 @@ GADTs FlexibleContexts FlexibleInstances+ InstanceSigs UndecidableInstances TypeFamilies
src/Data/Profunctor.hs view
@@ -1,10 +1,6 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ < 708-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2011-2015 Edward Kmett,@@ -42,9 +38,7 @@ , Costar(..) , WrappedArrow(..) , Forget(..)-#ifndef HLINT , (:->)-#endif ) where import Data.Profunctor.Choice
src/Data/Profunctor/Cayley.hs view
@@ -1,8 +1,5 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE RankNTypes #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2014-2015 Edward Kmett@@ -72,7 +69,7 @@ right = Cayley . fmap right . runCayley Cayley ab +++ Cayley cd = Cayley $ liftA2 (+++) ab cd Cayley ac ||| Cayley bc = Cayley $ liftA2 (|||) ac bc- + instance (Applicative f, ArrowLoop p) => ArrowLoop (Cayley f p) where loop = Cayley . fmap loop . runCayley @@ -86,7 +83,7 @@ mapCayley f (Cayley g) = Cayley (f g) -- instance Adjunction f g => ProfunctorAdjunction (Cayley f) (Cayley g) where- + {- newtype Uncayley p a = Uncayley (p () a) @@ -107,7 +104,7 @@ -- only a true iso for Stronger p and q, no? _Smash :: (Strong p, Closed q) => Iso (Cayley (Uncayley p) (->) a b)- (Cayley (Uncayley q) (->) c d) + (Cayley (Uncayley q) (->) c d) (p a b) (q c d) _Smash = dimap hither (fmap yon) where
src/Data/Profunctor/Choice.hs view
@@ -3,9 +3,6 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2014-2015 Edward Kmett@@ -103,9 +100,7 @@ right' :: p a b -> p (Either c a) (Either c b) right' = dimap (either Right Left) (either Right Left) . left' -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708 {-# MINIMAL left' | right' #-}-#endif instance Choice (->) where left' ab (Left a) = Left (ab a)@@ -336,9 +331,7 @@ unright :: p (Either d a) (Either d b) -> p a b unright = unleft . dimap (either Right Left) (either Right Left) -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708 {-# MINIMAL unleft | unright #-}-#endif instance Cochoice (->) where unleft f = go . Left where go = either id (go . Right) . f
src/Data/Profunctor/Closed.hs view
@@ -1,16 +1,14 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-}+{-# LANGUAGE InstanceSigs #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-}--#if __GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 708+{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE Trustworthy #-}-#endif- ----------------------------------------------------------------------------- -- |--- Copyright : (C) 2014-2015 Edward Kmett+-- Copyright : (C) 2014-2018 Edward Kmett -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>@@ -33,6 +31,7 @@ import Control.Comonad import Data.Bifunctor.Product (Product(..)) import Data.Bifunctor.Tannen (Tannen(..))+import Data.Coerce (Coercible, coerce) import Data.Distributive import Data.Profunctor.Adjunction import Data.Profunctor.Monad@@ -105,8 +104,12 @@ dimap f g (Closure p) = Closure $ dimap (fmap f) (fmap g) p lmap f (Closure p) = Closure $ lmap (fmap f) p rmap f (Closure p) = Closure $ rmap (fmap f) p- w #. Closure p = Closure $ fmap w #. p- Closure p .# w = Closure $ p .# fmap w++ (#.) :: forall a b c q. Coercible c b => q b c -> Closure p a b -> Closure p a c+ _ #. Closure p = Closure $ fmap (coerce (id :: c -> c) :: b -> c) #. p++ (.#) :: forall a b c q. Coercible b a => Closure p b c -> q a b -> Closure p a c+ Closure p .# _ = Closure $ p .# fmap (coerce (id :: b -> b) :: a -> b) instance ProfunctorFunctor Closure where promap f (Closure p) = Closure (f p)
src/Data/Profunctor/Composition.hs view
@@ -1,13 +1,9 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Data.Profunctor.Composition@@ -86,9 +82,9 @@ rmap k (Procompose f g) = Procompose (rmap k f) g {-# INLINE lmap #-} k #. Procompose f g = Procompose (k #. f) g- {-# INLINE ( #. ) #-}+ {-# INLINE (#.) #-} Procompose f g .# k = Procompose f (g .# k)- {-# INLINE ( .# ) #-}+ {-# INLINE (.#) #-} instance Profunctor p => Functor (Procompose p q a) where fmap k (Procompose f g) = Procompose (rmap k f) g@@ -259,7 +255,7 @@ rmap bd f = Rift (runRift f . lmap bd) {-# INLINE rmap #-} bd #. f = Rift (\p -> runRift f (p .# bd))- {-# INLINE ( #. ) #-}+ {-# INLINE (#.) #-} f .# ca = Rift (\p -> runRift f p .# ca) {-# INLINE (.#) #-}
src/Data/Profunctor/Mapping.hs view
@@ -1,6 +1,16 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-}+-----------------------------------------------------------------------------+-- |+-- Copyright : (C) 2015-2018 Edward Kmett+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : experimental+-- Portability : portable+--+---------------------------------------------------------------------------- module Data.Profunctor.Mapping ( Mapping(..) , CofreeMapping(..)
src/Data/Profunctor/Ran.hs view
@@ -1,10 +1,6 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE Rank2Types #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2013-2015 Edward Kmett and Dan Doel@@ -54,7 +50,7 @@ rmap bd f = Ran (rmap bd . runRan f) {-# INLINE rmap #-} bd #. f = Ran (\p -> bd #. runRan f p)- {-# INLINE ( #. ) #-}+ {-# INLINE (#.) #-} f .# ca = Ran (\p -> runRan f (ca #. p)) {-# INLINE (.#) #-} @@ -103,7 +99,7 @@ rmap bd f = Codensity (rmap bd . runCodensity f) {-# INLINE rmap #-} bd #. f = Codensity (\p -> bd #. runCodensity f p)- {-# INLINE ( #. ) #-}+ {-# INLINE (#.) #-} f .# ca = Codensity (\p -> runCodensity f (ca #. p)) {-# INLINE (.#) #-}
src/Data/Profunctor/Rep.hs view
@@ -6,9 +6,6 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Data.Profunctor.Rep@@ -48,6 +45,7 @@ import Control.Applicative import Control.Arrow import Control.Comonad+import Control.Monad ((>=>)) import Data.Functor.Identity import Data.Profunctor import Data.Profunctor.Sieve@@ -193,7 +191,7 @@ instance (Monad (Rep p), Representable p) => Monad (Prep p) where return a = Prep () $ tabulate $ const $ return a- Prep xa pa >>= f = Prep xa $ tabulate $ \xa' -> sieve pa xa' >>= \a -> case f a of+ Prep xa pa >>= f = Prep xa $ tabulate $ sieve pa >=> \a -> case f a of Prep xb pb -> sieve pb xb prepAdj :: (forall a. Prep p a -> g a) -> p :-> Star g
src/Data/Profunctor/Sieve.hs view
@@ -3,10 +3,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2015 Edward Kmett
src/Data/Profunctor/Strong.hs view
@@ -4,10 +4,6 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-} -#if __GLASGOW_HASKELL__ >= 704 && __GLASGOW_HASKELL__ < 708-{-# LANGUAGE Trustworthy #-}-#endif- ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2014-2015 Edward Kmett@@ -93,9 +89,7 @@ second' :: p a b -> p (c, a) (c, b) second' = dimap swap swap . first' -#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL first' | second' #-}-#endif uncurry' :: Strong p => p a (b -> c) -> p (a, b) c uncurry' = rmap (\(f,x) -> f x) . first'@@ -345,9 +339,7 @@ unsecond :: p (d, a) (d, b) -> p a b unsecond = unfirst . dimap swap swap -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708 {-# MINIMAL unfirst | unsecond #-}-#endif instance Costrong (->) where unfirst f a = b where (b, d) = f (a, d)
src/Data/Profunctor/Traversing.hs view
@@ -118,9 +118,7 @@ wander :: (forall f. Applicative f => (a -> f b) -> s -> f t) -> p a b -> p s t wander f pab = dimap (\s -> Baz $ \afb -> f afb s) sold (traverse' pab) -#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL wander | traverse' #-}-#endif instance Traversing (->) where traverse' = fmap
src/Data/Profunctor/Types.hs view
@@ -3,9 +3,7 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- |@@ -30,28 +28,21 @@ , Costar(..) , WrappedArrow(..) , Forget(..)-#ifndef HLINT , (:->)-#endif ) where import Control.Applicative hiding (WrappedArrow(..)) import Control.Arrow import Control.Category import Control.Comonad-import Control.Monad (MonadPlus(..))+import Control.Monad (MonadPlus(..), (>=>))+import Data.Coerce (Coercible, coerce) import Data.Distributive import Data.Foldable import Data.Monoid hiding (Product) import Data.Profunctor.Unsafe import Data.Traversable-import Prelude hiding (id,(.),sequence)--#if __GLASGOW_HASKELL__ >= 708-import Data.Coerce-#else-import Unsafe.Coerce-#endif+import Prelude hiding (id,(.)) infixr 0 :-> type p :-> q = forall a b. p a b -> q a b@@ -70,13 +61,9 @@ {-# INLINE lmap #-} rmap k (Star f) = Star (fmap k . f) {-# INLINE rmap #-}- -- We cannot safely overload ( #. ) because we didn't write the 'Functor'.-#if __GLASGOW_HASKELL__ >= 708+ -- We cannot safely overload (#.) because we didn't write the 'Functor'. p .# _ = coerce p-#else- p .# _ = unsafeCoerce p-#endif- {-# INLINE ( .# ) #-}+ {-# INLINE (.#) #-} instance Functor f => Functor (Star f a) where fmap = rmap@@ -109,7 +96,7 @@ instance Monad f => Category (Star f) where id = Star return- Star f . Star g = Star $ \a -> g a >>= f+ Star f . Star g = Star $ g >=> f ------------------------------------------------------------------------------ -- Costar@@ -125,13 +112,9 @@ {-# INLINE lmap #-} rmap k (Costar f) = Costar (k . f) {-# INLINE rmap #-}-#if __GLASGOW_HASKELL__ >= 708- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b-#else- ( #. ) _ = unsafeCoerce-#endif- {-# INLINE ( #. ) #-}- -- We cannot overload ( .# ) because we didn't write the 'Functor'.+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ {-# INLINE (#.) #-}+ -- We cannot overload (.#) because we didn't write the 'Functor'. instance Distributive (Costar f d) where distribute fs = Costar $ \gd -> fmap (($ gd) .# runCostar) fs@@ -204,7 +187,7 @@ {-# INLINE lmap #-} rmap = (^<<) {-# INLINE rmap #-}- -- We cannot safely overload ( #. ) or ( .# ) because we didn't write the 'Arrow'.+ -- We cannot safely overload (#.) or (.#) because we didn't write the 'Arrow'. ------------------------------------------------------------------------------ -- Forget
src/Data/Profunctor/Unsafe.hs view
@@ -1,13 +1,9 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 708 {-# LANGUAGE Trustworthy #-}-#elif __GLASGOW_HASKELL >= 704-{-# LANGUAGE Unsafe #-}-#endif {-# LANGUAGE ScopedTypeVariables #-} ----------------------------------------------------------------------------- -- |--- Copyright : (C) 2011-2015 Edward Kmett+-- Copyright : (C) 2011-2018 Edward Kmett -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>@@ -42,24 +38,15 @@ import Data.Bifunctor.Clown (Clown(..)) import Data.Bifunctor.Joker (Joker(..)) import Data.Bifunctor.Product (Product(..))+import Data.Bifunctor.Sum (Sum(..)) import Data.Bifunctor.Tannen (Tannen(..))+import Data.Coerce (Coercible, coerce) #if __GLASGOW_HASKELL__ < 710 import Data.Functor #endif import Data.Functor.Contravariant (Contravariant(..)) import Data.Tagged-import Prelude hiding (id,(.),sequence)--#if __GLASGOW_HASKELL__ >= 708-import Data.Coerce-#else-import Unsafe.Coerce-#endif--#ifdef HLINT-{-# ANN module "Hlint: ignore Redundant lambda" #-}-{-# ANN module "Hlint: ignore Collapse lambdas" #-}-#endif+import Prelude hiding (id,(.)) infixr 9 #. infixl 8 .#@@ -145,14 +132,10 @@ -- The semantics of this function with respect to bottoms -- should match the default definition: --- -- @('Profuctor.Unsafe.#.') ≡ \\f -> \\p -> p \`seq\` 'rmap' f p@-#if __GLASGOW_HASKELL__ >= 708- ( #. ) :: Coercible c b => (b -> c) -> p a b -> p a c-#else- ( #. ) :: (b -> c) -> p a b -> p a c-#endif- ( #. ) = \f -> \p -> p `seq` rmap f p- {-# INLINE ( #. ) #-}+ -- @('Profuctor.Unsafe.#.') ≡ \\_ -> \\p -> p \`seq\` 'rmap' 'coerce' p@+ (#.) :: forall a b c q. Coercible c b => q b c -> p a b -> p a c+ (#.) = \_ -> \p -> p `seq` rmap (coerce (id :: c -> c) :: b -> c) p+ {-# INLINE (#.) #-} -- | Strictly map the first argument argument -- contravariantly with a function that is assumed@@ -175,18 +158,12 @@ -- will only call this with a second argument that is -- operationally identity. --- -- @('.#') ≡ \\p -> p \`seq\` \\f -> 'lmap' f p@-#if __GLASGOW_HASKELL__ >= 708- ( .# ) :: Coercible b a => p b c -> (a -> b) -> p a c-#else- ( .# ) :: p b c -> (a -> b) -> p a c-#endif- ( .# ) = \p -> p `seq` \f -> lmap f p- {-# INLINE ( .# ) #-}+ -- @('.#') ≡ \\p -> p \`seq\` \\f -> 'lmap' 'coerce' p@+ (.#) :: forall a b c q. Coercible b a => p b c -> q a b -> p a c+ (.#) = \p -> p `seq` \_ -> lmap (coerce (id :: b -> b) :: a -> b) p+ {-# INLINE (.#) #-} -#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL dimap | (lmap, rmap) #-}-#endif instance Profunctor (->) where dimap ab cd bc = cd . bc . ab@@ -195,15 +172,10 @@ {-# INLINE lmap #-} rmap = (.) {-# INLINE rmap #-}-#if __GLASGOW_HASKELL__ >= 708- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b- ( .# ) pbc _ = coerce pbc-#else- ( #. ) _ = unsafeCoerce- ( .# ) pbc _ = unsafeCoerce pbc-#endif- {-# INLINE ( #. ) #-}- {-# INLINE ( .# ) #-}+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ (.#) pbc _ = coerce pbc+ {-# INLINE (#.) #-}+ {-# INLINE (.#) #-} instance Profunctor Tagged where dimap _ f (Tagged s) = Tagged (f s)@@ -212,14 +184,10 @@ {-# INLINE lmap #-} rmap = fmap {-# INLINE rmap #-}-#if __GLASGOW_HASKELL__ >= 708- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b-#else- ( #. ) _ = unsafeCoerce-#endif- {-# INLINE ( #. ) #-}+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ {-# INLINE (#.) #-} Tagged s .# _ = Tagged s- {-# INLINE ( .# ) #-}+ {-# INLINE (.#) #-} instance Monad m => Profunctor (Kleisli m) where dimap f g (Kleisli h) = Kleisli (liftM g . h . f)@@ -229,12 +197,8 @@ rmap k (Kleisli f) = Kleisli (liftM k . f) {-# INLINE rmap #-} -- We cannot safely overload (#.) because we didn't provide the 'Monad'.-#if __GLASGOW_HASKELL__ >= 708- ( .# ) pbc _ = coerce pbc-#else- ( .# ) pbc _ = unsafeCoerce pbc-#endif- {-# INLINE ( .# ) #-}+ (.#) pbc _ = coerce pbc+ {-# INLINE (.#) #-} instance Functor w => Profunctor (Cokleisli w) where dimap f g (Cokleisli h) = Cokleisli (g . h . fmap f)@@ -244,12 +208,8 @@ rmap k (Cokleisli f) = Cokleisli (k . f) {-# INLINE rmap #-} -- We cannot safely overload (.#) because we didn't provide the 'Functor'.-#if __GLASGOW_HASKELL__ >= 708- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b-#else- ( #. ) _ = unsafeCoerce-#endif- {-# INLINE ( #. ) #-}+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ {-# INLINE (#.) #-} instance Contravariant f => Profunctor (Clown f) where lmap f (Clown fa) = Clown (contramap f fa)@@ -279,11 +239,28 @@ {-# INLINE rmap #-} dimap f g (Pair p q) = Pair (dimap f g p) (dimap f g q) {-# INLINE dimap #-}- ( #. ) f (Pair p q) = Pair (f #. p) (f #. q)- {-# INLINE ( #. ) #-}- ( .# ) (Pair p q) f = Pair (p .# f) (q .# f)- {-# INLINE ( .# ) #-}+ (#.) f (Pair p q) = Pair (f #. p) (f #. q)+ {-# INLINE (#.) #-}+ (.#) (Pair p q) f = Pair (p .# f) (q .# f)+ {-# INLINE (.#) #-} +instance (Profunctor p, Profunctor q) => Profunctor (Sum p q) where+ lmap f (L2 x) = L2 (lmap f x)+ lmap f (R2 y) = R2 (lmap f y)+ {-# INLINE lmap #-}+ rmap g (L2 x) = L2 (rmap g x)+ rmap g (R2 y) = R2 (rmap g y)+ {-# INLINE rmap #-}+ dimap f g (L2 x) = L2 (dimap f g x)+ dimap f g (R2 y) = R2 (dimap f g y)+ {-# INLINE dimap #-}+ f #. L2 x = L2 (f #. x)+ f #. R2 y = R2 (f #. y)+ {-# INLINE (#.) #-}+ L2 x .# f = L2 (x .# f)+ R2 y .# f = R2 (y .# f)+ {-# INLINE (.#) #-}+ instance (Functor f, Profunctor p) => Profunctor (Tannen f p) where lmap f (Tannen h) = Tannen (lmap f <$> h) {-# INLINE lmap #-}@@ -291,7 +268,7 @@ {-# INLINE rmap #-} dimap f g (Tannen h) = Tannen (dimap f g <$> h) {-# INLINE dimap #-}- ( #. ) f (Tannen h) = Tannen ((f #.) <$> h)- {-# INLINE ( #. ) #-}- ( .# ) (Tannen h) f = Tannen ((.# f) <$> h)- {-# INLINE ( .# ) #-}+ (#.) f (Tannen h) = Tannen ((f #.) <$> h)+ {-# INLINE (#.) #-}+ (.#) (Tannen h) f = Tannen ((.# f) <$> h)+ {-# INLINE (.#) #-}
src/Data/Profunctor/Yoneda.hs view
@@ -1,12 +1,9 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-}-{-# LANGUAGE Rank2Types #-}+{-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 702 && __GLASGOW_HASKELL__ <= 708 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright : (C) 2017 Edward Kmett@@ -23,18 +20,13 @@ ) where import Control.Category+import Data.Coerce (Coercible, coerce) import Data.Profunctor import Data.Profunctor.Monad import Data.Profunctor.Traversing import Data.Profunctor.Unsafe import Prelude hiding (id,(.)) -#if __GLASGOW_HASKELL__ >= 708-import Data.Coerce-#else-import Unsafe.Coerce-#endif- -------------------------------------------------------------------------------- -- * Yoneda --------------------------------------------------------------------------------@@ -68,17 +60,10 @@ {-# INLINE lmap #-} rmap r p = Yoneda $ \l r' -> runYoneda p l (r' . r) {-# INLINE rmap #-}-#if __GLASGOW_HASKELL__ >= 708- ( .# ) p _ = coerce p- {-# INLINE ( .# ) #-}- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b- {-# INLINE ( #. ) #-}-#else- ( .# ) p _ = unsafeCoerce p- {-# INLINE ( .# ) #-}- ( #. ) _ = unsafeCoerce- {-# INLINE ( #. ) #-}-#endif+ (.#) p _ = coerce p+ {-# INLINE (.#) #-}+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ {-# INLINE (#.) #-} instance Functor (Yoneda p a) where fmap f p = Yoneda $ \l r -> runYoneda p l (r . f)@@ -178,17 +163,10 @@ {-# INLINE lmap #-} rmap r (Coyoneda l r' p) = Coyoneda l (r . r') p {-# INLINE rmap #-}-#if __GLASGOW_HASKELL__ >= 708- ( .# ) p _ = coerce p- {-# INLINE ( .# ) #-}- ( #. ) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b- {-# INLINE ( #. ) #-}-#else- ( .# ) p _ = unsafeCoerce p- {-# INLINE ( .# ) #-}- ( #. ) _ = unsafeCoerce- {-# INLINE ( #. ) #-}-#endif+ (.#) p _ = coerce p+ {-# INLINE (.#) #-}+ (#.) _ = coerce (\x -> x :: b) :: forall a b. Coercible b a => a -> b+ {-# INLINE (#.) #-} instance ProfunctorFunctor Coyoneda where promap f (Coyoneda l r p) = Coyoneda l r (f p)