comonad 4.3 → 5.0.10
raw patch · 26 files changed
Files
- .ghci +0/−1
- .gitignore +19/−0
- .hlint.yaml +4/−0
- .travis.yml +0/−48
- CHANGELOG.markdown +55/−3
- HLint.hs +0/−4
- README.markdown +17/−16
- Setup.lhs +2/−51
- comonad.cabal +38/−45
- examples/History.hs +3/−2
- src/Control/Comonad.hs +15/−48
- src/Control/Comonad/Env.hs +0/−5
- src/Control/Comonad/Env/Class.hs +0/−7
- src/Control/Comonad/Hoist/Class.hs +1/−0
- src/Control/Comonad/Identity.hs +0/−5
- src/Control/Comonad/Store.hs +0/−5
- src/Control/Comonad/Store/Class.hs +0/−6
- src/Control/Comonad/Traced.hs +0/−5
- src/Control/Comonad/Traced/Class.hs +0/−6
- src/Control/Comonad/Trans/Class.hs +0/−5
- src/Control/Comonad/Trans/Env.hs +10/−46
- src/Control/Comonad/Trans/Identity.hs +0/−5
- src/Control/Comonad/Trans/Store.hs +5/−36
- src/Control/Comonad/Trans/Traced.hs +13/−42
- src/Data/Functor/Composition.hs +1/−0
- tests/doctests.hsc +0/−76
− .ghci
@@ -1,1 +0,0 @@-:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
.gitignore view
@@ -1,4 +1,5 @@ dist+dist-* docs wiki TAGS@@ -11,3 +12,21 @@ *.hi *~ *#+.stack-work/+cabal-dev+*.chi+*.chs.h+*.dyn_o+*.dyn_hi+.hpc+.hsenv+.cabal-sandbox/+cabal.sandbox.config+*.prof+*.aux+*.hp+*.eventlog+cabal.project.local+cabal.project.local~+.HTF/+.ghc.environment.*
+ .hlint.yaml view
@@ -0,0 +1,4 @@+- arguments: [--cpp-define=HLINT, --cpp-ansi]++- ignore: {name: Eta reduce}+- ignore: {name: Use import/export shortcut}
− .travis.yml
@@ -1,48 +0,0 @@-env:- - GHCVER=7.0.1 CABALVER=1.16- - GHCVER=7.0.4 CABALVER=1.16- - GHCVER=7.2.2 CABALVER=1.16- - GHCVER=7.4.2 CABALVER=1.16- - GHCVER=7.6.3 CABALVER=1.16- - GHCVER=7.8.4 CABALVER=1.18- - GHCVER=7.10.2 CABALVER=1.22- - GHCVER=head CABALVER=1.22--matrix:- allow_failures:- - env: GHCVER=7.0.1 CABALVER=1.16- - env: GHCVER=7.0.4 CABALVER=1.16- - env: GHCVER=7.2.2 CABALVER=1.16- - env: GHCVER=head CABALVER=1.22--before_install:- - travis_retry sudo add-apt-repository -y ppa:hvr/ghc- - travis_retry sudo apt-get update- - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - cabal --version--install:- - travis_retry cabal update- - cabal install --enable-tests --only-dependencies--script:- - cabal configure -v2 --enable-tests- - cabal build- - cabal sdist- - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;- cd dist/;- if [ -f "$SRC_TGZ" ]; then- cabal install "$SRC_TGZ";- else- echo "expected '$SRC_TGZ' not found";- exit 1;- fi--notifications:- irc:- channels:- - "irc.freenode.org#haskell-lens"- skip_join: true- template:- - "\x0313comonad\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"
CHANGELOG.markdown view
@@ -1,10 +1,62 @@-4.3--------+5.0.10 [2026.01.10]+-------------------+* Support building with MicroHs.+* Remove unused `transformers-compat` dependency.++5.0.9 [2024.12.04]+------------------+* Drop support for pre-8.0 versions of GHC.++5.0.8 [2020.12.30]+-----------------+* Explicitly mark modules as Safe or Trustworthy+* The build-type has been changed from `Custom` to `Simple`.+ To achieve this, the `doctests` test suite has been removed in favor of using [`cabal-docspec`](https://github.com/phadej/cabal-extras/tree/master/cabal-docspec) to run the doctests.++5.0.7 [2020.12.15]+------------------+* Move `FunctorWithIndex (TracedT m w)` instance from `lens`.+ This instance depends on the `indexed-traversable` package. This can be disabled using the flag of the same name.++5.0.6 [2019.11.26]+------------------+* Achieve forward compatibility with+ [GHC proposal 229](https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0229-whitespace-bang-patterns.rst).++5.0.5 [2019.05.02]+------------------+* Raised the minimum `semigroups` version to 0.16.2. In addition, the+ package will only be required at all for GHCs before 8.0.+* Drop the `contravariant` flag from `comonad.cabal`, as `comonad` no longer+ depends on the `contravariant` library.++5.0.4 [2018.07.01]+------------------+* Add `Comonad` instances for `Tagged s` with `s` of any kind. Before the+ change, `s` had to be of kind `*`.+* Allow `containers-0.6`.++5.0.3 [2018.02.06]+------------------+* Don't enable `Safe` on GHC 7.2.++5.0.2+-----+* Support `doctest-0.12`++5.0.1+-----+* Revamp `Setup.hs` to use `cabal-doctest`. This makes it build+ with `Cabal-1.25`, and makes the `doctest`s work with `cabal new-build` and+ sandboxes.++5+- * Removed module `Data.Functor.Coproduct` in favor of the `transformers` package's `Data.Functor.Sum`. n.b. Compatibility with older versions of `transformers` is possible using `transformers-compat`.- * Add `Comonad` instance for `Data.Functor.Sum.Sum`+* GHC 8 compatibility 4.2.7.2 -------
− HLint.hs
@@ -1,4 +0,0 @@-import "hint" HLint.HLint--ignore "Eta reduce"-ignore "Use import/export shortcut"
README.markdown view
@@ -1,9 +1,10 @@ comonad ======= -[](https://hackage.haskell.org/package/comonad) [](http://travis-ci.org/ekmett/comonad)+[](https://github.com/ekmett/comonad/actions?query=workflow%3AHaskell-CI) -This package provides comonads, the categorical dual of monads.+This package provides comonads, the categorical dual of monads. The typeclass+provides three methods: `extract`, `duplicate`, and `extend`. class Functor w => Comonad w where extract :: w a -> a@@ -12,42 +13,42 @@ There are two ways to define a comonad: -I. Provide definitions for 'extract' and 'extend' satisfying these laws:+I. Provide definitions for `extract` and `extend` satisfying these laws: extend extract = id extract . extend f = f extend f . extend g = extend (f . extend g) -In this case, you may simply set 'fmap' = 'liftW'.+In this case, you may simply set `fmap` = `liftW`. -These laws are directly analogous to the laws for monads-and perhaps can be made clearer by viewing them as laws stating-that Cokleisli composition must be associative, and has extract for-a unit:+These laws are directly analogous to the [laws for+monads](https://wiki.haskell.org/Monad_laws). The comonad laws can+perhaps be made clearer by viewing them as stating that Cokleisli composition+must be a) associative and b) have `extract` for a unit: f =>= extract = f extract =>= f = f (f =>= g) =>= h = f =>= (g =>= h) -II. Alternately, you may choose to provide definitions for 'fmap',-'extract', and 'duplicate' satisfying these laws:+II. Alternately, you may choose to provide definitions for `fmap`,+`extract`, and `duplicate` satisfying these laws: extract . duplicate = id fmap extract . duplicate = id duplicate . duplicate = fmap duplicate . duplicate -In this case you may not rely on the ability to define 'fmap' in-terms of 'liftW'.+In this case, you may not rely on the ability to define `fmap` in+terms of `liftW`. -You may of course, choose to define both 'duplicate' /and/ 'extend'.-In that case you must also satisfy these laws:+You may, of course, choose to define both `duplicate` _and_ `extend`.+In that case, you must also satisfy these laws: extend f = fmap f . duplicate duplicate = extend id fmap f = extend (f . extract) -These are the default definitions of 'extend' and'duplicate' and-the definition of 'liftW' respectively.+These implementations are the default definitions of `extend` and`duplicate` and+the definition of `liftW` respectively. Contact Information -------------------
Setup.lhs view
@@ -1,55 +1,6 @@-#!/usr/bin/runhaskell \begin{code}-{-# OPTIONS_GHC -Wall #-} module Main (main) where--import Data.List ( nub )-import Data.Version ( showVersion )-import Distribution.Package ( PackageName(PackageName), Package, PackageId, InstalledPackageId, packageVersion, packageName )-import Distribution.PackageDescription ( PackageDescription(), TestSuite(..) )-import Distribution.Simple ( defaultMainWithHooks, UserHooks(..), simpleUserHooks )-import Distribution.Simple.Utils ( rewriteFile, createDirectoryIfMissingVerbose, copyFiles )-import Distribution.Simple.BuildPaths ( autogenModulesDir )-import Distribution.Simple.Setup ( BuildFlags(buildVerbosity), Flag(..), fromFlag, HaddockFlags(haddockDistPref))-import Distribution.Simple.LocalBuildInfo ( withLibLBI, withTestLBI, LocalBuildInfo(), ComponentLocalBuildInfo(componentPackageDeps) )-import Distribution.Text ( display )-import Distribution.Verbosity ( Verbosity, normal )-import System.FilePath ( (</>) )-+import Distribution.Simple (defaultMain) main :: IO ()-main = defaultMainWithHooks simpleUserHooks- { buildHook = \pkg lbi hooks flags -> do- generateBuildModule (fromFlag (buildVerbosity flags)) pkg lbi- buildHook simpleUserHooks pkg lbi hooks flags- , postHaddock = \args flags pkg lbi -> do- copyFiles normal (haddockOutputDir flags pkg) []- postHaddock simpleUserHooks args flags pkg lbi- }--haddockOutputDir :: Package p => HaddockFlags -> p -> FilePath-haddockOutputDir flags pkg = destDir where- baseDir = case haddockDistPref flags of- NoFlag -> "."- Flag x -> x- destDir = baseDir </> "doc" </> "html" </> display (packageName pkg)--generateBuildModule :: Verbosity -> PackageDescription -> LocalBuildInfo -> IO ()-generateBuildModule verbosity pkg lbi = do- let dir = autogenModulesDir lbi- createDirectoryIfMissingVerbose verbosity True dir- withLibLBI pkg lbi $ \_ libcfg -> do- withTestLBI pkg lbi $ \suite suitecfg -> do- rewriteFile (dir </> "Build_" ++ testName suite ++ ".hs") $ unlines- [ "module Build_" ++ testName suite ++ " where"- , "deps :: [String]"- , "deps = " ++ (show $ formatdeps (testDeps libcfg suitecfg))- ]- where- formatdeps = map (formatone . snd)- formatone p = case packageName p of- PackageName n -> n ++ "-" ++ showVersion (packageVersion p)--testDeps :: ComponentLocalBuildInfo -> ComponentLocalBuildInfo -> [(InstalledPackageId, PackageId)]-testDeps xs ys = nub $ componentPackageDeps xs ++ componentPackageDeps ys-+main = defaultMain \end{code}
comonad.cabal view
@@ -1,6 +1,6 @@ name: comonad category: Control, Comonads-version: 4.3+version: 5.0.10 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -12,25 +12,31 @@ copyright: Copyright (C) 2008-2014 Edward A. Kmett, Copyright (C) 2004-2008 Dave Menendez synopsis: Comonads-description: Comonads-build-type: Custom-tested-with: GHC==7.0.1, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2+description: Comonads.+build-type: Simple+tested-with: GHC == 8.0.2+ , GHC == 8.2.2+ , GHC == 8.4.4+ , GHC == 8.6.5+ , GHC == 8.8.4+ , GHC == 8.10.7+ , GHC == 9.0.2+ , GHC == 9.2.8+ , GHC == 9.4.8+ , GHC == 9.6.7+ , GHC == 9.8.4+ , GHC == 9.10.3+ , GHC == 9.12.2+ , GHC == 9.14.1 extra-source-files:- .ghci .gitignore- .travis.yml+ .hlint.yaml .vim.custom coq/Store.v README.markdown CHANGELOG.markdown examples/History.hs- HLint.hs --- You can disable the doctests test suite with -f-test-doctests-flag test-doctests- default: True- manual: True- flag containers description: You can disable the use of the `containers` package using `-f-containers`.@@ -39,24 +45,24 @@ default: True manual: True -flag contravariant+flag distributive description:- You can disable the use of the `contravariant` package using `-f-contravariant`.+ You can disable the use of the `distributive` package using `-f-distributive`. . Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users. .- If disabled we will not supply instances of `Contravariant`+ If disabled we will not supply instances of `Distributive` . default: True manual: True -flag distributive+flag indexed-traversable description:- You can disable the use of the `distributive` package using `-f-distributive`.+ You can disable the use of the `indexed-traversable` package using `-f-indexed-traversable`. . Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users. .- If disabled we will not supply instances of `Distributive`+ If disabled we will not supply instances of `FunctorWithIndex` . default: True manual: True@@ -64,7 +70,7 @@ source-repository head type: git- location: git://github.com/ekmett/comonad.git+ location: https://github.com/ekmett/comonad.git library hs-source-dirs: src@@ -72,21 +78,24 @@ ghc-options: -Wall build-depends:- base >= 4 && < 5,- semigroups >= 0.8.3.1 && < 1,- tagged >= 0.1 && < 1,- transformers >= 0.2 && < 0.6,- transformers-compat >= 0.3 && < 1+ base >= 4.9 && < 5,+ tagged >= 0.8.6.1 && < 1,+ transformers >= 0.5 && < 0.7 if flag(containers)- build-depends: containers >= 0.3 && < 0.6-- if flag(contravariant)- build-depends: contravariant >= 0.2.0.1 && < 2+ build-depends: containers >= 0.3 && < 0.9 if flag(distributive)- build-depends: distributive >= 0.2.2 && < 1 + build-depends: distributive >= 0.5.2 && < 1 + if flag(indexed-traversable)+ build-depends: indexed-traversable >= 0.1.1 && < 0.2++ if impl(ghc >= 9.0)+ -- these flags may abort compilation with GHC-8.10+ -- https://gitlab.haskell.org/ghc/ghc/-/merge_requests/3295+ ghc-options: -Winferred-safe-imports -Wmissing-safe-haskell-mode+ exposed-modules: Control.Comonad Control.Comonad.Env@@ -111,19 +120,3 @@ FunctionalDependencies FlexibleInstances UndecidableInstances--test-suite doctests- type: exitcode-stdio-1.0- default-language: Haskell2010- main-is: doctests.hs- ghc-options: -Wall -threaded- hs-source-dirs: tests-- if !flag(test-doctests)- buildable: False- else- build-depends:- base,- directory >= 1.0,- doctest >= 0.9.10,- filepath
examples/History.hs view
@@ -2,12 +2,13 @@ {-# OPTIONS_GHC -Wall #-} -- http://www.mail-archive.com/haskell@haskell.org/msg17244.html+module History where -import Prelude hiding (id,(.),sum) import Control.Category import Control.Comonad import Data.Foldable hiding (sum) import Data.Traversable+import Prelude hiding (id,(.),sum) infixl 4 :> @@ -51,7 +52,7 @@ ini dx = extract dx `fby` extend ini dx fibo :: Num b => History a -> b-fibo d = wfix $ d $> fby 0 . extend (\dfibo -> extract dfibo + fby 1 dfibo) +fibo d = wfix $ d $> fby 0 . extend (\dfibo -> extract dfibo + fby 1 dfibo) fibo' :: Num b => History a -> b fibo' d = fst $ wfix $ d $> fby (0, 1) . fmap (\(x, x') -> (x',x+x'))
src/Control/Comonad.hs view
@@ -1,9 +1,8 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 707-{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving, Safe, DefaultSignatures #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy, DefaultSignatures #-}-#endif+{-# LANGUAGE DefaultSignatures #-}+{-# LANGUAGE Safe #-}+{-# LANGUAGE StandaloneDeriving #-}+{-# LANGUAGE PolyKinds #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad@@ -46,11 +45,6 @@ import Control.Arrow import Control.Category import Control.Monad (ap)-#if MIN_VERSION_base(4,7,0)--- Control.Monad.Instances is empty-#else-import Control.Monad.Instances-#endif import Control.Monad.Trans.Identity import Data.Functor.Identity import qualified Data.Functor.Sum as FSum@@ -59,7 +53,6 @@ import Data.Tagged import Prelude hiding (id, (.)) import Control.Monad.Fix-import Data.Typeable #ifdef MIN_VERSION_containers import Data.Tree@@ -143,9 +136,7 @@ extend :: (w a -> b) -> w a -> w b extend f = fmap f . duplicate -#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL extract, (duplicate | extend) #-}-#endif instance Comonad ((,)e) where@@ -154,7 +145,6 @@ extract = snd {-# INLINE extract #-} -#if MIN_VERSION_semigroups(0,16,2) instance Comonad (Arg e) where duplicate w@(Arg a _) = Arg a w {-# INLINE duplicate #-}@@ -162,7 +152,6 @@ {-# INLINE extend #-} extract (Arg _ b) = b {-# INLINE extract #-}-#endif instance Monoid m => Comonad ((->)m) where duplicate f m = f . mappend m@@ -176,6 +165,13 @@ extract = runIdentity {-# INLINE extract #-} +-- $+-- The variable `s` can have any kind.+-- For example, here it has kind `Bool`:+-- >>> :set -XDataKinds+-- >>> import Data.Tagged+-- >>> extract (Tagged 42 :: Tagged 'True Integer)+-- 42 instance Comonad (Tagged s) where duplicate = Tagged {-# INLINE duplicate #-}@@ -195,7 +191,8 @@ #endif instance Comonad NonEmpty where- extend f w@ ~(_ :| aas) = f w :| case aas of+ extend f w@(~(_ :| aas)) =+ f w :| case aas of [] -> [] (a:as) -> toList (extend f (a :| as)) extract ~(a :| _) = a@@ -245,10 +242,8 @@ class Comonad w => ComonadApply w where (<@>) :: w (a -> b) -> w a -> w b-#if __GLASGOW_HASKELL__ >= 702 default (<@>) :: Applicative w => w (a -> b) -> w a -> w b (<@>) = (<*>)-#endif (@>) :: w a -> w b -> w b a @> b = const id <$> a <@> b@@ -287,8 +282,8 @@ -- | A suitable default definition for 'fmap' for a 'Comonad'. -- Promotes a function to a comonad. ----- You can only safely use to define 'fmap' if your 'Comonad'--- defined 'extend', not just 'duplicate', since defining+-- You can only safely use 'liftW' to define 'fmap' if your 'Comonad'+-- defines 'extend', not just 'duplicate', since defining -- 'extend' in terms of duplicate uses 'fmap'! -- -- @@@ -351,25 +346,7 @@ -- | The 'Cokleisli' 'Arrow's of a given 'Comonad' newtype Cokleisli w a b = Cokleisli { runCokleisli :: w a -> b }-#if __GLASGOW_HASKELL__ >= 707- deriving Typeable-#else-#ifdef __GLASGOW_HASKELL__-instance Typeable1 w => Typeable2 (Cokleisli w) where- typeOf2 twab = mkTyConApp cokleisliTyCon [typeOf1 (wa twab)]- where wa :: Cokleisli w a b -> w a- wa = undefined-#endif -cokleisliTyCon :: TyCon-#if MIN_VERSION_base(4,4,0)-cokleisliTyCon = mkTyCon3 "comonad" "Control.Comonad" "Cokleisli"-#else-cokleisliTyCon = mkTyCon "Control.Comonad.Cokleisli"-#endif-{-# NOINLINE cokleisliTyCon #-}-#endif- instance Comonad w => Category (Cokleisli w) where id = Cokleisli extract Cokleisli f . Cokleisli g = Cokleisli (f =<= g)@@ -401,13 +378,3 @@ instance Monad (Cokleisli w a) where return = pure Cokleisli k >>= f = Cokleisli $ \w -> runCokleisli (f (k w)) w--#if !(MIN_VERSION_base(4,7,0))--infixl 4 $>---- | Replace the contents of a functor uniformly with a constant value.-($>) :: Functor f => f a -> b -> f b-($>) = flip (<$)--#endif
src/Control/Comonad/Env.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Env
src/Control/Comonad/Env/Class.hs view
@@ -2,12 +2,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Env.Class@@ -44,10 +39,8 @@ instance ComonadEnv e ((,)e) where ask = fst -#if MIN_VERSION_semigroups(0,16,2) instance ComonadEnv e (Arg e) where ask (Arg e _) = e-#endif lowerAsk :: (ComonadEnv e w, ComonadTrans t) => t w a -> e lowerAsk = ask . lower
src/Control/Comonad/Hoist/Class.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE RankNTypes #-}+{-# LANGUAGE Safe #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Hoist.Class
src/Control/Comonad/Identity.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Identity
src/Control/Comonad/Store.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Store
src/Control/Comonad/Store/Class.hs view
@@ -1,11 +1,8 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Safe #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Store.Class@@ -28,9 +25,6 @@ import qualified Control.Comonad.Trans.Store as Store import Control.Comonad.Trans.Traced import Control.Comonad.Trans.Identity-#if __GLASGOW_HASKELL__ < 710-import Data.Semigroup-#endif class Comonad w => ComonadStore s w | w -> s where pos :: w a -> s
src/Control/Comonad/Traced.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Traced
src/Control/Comonad/Traced/Class.hs view
@@ -1,11 +1,8 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-}-#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Safe #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Traced.Class@@ -27,9 +24,6 @@ import Control.Comonad.Trans.Store import qualified Control.Comonad.Trans.Traced as Traced import Control.Comonad.Trans.Identity-#if __GLASGOW_HASKELL__ < 710-import Data.Semigroup-#endif class Comonad w => ComonadTraced m w | w -> m where trace :: m -> w a -> a
src/Control/Comonad/Trans/Class.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Trans.Class
src/Control/Comonad/Trans/Env.hs view
@@ -1,13 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-}-#if __GLASGOW_HASKELL__ >= 707-{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif-#ifndef MIN_VERSION_base-#define MIN_VERSION_base(x,y,z) 1-#endif+{-# LANGUAGE Safe #-}+{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Trans.Env@@ -62,54 +56,26 @@ , local ) where -#if !(MIN_VERSION_base(4,8,0))-import Control.Applicative-#endif import Control.Comonad import Control.Comonad.Hoist.Class import Control.Comonad.Trans.Class-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable-import Data.Traversable-#endif+import Data.Data import Data.Functor.Identity+#if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-#if __GLASGOW_HASKELL__ >= 707-#define Typeable1 Typeable #endif-import Data.Data -#if __GLASGOW_HASKELL__ >= 707-deriving instance Typeable EnvT-#else-instance (Typeable s, Typeable1 w) => Typeable1 (EnvT s w) where- typeOf1 dswa = mkTyConApp envTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: EnvT s w a -> s- s = undefined- w :: EnvT s w a -> w a- w = undefined--envTTyCon :: TyCon-#if __GLASGOW_HASKELL__ < 704-envTTyCon = mkTyCon "Control.Comonad.Trans.Env.EnvT"-#else-envTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Env" "EnvT"-#endif-{-# NOINLINE envTTyCon #-}-+#ifdef __MHS__+import Data.Foldable+import Data.Traversable #endif -#if __GLASGOW_HASKELL__ < 707-instance (Typeable s, Typeable1 w, Typeable a) => Typeable (EnvT s w a) where- typeOf = typeOfDefault-#endif+-- $setup+-- >>> import Control.Comonad instance ( Data e- , Typeable1 w, Data (w a)+ , Typeable w, Data (w a) , Data a ) => Data (EnvT e w a) where gfoldl f z (EnvT e wa) = z EnvT `f` e `f` wa@@ -127,8 +93,6 @@ envTDataType :: DataType envTDataType = mkDataType "Control.Comonad.Trans.Env.EnvT" [envTConstr] {-# NOINLINE envTDataType #-}--#endif type Env e = EnvT e Identity data EnvT e w a = EnvT e (w a)
src/Control/Comonad/Trans/Identity.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Trans.Identity
src/Control/Comonad/Trans/Store.hs view
@@ -1,9 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 707-{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif+{-# LANGUAGE Safe #-}+{-# LANGUAGE StandaloneDeriving #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Trans.Store@@ -75,45 +72,17 @@ , experiment ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif import Control.Comonad import Control.Comonad.Hoist.Class import Control.Comonad.Trans.Class import Data.Functor.Identity+#if !(MIN_VERSION_base(4,11,0)) import Data.Semigroup--#ifdef __GLASGOW_HASKELL__-import Data.Typeable+#endif -- $setup+-- >>> import Control.Comonad -- >>> import Data.Tuple (swap)--#if __GLASGOW_HASKELL__ >= 707-deriving instance Typeable StoreT-#else-instance (Typeable s, Typeable1 w) => Typeable1 (StoreT s w) where- typeOf1 dswa = mkTyConApp storeTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: StoreT s w a -> s- s = undefined- w :: StoreT s w a -> w a- w = undefined--instance (Typeable s, Typeable1 w, Typeable a) => Typeable (StoreT s w a) where- typeOf = typeOfDefault--storeTTyCon :: TyCon-#if __GLASGOW_HASKELL__ < 704-storeTTyCon = mkTyCon "Control.Comonad.Trans.Store.StoreT"-#else-storeTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Store" "StoreT"-#endif-{-# NOINLINE storeTTyCon #-}-#endif--#endif type Store s = StoreT s Identity
src/Control/Comonad/Trans/Traced.hs view
@@ -1,8 +1,8 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 707-{-# LANGUAGE StandaloneDeriving, DeriveDataTypeable, Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE Safe #-}+{-# LANGUAGE StandaloneDeriving #-}+#ifdef MIN_VERSION_indexed_traversable+{-# LANGUAGE MultiParamTypeClasses, UndecidableInstances #-} #endif ----------------------------------------------------------------------------- -- |@@ -36,14 +36,6 @@ , censor ) where -#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif--#if __GLASGOW_HASKELL__ < 707-import Control.Monad.Instances ()-#endif- import Control.Monad (ap) import Control.Comonad import Control.Comonad.Hoist.Class@@ -53,13 +45,11 @@ import Data.Distributive #endif -import Data.Functor.Identity--#if __GLASGOW_HASKELL__ < 710-import Data.Semigroup+#ifdef MIN_VERSION_indexed_traversable+import Data.Functor.WithIndex #endif -import Data.Typeable+import Data.Functor.Identity type Traced m = TracedT m Identity@@ -97,6 +87,12 @@ distribute = TracedT . fmap (\tma m -> fmap ($ m) tma) . collect runTracedT #endif +#ifdef MIN_VERSION_indexed_traversable+instance FunctorWithIndex i w => FunctorWithIndex (s, i) (TracedT s w) where+ imap f (TracedT w) = TracedT $ imap (\k' g k -> f (k, k') (g k)) w+ {-# INLINE imap #-}+#endif+ trace :: Comonad w => m -> TracedT m w a -> a trace m (TracedT wf) = extract wf m @@ -108,28 +104,3 @@ censor :: Functor w => (m -> m) -> TracedT m w a -> TracedT m w a censor g = TracedT . fmap (. g) . runTracedT--#ifdef __GLASGOW_HASKELL__--#if __GLASGOW_HASKELL__ >= 707-deriving instance Typeable TracedT-#else-instance (Typeable s, Typeable1 w) => Typeable1 (TracedT s w) where- typeOf1 dswa = mkTyConApp tracedTTyCon [typeOf (s dswa), typeOf1 (w dswa)]- where- s :: TracedT s w a -> s- s = undefined- w :: TracedT s w a -> w a- w = undefined--tracedTTyCon :: TyCon-#if __GLASGOW_HASKELL__ < 704-tracedTTyCon = mkTyCon "Control.Comonad.Trans.Traced.TracedT"-#else-tracedTTyCon = mkTyCon3 "comonad-transformers" "Control.Comonad.Trans.Traced" "TracedT"-#endif-{-# NOINLINE tracedTTyCon #-}--#endif--#endif
src/Data/Functor/Composition.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE Safe #-} module Data.Functor.Composition ( Composition(..) ) where
− tests/doctests.hsc
@@ -1,76 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ForeignFunctionInterface #-}--------------------------------------------------------------------------------- |--- Module : Main (doctests)--- Copyright : (C) 2012-13 Edward Kmett--- License : BSD-style (see the file LICENSE)--- Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------ This module provides doctests for a project based on the actual versions--- of the packages it was built with. It requires a corresponding Setup.lhs--- to be added to the project-------------------------------------------------------------------------------module Main where--import Build_doctests (deps)-#if __GLASGOW_HASKELL__ < 710-import Control.Applicative-#endif-import Control.Monad-import Data.List-import System.Directory-import System.FilePath-import Test.DocTest--##if defined(mingw32_HOST_OS)-##if defined(i386_HOST_ARCH)-##define USE_CP-import Control.Applicative-import Control.Exception-import Foreign.C.Types-foreign import stdcall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool-foreign import stdcall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt-##elif defined(x86_64_HOST_ARCH)-##define USE_CP-import Control.Applicative-import Control.Exception-import Foreign.C.Types-foreign import ccall "windows.h SetConsoleCP" c_SetConsoleCP :: CUInt -> IO Bool-foreign import ccall "windows.h GetConsoleCP" c_GetConsoleCP :: IO CUInt-##endif-##endif---- | Run in a modified codepage where we can print UTF-8 values on Windows.-withUnicode :: IO a -> IO a-##ifdef USE_CP-withUnicode m = do- cp <- c_GetConsoleCP- (c_SetConsoleCP 65001 >> m) `finally` c_SetConsoleCP cp-##else-withUnicode m = m-##endif--main :: IO ()-main = withUnicode $ getSources >>= \sources -> doctest $- "-isrc"- : "-idist/build/autogen"- : "-optP-include"- : "-optPdist/build/autogen/cabal_macros.h"- : "-hide-all-packages"- : "-Iincludes"- : map ("-package="++) deps ++ sources--getSources :: IO [FilePath]-getSources = filter (isSuffixOf ".hs") <$> go "src"- where- go dir = do- (dirs, files) <- getFilesAndDirectories dir- (files ++) . concat <$> mapM go dirs--getFilesAndDirectories :: FilePath -> IO ([FilePath], [FilePath])-getFilesAndDirectories dir = do- c <- map (dir </>) . filter (`notElem` ["..", "."]) <$> getDirectoryContents dir- (,) <$> filterM doesDirectoryExist c <*> filterM doesFileExist c