packages feed

fmlist 0.8 → 0.9

raw patch · 2 files changed

+46/−29 lines, 2 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Data.FMList: cycle :: FMList a -> FMList a

Files

Data/FMList.hs view
@@ -29,57 +29,58 @@ {-# LANGUAGE RankNTypes #-}  -module Data.FMList ( +module Data.FMList (      FMList(..)   , transform-    -  -- * Construction  ++  -- * Construction   , empty   , singleton   , cons   , snoc   , pair   , append-  +   , fromList   , fromFoldable-  +   -- * Basic functions   , null   , length   , genericLength-  +   , head   , tail   , last   , init   , reverse-  +   -- * Folding   , toList   , flatten   , foldMapA-  +   , filter   , take   , drop   , takeWhile   , dropWhile-  +   , zip   , zipWith-  +   -- * Unfolding   , iterate   , repeat+  , cycle   , unfold   , unfoldr-  +   ) where -import Prelude -  ( (.), ($), ($!), flip, const, id, error+import Prelude+  ( (.), ($), ($!), flip, const, error   , Either(..), either   , Bool(..), (&&)   , Ord(..), Num(..), Int@@ -87,8 +88,8 @@   ) import Data.Maybe (Maybe(..), maybe, fromMaybe, isNothing) import Data.Monoid-import Data.Foldable-import Data.Traversable+import Data.Foldable (Foldable, foldMap, foldr, toList)+import Data.Traversable (Traversable, traverse) import Control.Monad import Control.Applicative @@ -96,7 +97,7 @@ -- newtype FMList a = FM { unFM :: forall m . Monoid m => (a -> m) -> m } --- | The function 'transform' transforms a list by changing +-- | The function 'transform' transforms a list by changing -- the map function that is passed to 'foldMap'. -- -- It has the following property:@@ -116,7 +117,7 @@ --  * @= transform ((. g) . foldMap) m@ -- --  * @= transform (\\f -> foldMap f . g) m@--- +-- transform :: (forall m. Monoid m => (a -> m) -> (b -> m)) -> FMList b -> FMList a transform t (FM l) = FM (l . t) @@ -216,9 +217,13 @@ iterate      :: (a -> a) -> a -> FMList a iterate f x  = x `cons` iterate f (f x) +-- | 'repeat' buids an infinite list of a single value.+-- While infinite, the result is still accessible from both the start and end. repeat       :: a -> FMList a repeat       = cycle . one +-- | 'cycle' repeats a list to create an infinite list.+-- It is also accessible from the end, where @last (cycle l)@ equals @last l@. cycle        :: FMList a -> FMList a cycle l      = l >< cycle l >< l @@ -255,7 +260,7 @@   mempty                          = WrapApp $ pure mempty   mappend (WrapApp a) (WrapApp b) = WrapApp $ mappend <$> a <*> b --- | Map each element of a structure to an action, evaluate these actions from left to right, +-- | Map each element of a structure to an action, evaluate these actions from left to right, -- and concat the monoid results. foldMapA :: (Foldable t, Applicative f, Monoid m) => (a -> f m) -> t a -> f m foldMapA f = unWrapApp . foldMap (WrapApp . f)@@ -263,38 +268,42 @@   instance Functor FMList where-  fmap g     = transform (. g)-  +  fmap g     = transform (\f -> f . g)+  a <$ l     = transform (\f -> const (f a)) l+ instance Foldable FMList where   foldMap    = flip unFM-  + instance Traversable FMList where   traverse f = foldMapA (fmap one . f)  instance Monad FMList where   return     = one   m >>= g    = transform (\f -> foldMap f . g) m+  m >> k     = transform (\f -> const (foldMap f k)) m   fail _     = nil  instance Applicative FMList where   pure       = one   gs <*> xs  = transform (\f g -> unFM xs (f . g)) gs-    +  as <*  bs  = transform (\f a -> unFM bs (const (f a))) as+  as  *> bs  = transform (\f   -> const (unFM bs f)) as+ instance Monoid (FMList a) where   mempty     = nil   mappend    = (><)-  + instance MonadPlus FMList where   mzero      = nil   mplus      = (><)-  + instance Alternative FMList where   empty      = nil   (<|>)      = (><)-  + instance Show a => Show (FMList a) where   show l     = "fromList " ++ (show $! toList l)-  +  fromMaybeOrError :: Maybe a -> String -> a fromMaybeOrError ma e = fromMaybe (error e) ma
fmlist.cabal view
@@ -1,7 +1,7 @@ name:                fmlist-version:             0.8+version:             0.9 synopsis:            FoldMap lists-description:         +description:   FoldMap lists are lists represented by their foldMap function.   FoldMap lists have O(1) cons, snoc and append, just like DLists,   but other operations might have favorable performance@@ -12,9 +12,17 @@ license-file:        LICENSE author:              Sjoerd Visscher maintainer:          sjoerd@w3future.com+homepage:            https://github.com/sjoerdvisscher/fmlist+bug-reports:         https://github.com/sjoerdvisscher/fmlist/issues+ build-type:          Simple-cabal-version:       >= 1.2+cabal-version:       >= 1.10  Library   exposed-modules:     Data.FMList   build-depends:       base >= 3 && < 5+  default-language:    Haskell98++source-repository head+  type:     git+  location: git://github.com/sjoerdvisscher/fmlist.git