The Cardinality package

[ Tags: data, lgpl, library ] [ Propose Tags ]

This module introduces typeclasses

No, it's not about playing cards. It's about cardinalities. Wikipedia: "/In mathematics, the cardinality of a set is a measure of the number of elements of the set. For example, the set A = 2, 4, 6 contains 3 elements, and therefore A has a cardinality of 3./" In this package I dare to extend the definition a bit to "C. is a measure of the number of elements in a container"

Usual containers are (together with their cardinality ranges):

I extended this to the folowing list:

Typeclass HasCardUCT together with function sContTrans (safe container transform) provides a facility to safely change container from one to another keepeng the content. If content doesn't fit to target container, Nothing is returned. However, when transforming from list [a] to (Maybe a) it won't check list length further first 2 elements. The complexity and power of this package is that it provides a facility to lazily evaluate amount of content in the container.

To interface package functions

import Data.Cardinality


Versions 0.1, 0.2
Change log NEWS
Dependencies base (==4.*), containers, mtl [details]
License LGPL
Copyright Copyright (c) 2010 Andrejs Sisojevs
Author Andrejs Sisojevs <>
Maintainer Andrejs Sisojevs <>
Category Data
Uploaded Wed Jan 20 13:19:09 UTC 2010 by AndreySisoyev
Distributions NixOS:0.2
Downloads 820 total (8 in the last 30 days)
Rating 0.0 (0 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]
Hackage Matrix CI




Maintainer's Corner

For package maintainers and hackage trustees