Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/athanclark/hset
A faux heterogeneous set implementation in Haskell, leveraging Typeable
https://github.com/athanclark/hset
haskell heterogeneous-sets hset
Last synced: about 1 month ago
JSON representation
A faux heterogeneous set implementation in Haskell, leveraging Typeable
- Host: GitHub
- URL: https://github.com/athanclark/hset
- Owner: athanclark
- License: bsd-3-clause
- Created: 2016-04-26T06:57:27.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-09-28T09:33:08.000Z (over 1 year ago)
- Last Synced: 2023-09-28T11:12:15.261Z (over 1 year ago)
- Topics: haskell, heterogeneous-sets, hset
- Language: Haskell
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HSet
A simple implementation of heterogeneous sets
in Haskell, assuming they implement `Typeable`:```haskell
{-# LANGUAGE
DeriveDataTypeable
, ScopedTypeVariables
#-}import Data.Typeable
import Data.HSet.Mutable as HSet
import Control.Monad.STdata Foo = Foo
{ foo1 :: Int
, foo2 :: Int
} deriving (Typeable)data Bar = Bar
{ bar1 :: Double
} deriving (Typeable)mySet :: ST s (HSet s)
mySet = do
xs <- HSet.new
(fooKey :: HKey Foo) <- HSet.insert (Foo 1 2) xs
(barKey :: HKey Bar) <- HSet.insert (Bar 3.45) xs
```You can then do lookups and deletions with the
`fooKey` and `barKey` mutable references.