catamorphism 0.5.0.1 → 0.5.1.0
raw patch · 2 files changed
+13/−3 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- catamorphism.cabal +3/−3
- src/Data/Morphism/Cata.hs +10/−0
catamorphism.cabal view
@@ -1,8 +1,8 @@ name: catamorphism-version: 0.5.0.1+version: 0.5.1.0 synopsis: A package exposing a helper function for generating catamorphisms. description: A package exposing a helper function for generating catamorphisms.-homepage: http://github.com/frerich/catamorphism+homepage: https://github.com/frerich/catamorphism license: BSD3 license-file: LICENSE author: Frerich Raabe@@ -16,7 +16,7 @@ source-repository head type: git- location: http://github.com/frerich/catamorphism+ location: https://github.com/frerich/catamorphism library exposed-modules: Data.Morphism.Cata
src/Data/Morphism/Cata.hs view
@@ -24,6 +24,11 @@ > > -- Defines 'either :: (a -> c) -> (b -> c) -> Either a b -> c' > $(makeCata defaultOptions ''Either)+>+> -- Defines 'fold :: b -> (a -> b -> b) -> [a] -> b', i.e. 'flip foldr'. Note+> -- that a custom catamorphism name has to be specified since '[]' is not a+> -- valid function name.+> $(makeCata defaultOptions { cataName = "fold" } ''[]) However, catamorphisms are especially useful for recursive data structures. Consider the following simple example which defines a basic data type for modelling sums@@ -70,6 +75,7 @@ import Data.Functor ((<$>)) import Language.Haskell.TH+import Language.Haskell.TH.Syntax (mkNameG, NameSpace(TcClsName)) {-| Values of the 'CataOptions' type can be passed to 'makeCata' in order to@@ -96,6 +102,9 @@ defaultOptions :: CataOptions defaultOptions = CataOptions "" +listName :: Name+listName = mkNameG TcClsName "ghc-prim" "GHC.Types" "[]"+ makeFuncT :: Type -> Type -> Type makeFuncT a = AppT (AppT ArrowT a) @@ -114,6 +123,7 @@ typeName :: Type -> Maybe Name typeName (AppT t _) = typeName t typeName (ConT n) = Just n+typeName ListT = Just listName typeName _ = Nothing conType :: Name -> Name -> Con -> Type