fmlist 0.7 → 0.8
raw patch · 2 files changed
+11/−9 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.FMList: instance (Show a) => Show (FMList a)
+ Data.FMList: instance Show a => Show (FMList a)
- Data.FMList: FM :: (forall m. (Monoid m) => (a -> m) -> m) -> FMList a
+ Data.FMList: FM :: (forall m. Monoid m => (a -> m) -> m) -> FMList a
- Data.FMList: empty :: (Alternative f) => forall a. f a
+ Data.FMList: empty :: Alternative f => forall a. f a
- Data.FMList: flatten :: (Foldable t) => FMList (t a) -> FMList a
+ Data.FMList: flatten :: Foldable t => FMList (t a) -> FMList a
- Data.FMList: fromFoldable :: (Foldable f) => f a -> FMList a
+ Data.FMList: fromFoldable :: Foldable f => f a -> FMList a
- Data.FMList: genericLength :: (Num b) => FMList a -> b
+ Data.FMList: genericLength :: Num b => FMList a -> b
- Data.FMList: toList :: (Foldable t) => t a -> [a]
+ Data.FMList: toList :: Foldable t => t a -> [a]
- Data.FMList: transform :: (forall m. (Monoid m) => (a -> m) -> (b -> m)) -> FMList b -> FMList a
+ Data.FMList: transform :: (forall m. Monoid m => (a -> m) -> (b -> m)) -> FMList b -> FMList a
- Data.FMList: unFM :: FMList a -> forall m. (Monoid m) => (a -> m) -> m
+ Data.FMList: unFM :: FMList a -> forall m. Monoid m => (a -> m) -> m
Files
- Data/FMList.hs +10/−8
- fmlist.cabal +1/−1
Data/FMList.hs view
@@ -92,7 +92,6 @@ import Control.Monad import Control.Applicative - -- | 'FMList' is a 'foldMap' function wrapped up in a newtype. -- newtype FMList a = FM { unFM :: forall m . Monoid m => (a -> m) -> m }@@ -170,13 +169,13 @@ head :: FMList a -> a-head l = mhead l `fromJustOrError` "Data.FMList.head: empty list"+head l = mhead l `fromMaybeOrError` "Data.FMList.head: empty list" tail :: FMList a -> FMList a tail l = if null l then error "Data.FMList.tail: empty list" else drop (1::Int) l last :: FMList a -> a-last l = getLast (unFM l (Last . Just)) `fromJustOrError` "Data.FMList.last: empty list"+last l = getLast (unFM l (Last . Just)) `fromMaybeOrError` "Data.FMList.last: empty list" init :: FMList a -> FMList a init l = if null l then error "Data.FMList.init: empty list" else reverse . drop (1::Int) . reverse $ l@@ -184,12 +183,11 @@ reverse :: FMList a -> FMList a reverse l = FM $ getDual . unFM l . (Dual .) - flatten :: Foldable t => FMList (t a) -> FMList a flatten = transform foldMap filter :: (a -> Bool) -> FMList a -> FMList a-filter p = transform (\f e -> if p e then f e else mempty)+filter p = transform (\f x -> if p x then f x else mempty) -- transform the foldMap to foldr with state.@@ -219,8 +217,11 @@ iterate f x = x `cons` iterate f (f x) repeat :: a -> FMList a-repeat x = xs where xs = x `cons` xs+repeat = cycle . one +cycle :: FMList a -> FMList a+cycle l = l >< cycle l >< l+ -- | 'unfoldr' builds an 'FMList' from a seed value from left to right. -- The function takes the element and returns 'Nothing' -- if it is done producing the list or returns 'Just' @(a,b)@, in which@@ -273,6 +274,7 @@ instance Monad FMList where return = one m >>= g = transform (\f -> foldMap f . g) m+ fail _ = nil instance Applicative FMList where pure = one@@ -294,5 +296,5 @@ show l = "fromList " ++ (show $! toList l) -fromJustOrError :: Maybe a -> String -> a-fromJustOrError ma e = fromMaybe (error e) ma+fromMaybeOrError :: Maybe a -> String -> a+fromMaybeOrError ma e = fromMaybe (error e) ma
fmlist.cabal view
@@ -1,5 +1,5 @@ name: fmlist-version: 0.7+version: 0.8 synopsis: FoldMap lists description: FoldMap lists are lists represented by their foldMap function.