Haskellers are usually familiar with monoids. A monoid has an appending operation
mappend and an identity element
mempty. A Semigroup has an append
<>, but does not require an
mempty element. A Monoid can be made a Semigroup with just
instance Semigroup MyMonoid
More formally, 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.
Data.List.NonEmpty were added to
base as of 18.104.22.168. This package now offers a backwards-compatible API and some tools for deriving semigroups with generics.
Contributions and bug reports are welcome!
Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.
GenericSemigroupMonoid, an adapter newtype suitable for
- Work around a bug related to the backported
Generic(1)instances in this package (that could only be triggered on GHC 7.2 or 7.4) in which the hand-written
Selectorinstances for internal data types could overlap with GHC-generated instances.
(<>)method of the backported
Semigroupclass no longer has a default implementation in terms of
mappend. This mirrors the
Data.SemigroupAPI that was introduced in
base-4.9. This is a breaking change for any
Semigroupinstances that are defined in tandem with versions of
baseolder than 4.9.
- Make the backported
Hashable Arginstance reflect its respective variants in the
Hashable Arginstance only hashes the first argument, lest equal values have different hashes.
- Backport the
Lift (NonEmpty a)instance introduced in
Data.List.NonEmptyis now unconditionally
- Use a more efficient
Semigroupinstances for strict and lazy
ST, which were added in
IO, as well as for
Generic1instances back to GHC 7.2, and expose the
Data.Semigroup.Genericmodule on GHC 7.2
- Depend on the
bytestring-builderpackage to ensure
Semigroupinstances for bytestring
ShortByteStringare always defined
- Allow building with
- Add the missing instance for
- Added support for
- Removed the partial functions
- Fixed the
sortWithto match the “Comprehensive comprehensions” paper and
times1pin favor of
- Cleaned up imports to remove warnings on GHC 7.10.
- Restored the ability to build on GHC < 7.6. (
Generic1deriving was only added in GHC 7.6)
GSemigroupclass for generically deriving Semigroup instances.
Arg a bwhich only compares for equality/order on its first argument, which can be used to compute
Arginstance to avoid orphans for GHC 7.10+.
- Added missing
Data.Monoid.Genericmodule to source control.
Semigroupinstances for various Builder constructions in
deepseqversion bound for GHC 7.10 compatibility.
timesNare now reduced to accepting only a
Wholedoesn’t exist in GHC 7.10’s Numeric.Natural, and
natsversion 1 has removed support for the class.
Data.Coerce.coerceon GHC 7.8+ to reduce the number of eta-expansions in the resulting core.
- Avoid conflict with pending
instance NFData a => NFData (NonEmpty a)
NFDatainstances for the types in Data.Semigroup
- Fixed a Trustworthiness problem for GHC 7.8+
- Nathan van Doorn fixed a number of embarrassing bugs in the
instance IsList NonEmpty
Allow for manual removal of dependencies to support advanced sandbox users who explicitly want to avoid compiling certain dependencies they know they aren’t using.
We will fix bugs caused by any combination of these package flags, but the API of the package should be considered the default build configuration with all of the package dependency flags enabled.
Will now build as full-fledged
SafeHaskell if you configure with -f-hashable.
Added some missing
ghc-primon GHC 7.4.
- Added instances for ‘Generic’, ‘Foldable’, ‘Traversable’, ‘Enum’, ‘Functor’, ‘Hashable’, ‘Applicative’, ‘Monad’ and ‘MonadFix’
- Vastly widened the dependency bound on
- Updated to support the new version of
- Added an instance for
- Added the missing instance for
- Added support for
- Added a
(<>)in terms of
Numeric.Naturalto a separate