@@ -1,30 +1,30 @@
11name: type-level-sets
2−version: 0.6
3−synopsis: Type-level sets and finite maps (with value-level counterparts and various operations)
2+version: 0.6.1
3+synopsis: Type-level sets and finite maps (with value-level counterparts)
44description:
55 This package provides type-level sets (no duplicates, sorted to provide a normal form) via 'Set' and type-level
6− maps via 'Map', with value-level counterparts.
6+ finite maps via 'Map', with value-level counterparts.
77 .
88 Described in the paper \"Embedding effect systems in Haskell\" by Dominic Orchard
9− and Tomas Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf> (Haskell Symposium, 2014)
9+ and Tomas Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf> (Haskell Symposium, 2014). This version now uses Quicksort to normalise the representation.
1010 .
11− Here is a brief example:
11+ Here is a brief example for finite maps.:
1212 .
1313 >
1414 > import Data.Type.Map
1515 >
16− > foo :: Set '["x" :-> Int, "z" :-> Int, "w" :-> Int]
16+ > foo :: Map '["x" :-> Int, "z" :-> Int, "w" :-> Int]
1717 > foo = Ext ((Var :: (Var "x")) :-> 2) $
1818 > Ext ((Var :: (Var "z")) :-> 4) $
1919 > Ext ((Var :: (Var "w")) :-> 5) $
2020 > Empty
2121 >
22− > bar :: Set '["y" :-> Int, "w" :-> Int]
22+ > bar :: Map '["y" :-> Int, "w" :-> Int]
2323 > bar = Ext ((Var :: (Var "y")) :-> 3) $
2424 > Ext ((Var :: (Var "w")) :-> 1) $
2525 > Empty
2626 >
27− > -- foobar :: Set '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
27+ > -- foobar :: Map '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
2828 > foobar = foo `union` bar
2929 .
3030 The 'Set' type for 'foobar' here shows the normalised form (sorted with no duplicates).
@@ -34,11 +34,31 @@ description:
3434 > [(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)]
3535 .
3636 Thus, we see that the first value paired with the \"w\" variable is dropped.
37+ For sets, here is an example:
38+ .
39+ > import GHC.TypeLits
40+ > import Data.Type.Set
41+ > type instance Cmp (Natural n) (Natural m) = CmpNat n m
42+ >
43+ > data Natural (a :: Nat) where
44+ > Z :: Natural 0
45+ > S :: Natural n -> Natural (n + 1)
46+ >
47+ > -- foo :: Set '[Natural 0, Natural 1, Natural 3]
48+ > foo = asSet $ Ext (S Z) (Ext (S (S (S Z))) (Ext Z Empty))
49+ >
50+ > -- bar :: Set '[Natural 1, Natural 2]
51+ > bar = asSet $ Ext (S (S Z)) (Ext (S Z) (Ext (S Z) Empty))
52+ >
53+ > -- foobar :: Set '[Natural 0, Natural 1, Natural 2, Natural 3]
54+ > foobar = foo `union` bar
55+ .
56+ Note the types here are all inferred.
3757 .
3858license: BSD3
3959license-file: LICENSE
4060category: Type System, Data Structures
41−copyright: 2013-14 University of Cambridge
61+copyright: 2013-16 University of Cambridge
4262author: Dominic Orchard
4363maintainer: Dominic Orchard
4464stability: experimental