packages feed

iterable 1.0 → 2.0

raw patch · 5 files changed

+34/−33 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Data.Iterable: ifoldM :: (Iterable a b, Monad m) => (c -> b -> m c) -> c -> a -> m c
- Data.Iterable: ifoldl :: Iterable a b => (c -> b -> c) -> c -> a -> c
- Data.Iterable: ifoldl' :: Iterable a b => (c -> b -> c) -> c -> a -> c
- Data.Iterable: ifoldr :: Iterable a b => (b -> c -> c) -> c -> a -> c
- Data.Iterable: ilength :: Iterable a b => b -> a -> Int
- Data.Iterable: imap :: Iterable a b => (b -> b) -> a -> a
- Data.Iterable: imapM :: (Iterable a b, Monad m) => (b -> m b) -> a -> m a
+ Data.Iterable: itfoldM :: (Iterable a b, Monad m) => (c -> b -> m c) -> c -> a -> m c
+ Data.Iterable: itfoldl :: Iterable a b => (c -> b -> c) -> c -> a -> c
+ Data.Iterable: itfoldl' :: Iterable a b => (c -> b -> c) -> c -> a -> c
+ Data.Iterable: itfoldr :: Iterable a b => (b -> c -> c) -> c -> a -> c
+ Data.Iterable: itlength :: Iterable a b => b -> a -> Int
+ Data.Iterable: itmap :: Iterable a b => (b -> b) -> a -> a
+ Data.Iterable: itmapM :: (Iterable a b, Monad m) => (b -> m b) -> a -> m a
- Data.Iterable: class Iterable a b where imap f e = runIdentity $ imapM (return . f) e
+ Data.Iterable: class Iterable a b where itmap f e = runIdentity $ itmapM (return . f) e

Files

