semigroups 0.11 → 0.12
raw patch · 3 files changed
+10/−1 lines, 3 files
Files
- semigroups.cabal +1/−1
- src/Data/List/NonEmpty.hs +6/−0
- src/Data/Semigroup.hs +3/−0
semigroups.cabal view
@@ -1,6 +1,6 @@ name: semigroups category: Algebra, Data, Data Structures, Math-version: 0.11+version: 0.12 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE
src/Data/List/NonEmpty.hs view
@@ -47,6 +47,7 @@ , cycle -- :: NonEmpty a -> NonEmpty a , unfold -- :: (a -> (b, Maybe a) -> a -> NonEmpty b , insert -- :: (Foldable f, Ord a) => a -> f a -> NonEmpty a+ , some1 -- :: Alternative f => f a -> f (NonEmpty a) -- * Extracting sublists , take -- :: Int -> NonEmpty a -> [a] , drop -- :: Int -> NonEmpty a -> [a]@@ -298,6 +299,11 @@ insert :: (Foldable f, Ord a) => a -> f a -> NonEmpty a insert a = fromList . List.insert a . Foldable.toList {-# INLINE insert #-}++-- | @'some1' x@ sequences @x@ one or more times.+some1 :: Alternative f => f a -> f (NonEmpty a)+some1 x = (:|) <$> x <*> many x+{-# INLINE some1 #-} -- | 'scanl' is similar to 'foldl', but returns a stream of successive -- reduced values from the left:
src/Data/Semigroup.hs view
@@ -205,6 +205,9 @@ instance Num a => Semigroup (Product a) where Product a <> Product b = Product (a * b) +instance Semigroup a => Semigroup (Const a b) where+ Const a <> Const b = Const (a <> b)+ #if MIN_VERSION_base(3,0,0) instance Semigroup (Monoid.First a) where Monoid.First Nothing <> b = b