packages feed

recursion 2.2.4.0 → 2.2.4.1

raw patch · 6 files changed

+62/−42 lines, 6 files

Files

CHANGELOG.md view
@@ -1,13 +1,15 @@ # recursion +## 2.2.4.1++* Add more doctests+* Fix documentation typo+ ## 2.2.4.0  * Move `transverse`, `cotransverse`, and `hoist` to new module   `Control.Recursion.GHC` * `recursion` now builds with `eta`--## 2.2.3.1- * Add doctests  ## 2.2.3.0
LICENSE view
@@ -1,4 +1,4 @@-Copyright Vanessa McHale (c) 2018+Copyright Vanessa McHale (c) 2018-2019  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 
README.md view
@@ -1,8 +1,7 @@ # recursion -This is heavily inspired by Edward Kmett's+This is a loose fork of Edward Kmett's [recursion-schemes](http://hackage.haskell.org/package/recursion-schemes)-library, and some code is drawn from it. As such, you will find it-suitable most places that `recusion-schemes` is.+library.  It also provides monadic versions of several common recursion schemes.
cabal.project view
@@ -1,2 +1,3 @@ packages: ./ constraints: recursion +development+write-ghc-environment-files: always
recursion.cabal view
@@ -1,56 +1,56 @@-cabal-version: 1.18-name: recursion-version: 2.2.4.0-license: BSD3-license-file: LICENSE-copyright: Copyright: (c) 2018-2019 Vanessa McHale-maintainer: vamchale@gmail.com-author: Vanessa McHale-bug-reports: https://hub.darcs.net/vmchale/recursion/issues-synopsis: A recursion schemes library for GHC.+cabal-version:      1.18+name:               recursion+version:            2.2.4.1+license:            BSD3+license-file:       LICENSE+copyright:          Copyright: (c) 2018-2019 Vanessa McHale+maintainer:         vamchale@gmail.com+author:             Vanessa McHale+bug-reports:        https://hub.darcs.net/vmchale/recursion/issues+synopsis:           A recursion schemes library for Haskell. description:     A performant recursion schemes library for Haskell with minimal dependencies-category: Control, Recursion-build-type: Simple-extra-source-files:-    cabal.project-extra-doc-files: README.md-                 CHANGELOG.md +category:           Control, Recursion+build-type:         Simple+extra-source-files: cabal.project+extra-doc-files:+    README.md+    CHANGELOG.md+ source-repository head-    type: darcs+    type:     darcs     location: https://hub.darcs.net/vmchale/recursion  flag development-    description:-        Enable `-Werror`-    default: False-    manual: True+    description: Enable `-Werror`+    default:     False+    manual:      True  library-    exposed-modules:-        Control.Recursion-    hs-source-dirs: src+    exposed-modules:  Control.Recursion+    hs-source-dirs:   src     default-language: Haskell2010-    other-extensions: DeriveFunctor FlexibleContexts-                      ExistentialQuantification RankNTypes TypeFamilies DeriveFoldable-                      DeriveTraversable DefaultSignatures TypeOperators-                      MultiParamTypeClasses-    ghc-options: -Wall+    other-extensions:+        DeriveFunctor FlexibleContexts ExistentialQuantification RankNTypes+        TypeFamilies DeriveFoldable DeriveTraversable DefaultSignatures+        TypeOperators MultiParamTypeClasses++    ghc-options:      -Wall     build-depends:         base >=4.9 && <5,         composition-prelude -any      if !impl(eta -any)-        exposed-modules:-            Control.Recursion.GHC+        exposed-modules: Control.Recursion.GHC      if (flag(development) && !impl(ghc >=8.8))         ghc-options: -Werror      if impl(ghc >=8.0)-        ghc-options: -Wincomplete-uni-patterns -Wincomplete-record-updates-                     -Wredundant-constraints -Wnoncanonical-monad-instances+        ghc-options:+            -Wincomplete-uni-patterns -Wincomplete-record-updates+            -Wredundant-constraints -Wnoncanonical-monad-instances      if impl(ghc >=8.4)         ghc-options: -Wmissing-export-lists
src/Control/Recursion.hs view
@@ -66,7 +66,6 @@ import           Data.Foldable       (toList) import           Data.List.NonEmpty  (NonEmpty (..)) import qualified Data.List.NonEmpty  as NE--- import           Data.Traversable    (Traversable (..)) import           GHC.Generics import           Numeric.Natural     (Natural) @@ -215,6 +214,9 @@ zygoM :: (Recursive t, Traversable (Base t), Monad m) => (Base t b -> m b) -> (Base t (b, a) -> m a) -> t -> m a zygoM f g = fmap snd . cataM (\x -> zipA (f (fmap fst x)) (g x)) +-- | See+-- [here](http://hackage.haskell.org/package/cpkg-0.2.3.1/src/src/Package/C/Build/Tree.hs)+-- for an example zygoM' :: (Recursive t, Traversable (Base t), Monad m) => (Base t b -> m b) -> (Base t (b, a) -> m a) -> t -> m a zygoM' f g = fmap snd . cataM (\x -> zipM (f (fmap fst x)) (g x)) @@ -361,7 +363,7 @@ mcata :: (forall y. ((y -> c) -> f y -> c)) -> Fix f -> c mcata ψ = mc where mc = ψ mc . unFix --- | Mendler's histomorφsm+-- | Mendler's histomorphism mhisto :: (forall y. ((y -> c) -> (y -> f y) -> f y -> c)) -> Fix f -> c mhisto ψ = mh where mh = ψ mh unFix . unFix @@ -389,6 +391,22 @@ elgot φ ψ = h where h = either id (φ . fmap h) . ψ  -- | Anamorphism allowing shortcuts. Compare 'apo'+--+-- >>> :{+-- let {+--   collatzSequence :: Integer -> [Integer] ;+--   collatzSequence = micro pc+--     where+--       pc :: Integer -> Either [Integer] (ListF Integer Integer)+--       pc 1 = Left [1]+--       pc n+--         | n `mod` 2 == 0 = Right $ Cons n (div n 2)+--         | otherwise = Right $ Cons n (3 * n + 1)+-- }+-- :}+--+-- >>> collatzSequence 13+-- [13,40,20,10,5,16,8,4,2,1] micro :: (Corecursive a) => (b -> Either a (Base a b)) -> b -> a micro = elgot embed