Data/Iterable.hs view
@@ -2,16 +2,15 @@ -- | Declares Iterable class for handling multi-level, heterogeneous, monomorphic collections that allow nested iteration. module Data.Iterable(Iterable(..)) where -import Language.Haskell.TH.Syntax import Control.Monad.Identity(runIdentity,foldM)  -- | Class for iterating all nested components `b` of type `a`. class Iterable a b where-  imapM   :: (Monad m) => (b -> m b) -> a -> m a-  imap    ::              (b ->   b) -> a ->   a-  imap f e = runIdentity $ imapM (return . f) e-  ifoldM  :: (Monad m) => (c -> b -> m c) -> c -> a -> m c-  ifoldr  ::              (b -> c ->   c) -> c -> a ->   c-  ifoldl  ::              (c -> b ->   c) -> c -> a ->   c-  ifoldl' ::              (c -> b ->   c) -> c -> a ->   c-  ilength :: b -> a -> Int -- NOTE: b is 'dummy' type argument to satisfy Iterable a b constraint+  itmapM   :: (Monad m) => (b -> m b) -> a -> m a+  itmap    ::              (b ->   b) -> a ->   a+  itmap f e = runIdentity $ itmapM (return . f) e+  itfoldM  :: (Monad m) => (c -> b -> m c) -> c -> a -> m c+  itfoldr  ::              (b -> c ->   c) -> c -> a ->   c+  itfoldl  ::              (c -> b ->   c) -> c -> a ->   c+  itfoldl' ::              (c -> b ->   c) -> c -> a ->   c+  itlength :: b -> a -> Int -- NOTE: b is 'dummy' type argument to satisfy Iterable a b constraint
Data/Iterable/Instantiate.hs view
@@ -10,24 +10,24 @@ --self_iterable typA = gen_iterable typA typA [e| id |] [e| L.singleton |] self_iterable typA =    [d| instance Iterable $(typA) $(typA) where-        imapM f a     = f a -        ifoldM  f e a = f e a-        ifoldr  f e a = f a e-        ifoldl  f e a = f e a -        ifoldl' f e a = f e a-        ilength   d a = 1+        itmapM f a     = f a +        itfoldM  f e a = f e a+        itfoldr  f e a = f a e+        itfoldl  f e a = f e a +        itfoldl' f e a = f e a+        itlength   d a = 1     |]  -- | Generates a transitive instance of `Iterable` between $typA and $typC, --   assuming existence of `Iterable` $typA $typB, and `Iterable` $typB $typC. trans_iterable typA typB typC =    [d| instance Iterable $(typA) $(typC) where-        imapM   f a   = (imapM   :: (Monad m) => ( $(typB) -> m $(typB) ) -> $(typA)   -> m $(typA) ) (imapM f) a -        imap    f a   = (imap    ::              ( $(typB) ->   $(typB) ) -> $(typA)   ->   $(typA) ) (imap  f) a -        ifoldM  f e a = (ifoldM  :: (Monad m) => (c -> $(typB)   -> m c) -> c   -> $(typA)   -> m c       ) (ifoldM  f) e a -        ifoldr  f e a = (ifoldr  ::              ($(typB) -> c   ->   c) -> c   -> $(typA)   ->   c       ) (\bb cc -> ifoldr  f cc bb) e a-        ifoldl  f e a = (ifoldl  ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (ifoldl  f) e a-        ifoldl' f e a = (ifoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (ifoldl' f) e a-        ilength _   a = (ifoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (\a b-> a + ilength (undefined :: $(typC)) b) 0 a+        itmapM   f a   = (itmapM   :: (Monad m) => ( $(typB) -> m $(typB) ) -> $(typA)   -> m $(typA) ) (itmapM f) a +        itmap    f a   = (itmap    ::              ( $(typB) ->   $(typB) ) -> $(typA)   ->   $(typA) ) (itmap  f) a +        itfoldM  f e a = (itfoldM  :: (Monad m) => (c -> $(typB)   -> m c) -> c   -> $(typA)   -> m c       ) (itfoldM  f) e a +        itfoldr  f e a = (itfoldr  ::              ($(typB) -> c   ->   c) -> c   -> $(typA)   ->   c       ) (\bb cc -> itfoldr  f cc bb) e a+        itfoldl  f e a = (itfoldl  ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (itfoldl  f) e a+        itfoldl' f e a = (itfoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (itfoldl' f) e a+        itlength _   a = (itfoldl' ::              (c -> $(typB)   ->   c) -> c   -> $(typA)   ->   c       ) (\a b-> a + itlength (undefined :: $(typC)) b) 0 a     |] 
Data/Iterable/Instantiate/Vector.hs view
@@ -4,7 +4,7 @@  import           Language.Haskell.TH.Syntax import           Data.Iterable-import qualified Data.Vector as L+import qualified Data.Vector as V  -- | Generates a direct instance of iterable between $typA and $typB with --   given names of getter and setter, so that:@@ -12,13 +12,13 @@ --   $setter :: $typB -> $typA -> $typA gen_vector_iterable typA typB getter setter =    [d| instance Iterable $(typA) $(typB) where-        imapM f a =-          do b' <- L.mapM f ( $(getter) a)+        itmapM f a =+          do b' <- V.mapM f ( $(getter) a)              return $ $(setter) a b'-        ifoldM  f e a  = do r <- L.foldM f e ( $(getter) a)-                            return r-        ifoldr  f e a = L.foldr  f e ( $(getter) a)-        ifoldl  f e a = L.foldl  f e ( $(getter) a)-        ifoldl' f e a = L.foldl' f e ( $(getter) a) -        ilength   d a = L.length ( $(getter) a)+        itfoldM  f e a  = do r <- V.foldM f e ( $(getter) a)+                             return r+        itfoldr  f e a = V.foldr  f e ( $(getter) a)+        itfoldl  f e a = V.foldl  f e ( $(getter) a)+        itfoldl' f e a = V.foldl' f e ( $(getter) a) +        itlength   d a = V.length ( $(getter) a)     |]
README.md view
@@ -3,6 +3,8 @@ Typeclass and TemplateHaskell instantiating methods for accessing data within multilevel, monomorphic, heterogeneous collections. -Used as a main interface to Protein Databank structures parsed by hPDB library.+[![Build Status](https://api.travis-ci.org/mgajda/iterable.png?branch=master)](https://www.travis-ci.org/mgajda/iterable)++Used as a main interface to Protein Databank structures parsed by [hPDB](http://hackage.haskell.org/package/hPDB) library.  Details on official releases are on [Hackage](http://hackage.haskell.org/package/iterable).
iterable.cabal view
@@ -1,5 +1,5 @@ name:                iterable-version:             1.0+version:             2.0 stability:           stable homepage:            https://github.com/mgajda/iterable package-url:         http://hackage.haskell.org/package/iterable