Sets: Simple set types. Useful to create sets of arbitrary types and nested sets.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

This package answers two problems : how to make sets of types which does not implement the Ord typeclass and how to make arbitrarily nested sets as set theory allows. The first problem is resolved thanks to HomogeneousSet which is a list where duplicates elements are not allowed and the order of elements is forgotten. The second problem is resolved thanks to PureSet, it is a tree structure where the order of the branches does not matter.


[Skip to Readme]

Properties

Versions 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.15.0.0 && <4.16) [details]
License LGPL-3.0-or-later
Author Guillaume Sabbagh
Maintainer guillaumesabbagh@protonmail.com
Category Math, Data
Home page https://gitlab.utc.fr/gsabbagh/sets
Uploaded by gsabbagh at 2022-07-12T12:54:01Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for Sets-0.1.0.0

[back to package description]

Sets

This is a Haskell package which defines sets in a more general way than Data.Set.

Data.Set only allows to create sets of types which implements the Ord typeclass, this package introduces HomogeneousSet which does not require the typeclass Ord.

The PureSet type allows to create nested sets easily. It may be used to study set theory for example.

General info

The homogenous sets implemented in this package require the type contained in the set to implement the typeclass Eq. It ensures there are no duplicate element in the set and that the order of elements does not matter when testing equality. It is slower than Data.Set because we do not require the Ord typeclass, if you only use types which are orderable, use Data.Set instead.

The pure set type implemented in this package is a tree like structure where the order of branches does not matter. It allows arbitrary nesting of sets which is useful to do set theoretic constructions.

Installation

cabal install Sets

Usage

Example usage of homogenous sets :

ghci> import HomogeneousSet
ghci> data Foo = Foo Int Char deriving (Eq) -- an arbitrary type which is not required to implement >Ord typeclass
ghci> s1 = set [Foo 3 'a', Foo 2 'c', Foo 3 'a']
ghci> s2 = set [Foo 2 'c', Foo 3 'a']
ghci> s1 == s2
True

Example usage of pure sets :

ghci> import PureSet
ghci> numberToSet 3
(pureSet [(pureSet []),(pureSet [(pureSet [])]),(pureSet [(pureSet []),(pureSet [(pureSet [])])])])
ghci> putStrLn.prettify $ numberToSet 3
{{}, {{}}, {{}, {{}}}}

Contribution

Any input is appreciated ! Send an email for any remark or question. The git repository : https://gitlab.utc.fr/gsabbagh/sets