packages feed

recursion-schemes-ext (empty) → 0.1.0.0

raw patch · 9 files changed

+160/−0 lines, 9 filesdep +basedep +compositiondep +criterionsetup-changed

Dependencies added: base, composition, criterion, hspec, recursion-schemes, recursion-schemes-ext

Files

+ .travis.yml view
@@ -0,0 +1,18 @@+sudo: false+language: default+cache:+  directories:+  - $HOME/.stack+addons:+    apt:+        packages:+            - libgmp3-dev+before_install:+- mkdir -p ~/.local/bin+- export PATH=$HOME/.local/bin:$PATH+- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'+- chmod a+x ~/.local/bin/stack+install:+- stack --no-terminal --install-ghc test --only-dependencies+script:+- stack --no-terminal test --bench --haddock --no-haddock-deps
+ LICENSE view
@@ -0,0 +1,11 @@+Copyright Vanessa McHale (c) 2017++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.++2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.++3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,5 @@+# recursion-schemes-ext++This adds several functions to+[recursion-schemes](https://hackage.haskell.org/package/recursion-schemes-5.0.2),+including a `cataM`.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ bench/Bench.hs view
@@ -0,0 +1,8 @@+module Main where++import Criterion.Main++main = do+    defaultMain [ bgroup "head"+                      [ bench "fortune-teller" $ whnf head [1..] ]+                ]
+ recursion-schemes-ext.cabal view
@@ -0,0 +1,63 @@+name:                recursion-schemes-ext+version:             0.1.0.0+synopsis:            Amateur addenda to recursion-schemes+description:         This package provides some exotic recursion schemes that I miss when I leave Idris.+homepage:            https://hub.darcs.net/vmchale/recursion-schemes-ext#readme+license:             BSD3+license-file:        LICENSE+author:              Vanessa McHale+maintainer:          vanessa.mchale@reconfigure.io+copyright:           Copyright: (c) 2017 Vanessa McHale+category:            Control+build-type:          Simple+extra-source-files:  README.md+                   , stack.yaml+                   , .travis.yml+cabal-version:       >=1.10++Flag development {+  Description: Enable `-Werror`+  manual: True+  default: False+}++library+  hs-source-dirs:      src+  exposed-modules:     Data.Foldable.Functor.Extensions+  build-depends:       base >= 4.7 && < 5+                     , recursion-schemes+                     , composition+  default-language:    Haskell2010+  if flag(development)+    ghc-options: -Werror+  ghc-options:         -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-import-lists++test-suite recursion-schemes-ext-test+  type:                exitcode-stdio-1.0+  hs-source-dirs:      test+  main-is:             Spec.hs+  build-depends:       base+                     , recursion-schemes-ext+                     , hspec+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N+  default-language:    Haskell2010+  if flag(development)+    ghc-options: -Werror+  ghc-options:         -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-import-lists++benchmark recursion-schemes-ext-bench+  type:                exitcode-stdio-1.0+  hs-source-dirs:      bench+  main-is:             Bench.hs+  build-depends:       base+                     , recursion-schemes-ext+                     , criterion+  ghc-options:         -threaded -rtsopts -with-rtsopts=-N -O3+  default-language:    Haskell2010+  if flag(development)+    ghc-options: -Werror+  ghc-options:         -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wmissing-import-lists++source-repository head+  type:     git+  location: https://hub.darcs.net/vmchale/recursion-schemes-ext
+ src/Data/Foldable/Functor/Extensions.hs view
@@ -0,0 +1,37 @@+{-# LANGUAGE AllowAmbiguousTypes   #-}+{-# LANGUAGE FlexibleContexts      #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}++module Data.Foldable.Functor.Extensions+    ( dicata+    , dendro+    , micro+    , cataM+    ) where++import           Control.Arrow         ((&&&))+import           Control.Monad         ((<=<))+import           Data.Composition      ((.*))+import           Data.Functor.Foldable (Base, Corecursive, Recursive, cata,+                                        elgot, embed, project)++-- | Class that yields F-algebra homomorphisms between mutually recursive types+class (Functor f, Functor g) => SubHom f g a b where+    homo :: (f a -> a) -> (g b -> b) -> (g b -> b)++-- FIXME codependent data types in test suite should be called "Ernie" and "Bert"++dendro :: (SubHom (Base t1) (Base t2) a b, Recursive t2) => (Base t1 a -> a) -> (Base t2 b -> b) -> t2 -> b+dendro = cata .* homo++-- | Catamorphism collapsing mutually data types simultaneously+dicata :: (Recursive a) => (Base a (b, a) -> b) -> (Base a (b, a) -> a) -> a -> b+dicata f g = fst . cata (f &&& g)++-- | A micromorphism is an Elgot algebra specialized to unfolding.+micro :: (Corecursive a) => (b -> Either a (Base a b)) -> b -> a+micro = elgot embed++cataM :: (Recursive t, Traversable (Base t), Monad m) => (Base t a -> m a) -> (t -> m a)+cataM phi = g where g = phi <=< (mapM g . project)
+ stack.yaml view
@@ -0,0 +1,8 @@+resolver: lts-9.0+packages:+- '.'+extra-deps: []+flags:+    recursion-schemes-ext:+        development: false+extra-package-dbs: []
+ test/Spec.hs view
@@ -0,0 +1,8 @@+import           Data.Foldable.Functor.Extensions+import           Test.Hspec++main :: IO ()+main = hspec $ do+    describe "head" $ do+        parallel $ it "parses a .mad string with modifiers" $ do+            head [1..] `shouldBe` 1