# 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 :

```haskell
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 :

```haskell
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

