cluss: simple alternative to type classes
A cluss enables you to achieve function overloading, or ad-hoc polymorphism, without creating a new type class.
In order to give ad-hoc polymorphism to a type variable
you simply use
with a list of "type patterns" like
In [Type T, ...] a,
which indicates that the type matches some of the patterns;
which is analogous to a type class indicating that a type matches some of its "instances".
In [Type T, ...] a is what we call a "cluss".
Clusses can easily be used in a nested way and even be recursive; therefore, they are expressive enough to imitate Haskell-98-style type classes.
Clusses, however, go beyond a mere alternative to type classes. They have closed and prioritized instances and open methods, while type classes have open and unprioritized instances and closed methods. Those properties give clusses the advantages different from type classes:
You can judge whether a type
abelongs to a cluss
, on some level, writing
Has as a, since cluss instances are closed.
You can make cluss instances more flexibly, without causing overlapping instances or incoherent instances, since cluss instances are prioritized.
You can create new methods for clusses anywhere in any module, since cluss methods are open.
|Versions [faq]||0.1, 0.2, 0.3|
|Dependencies||base (==4.*), template-haskell (>=2.5) [details]|
|Copyright||(c) Yusuke Matsushita 2014|
|Maintainer||Yusuke Matsushita <email@example.com>|
|Revised||Revision 4 made by Kinokkory at Mon Oct 6 11:41:28 UTC 2014|
|Category||type system, constraints|
|Source repo||head: git clone firstname.lastname@example.org:Kinokkory/cluss.git|
|Uploaded||by Kinokkory at Mon Oct 6 11:27:47 UTC 2014|
|Downloads||2923 total (100 in the last 30 days)|
|Rating||(no votes yet) [estimated by Bayesian average]|
Docs uploaded by user
Build status unknown [no reports yet]
Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.
For package maintainers and hackage trustees