semigroupoids
Semigroupoids: Category sans id
http://github.com/ekmett/semigroupoids
| LTS Haskell 24.16: | 6.0.1@rev:2 |
| Stackage Nightly 2025-10-24: | 6.0.1@rev:2 |
| Latest on Hackage: | 6.0.1@rev:2 |
semigroupoids-6.0.1@sha256:bfee06a6d88038a88ddd10fc21c230bf5ee3a14d0584dc6ab7ad54a9252c2c21,7539Module documentation for 6.0.1
- Data
- Data.Bifunctor
- Data.Functor
- Data.Groupoid
- Data.Isomorphism
- Data.Semigroup
- Data.Semigroupoid
- Data.Traversable
- Semigroupoids
semigroupoids
A semigroupoid is a Category without id. This package provides a range of
id-free versions of type classes, as well as some supporting functions and
data types.
Field Guide
The diagram below describes the relationships between the type classes defined
in this package, and those from base (with some from contravariant as well). Thick-bordered
nodes correspond to type classes defined in this package; thin-bordered ones are
from elsewhere. Solid edges represent subclass relationships that actually
exist; dashed edges are those which should exist in theory.
We also provide the following table. This is structured in superclass order -
thus, for any type class T, all superclasses of T will be listed before T
in the table.
| Name | Location | Superclass of | Ideally superclass of |
|---|---|---|---|
Functor |
base |
Alt, Apply, Traversable |
|
Foldable |
base |
Traversable, Foldable1 |
|
Bifunctor |
base |
Biapply |
|
Contravariant |
base |
Divise, Decide |
|
Semigroupoid |
semigroupoids |
Category |
|
Alt |
semigroupoids |
Plus |
|
Apply |
semigroupoids |
Bind |
Applicative |
Traversable |
base |
Traversable1 |
|
Foldable1 |
semigroupoids |
Traversable1 |
|
Biapply |
semigroupoids |
||
Divise |
semigroupoids |
Divisible |
|
Decide |
semigroupoids |
Conclude |
Decidable |
Category |
base |
Arrow |
|
Plus |
semigroupoids |
Alternative |
|
Applicative |
base |
Alternative, Monad |
|
Bind |
semigroupoids |
Monad |
|
Traversable1 |
semigroupoids |
||
Divisible |
contravariant |
||
Conclude |
semigroupoids |
Decidable |
|
Arrow |
base |
||
Alternative |
base |
MonadPlus |
|
Monad |
base |
MonadPlus |
|
Decidable |
contravariant |
||
MonadPlus |
base |
We omit some type class relationships from this diagram, as they are not relevant for the purposes of this package.
Contact Information
Contributions and bug reports are welcome!
Please feel free to contact me through Github or on the #haskell IRC channel on LiberaChat.
-Edward Kmett
Changes
6.0.1 [2024.05.04]
- Fix a build error when compiling with
-f-contravariant.
6.0.0.1 [2023.03.16]
- When building with GHC 9.6, require
transformers >= 0.6.1andcontainers >= 0.6.7. This ensures thatsemigroupoidsalways providesTraversable1instances for data types fromtransformersandcontainersunconditionally.
6 [2023.03.12]
-
Drop support for GHC 7.10 and earlier.
-
The
Foldable1andBifoldable1classes have been migrated:- When building with
base-4.18or later,semigroupoidsre-exportsFoldable1andBifoldable1frombase. (These classes were added tobase-4.18as a result of this Core Libraries proposal.) - When building with older versions of
base,semigroupoidsre-exportsFoldable1andBifoldable1from thefoldable1-classes-compatcompatibility package.
Note that the version of
Foldable1thatsemigroupoidsdefined in previous releases only had three class methods:fold1,foldMap1, andtoNonEmpty. Moreover,foldMap1had a default implementation in terms of aFoldableconstraint.base’s version ofFoldable1, however, has some notable differences:- It has many more methods than the three listed above, such as the
foldrMap1method. foldMap1now has a default implementation in terms offoldrMap1instead of in terms of aFoldableconstraint.
To avoid (1) causing issues when upgrading to
semigroupoids-6,Data.Semigroup.Foldableonly re-exports thefold1,foldMap1, andtoNonEmptymethods, which reflects the API in previoussemigroupoidsreleases. If you want to use the other, new class methods ofFoldable1, consider importing it fromData.Foldable1(its home inbase) instead.Difference (2) is trickier, because it is possible that existing code that defines valid
Foldable1instances will need to be migrated. If you have an instance like this:import Data.Semigroup.Foldable data T a = MkT a instance Foldable T where foldMap f (MkT x) = f x instance Foldable1 T -- Relying on Foldable-based defaultsThen calling
foldMap1onTwill throw an error withsemigroupoids-6, asfoldMap1’s default implementation no longer usesFoldable. To migrate this code, change the instance to explicitly definefoldMap1:instance Foldable1 T where foldMap1 f (MkT x) = f xThis approach should be backwards-compatible with previous
semigroupoidsreleases.Some other side effects of this migration include:
- The
Data.Semigroup.Foldable.Classmodule has been deprecated. It no longer serves a useful role, as it simply re-exports a limited subset of theData.Foldable1andData.Bifoldable1API. - All of the
Foldable1andBifoldable1instances that were previously defined insemigroupoidshave now been migrated to downstream libraries (base,bifunctors,containers,tagged, andtransformers), so it is no longer strictly necessary to depend onsemigroupoidsto make use of these instances.
- When building with
-
Add
Generic1-based functions for many classes, useful for writing instances:Data.Functor.Alt.(<!>)->Data.Functor.Alt.galtData.Functor.Apply.{liftF2,liftF3}->Data.Functor.Apply.{gliftF2,gliftF3}Data.Functor.Bind.(>>-)->Data.Functor.Bind.gbindData.Functor.Contravariant.Conclude.{conclude,concluded}->Data.Functor.Contravariant.Conclude.{gconclude,gconcluded}Data.Functor.Contravariant.Decide.{decide,decided}->Data.Functor.Contravariant.Decide.{gdecide,gdecided}Data.Functor.Contravariant.Divise.{divise,divised}->Data.Functor.Contravariant.Divise.{gdivise,gdivised}Data.Functor.Extend.{duplicated,extended}->Data.Functor.Extend.{gduplicated,gextended}Data.Functor.Plus.zero->Data.Functor.Plus.gzeroData.Semigroup.Foldable.{fold1,foldMap1,toNonEmpty}->Data.Semigroup.Foldable.{gfold1,gfoldMap1,gtoNonEmpty}Data.Semigroup.Traversable.{traverse1,sequence1}->Data.Semigroup.Traversable.{gtraverse1,gsequence1}
5.3.7 [2022.01.09]
-
Relax the
Bindconstraints in the following instances toFunctor:-instance (Bind f, Monad f) => Alt (MaybeT f) -instance (Bind f, Monad f) => Plus (MaybeT f) +instance (Functor f, Monad f) => Alt (MaybeT f) +instance (Functor f, Monad f) => Plus (MaybeT f) -instance (Bind f, Monad f, Semigroup e) => Alt (ExceptT e f) -instance (Bind f, Monad f, Semigroup e, Monoid e) => Plus (ExceptT e f) +instance (Functor f, Monad f, Semigroup e) => Alt (ExceptT e f) +instance (Functor f, Monad f, Semigroup e, Monoid e) => Plus (ExceptT e f) -- If building with transformers-0.5.* or older -instance (Bind f, Monad f) => Alt (ErrorT e f) -instance (Bind f, Monad f, Error e) => Plus (ErrorT e f +instance (Functor f, Monad f) => Alt (ErrorT e f) +instance (Functor f, Monad f, Error e) => Plus (ErrorT e f)
5.3.6 [2021.10.07]
- Allow building with GHC 9.2.
- Allow building with
transformers-0.6.*. - Add
Altinstance forIdentity. - Add
Conclude,DecideandDivisetype classes and instances. - Add
(<.*>),(<*.>), andtraverseMaybefunctions, which make it easier to definedTraversable1instances for data types that have fields with a combination ofTraversableandTraversable1instances. - Add
Semigroupoids.Domodule with overloads for use withQualifiedDo. - Add
Apply,Alt,Plus,BindandBindTransinstances for the CPS versions ofWriterTandRWST. - Add
psumfunction toData.Functor.Plus. - Add
Categoricaldata type.
5.3.5 [2020.12.31]
- The build-type has been changed from
CustomtoSimple. To achieve this, thedocteststest suite has been removed in favor of usingcabal-docspecto run the doctests. - Explicitly mark modules as
Safe.
5.3.4 [2019.11.26]
- Achieve forward compatibility with GHC proposal 229.
5.3.3 [2019.08.27]
- Add
AltandPlusinstances forHashMapfrom theunordered-containerspackage.
5.3.2 [2019.01.04]
- Bump the lower bound on
semigroupsto 0.16.2, and avoid incurring the dependency entirely on recent GHCs. - Fix the build on GHC 7.0 and 7.2.
5.3.1 [2018.07.02]
- Fix a regression introduced in
semigroupoids-5.3in which some modules regressed fromTrustworthytoUnsafe.
5.3 [2018.07.02]
- Allow building with
containers-0.6. - Add
Altinstances forFirstandLastfromData.Semigroup, andAltandPlusinstances forFirstandLastfromData.Monoid. - Add missing
Apply,Bind,Extend,Foldable1andTraversable1instances forData.Semigroups,Data.MonoidandGHC.Generics.
5.2.2 [2018.01.18]
- Add
optionaltoData.Functor.Alt(analogous to theoptionalfunction inControl.Applicative) liftF2is now a class method ofApply(mirroring the fact thatliftA2is now a class method ofApplicative).liftF2and(<.>)have default definitions in terms of the other.- Allow building with GHC 8.4
ApplyandBindinstances forQ, from thetemplate-haskellpackage. (As a consequence,Data.Semigroup.Foldableis no longer aTrustworthymodule.)- Add instances for
(:~:)and(:~~:)fromData.Type.Equality, andCoercionfromData.Type.Coercion
5.2.1
- Add the
toNonEmptymethod toFoldable1. AddfoldrM1andfoldlM1functions toData.Semigroup.Foldablethat are defined in terms oftoNonEmpty. - Add
Apply,Bind,Foldable1, andTraversable1instances forComplex - Add
ApplyandBindinstances forHashMapfrom theunordered-containerspackage (on whichsemigroupoidsnow depends) - Add
Semigroupoidinstances forTaggedandConst
5.2
- Revamp
Setup.hsto usecabal-doctest. This makes it build withCabal-1.25, and makes thedoctests work withcabal new-buildand sandboxes. - Added instances to
Alt,Plus,Apply,BindandExtendforGHC.Generics,TaggedandProxywhere appropriate.
5.1
- The remaining orphan instances in
Data.Traversable.Instanceshave been replaced in favor of the orphan instances fromtransformers-compat-0.5. - The documentation now states laws that instances of
Applyare expected to uphold. doctest-0.11support- Fixed compilation of tests with
stack
5.0.1
transformers-compat0.5 support- Removed some redundant constraints.
- GHC 8 support
5.0.0.4
doctest0.10 support
5.0.0.2
- Bugfix for GHC 7.4. PolyKinds on 7.4 cause all sorts of haskell interface file errors. One of the #if guards that turned it off on 7.4 was missing and has been fixed.
5.0.0.1
- Added the CHANGELOG to the distribution so that
hackagecan link to it in the haddocks.
5
- Absorbed
Data.Bifunctor.Apply,Data.Semigroup.BifoldableandData.Semigroup.Traversablefrombifunctors. - This caused us to pick up a dependency on
tagged. - Exiled
Data.Semifunctor.*,Data.Semigroupoid.ProductandData.Semigroupoid.Coproducttosemigroupoid-extras. - This let us open up to older versions of GHC again.
- Set an explicit fixity for
-<-and->-.
4.5
- Major changes to the API to support PolyKinds and DataKinds. This necessarily shuts off GHC <= 7.4.
- Orphan instances have moved upstream into a common
base-orphanspackage.
4.3.1
- Added
asum1toData.Semigroup.Foldable.
4.3.0.1
- Support for ‘ConstrainedClassMethods’ is currently required for GHC HEAD.
4.3
- Added missing instances for
ExceptT. Obtain it viatransformers-compatif need be for oldtransformersversions. - Several
BindandApplyinstances now require somewhat more minimal contexts.
4.2
- Backported
Foldable/Traversableinstances fromlens
4.1
Foldable1/Traversable1for tuples
4.0.4
contravariant1.0 support.
4.0.3
- Added flags to provide unsupported cabal sandbox build modes.
4.0.1
- Fixed bitrot in the
Data.Functor.Extenddocumentation. - Fixed warnings on GHC 7.8.1rc2 caused by importing
Control.Monad.Instances.
4.0
- Merged in the contents of the
groupoidsandsemigroupoid-extraspackages.
3.1
- Added the rectangular band
Semigroupoidfor(,). Would that make it a Bandoid?
3.0.3
- Claim to be
Trustworthywhere necessary
3.0.2
- Tightened the upper bounds slightly to enable PVP compliance while retaining a flexible development cycle.
- Raised the upper bound on
contravariant.
3.0.1
- Removed upper bounds relative to my other packages
- Refactored directory layout