semigroups 0.10 → 0.11
raw patch · 4 files changed
+19/−12 lines, 4 files
Files
- LICENSE +1/−5
- semigroups.cabal +3/−5
- src/Data/List/NonEmpty.hs +9/−1
- src/Data/Semigroup.hs +6/−1
LICENSE view
@@ -1,4 +1,4 @@-Copyright 2011 Edward Kmett+Copyright 2011-2013 Edward Kmett All rights reserved. @@ -12,10 +12,6 @@ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.--3. Neither the name of the author nor the names of his contributors- may be used to endorse or promote products derived from this software- without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
semigroups.cabal view
@@ -1,6 +1,6 @@ name: semigroups category: Algebra, Data, Data Structures, Math-version: 0.10+version: 0.11 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -9,11 +9,9 @@ stability: provisional homepage: http://github.com/ekmett/semigroups/ bug-reports: http://github.com/ekmett/semigroups/issues-copyright: Copyright (C) 2011 Edward A. Kmett-synopsis: Haskell 98 semigroups+copyright: Copyright (C) 2011-2013 Edward A. Kmett+synopsis: Anything that associates description:- Haskell 98 semigroups- . In mathematics, a semigroup is an algebraic structure consisting of a set together with an associative binary operation. A semigroup generalizes a monoid in that there might not exist an identity element. It also (originally) generalized a group (a monoid with all inverses) to a type where every element did not have to have an inverse, thus the name semigroup. build-type: Simple extra-source-files: .travis.yml README.markdown
src/Data/List/NonEmpty.hs view
@@ -5,7 +5,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Data.List.NonEmpty--- Copyright : (C) 2011 Edward Kmett,+-- Copyright : (C) 2011-2013 Edward Kmett, -- (C) 2010 Tony Morris, Oliver Taylor, Eelis van der Weegen -- License : BSD-style (see the file LICENSE) --@@ -36,6 +36,7 @@ , init -- :: NonEmpty a -> [a] , (<|), cons -- :: a -> NonEmpty a -> NonEmpty a , uncons -- :: NonEmpty a -> (a, Maybe (NonEmpty a))+ , unfoldr -- :: (a -> (b, Maybe a)) -> a -> NonEmpty b , sort -- :: NonEmpty a -> NonEmpty a , reverse -- :: NonEmpty a -> NonEmpty a , inits -- :: Foldable f => f a -> NonEmpty a@@ -153,6 +154,13 @@ uncons :: NonEmpty a -> (a, Maybe (NonEmpty a)) uncons ~(a :| as) = (a, nonEmpty as) {-# INLINE uncons #-}++unfoldr :: (a -> (b, Maybe a)) -> a -> NonEmpty b+unfoldr f a = case f a of+ (b, mc) -> b :| maybe [] go mc+ where+ go c = case f c of+ (d, me) -> d : maybe [] go me instance Functor NonEmpty where fmap f ~(a :| as) = f a :| fmap f as
src/Data/Semigroup.hs view
@@ -9,7 +9,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Data.Semigroup--- Copyright : (C) 2011 Edward Kmett,+-- Copyright : (C) 2011-2013 Edward Kmett, -- License : BSD-style (see the file LICENSE) -- -- Maintainer : Edward Kmett <ekmett@gmail.com>@@ -80,6 +80,7 @@ import Data.Text.Lazy as Lazy import Data.Hashable import Data.HashMap.Lazy as Lazy+import Data.HashSet #endif #ifdef LANGUAGE_DeriveDataTypeable@@ -291,6 +292,10 @@ instance (Hashable k, Eq k) => Semigroup (Lazy.HashMap k a) where (<>) = mappend++instance (Hashable a, Eq a) => Semigroup (HashSet a) where+ (<>) = mappend+ times1p _ a = a #endif -- | Provide a Semigroup for an arbitrary Monoid.