packages feed

semigroupoids 5.3.7 → 6

raw patch · 29 files changed

+436/−761 lines, 29 filesdep +foldable1-classes-compatdep −generic-derivingdep −ghc-primdep −semigroupsdep ~basedep ~bifunctorsdep ~containers

Dependencies added: foldable1-classes-compat

Dependencies removed: generic-deriving, ghc-prim, semigroups, void

Dependency ranges changed: base, bifunctors, containers, hashable, tagged, template-haskell, transformers, transformers-compat

Files

CHANGELOG.markdown view
@@ -1,3 +1,82 @@+6 [2023.03.12]+--------------+* Drop support for GHC 7.10 and earlier.+* The `Foldable1` and `Bifoldable1` classes have been migrated:+  * When building with `base-4.18` or later, `semigroupoids` re-exports+    `Foldable1` and `Bifoldable1` from `base`. (These classes were added to+    `base-4.18` as a result of+    [this Core Libraries proposal](haskell/core-libraries-committee#9).)+  * When building with older versions of `base`, `semigroupoids` re-exports+    `Foldable1` and `Bifoldable1` from the+    [`foldable1-classes-compat`](https://github.com/haskell-compat/foldable1-classes-compat)+    compatibility package.++  Note that the version of `Foldable1` that `semigroupoids` defined in previous+  releases only had three class methods: `fold1`, `foldMap1`, and `toNonEmpty`.+  Moreover, `foldMap1` had a default implementation in terms of a `Foldable`+  constraint. `base`'s version of `Foldable1`, however, has some notable+  differences:++  1. It has many more methods than the three listed above, such as the+     `foldrMap1` method.+  2. `foldMap1` now has a default implementation in terms of `foldrMap1` instead+     of in terms of a `Foldable` constraint.++  To avoid (1) causing issues when upgrading to `semigroupoids-6`,+  `Data.Semigroup.Foldable` only re-exports the `fold1`, `foldMap1`, and+  `toNonEmpty` methods, which reflects the API in previous `semigroupoids`+  releases. If you want to use the other, new class methods of `Foldable1`,+  consider importing it from `Data.Foldable1` (its home in `base`) instead.++  Difference (2) is trickier, because it is possible that existing code that+  defines valid `Foldable1` instances will need to be migrated. If you have an+  instance like this:++  ```hs+  import Data.Semigroup.Foldable++  data T a = MkT a++  instance Foldable T where+    foldMap f (MkT x) = f x++  instance Foldable1 T -- Relying on Foldable-based defaults+  ```++  Then calling `foldMap1` on `T` will throw an error with `semigroupoids-6`, as+  `foldMap1`'s default implementation no longer uses `Foldable`. To migrate this+  code, change the instance to explicitly define `foldMap1`:++  ```hs+  instance Foldable1 T where+    foldMap1 f (MkT x) = f x+  ```++  This approach should be backwards-compatible with previous `semigroupoids`+  releases.++  Some other side effects of this migration include:++  * The `Data.Semigroup.Foldable.Class` module has been deprecated. It no+    longer serves a useful role, as it simply re-exports a limited subset of+    the `Data.Foldable1` and `Data.Bifoldable1` API.+  * All of the `Foldable1` and `Bifoldable1` instances that were previously+    defined in `semigroupoids` have now been migrated to downstream libraries+    (`base`, `bifunctors`, `containers`, `tagged`, and `transformers`), so it+    is no longer strictly necessary to depend on `semigroupoids` to make use of+    these instances.+* Add `Generic1`-based functions for many classes, useful for writing instances:+  - `Data.Functor.Alt.(<!>)` -> `Data.Functor.Alt.galt`+  - `Data.Functor.Apply.{liftF2,liftF3}` -> `Data.Functor.Apply.{gliftF2,gliftF3}`+  - `Data.Functor.Bind.(>>-)` -> `Data.Functor.Bind.gbind`+  - `Data.Functor.Contravariant.Conclude.{conclude,concluded}` -> `Data.Functor.Contravariant.Conclude.{gconclude,gconcluded}`+  - `Data.Functor.Contravariant.Decide.{decide,decided}` -> `Data.Functor.Contravariant.Decide.{gdecide,gdecided}`+  - `Data.Functor.Contravariant.Divise.{divise,divised}` -> `Data.Functor.Contravariant.Divise.{gdivise,gdivised}`+  - `Data.Functor.Extend.{duplicated,extended}` -> `Data.Functor.Extend.{gduplicated,gextended}`+  - `Data.Functor.Plus.zero` -> `Data.Functor.Plus.gzero`+  - `Data.Semigroup.Foldable.{fold1,foldMap1,toNonEmpty}` -> `Data.Semigroup.Foldable.{gfold1,gfoldMap1,gtoNonEmpty}`+  - `Data.Semigroup.Traversable.{traverse1,sequence1}` -> `Data.Semigroup.Traversable.{gtraverse1,gsequence1}`+ 5.3.7 [2022.01.09] ------------------ * Relax the `Bind` constraints in the following instances to `Functor`:
semigroupoids.cabal view
@@ -1,8 +1,8 @@+cabal-version: 1.24 name:          semigroupoids category:      Control, Comonads-version:       5.3.7+version:       6 license:       BSD2-cabal-version: 1.18 license-file:  LICENSE author:        Edward A. Kmett maintainer:    Edward A. Kmett <ekmett@gmail.com>@@ -10,19 +10,16 @@ homepage:      http://github.com/ekmett/semigroupoids bug-reports:   http://github.com/ekmett/semigroupoids/issues copyright:     Copyright (C) 2011-2015 Edward A. Kmett-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+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.4-             , GHC == 9.0.1+             , GHC == 8.10.7+             , GHC == 9.0.2+             , GHC == 9.2.7+             , GHC == 9.4.4+             , GHC == 9.6.1 build-type:    Simple synopsis:      Semigroupoids: Category sans id extra-source-files:@@ -128,27 +125,18 @@  library   build-depends:-    base                >= 4.3     && < 5,+    base                >= 4.9     && < 5,     base-orphans        >= 0.8.4   && < 1,-    bifunctors          >= 5.5.9   && < 6,-    template-haskell    >= 0.2.5.0,-    transformers        >= 0.3     && < 0.7,-    transformers-compat >= 0.5     && < 0.8--  if impl(ghc >= 7.0 && < 7.2)-    build-depends: generic-deriving >= 1.14 && < 1.15--  if impl(ghc >= 7.2 && < 7.6)-    build-depends: ghc-prim--  if !impl(ghc >= 7.10)-    build-depends: void >= 0.4 && < 1+    bifunctors          >= 5.6     && < 6,+    template-haskell    >= 0.2.11,+    transformers        >= 0.5     && < 0.7,+    transformers-compat >= 0.6     && < 0.8 -  if !impl(ghc >= 8.0)-    build-depends: semigroups >= 0.18.5 && < 1+  if !impl(ghc >= 9.6)+    build-depends: foldable1-classes-compat >= 0.1 && < 0.2    if flag(containers)-    build-depends: containers >= 0.3 && < 0.7+    build-depends: containers >= 0.5.7.1 && < 0.7    if flag(contravariant)     build-depends: contravariant >= 1.5.3 && < 2@@ -160,15 +148,11 @@     build-depends: comonad >= 5.0.8 && < 6    if flag(tagged)-    build-depends: tagged >= 0.8.6.1 && < 1+    build-depends: tagged >= 0.8.7 && < 1    if flag(unordered-containers)-    if impl(ghc >= 7.4)-      build-depends: hashable >= 1.2.7.0  && < 1.5,-                     unordered-containers >= 0.2.8.0  && < 0.3-    else-      build-depends: hashable >= 1.2.5.0  && < 1.5,-                     unordered-containers >= 0.2.8.0  && < 0.3+    build-depends: hashable >= 1.2.7.0 && < 1.5,+                   unordered-containers >= 0.2.8.0  && < 0.3    hs-source-dirs: src @@ -202,10 +186,7 @@   other-modules:     Semigroupoids.Internal -  ghc-options: -Wall -fno-warn-warnings-deprecations--  if impl(ghc >= 7.10)-    ghc-options: -fno-warn-trustworthy-safe+  ghc-options: -Wall -Wno-warnings-deprecations -Wno-trustworthy-safe    if impl(ghc >= 9.0)     -- these flags may abort compilation with GHC-8.10
src/Data/Bifunctor/Apply.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett
src/Data/Functor/Alt.hs view
@@ -1,16 +1,11 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE ConstrainedClassMethods #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-}--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif--#if __GLASGOW_HASKELL__ >= 711-{-# LANGUAGE ConstrainedClassMethods #-}-#endif-{-# options_ghc -fno-warn-deprecations #-}+{-# options_ghc -Wno-deprecations #-} ----------------------------------------------------------------------------- -- | -- Module      :  Data.Functor.Alt@@ -25,6 +20,7 @@ module Data.Functor.Alt   ( Alt(..)   , optional+  , galt   , module Data.Functor.Apply   ) where @@ -56,9 +52,11 @@ import Data.Functor.Reverse import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.Monoid as Monoid+import Data.Proxy import Data.Semigroup (Semigroup(..)) import qualified Data.Semigroup as Semigroup-import Prelude (($),Either(..),Maybe(..),const,IO,(++),(.),either,seq,undefined,repeat)+import GHC.Generics+import Prelude (($),Either(..),Maybe(..),const,IO,(++),(.),either,seq,undefined,repeat,mappend) import Unsafe.Coerce  #if !(MIN_VERSION_transformers(0,6,0))@@ -66,12 +64,6 @@ import Control.Monad.Trans.List #endif -#if MIN_VERSION_base(4,8,0)-import Prelude (mappend)-#else-import Data.Monoid (mappend)-#endif- #if !(MIN_VERSION_base(4,16,0)) import Data.Semigroup (Option(..)) #endif@@ -85,10 +77,6 @@ import Prelude (Ord) #endif -#if defined(MIN_VERSION_tagged) || (MIN_VERSION_base(4,7,0))-import Data.Proxy-#endif- #ifdef MIN_VERSION_unordered_containers import Data.Hashable import Data.HashMap.Lazy (HashMap)@@ -96,13 +84,6 @@ import Prelude (Eq) #endif -#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base-#else-import GHC.Generics-#endif-- infixl 3 <!>  -- | Laws:@@ -153,9 +134,22 @@ optional :: (Alt f, Applicative f) => f a -> f (Maybe a) optional v = Just <$> v <!> pure Nothing +-- | Generic ('<!>'). Caveats:+--+--   1. Will not compile if @f@ is a sum type.+--   2. Any types where the @a@ does not appear must have a 'Semigroup' instance.+--+-- @since 5.3.8+galt :: (Generic1 f, Alt (Rep1 f)) => f a -> f a -> f a+galt as bs = to1 $ from1 as <!> from1 bs+ instance (Alt f, Alt g) => Alt (f :*: g) where   (as :*: bs) <!> (cs :*: ds) = (as <!> cs) :*: (bs <!> ds) +-- | @since 5.3.8+instance (Alt f, Functor g) => Alt (f :.: g) where+  Comp1 as <!> Comp1 bs = Comp1 (as <!> bs)+ newtype Magic f = Magic { runMagic :: forall a. Applicative f => f a -> f [a] }  instance Alt f => Alt (M1 i c f) where@@ -168,6 +162,10 @@   some = runMagic (unsafeCoerce (Magic some :: Magic f))   many = runMagic (unsafeCoerce (Magic many :: Magic f)) +-- | @since 5.3.8@+instance Semigroup c => Alt (K1 i c) where+  K1 c1 <!> K1 c2 = K1 $ c1 <> c2+ instance Alt U1 where   _ <!> _ = U1   some _ = U1@@ -178,12 +176,10 @@   some v = v `seq` undefined   many v = v `seq` undefined -#if defined(MIN_VERSION_tagged) || (MIN_VERSION_base(4,7,0)) instance Alt Proxy where   _ <!> _ = Proxy   some _ = Proxy   many _ = Proxy-#endif  instance Alt (Either a) where   Left _ <!> b = b
src/Data/Functor/Apply.hs view
@@ -1,8 +1,5 @@-{-# LANGUAGE CPP #-}--#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -24,6 +21,8 @@   , Apply(..)   , (<..>)    -- :: Apply w => w a -> w (a -> b) -> w b   , liftF3    -- :: Apply w => (a -> b -> c -> d) -> w a -> w b -> w c -> w d+  , gliftF2+  , gliftF3    -- * Wrappers   , WrappedApplicative(..)@@ -34,6 +33,7 @@  import Data.Functor import Data.Functor.Bind.Class+import GHC.Generics  infixl 4 <..> @@ -48,12 +48,17 @@ liftF3 f a b c = f <$> a <.> b <.> c {-# INLINE liftF3 #-} -#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 (<$)+-- | Generic 'liftF2'. Caveats:+--+--   1. Will not compile if @w@ is a sum type.+--   2. Types in @w@ that do not mention the type variable must be instances of 'Semigroup'.+--+-- @since 5.3.8+gliftF2 :: (Generic1 w, Apply (Rep1 w)) => (a -> b -> c) -> w a -> w b -> w c+gliftF2 f wa wb = to1 $ liftF2 f (from1 wa) (from1 wb) -#endif+-- | Generic 'liftF3'. Caveats are the same as for 'gliftF2'.+--+-- @since 5.3.8+gliftF3 :: (Generic1 w, Apply (Rep1 w)) => (a -> b -> c -> d) -> w a -> w b -> w c -> w d+gliftF3 f wa wb wc = to1 $ liftF3 f (from1 wa) (from1 wb) (from1 wc)
src/Data/Functor/Bind.hs view
@@ -1,12 +1,5 @@-{-# LANGUAGE CPP #-}--#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Trustworthy #-}-#endif--#if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKELL__ < 710-{-# OPTIONS_GHC -fno-warn-amp #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -31,6 +24,7 @@   , MaybeApply(..)   -- * Bindable functors   , Bind(..)+  , gbind   , (-<<)   , (-<-)   , (->-)@@ -40,7 +34,19 @@  import Data.Functor.Apply import Data.Functor.Bind.Class+import GHC.Generics +-- | Generic '(>>-)'. Caveats:+--+--   1. Will not compile if @m@ is a sum type.+--   2. Will not compile if @m@ contains fields that do not mention its type variable.+--   3. Will not compile if @m@ contains fields where the type variable appears underneath the composition of type constructors (e.g., @f (g a)@).+--   4. May do redundant work, due to the nature of the 'Bind' instance for (':*:')+--+-- @since 5.3.8+gbind :: (Generic1 m, Bind (Rep1 m)) => m a -> (a -> m b) -> m b+gbind m f = to1 $ from1 m >>- (\a -> from1 $ f a)+ infixr 1 -<<, -<-, ->-  (-<<) :: Bind m => (a -> m b) -> m a -> m b@@ -51,5 +57,3 @@  (-<-) :: Bind m => (b -> m c) -> (a -> m b) -> a -> m c g -<- f = \a -> f a >>- g--
src/Data/Functor/Bind/Class.hs view
@@ -1,23 +1,12 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE EmptyCase #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE StandaloneDeriving #-}-{-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE EmptyCase #-}-#endif--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif-+{-# LANGUAGE TypeOperators #-}+{-# OPTIONS_GHC -Wno-deprecations #-} {-# OPTIONS_HADDOCK not-home #-} -#if __GLASGOW_HASKELL__ >= 708 && __GLASGOW_HASKELL__ < 710-{-# OPTIONS_GHC -fno-warn-amp #-}-#endif--{-# OPTIONS_GHC -fno-warn-deprecations #-}- ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2018 Edward Kmett@@ -80,6 +69,7 @@ import Data.Bifunctor.Product as Bifunctor import Data.Bifunctor.Tannen import Data.Bifunctor.Wrapped+import Data.Complex import Data.Functor.Compose import Data.Functor.Constant import Data.Functor.Identity@@ -87,9 +77,12 @@ import Data.Functor.Reverse import Data.Functor.Extend import Data.List.NonEmpty (NonEmpty)+import Data.Ord (Down (..))+import Data.Proxy import Data.Semigroup as Semigroup import qualified Data.Monoid as Monoid import Data.Orphans ()+import GHC.Generics as Generics import Language.Haskell.TH (Q) import Prelude hiding (id, (.)) @@ -98,17 +91,6 @@ import Control.Monad.Trans.List #endif -#if MIN_VERSION_base(4,6,0)-import Data.Ord (Down (..))-#else-import GHC.Exts (Down (..))-#endif---#if MIN_VERSION_base(4,4,0)-import Data.Complex-#endif- #ifdef MIN_VERSION_containers import qualified Data.IntMap as IntMap import Data.IntMap (IntMap)@@ -122,26 +104,12 @@ import Data.Tagged #endif -#if defined(MIN_VERSION_tagged) || MIN_VERSION_base(4,7,0)-import Data.Proxy-#endif- #ifdef MIN_VERSION_unordered_containers import Data.Hashable import Data.HashMap.Lazy (HashMap) import qualified Data.HashMap.Lazy as HashMap #endif -#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base as Generics-#else-import GHC.Generics as Generics-#endif--#if __GLASGOW_HASKELL__ < 710-import Data.Traversable-#endif- #ifdef MIN_VERSION_comonad import Control.Comonad import Control.Comonad.Trans.Env@@ -192,9 +160,7 @@   liftF2 f a b = f <$> a <.> b   {-# INLINE liftF2 #-} -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708   {-# MINIMAL (<.>) | liftF2 #-}-#endif  #ifdef MIN_VERSION_tagged instance Apply (Tagged a) where@@ -203,12 +169,10 @@   (.>) = (*>) #endif -#if defined(MIN_VERSION_tagged) || MIN_VERSION_base(4,7,0) instance Apply Proxy where   (<.>) = (<*>)   (<.) = (<*)   (.>) = (*>)-#endif  instance Apply f => Apply (Backwards f) where   Backwards f <.> Backwards a = Backwards (flip id <$> a <.> f)@@ -312,10 +276,8 @@   (<. ) = (<* )   ( .>) = ( *>) -#if MIN_VERSION_base(4,4,0) instance Apply Complex where   (a :+ b) <.> (c :+ d) = a c :+ b d-#endif  -- Applicative Q was only added in template-haskell 2.7 (GHC 7.4), so -- define in terms of Monad instead.@@ -510,9 +472,7 @@ instance Apply Monoid.Dual where (<.>)=(<*>);(.>)=(*>);(<.)=(<*) instance Apply Monoid.First where (<.>)=(<*>);(.>)=(*>);(<.)=(<*) instance Apply Monoid.Last where (<.>)=(<*>);(.>)=(*>);(<.)=(<*)-#if MIN_VERSION_base(4,8,0) deriving instance Apply f => Apply (Monoid.Alt f)-#endif -- in GHC 8.6 we'll have to deal with Apply f => Apply (Ap f) the same way instance Apply Semigroup.First where (<.>)=(<*>);(.>)=(*>);(<.)=(<*) instance Apply Semigroup.Last where (<.>)=(<*>);(.>)=(*>);(<.)=(<*)@@ -539,11 +499,7 @@  -- | A 'V1' is not 'Applicative', but it is an instance of 'Apply' instance Apply Generics.V1 where-#if __GLASGOW_HASKELL__ >= 708   e <.> _ = case e of {}-#else-  e <.> _ = e `seq` undefined-#endif  -- | A 'Monad' sans 'return'. --@@ -575,9 +531,7 @@   join :: m (m a) -> m a   join = (>>- id) -#if __GLASGOW_HASKELL__ >= 708   {-# MINIMAL (>>-) | join #-}-#endif  returning :: Functor f => f a -> (a -> b) -> f b returning = flip fmap@@ -595,11 +549,9 @@   join (Tagged a) = a #endif -#if defined(MIN_VERSION_tagged) || MIN_VERSION_base(4,7,0) instance Bind Proxy where   _ >>- _ = Proxy   join _ = Proxy-#endif  instance Bind (Either a) where   Left a  >>- _ = Left a@@ -722,13 +674,11 @@ instance Bind (ContT r m) where   m >>- k = ContT $ \c -> runContT m $ \a -> runContT (k a) c -#if MIN_VERSION_base(4,4,0) instance Bind Complex where   (a :+ b) >>- f = a' :+ b' where     a' :+ _  = f a     _  :+ b' = f b   {-# INLINE (>>-) #-}-#endif  #ifdef MIN_VERSION_containers -- | A 'Map k' is not a 'Monad', but it is an instance of 'Bind'@@ -764,10 +714,8 @@ instance Bind Monoid.Dual where (>>-) = (>>=) instance Bind Monoid.First where (>>-) = (>>=) instance Bind Monoid.Last where (>>-) = (>>=)-#if MIN_VERSION_base(4,8,0) instance Bind f => Bind (Monoid.Alt f) where   Monoid.Alt m >>- k = Monoid.Alt (m >>- Monoid.getAlt . k)-#endif -- in GHC 8.6 we'll have to deal with Bind f => Bind (Ap f) the same way instance Bind Semigroup.First where (>>-) = (>>=) instance Bind Semigroup.Last where (>>-) = (>>=)@@ -775,11 +723,30 @@ instance Bind Semigroup.Max where (>>-) = (>>=) -- | A 'V1' is not a 'Monad', but it is an instance of 'Bind' instance Bind Generics.V1 where-#if __GLASGOW_HASKELL__ >= 708   m >>- _ = case m of {}-#else-  m >>- _ = m `seq` undefined-#endif++-- | @since 5.3.8+instance Bind Generics.U1 where (>>-)=(>>=)++-- | @since 5.3.8+instance Bind f => Bind (Generics.M1 i c f) where+  M1 m >>- f = M1 $ m >>- \a -> case f a of+    M1 m' -> m'++-- | @since 5.3.8+instance Bind m => Bind (Generics.Rec1 m) where+  Rec1 m >>- f = Rec1 $ m >>- \a -> case f a of+    Rec1 m' -> m'++-- | @since 5.3.8+instance Bind Generics.Par1 where+  Par1 m >>- f = f m++-- | @since 5.3.8+instance (Bind f, Bind g) => Bind (f :*: g) where+  m :*: n >>- f = (m >>- fstP . f) :*: (n >>- sndP . f) where+    fstP (a :*: _) = a+    sndP (_ :*: b) = b  infixl 4 <<.>>, <<., .>> 
src/Data/Functor/Bind/Trans.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Module      :  Data.Functor.Bind.Trans
src/Data/Functor/Contravariant/Conclude.hs view
@@ -1,10 +1,7 @@ {-# LANGUAGE CPP           #-}-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeOperators #-}+{-# LANGUAGE Safe #-}  ----------------------------------------------------------------------------- -- |@@ -18,7 +15,9 @@ ---------------------------------------------------------------------------- module Data.Functor.Contravariant.Conclude (     Conclude(..)+  , gconclude   , concluded+  , gconcluded   ) where  import Control.Applicative.Backwards@@ -40,31 +39,19 @@ import Data.Functor.Contravariant.Divisible import Data.Functor.Product import Data.Functor.Reverse+import Data.Monoid (Alt(..))+import Data.Proxy import Data.Void+import GHC.Generics  #if !(MIN_VERSION_transformers(0,6,0)) import Control.Monad.Trans.List #endif -#if MIN_VERSION_base(4,8,0)-import Data.Monoid (Alt(..))-#else-import Control.Applicative-#endif--#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged)-import Data.Proxy-#endif- #ifdef MIN_VERSION_StateVar import Data.StateVar #endif -#if __GLASGOW_HASKELL__ >= 702-#define GHC_GENERICS-import GHC.Generics-#endif- -- | The contravariant analogue of 'Plus'.  Adds on to 'Decide' the ability -- to express a combinator that rejects all input, to act as the dead-end. -- Essentially 'Decidable' without a superclass constraint on 'Divisible'.@@ -96,6 +83,15 @@     -- | The consumer that cannot ever receive /any/ input.     conclude :: (a -> Void) -> f a +-- | Generic 'conclude'. Caveats:+--+--   1. Will not compile if @f@ is a sum type.+--   2. Will not compile if @f@ contains fields that do not mention its type variable.+--+-- @since 5.3.8+gconclude :: (Generic1 f, Conclude (Rep1 f)) => (a -> Void) -> f a+gconclude f = to1 $ conclude f+ -- | A potentially more meaningful form of 'conclude', the consumer that cannot -- ever receive /any/ input.  That is because it expects only input of type -- 'Void', but such a type has no values.@@ -108,6 +104,12 @@ concluded :: Conclude f => f Void concluded = conclude id +-- | Generic 'concluded'. Caveats are the same as for 'gconclude'.+--+-- @since 5.3.8+gconcluded :: (Generic1 f, Conclude (Rep1 f)) => f Void+gconcluded = to1 concluded+ -- | @since 5.3.6 instance Decidable f => Conclude (WrappedDivisible f) where     conclude f = WrapDivisible (lose f)@@ -125,23 +127,18 @@ instance Conclude (Op r) where   conclude f = Op $ absurd . f -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) -- | @since 5.3.6 instance Conclude Proxy where conclude = lose-#endif  #ifdef MIN_VERSION_StateVar -- | @since 5.3.6 instance Conclude SettableStateVar where conclude = lose #endif -#if MIN_VERSION_base(4,8,0) -- | @since 5.3.6 instance Conclude f => Conclude (Alt f) where   conclude = Alt . conclude-#endif -#ifdef GHC_GENERICS -- | @since 5.3.6 instance Conclude U1 where conclude = lose @@ -160,7 +157,6 @@ -- | @since 5.3.6 instance (Apply f, Applicative f, Conclude g) => Conclude (f :.: g) where   conclude = Comp1 . pure . conclude-#endif  -- | @since 5.3.6 instance Conclude f => Conclude (Backwards f) where
src/Data/Functor/Contravariant/Decide.hs view
@@ -1,14 +1,9 @@-{-# LANGUAGE BangPatterns  #-}-{-# LANGUAGE CPP           #-}-{-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE BangPatterns     #-}+{-# LANGUAGE CPP              #-}+{-# LANGUAGE EmptyCase #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif-#if MIN_VERSION_base(4,7,0)-{-# LANGUAGE EmptyCase     #-}-#endif+{-# LANGUAGE TypeOperators    #-}  ----------------------------------------------------------------------------- -- |@@ -22,7 +17,9 @@ ---------------------------------------------------------------------------- module Data.Functor.Contravariant.Decide (     Decide(..)+  , gdecide   , decided+  , gdecided   ) where  import Control.Applicative.Backwards@@ -43,6 +40,9 @@ import Data.Functor.Contravariant.Divisible import Data.Functor.Product import Data.Functor.Reverse+import Data.Monoid (Alt(..))+import Data.Proxy+import GHC.Generics  #if !(MIN_VERSION_transformers(0,6,0)) import Control.Arrow@@ -50,23 +50,10 @@ import Data.Either #endif -#if MIN_VERSION_base(4,8,0)-import Data.Monoid (Alt(..))-#endif--#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged)-import Data.Proxy-#endif- #ifdef MIN_VERSION_StateVar import Data.StateVar #endif -#if __GLASGOW_HASKELL__ >= 702-#define GHC_GENERICS-import GHC.Generics-#endif- -- | The contravariant analogue of 'Alt'. -- -- If one thinks of @f a@ as a consumer of @a@s, then 'decide' allows one@@ -89,6 +76,16 @@     -- returns the wrapped/combined consumer.     decide :: (a -> Either b c) -> f b -> f c -> f a +-- | Generic 'decide'. Caveats:+--+--   1. Will not compile if @f@ is a sum type.+--   2. Will not compile if @f@ contains fields that do not mention its type variable.+--   3. @-XDeriveGeneric@ is not smart enough to make instances where the type variable appears in negative position.+--+-- @since 5.3.8+gdecide :: (Generic1 f, Decide (Rep1 f)) => (a -> Either b c) -> f b -> f c -> f a+gdecide f fb fc = to1 $ decide f (from1 fb) (from1 fc)+ -- | For @'decided' x y@, the resulting @f ('Either' b c)@ will direct -- 'Left's to be consumed by @x@, and 'Right's to be consumed by y. --@@ -96,6 +93,12 @@ decided :: Decide f => f b -> f c -> f (Either b c) decided = decide id +-- | Generic 'decided'. Caveats are the same as for 'gdecide'.+--+-- @since 5.3.8+gdecided :: (Generic1 f, Decide (Rep1 f)) => f b -> f c -> f (Either b c)+gdecided fb fc = gdecide id fb fc+ -- | @since 5.3.6 instance Decidable f => Decide (WrappedDivisible f) where     decide f (WrapDivisible x) (WrapDivisible y) = WrapDivisible (choose f x y)@@ -115,24 +118,17 @@ instance Decide (Op r) where   decide f (Op g) (Op h) = Op $ either g h . f -#if MIN_VERSION_base(4,8,0) -- | @since 5.3.6 instance Decide f => Decide (Alt f) where   decide f (Alt l) (Alt r) = Alt $ decide f l r-#endif -#ifdef GHC_GENERICS -- | @since 5.3.6 instance Decide U1 where decide = choose  -- | Has no 'Decidable' or 'Conclude' instance. -- -- @since 5.3.6-#if MIN_VERSION_base(4,7,0) instance Decide V1 where decide _ x = case x of {}-#else-instance Decide V1 where decide _ x = case x of !_ -> error "V1"-#endif  -- | @since 5.3.6 instance Decide f => Decide (Rec1 f) where@@ -151,7 +147,6 @@ -- @since 5.3.6 instance (Apply f, Decide g) => Decide (f :.: g) where   decide f (Comp1 l) (Comp1 r) = Comp1 (liftF2 (decide f) l r)-#endif  -- | @since 5.3.6 instance Decide f => Decide (Backwards f) where@@ -237,11 +232,9 @@ betuple3 :: s -> w -> a -> (a, s, w) betuple3 s w a = (a, s, w) -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) -- | @since 5.3.6 instance Decide Proxy where   decide _ Proxy Proxy = Proxy-#endif  #ifdef MIN_VERSION_StateVar -- | @since 5.3.6
src/Data/Functor/Contravariant/Divise.hs view
@@ -1,14 +1,9 @@ {-# LANGUAGE BangPatterns  #-} {-# LANGUAGE CPP           #-}-{-# LANGUAGE TypeOperators #-}-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif-#if MIN_VERSION_base(4,7,0) {-# LANGUAGE EmptyCase     #-}-#endif+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE Safe #-}+{-# LANGUAGE TypeOperators #-}  ----------------------------------------------------------------------------- -- |@@ -22,7 +17,9 @@ ---------------------------------------------------------------------------- module Data.Functor.Contravariant.Divise (     Divise(..)+  , gdivise   , divised+  , gdivised   , WrappedDivisible(..)   ) where @@ -47,35 +44,23 @@ import Data.Functor.Contravariant.Divisible import Data.Functor.Product import Data.Functor.Reverse+import Data.Monoid (Alt(..))+import Data.Proxy+import GHC.Generics  #if !(MIN_VERSION_transformers(0,6,0)) import Control.Monad.Trans.Error import Control.Monad.Trans.List #endif -#if MIN_VERSION_base(4,8,0)-import Data.Monoid (Alt(..))-#else-import Data.Monoid (Monoid(..))-#endif--#if MIN_VERSION_base(4,9,0) && !MIN_VERSION_base(4,12,0)+#if !MIN_VERSION_base(4,12,0) import Data.Semigroup (Semigroup(..)) #endif -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged)-import Data.Proxy-#endif- #ifdef MIN_VERSION_StateVar import Data.StateVar #endif -#if __GLASGOW_HASKELL__ >= 702-#define GHC_GENERICS-import GHC.Generics-#endif- -- | The contravariant analogue of 'Apply'; it is -- 'Divisible' without 'conquer'. --@@ -106,6 +91,16 @@     -- returns the wrapped/combined consumer.     divise :: (a -> (b, c)) -> f b -> f c -> f a +-- | Generic 'divise'. Caveats:+--+--   1. Will not compile if @f@ is a sum type.+--   2. Will not compile if @f@ contains fields that do not mention its type variable.+--   3. @-XDeriveGeneric@ is not smart enough to make instances where the type variable appears in negative position.+--+-- @since 5.3.8+gdivise :: (Divise (Rep1 f), Generic1 f) => (a -> (b, c)) -> f b -> f c -> f a+gdivise f x y = to1 $ divise f (from1 x) (from1 y)+ -- | Combine a consumer of @a@ with a consumer of @b@ to get a consumer of -- @(a, b)@. --@@ -117,6 +112,12 @@ divised :: Divise f => f a -> f b -> f (a, b) divised = divise id +-- | Generic 'divised'. Caveats are the same as for 'gdivise'.+--+-- @since 5.3.8+gdivised :: (Generic1 f, Divise (Rep1 f)) => f a -> f b -> f (a, b)+gdivised fa fb = gdivise id fa fb+ -- | Wrap a 'Divisible' to be used as a member of 'Divise' -- -- @since 5.3.6@@ -130,7 +131,6 @@ instance Divisible f => Divise (WrappedDivisible f) where   divise f (WrapDivisible x) (WrapDivisible y) = WrapDivisible (divide f x y) -#if MIN_VERSION_base(4,9,0) -- | Unlike 'Divisible', requires only 'Semigroup' on @r@. -- -- @since 5.3.6@@ -149,18 +149,8 @@ -- @since 5.3.6 instance Semigroup m => Divise (Constant m) where     divise _ (Constant a) (Constant b) = Constant (a <> b)-#else--- | @since 5.3.6-instance Monoid r => Divise (Op r) where divise = divide  -- | @since 5.3.6-instance Monoid m => Divise (Const m) where divise = divide---- | @since 5.3.6-instance Monoid m => Divise (Constant m) where divise = divide-#endif---- | @since 5.3.6 instance Divise Comparison where divise = divide  -- | @since 5.3.6@@ -169,34 +159,25 @@ -- | @since 5.3.6 instance Divise Predicate where divise = divide -#if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) -- | @since 5.3.6 instance Divise Proxy where divise = divide-#endif  #ifdef MIN_VERSION_StateVar -- | @since 5.3.6 instance Divise SettableStateVar where divise = divide #endif -#if MIN_VERSION_base(4,8,0) -- | @since 5.3.6 instance Divise f => Divise (Alt f) where   divise f (Alt l) (Alt r) = Alt $ divise f l r-#endif -#ifdef GHC_GENERICS -- | @since 5.3.6 instance Divise U1 where divise = divide  -- | Has no 'Divisible' instance. -- -- @since 5.3.6-#if MIN_VERSION_base(4,7,0) instance Divise V1 where divise _ x = case x of {}-#else-instance Divise V1 where divise _ !_ = error "V1"-#endif  -- | @since 5.3.6 instance Divise f => Divise (Rec1 f) where@@ -215,7 +196,6 @@ -- @since 5.3.6 instance (Apply f, Divise g) => Divise (f :.: g) where   divise f (Comp1 l) (Comp1 r) = Comp1 (liftF2 (divise f) l r)-#endif  -- | @since 5.3.6 instance Divise f => Divise (Backwards f) where
src/Data/Functor/Extend.hs view
@@ -1,13 +1,9 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE TypeOperators #-}--#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE EmptyCase #-}+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Trustworthy #-}-#endif+{-# LANGUAGE TypeOperators #-} -#if __GLASGOW_HASKELL__ >= 708-{-# LANGUAGE EmptyCase #-}-#endif ----------------------------------------------------------------------------- -- | -- Module      :  Data.Functor.Extend@@ -23,6 +19,8 @@   ( -- * Extendable Functors     -- $definition     Extend(..)+  , gduplicated+  , gextended   ) where  import Prelude hiding (id, (.))@@ -32,6 +30,11 @@ import Data.Functor.Sum as Functor (Sum(..)) import Data.List (tails) import Data.List.NonEmpty (NonEmpty(..), toList)+import Data.Orphans ()+import qualified Data.Monoid as Monoid+import Data.Proxy+import Data.Semigroup as Semigroup+import GHC.Generics as Generics  #ifdef MIN_VERSION_containers import Data.Sequence (Seq)@@ -39,7 +42,6 @@ import Data.Tree #endif - #ifdef MIN_VERSION_comonad import Control.Comonad.Trans.Env import Control.Comonad.Trans.Store@@ -50,20 +52,6 @@ import Data.Tagged #endif -#if defined(MIN_VERSION_tagged) || MIN_VERSION_base(4,7,0)-import Data.Proxy-#endif--#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base as Generics-#else-import GHC.Generics as Generics-#endif--import Data.Orphans ()-import qualified Data.Monoid as Monoid-import Data.Semigroup as Semigroup- class Functor w => Extend w where   -- |   -- > duplicated = extended id@@ -76,10 +64,23 @@   extended f = fmap f . duplicated   duplicated = extended id -#if __GLASGOW_HASKELL__ >= 708   {-# MINIMAL duplicated | extended #-}-#endif +-- | Generic 'duplicated'. Caveats:+--+--   1. Will not compile if @w@ is a product type.+--   2. Will not compile if @w@ contains fields where the type variable appears underneath the composition of type constructors (e.g., @f (g a)@).+--+-- @since 5.3.8+gduplicated :: (Extend (Rep1 w), Generic1 w) => w a -> w (w a)+gduplicated = to1 . fmap to1 . duplicated . from1++-- | Generic 'extended'. Caveats are the same as for 'gduplicated'.+--+-- @since 5.3.8+gextended :: (Extend (Rep1 w), Generic1 w) => (w a -> b) -> w a -> w b+gextended f = to1 . extended (f . to1) . from1+ -- * Extends for Prelude types: -- -- Instances: While Data.Functor.Extend.Instances would be symmetric@@ -99,11 +100,9 @@   duplicated = Tagged #endif -#if defined(MIN_VERSION_tagged) || MIN_VERSION_base(4,7,0) instance Extend Proxy where   duplicated _ = Proxy   extended _ _ = Proxy-#endif  instance Extend Maybe where   duplicated Nothing = Nothing@@ -177,15 +176,15 @@   extended f (L1 l) = L1 (extended (f . L1) l)   extended f (R1 r) = R1 (extended (f . R1) r) +-- | @since 5.3.8+instance Extend (Generics.K1 i c) where+  duplicated (K1 c) = K1 c+ instance Extend Generics.U1 where   extended _ U1 = U1  instance Extend Generics.V1 where-#if __GLASGOW_HASKELL__ >= 708   extended _ e = case e of {}-#else-  extended _ e = seq e undefined-#endif  instance Extend f => Extend (Generics.M1 i t f) where   extended f = M1 . extended (f . M1) . unM1@@ -205,10 +204,8 @@ instance Extend Monoid.Dual where   extended f w@Monoid.Dual{} = Monoid.Dual (f w) -#if MIN_VERSION_base(4,8,0) instance Extend f => Extend (Monoid.Alt f) where   extended f = Monoid.Alt . extended (f . Monoid.Alt) . Monoid.getAlt-#endif  -- in GHC 8.6 we'll have to deal with Apply f => Apply (Ap f) the same way instance Extend Semigroup.First where
src/Data/Functor/Plus.hs view
@@ -1,9 +1,7 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE TypeOperators #-}--#if __GLASGOW_HASKELL__ >= 702+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Trustworthy #-}-#endif+{-# LANGUAGE TypeOperators #-} ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -17,6 +15,7 @@ module Data.Functor.Plus   ( Plus(..)   , psum+  , gzero   , module Data.Functor.Alt   ) where @@ -47,7 +46,9 @@ import Data.Functor.Product import Data.Functor.Reverse import qualified Data.Monoid as Monoid+import Data.Proxy import Data.Semigroup hiding (Product)+import GHC.Generics import Prelude hiding (id, (.), foldr)  #if !(MIN_VERSION_transformers(0,6,0))@@ -63,22 +64,12 @@ import Data.Map (Map) #endif -#if defined(MIN_VERSION_tagged) || (MIN_VERSION_base(4,7,0))-import Data.Proxy-#endif- #ifdef MIN_VERSION_unordered_containers import Data.Hashable import Data.HashMap.Lazy (HashMap) import qualified Data.HashMap.Lazy as HashMap #endif -#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base-#else-import GHC.Generics-#endif- -- | Laws: -- -- > zero <!> m = m@@ -97,15 +88,36 @@ psum :: (Foldable t, Plus f) => t (f a) -> f a psum = foldr (<!>) zero +-- | Generic 'zero'. Caveats:+--+--   1. Will not compile if @f@ is a sum type.+--   2. Any types where the @a@ does not appear must have a 'Monoid' instance.+--+-- @since 5.3.8+gzero :: (Plus (Rep1 f), Generic1 f) => f a+gzero = to1 zero+ instance Plus Proxy where   zero = Proxy  instance Plus U1 where   zero = U1 +-- | @since 5.3.8+instance (Monoid c+#if !(MIN_VERSION_base(4,11,0))+         , Semigroup c+#endif+  ) => Plus (K1 i c) where+  zero = K1 mempty+ instance (Plus f, Plus g) => Plus (f :*: g) where   zero = zero :*: zero +-- | @since 5.3.8+instance (Plus f, Functor g) => Plus (f :.: g) where+  zero = Comp1 zero+ instance Plus f => Plus (M1 i c f) where   zero = M1 zero @@ -198,7 +210,7 @@ #if MIN_VERSION_transformers(0,5,6) -- | @since 5.3.6 instance (Plus f) => Plus (CPS.RWST r w s f) where-  zero = mkRWST $ \_ _ _ -> zero +  zero = mkRWST $ \_ _ _ -> zero #endif  instance Plus f => Plus (Backwards f) where
src/Data/Groupoid.hs view
@@ -1,12 +1,8 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-}-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -24,11 +20,8 @@  import Data.Semigroupoid import Data.Semigroupoid.Dual--#if MIN_VERSION_base(4,7,0) import qualified Data.Type.Coercion as Co import qualified Data.Type.Equality as Eq-#endif  -- | semigroupoid with inverses. This technically should be a category with inverses, except we need to use Ob to define the valid objects for the category class Semigroupoid k => Groupoid k where@@ -37,13 +30,11 @@ instance Groupoid k => Groupoid (Dual k) where   inv (Dual k) = Dual (inv k) -#if MIN_VERSION_base(4,7,0) instance Groupoid Co.Coercion where   inv = Co.sym  instance Groupoid (Eq.:~:) where   inv = Eq.sym-#endif  #if MIN_VERSION_base(4,10,0) instance Groupoid (Eq.:~~:) where
src/Data/Isomorphism.hs view
@@ -1,12 +1,5 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett
src/Data/Semigroup/Bifoldable.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -13,9 +8,15 @@ -- Stability   :  provisional -- Portability :  portable --+-- Re-exports a subset of the "Data.Bifoldable1" module along with some+-- additional combinators that require 'Bifoldable1' constraints.+-- ---------------------------------------------------------------------------- module Data.Semigroup.Bifoldable-  ( Bifoldable1(..)+  ( -- @Data.Bifoldable1@ re-exports+    Bifoldable1(bifold1, bifoldMap1)++    -- Additional @Bifoldable1@ functionality   , bitraverse1_   , bifor1_   , bisequenceA1_@@ -24,9 +25,9 @@  import Control.Applicative import Data.Bifoldable+import Data.Bifoldable1 import Data.Functor.Apply import Data.Semigroup-import Data.Semigroup.Foldable.Class import Prelude hiding (foldr)  newtype Act f a = Act { getAct :: f a }
src/Data/Semigroup/Bitraversable.hs view
@@ -1,9 +1,5 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett
src/Data/Semigroup/Foldable.hs view
@@ -1,9 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -13,27 +10,39 @@ -- Stability   :  provisional -- Portability :  portable --+-- Re-exports a subset of the "Data.Foldable1" module along with some additional+-- combinators that require 'Foldable1' constraints.+-- ---------------------------------------------------------------------------- module Data.Semigroup.Foldable-  ( Foldable1(..)+  ( -- @Data.Foldable1@ re-exports+    Foldable1(fold1, foldMap1, toNonEmpty)   , intercalate1+  , foldrM1+  , foldlM1++    -- Additional @Foldable1@ functionality   , intercalateMap1   , traverse1_   , for1_   , sequenceA1_   , foldMapDefault1   , asum1-  , foldrM1-  , foldlM1++    -- Generic defaults+  , gfold1+  , gfoldMap1+  , gtoNonEmpty   ) where  import Data.Foldable+import Data.Foldable1 import Data.Functor.Alt (Alt(..)) import Data.Functor.Apply import Data.List.NonEmpty (NonEmpty(..)) import Data.Traversable.Instances () import Data.Semigroup hiding (Product, Sum)-import Data.Semigroup.Foldable.Class+import GHC.Generics import Prelude hiding (foldr)  -- $setup@@ -45,21 +54,6 @@ instance Semigroup a => Semigroup (JoinWith a) where   JoinWith a <> JoinWith b = JoinWith $ \j -> a j <> j <> b j --- | Insert an @m@ between each pair of @t m@.  Equivalent to--- 'intercalateMap1' with 'id' as the second argument.------ >>> intercalate1 ", " $ "hello" :| ["how", "are", "you"]--- "hello, how, are, you"------ >>> intercalate1 ", " $ "hello" :| []--- "hello"------ >>> intercalate1 mempty $ "I" :| ["Am", "Fine", "You?"]--- "IAmFineYou?"-intercalate1 :: (Foldable1 t, Semigroup m) => m -> t m -> m-intercalate1 = flip intercalateMap1 id-{-# INLINE intercalate1 #-}- -- | Insert @m@ between each pair of @m@ derived from @a@. -- -- >>> intercalateMap1 " " show $ True :| [False, True]@@ -110,29 +104,23 @@ asum1 = getAlt_ . foldMap1 Alt_ {-# INLINE asum1 #-} --- | Monadic fold over the elements of a non-empty structure,--- associating to the right, i.e. from right to left.+-- | Generic 'fold1'. Caveats: ----- > let g = (=<<) . f--- > in foldrM1 f (x1 :| [x2, ..., xn]) == x1 `g` (x2 `g` ... (xn-1 `f` xn)...)+--   1. Will not compile if @t@ is an empty constructor.+--   2. Will not compile if @t@ has some fields that don't mention @a@, for exmaple @data Bar a = MkBar a Int@ ---foldrM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a-foldrM1 f = go . toNonEmpty-  where-    g = (=<<) . f--    go (e:|es) =-      case es of-        []   -> return e-        x:xs -> e `g` (go (x:|xs))+-- @since 5.3.8+gfold1 :: (Foldable1 (Rep1 t), Generic1 t, Semigroup m) => t m -> m+gfold1 = fold1 . from1 --- | Monadic fold over the elements of a non-empty structure,--- associating to the left, i.e. from left to right.+-- | Generic 'foldMap1'. Caveats are the same as for 'gfold1'. ----- > let g = flip $ (=<<) . f--- > in foldlM1 f (x1 :| [x2, ..., xn]) == (...((x1 `f` x2) `g` x2) `g`...) `g` xn+-- @since 5.3.8+gfoldMap1 :: (Foldable1 (Rep1 t), Generic1 t, Semigroup m) => (a -> m) -> t a -> m+gfoldMap1 f = foldMap1 f . from1++-- | Generic 'toNonEmpty'. Caveats are the same as for 'gfold1'. ---foldlM1 :: (Foldable1 t, Monad m) => (a -> a -> m a) -> t a -> m a-foldlM1 f t = foldlM f x xs-  where-    x:|xs = toNonEmpty t+-- @since 5.3.8+gtoNonEmpty :: (Foldable1 (Rep1 t), Generic1 t) => t a -> NonEmpty a+gtoNonEmpty = toNonEmpty . from1
src/Data/Semigroup/Foldable/Class.hs view
@@ -1,8 +1,4 @@-{-# LANGUAGE CPP, TypeOperators #-}--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif  ----------------------------------------------------------------------------- -- |@@ -15,272 +11,18 @@ -- ---------------------------------------------------------------------------- module Data.Semigroup.Foldable.Class-  ( Foldable1(..)-  , Bifoldable1(..)+  {-# DEPRECATED+        [ "This module re-exports a limited subset of the class methods in the "+        , "Foldable1 and Bifoldable1 classes, which are now located in the "+        , "Data.Foldable1 and Data.Bifoldable1 modules in base-4.18. "+        , "(On older versions of base, these can be found in the "+        , "foldable1-classes-compat library.) "+        , "Import from these modules instead."+        ]+    #-}+  ( Foldable1(fold1, foldMap1, toNonEmpty)+  , Bifoldable1(bifold1, bifoldMap1)   ) where -import Control.Applicative-import Control.Applicative.Backwards-import Control.Applicative.Lift-import Control.Monad.Trans.Identity-import Data.Bifoldable-import Data.Bifunctor.Biff-import Data.Bifunctor.Clown-import Data.Bifunctor.Flip-import Data.Bifunctor.Join-import Data.Bifunctor.Product as Bifunctor-import Data.Bifunctor.Joker-import Data.Bifunctor.Tannen-import Data.Bifunctor.Wrapped-import Data.Foldable--import Data.Functor.Identity-import Data.Functor.Product as Functor-import Data.Functor.Reverse-import Data.Functor.Sum as Functor-import Data.Functor.Compose-import Data.List.NonEmpty (NonEmpty(..))--#if MIN_VERSION_base(4,4,0)-import Data.Complex-#endif--#ifdef MIN_VERSION_tagged-import Data.Tagged-#endif--import Data.Traversable.Instances ()--#ifdef MIN_VERSION_containers-import Data.Tree-#endif--import qualified Data.Monoid as Monoid-import Data.Semigroup as Semigroup hiding (Product, Sum)-import Data.Orphans ()--- import Data.Ord -- missing Foldable, https://ghc.haskell.org/trac/ghc/ticket/15098#ticket--#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base-#else-import GHC.Generics-#endif--import Prelude hiding (foldr)--class Foldable t => Foldable1 t where-  fold1 :: Semigroup m => t m -> m-  foldMap1 :: Semigroup m => (a -> m) -> t a -> m-  toNonEmpty :: t a -> NonEmpty a--  foldMap1 f = maybe (error "foldMap1") id . getOptionCompat . foldMap (optionCompat . Just . f)-  fold1 = foldMap1 id-  toNonEmpty = foldMap1 (:|[])--instance Foldable1 Monoid.Sum where-  foldMap1 f (Monoid.Sum a) = f a--instance Foldable1 Monoid.Product where-  foldMap1 f (Monoid.Product a) = f a--instance Foldable1 Monoid.Dual where-  foldMap1 f (Monoid.Dual a) = f a--#if MIN_VERSION_base(4,8,0)-instance Foldable1 f => Foldable1 (Monoid.Alt f) where-  foldMap1 g (Monoid.Alt m) = foldMap1 g m-#endif--instance Foldable1 Semigroup.First where-  foldMap1 f (Semigroup.First a) = f a--instance Foldable1 Semigroup.Last where-  foldMap1 f (Semigroup.Last a) = f a--instance Foldable1 Semigroup.Min where-  foldMap1 f (Semigroup.Min a) = f a--instance Foldable1 Semigroup.Max where-  foldMap1 f (Semigroup.Max a) = f a--instance Foldable1 f => Foldable1 (Rec1 f) where-  foldMap1 f (Rec1 as) = foldMap1 f as--instance Foldable1 f => Foldable1 (M1 i c f) where-  foldMap1 f (M1 as) = foldMap1 f as--instance Foldable1 Par1 where-  foldMap1 f (Par1 a) = f a--instance (Foldable1 f, Foldable1 g) => Foldable1 (f :*: g) where-  foldMap1 f (as :*: bs) = foldMap1 f as <> foldMap1 f bs--instance (Foldable1 f, Foldable1 g) => Foldable1 (f :+: g) where-  foldMap1 f (L1 as) = foldMap1 f as-  foldMap1 f (R1 bs) = foldMap1 f bs--instance Foldable1 V1 where-  foldMap1 _ v = v `seq` undefined--instance (Foldable1 f, Foldable1 g) => Foldable1 (f :.: g) where-  foldMap1 f (Comp1 m) = foldMap1 (foldMap1 f) m--class Bifoldable t => Bifoldable1 t where-  bifold1 :: Semigroup m => t m m -> m-  bifold1 = bifoldMap1 id id-  {-# INLINE bifold1 #-}--  bifoldMap1 :: Semigroup m => (a -> m) -> (b -> m) -> t a b -> m-  bifoldMap1 f g = maybe (error "bifoldMap1") id-                 . getOptionCompat-                 . bifoldMap (optionCompat . Just . f) (optionCompat . Just . g)-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 Arg where-  bifoldMap1 f g (Arg a b) = f a <> g b--instance Bifoldable1 Either where-  bifoldMap1 f _ (Left a) = f a-  bifoldMap1 _ g (Right b) = g b-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 (,) where-  bifoldMap1 f g (a, b) = f a <> g b-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 ((,,) x) where-  bifoldMap1 f g (_,a,b) = f a <> g b-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 ((,,,) x y) where-  bifoldMap1 f g (_,_,a,b) = f a <> g b-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 ((,,,,) x y z) where-  bifoldMap1 f g (_,_,_,a,b) = f a <> g b-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 Const where-  bifoldMap1 f _ (Const a) = f a-  {-# INLINE bifoldMap1 #-}--#ifdef MIN_VERSION_tagged-instance Bifoldable1 Tagged where-  bifoldMap1 _ g (Tagged b) = g b-  {-# INLINE bifoldMap1 #-}-#endif--instance (Bifoldable1 p, Foldable1 f, Foldable1 g) => Bifoldable1 (Biff p f g) where-  bifoldMap1 f g = bifoldMap1 (foldMap1 f) (foldMap1 g) . runBiff-  {-# INLINE bifoldMap1 #-}--instance Foldable1 f => Bifoldable1 (Clown f) where-  bifoldMap1 f _ = foldMap1 f . runClown-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 p => Bifoldable1 (Flip p) where-  bifoldMap1 f g = bifoldMap1 g f . runFlip-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 p => Foldable1 (Join p) where-  foldMap1 f (Join a) = bifoldMap1 f f a-  {-# INLINE foldMap1 #-}--instance Foldable1 g => Bifoldable1 (Joker g) where-  bifoldMap1 _ g = foldMap1 g . runJoker-  {-# INLINE bifoldMap1 #-}--instance (Bifoldable1 f, Bifoldable1 g) => Bifoldable1 (Bifunctor.Product f g) where-  bifoldMap1 f g (Bifunctor.Pair x y) = bifoldMap1 f g x <> bifoldMap1 f g y-  {-# INLINE bifoldMap1 #-}--instance (Foldable1 f, Bifoldable1 p) => Bifoldable1 (Tannen f p) where-  bifoldMap1 f g = foldMap1 (bifoldMap1 f g) . runTannen-  {-# INLINE bifoldMap1 #-}--instance Bifoldable1 p => Bifoldable1 (WrappedBifunctor p) where-  bifoldMap1 f g = bifoldMap1 f g . unwrapBifunctor-  {-# INLINE bifoldMap1 #-}--#if MIN_VERSION_base(4,4,0)-instance Foldable1 Complex where-  foldMap1 f (a :+ b) = f a <> f b-  {-# INLINE foldMap1 #-}-#endif--#ifdef MIN_VERSION_containers-instance Foldable1 Tree where-  foldMap1 f (Node a []) = f a-  foldMap1 f (Node a (x:xs)) = f a <> foldMap1 (foldMap1 f) (x :| xs)-#endif--instance Foldable1 Identity where-  foldMap1 f = f . runIdentity--#ifdef MIN_VERSION_tagged-instance Foldable1 (Tagged a) where-  foldMap1 f (Tagged a) = f a-#endif--instance Foldable1 m => Foldable1 (IdentityT m) where-  foldMap1 f = foldMap1 f . runIdentityT--instance Foldable1 f => Foldable1 (Backwards f) where-  foldMap1 f = foldMap1 f . forwards--instance (Foldable1 f, Foldable1 g) => Foldable1 (Compose f g) where-  foldMap1 f = foldMap1 (foldMap1 f) . getCompose--instance Foldable1 f => Foldable1 (Lift f) where-  foldMap1 f (Pure x)  = f x-  foldMap1 f (Other y) = foldMap1 f y--instance (Foldable1 f, Foldable1 g) => Foldable1 (Functor.Product f g) where-  foldMap1 f (Functor.Pair a b) = foldMap1 f a <> foldMap1 f b--instance Foldable1 f => Foldable1 (Reverse f) where-  foldMap1 f = getDual . foldMap1 (Dual . f) . getReverse--instance (Foldable1 f, Foldable1 g) => Foldable1 (Functor.Sum f g) where-  foldMap1 f (Functor.InL x) = foldMap1 f x-  foldMap1 f (Functor.InR y) = foldMap1 f y--instance Foldable1 NonEmpty where-  foldMap1 f (a :| as) = foldr (\b g x -> f x <> g b) f as a-  toNonEmpty = id--instance Foldable1 ((,) a) where-  foldMap1 f (_, x) = f x--instance Foldable1 g => Foldable1 (Joker g a) where-  foldMap1 g = foldMap1 g . runJoker-  {-# INLINE foldMap1 #-}---- The default implementations of foldMap1 and bifoldMap1 above require the use--- of a Maybe type with the following Monoid instance:------   instance Semigroup a => Monoid (Maybe a) where ...------ Unfortunately, Maybe has only had such an instance since base-4.11. Prior--- to that, its Monoid instance had an instance context of Monoid a, which is--- too strong. To compensate, we use CPP to define an OptionCompat type--- synonym, which is an alias for Maybe on recent versions of base and an alias--- for Data.Semigroup.Option on older versions of base. We don't want to use--- Option on recent versions of base, as it has been removed.-#if MIN_VERSION_base(4,11,0)-type OptionCompat = Maybe--optionCompat :: Maybe a -> OptionCompat a-optionCompat = id--getOptionCompat :: OptionCompat a -> Maybe a-getOptionCompat = id-#else-type OptionCompat = Option--optionCompat :: Maybe a -> OptionCompat a-optionCompat = Option--getOptionCompat :: OptionCompat a -> Maybe a-getOptionCompat = getOption-#endif+import Data.Bifoldable1+import Data.Foldable1
src/Data/Semigroup/Traversable.hs view
@@ -1,9 +1,6 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -19,6 +16,8 @@   -- * Defining Traversable1 instances   -- $traversable1instances   , traverse1Maybe+  , gtraverse1+  , gsequence1   -- * Default superclass instance helpers   , foldMap1Default   ) where@@ -29,11 +28,34 @@ #endif import Data.Semigroup.Traversable.Class import Data.Functor.Bind.Class+import GHC.Generics  -- | Default implementation of 'foldMap1' given an implementation of 'Traversable1'. foldMap1Default :: (Traversable1 f, Semigroup m) => (a -> m) -> f a -> m foldMap1Default f = getConst . traverse1 (Const . f) +-- | Generic 'traverse1'. Caveats:+--+--   1. Will not compile if @t@ is an empty constructor.+--   2. Will not compile if @t@ has some fields that don't mention @a@, for exmaple @data Bar a = MkBar a Int@+--+-- @since 5.3.8+gtraverse1 ::+  (Traversable1 (Rep1 t), Apply f, Generic1 t) =>+  (a -> f b) ->+  t a ->+  f (t b)+gtraverse1 f x = to1 <$> traverse1 f (from1 x)++-- | Generic 'sequence1'. Caveats are the same for 'gtraverse1'.+--+-- @since 5.3.8+gsequence1 ::+  (Traversable1 (Rep1 t), Apply f, Generic1 t) =>+  t (f b) ->+  f (t b)+gsequence1 = fmap to1 . sequence1 . from1+ -- $traversable1instances -- Defining 'Traversable1' instances for types with both 'Traversable1' and 'Traversable' -- substructures can be done with 'traverse1Maybe', '(<*.>)', and '(<.*>)'.@@ -44,4 +66,3 @@ -- >   traverse1 f (Foo ma ma' a as) = Foo <$> traverseMaybe ma <*> traverseMaybe ma' <*.> f a <.*> traverseMaybe as -- > instance Foldable1 Foo where -- >   foldMap1 = foldMap1Default-
src/Data/Semigroup/Traversable/Class.hs view
@@ -1,8 +1,22 @@ {-# LANGUAGE CPP, TypeOperators #-}--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}++#ifdef MIN_VERSION_containers+# if MIN_VERSION_base(4,18,0)+#  define HAS_FOLDABLE1_CONTAINERS MIN_VERSION_containers(0,6,7)+# else+#  define HAS_FOLDABLE1_CONTAINERS 1+# endif+#else+# define HAS_FOLDABLE1_CONTAINERS 0 #endif++#if MIN_VERSION_base(4,18,0)+# define HAS_FOLDABLE1_TRANSFORMERS MIN_VERSION_transformers(0,6,1)+#else+# define HAS_FOLDABLE1_TRANSFORMERS 1+#endif+ ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett@@ -19,9 +33,6 @@   ) where  import Control.Applicative-import Control.Applicative.Backwards-import Control.Applicative.Lift-import Control.Monad.Trans.Identity import Data.Bitraversable import Data.Bifunctor import Data.Bifunctor.Biff@@ -35,9 +46,9 @@ import Data.Functor.Apply import Data.Functor.Compose +import Data.Complex import Data.Functor.Identity import Data.Functor.Product as Functor-import Data.Functor.Reverse import Data.Functor.Sum as Functor import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.Monoid as Monoid@@ -48,23 +59,18 @@ #ifdef MIN_VERSION_tagged import Data.Tagged #endif-#if __GLASGOW_HASKELL__ < 710-import Data.Traversable-#endif import Data.Traversable.Instances ()--#if MIN_VERSION_base(4,4,0)-import Data.Complex-#endif+import GHC.Generics -#ifdef MIN_VERSION_containers+#if HAS_FOLDABLE1_CONTAINERS import Data.Tree #endif -#ifdef MIN_VERSION_generic_deriving-import Generics.Deriving.Base-#else-import GHC.Generics+#if HAS_FOLDABLE1_TRANSFORMERS+import Control.Applicative.Backwards+import Control.Applicative.Lift+import Control.Monad.Trans.Identity+import Data.Functor.Reverse #endif  class (Bifoldable1 t, Bitraversable t) => Bitraversable1 t where@@ -76,9 +82,7 @@   bisequence1 = bitraverse1 id id   {-# INLINE bisequence1 #-} -#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ >= 708   {-# MINIMAL bitraverse1 | bisequence1 #-}-#endif  instance Bitraversable1 Arg where   bitraverse1 f g (Arg a b) = Arg <$> f a <.> g b@@ -156,9 +160,7 @@   sequence1 = traverse1 id   traverse1 f = sequence1 . fmap f -#if __GLASGOW_HASKELL__ >= 708   {-# MINIMAL traverse1 | sequence1 #-}-#endif  instance Traversable1 f => Traversable1 (Rec1 f) where   traverse1 f (Rec1 as) = Rec1 <$> traverse1 f as@@ -185,41 +187,41 @@ instance Traversable1 Identity where   traverse1 f = fmap Identity . f . runIdentity +instance (Traversable1 f, Traversable1 g) => Traversable1 (Functor.Product f g) where+  traverse1 f (Functor.Pair a b) = Functor.Pair <$> traverse1 f a <.> traverse1 f b++instance (Traversable1 f, Traversable1 g) => Traversable1 (Functor.Sum f g) where+  traverse1 f (Functor.InL x) = Functor.InL <$> traverse1 f x+  traverse1 f (Functor.InR y) = Functor.InR <$> traverse1 f y++instance (Traversable1 f, Traversable1 g) => Traversable1 (Compose f g) where+  traverse1 f = fmap Compose . traverse1 (traverse1 f) . getCompose++#if HAS_FOLDABLE1_TRANSFORMERS instance Traversable1 f => Traversable1 (IdentityT f) where   traverse1 f = fmap IdentityT . traverse1 f . runIdentityT  instance Traversable1 f => Traversable1 (Backwards f) where   traverse1 f = fmap Backwards . traverse1 f . forwards -instance (Traversable1 f, Traversable1 g) => Traversable1 (Compose f g) where-  traverse1 f = fmap Compose . traverse1 (traverse1 f) . getCompose- instance Traversable1 f => Traversable1 (Lift f) where   traverse1 f (Pure x)  = Pure <$> f x   traverse1 f (Other y) = Other <$> traverse1 f y -instance (Traversable1 f, Traversable1 g) => Traversable1 (Functor.Product f g) where-  traverse1 f (Functor.Pair a b) = Functor.Pair <$> traverse1 f a <.> traverse1 f b- instance Traversable1 f => Traversable1 (Reverse f) where   traverse1 f = fmap Reverse . forwards . traverse1 (Backwards . f) . getReverse--instance (Traversable1 f, Traversable1 g) => Traversable1 (Functor.Sum f g) where-  traverse1 f (Functor.InL x) = Functor.InL <$> traverse1 f x-  traverse1 f (Functor.InR y) = Functor.InR <$> traverse1 f y+#endif -#if MIN_VERSION_base(4,4,0) instance Traversable1 Complex where   traverse1 f (a :+ b) = (:+) <$> f a <.> f b   {-# INLINE traverse1 #-}-#endif  #ifdef MIN_VERSION_tagged instance Traversable1 (Tagged a) where   traverse1 f (Tagged a) = Tagged <$> f a #endif -#ifdef MIN_VERSION_containers+#if HAS_FOLDABLE1_CONTAINERS instance Traversable1 Tree where   traverse1 f (Node a []) = (`Node`[]) <$> f a   traverse1 f (Node a (x:xs)) = (\b (y:|ys) -> Node b (y:ys)) <$> f a <.> traverse1 (traverse1 f) (x :| xs)@@ -244,10 +246,8 @@ instance Traversable1 Monoid.Dual where   traverse1 g (Monoid.Dual a) = Monoid.Dual <$> g a -#if MIN_VERSION_base(4,8,0) instance Traversable1 f => Traversable1 (Monoid.Alt f) where   traverse1 g (Monoid.Alt m) = Monoid.Alt <$> traverse1 g m-#endif  instance Traversable1 Semigroup.First where   traverse1 g (Semigroup.First a) = Semigroup.First <$> g a
src/Data/Semigroupoid.hs view
@@ -1,13 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-}--#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif  ----------------------------------------------------------------------------- -- |@@ -30,9 +24,11 @@  import Control.Applicative import Control.Arrow+import Control.Category import Data.Functor.Bind import Data.Semigroup-import Control.Category+import qualified Data.Type.Coercion as Co+import qualified Data.Type.Equality as Eq import Prelude hiding (id, (.))  #ifdef MIN_VERSION_contravariant@@ -48,11 +44,6 @@ import Data.Tagged (Tagged (..)) #endif -#if MIN_VERSION_base(4,7,0)-import qualified Data.Type.Coercion as Co-import qualified Data.Type.Equality as Eq-#endif- -- | 'Control.Category.Category' sans 'Control.Category.id' class Semigroupoid c where   o :: c j k -> c i j -> c i k@@ -103,13 +94,11 @@   Tagged b `o` _ = Tagged b #endif -#if MIN_VERSION_base(4,7,0) instance Semigroupoid Co.Coercion where   o = flip Co.trans  instance Semigroupoid (Eq.:~:) where   o = flip Eq.trans-#endif  #if MIN_VERSION_base(4,10,0) instance Semigroupoid (Eq.:~~:) where
src/Data/Semigroupoid/Categorical.hs view
@@ -1,10 +1,8 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE RankNTypes #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}  ----------------------------------------------------------------------------- -- |
src/Data/Semigroupoid/Dual.hs view
@@ -1,12 +1,5 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 706 {-# LANGUAGE PolyKinds #-}-#endif-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2007-2015 Edward Kmett
src/Data/Semigroupoid/Ob.hs view
@@ -1,15 +1,9 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 706-{-# LANGUAGE PolyKinds #-}-#endif {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}-#if __GLASGOW_HASKELL__ >= 704+{-# LANGUAGE PolyKinds #-} {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015 Edward Kmett
src/Data/Semigroupoid/Static.hs view
@@ -1,8 +1,5 @@ {-# LANGUAGE CPP #-}--#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif  ----------------------------------------------------------------------------- -- |@@ -31,18 +28,11 @@ import Data.Semigroupoid import Prelude hiding ((.), id) -#ifdef LANGUAGE_DeriveDataTypeable-import Data.Typeable-#endif- #ifdef MIN_VERSION_comonad import Control.Comonad #endif  newtype Static f a b = Static { runStatic :: f (a -> b) }-#ifdef LANGUAGE_DeriveDataTypeable-  deriving (Typeable)-#endif  instance Functor f => Functor (Static f a) where   fmap f = Static . fmap (f .) . runStatic
src/Data/Traversable/Instances.hs view
@@ -1,9 +1,4 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif ----------------------------------------------------------------------------- -- | -- Copyright   :  (C) 2011-2015,2018 Edward Kmett
src/Semigroupoids/Do.hs view
@@ -1,18 +1,8 @@-{-# LANGUAGE CPP #-}--#if __GLASGOW_HASKELL__ >= 704 {-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif -#if __GLASGOW_HASKELL__ == 708-{-# OPTIONS_GHC -fno-warn-amp #-}-#endif- {-| -This module re-exports operators from "Data.Functor.Apply" and +This module re-exports operators from "Data.Functor.Apply" and "Data.Functor.Bind", but under the same names as their 'Applicative' and 'Monad' counterparts. This makes it convenient to use do-notation on a type that is a 'Bind' but not a monad (or an 'Apply'@@ -52,12 +42,7 @@   ) where -#if !MIN_VERSION_base(4,8,0)-import Control.Applicative (pure)-import Prelude (String, fmap, return)-#else import Prelude (String, fmap, pure, return)-#endif import Data.Functor.Apply (Apply, (<.), (.>), (<.>)) import Data.Functor.Bind (Bind, (>>-), join) import Data.Functor.Plus (Plus, zero)
src/Semigroupoids/Internal.hs view
@@ -1,7 +1,5 @@ {-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-}-#endif  module Semigroupoids.Internal where @@ -11,7 +9,7 @@ import Unsafe.Coerce (unsafeCoerce) #endif --- This is designed to avoid both https://hub.darcs.net/ross/transformers/issue/67 +-- This is designed to avoid both https://hub.darcs.net/ross/transformers/issue/67 -- and also the unnecessary Monoid constraints that the CPS versions of WriterT -- and RWST require.