packages feed

ffunctor 1.2.0 → 1.2.1

raw patch · 2 files changed

+68/−53 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

ffunctor.cabal view
@@ -1,66 +1,76 @@-cabal-version:       2.2-name:                ffunctor-version:             1.2.0-synopsis:            FFunctor typeclass-license:             BSD-3-Clause-license-file:        LICENSE-author:              Sam Halliday-maintainer:          Sam Halliday-copyright:           2019 Sam Halliday-bug-reports:         https://gitlab.com/fommil/ffunctor/merge_requests-tested-with:         GHC ^>= 8.4.4 || ^>= 8.6.3-category:            Constraints+cabal-version: 2.2+name:          ffunctor+version:       1.2.1+synopsis:      FFunctor typeclass+license:       BSD-3-Clause+license-file:  LICENSE+author:        Sam Halliday+maintainer:    Sam Halliday+copyright:     2019 Sam Halliday+bug-reports:   https://gitlab.com/fommil/ffunctor/merge_requests+tested-with:   GHC ^>=8.4.4 || ^>=8.6.5+category:      Constraints description:   Micro library with a Higher Kinded Functor in the spirit of HFunctor,   MFunctor and MonadTrans (which all have different kindedness).   .-  Useful to map over the type parameter in a record of-  functions, e.g. https://www.benjamin.pizza/posts/2017-12-15-functor-functors.html-  and https://discourse.haskell.org/t/local-capabilities-with-mtl/231-  and https://discourse.haskell.org/t/some-limits-of-mtl-with-records-of-functions/576+  Useful to map over the type parameter in a record of functions+  .+  * https://www.benjamin.pizza/posts/2017-12-15-functor-functors.html+  * https://discourse.haskell.org/t/local-capabilities-with-mtl/231+  * https://discourse.haskell.org/t/some-limits-of-mtl-with-records-of-functions/576+  * https://discourse.haskell.org/t/records-of-functions-and-implicit-parameters/747  source-repository head-  type: git+  type:     git   location: https://gitlab.com/fommil/ffunctor  flag transformers   description: Compile with transformers utilities-  manual: True-  default: True+  manual:      True+  default:     True  common deps-  build-depends:    , base ^>= 4.11.1.0 || ^>= 4.12.0.0-  ghc-options:        -Wall-                      -Werror=missing-home-modules-  default-language:   Haskell2010+  build-depends:    base >=4.11 && <5+  ghc-options:      -Wall -Werror=missing-home-modules+  default-language: Haskell2010  library-  import:             deps-  hs-source-dirs:     library-  exposed-modules:    Data.FFunctor+  import:          deps+  hs-source-dirs:  library++  -- cabal-fmt: expand library+  exposed-modules: Data.FFunctor+   if flag(transformers)-    build-depends:  , transformers-    cpp-options:      -DHAVE_TRANSFORMERS+    build-depends: transformers+    cpp-options:   -DHAVE_TRANSFORMERS -test-suite            tests+test-suite tests   import:             deps   hs-source-dirs:     test   type:               exitcode-stdio-1.0   main-is:            Driver.hs-  other-modules:      Data.FFunctor.ServantTest-                    , Data.FFunctor.TracingTest-  build-depends:    , ffunctor-                    , aeson            ^>= 1.4.1.0-                    , exceptions       ^>= 0.10.1-                    , mtl              ^>= 2.2.2-                    , generic-lens     ^>= 1.1.0.0-                    , http-client      ^>= 0.5.12-                    , servant          ^>= 0.14.1-                    , servant-client   ^>= 0.14-                    , tasty            ^>= 1.2.1-                    , tasty-hspec      ^>= 1.1.5-                    , tasty-quickcheck ^>= 0.10-                    , time             ^>= 1.8.0.2-                    , universum        ^>= 1.5.0-  build-tool-depends: tasty-discover:tasty-discover ^>= 4.2.1-  ghc-options: -threaded++  -- cabal-fmt: expand test -Driver+  other-modules:+    Data.FFunctor.ServantTest+    Data.FFunctor.TracingTest++  build-depends:+    , aeson             ^>=1.4.1.0+    , exceptions        ^>=0.10.1+    , ffunctor+    , generic-lens      ^>=1.1.0.0+    , http-client       ^>=0.5.12+    , mtl               ^>=2.2.2+    , servant           ^>=0.14.1+    , servant-client    ^>=0.14+    , tasty             ^>=1.2.1+    , tasty-hspec       ^>=1.1.5+    , tasty-quickcheck  ^>=0.10+    , time              ^>=1.8.0.2+    , universum         ^>=1.5.0++  build-tool-depends: tasty-discover:tasty-discover ^>=4.2.1+  ghc-options:        -threaded
library/Data/FFunctor.hs view
@@ -1,9 +1,10 @@ {-# LANGUAGE CPP               #-}-{-# LANGUAGE KindSignatures    #-}-{-# LANGUAGE Rank2Types        #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE EmptyCase         #-} {-# LANGUAGE FlexibleContexts  #-}+{-# LANGUAGE KindSignatures    #-}+{-# LANGUAGE Rank2Types        #-}+{-# LANGUAGE TypeOperators     #-}  -- | Functor of Functors module Data.FFunctor where@@ -12,26 +13,30 @@ import           Control.Monad.Trans.Class (MonadTrans, lift) #endif import           Control.Monad.IO.Class    (MonadIO, liftIO)-import qualified GHC.Generics as Generics+import           Data.Coerce import           Data.Functor.Compose+import           Data.Functor.Const import           Data.Functor.Product import           Data.Functor.Sum-import           Data.Functor.Const-import           Data.Coerce+import qualified GHC.Generics              as Generics +-- | A Functor over Functors (aka Higher Kinded Functor) class FFunctor (f :: (* -> *) -> *) where+  -- | Applies a natural transformation to a higher kinded type   ffmap :: (Functor m, Functor n) => (forall a . (m a -> n a)) -> f m -> f n    default ffmap :: (Generics.Generic1 f, FFunctor (Generics.Rep1 f), Functor m, Functor n) => (forall a . (m a -> n a)) -> f m -> f n   ffmap f = Generics.to1 . ffmap f . Generics.from1   {-# INLINE ffmap #-} --- | Lifts an IO impl of a record of functions into a more general MonadIO impl+-- | Lifts an IO implementation of a higher kinded type (e.g. record of functions) into a MonadIO+--+--   e.g. `luftIO logger` lifts a `Logger IO` into a `Logger m` luftIO :: FFunctor f => MonadIO m => f IO -> f m luftIO = ffmap liftIO  #ifdef HAVE_TRANSFORMERS--- | Lifts a record of functions (that has an FFunctor) into a monad transformer.+-- | Lifts a higher kinded type (e.g. record of functions) into a monad transformer. -- --   e.g. `luft logger` lifts a `Logger m` into a `Logger (ReaderT m Foo)` luft :: FFunctor f => Monad m => MonadTrans t => Functor (t m) => f m -> f (t m)