@@ -1,30 +1,30 @@
1name: type-level-sets
1name: type-level-sets
2−version: 0.6
2+version: 0.6.1
3−synopsis: Type-level sets and finite maps (with value-level counterparts and various operations)
3+synopsis: Type-level sets and finite maps (with value-level counterparts)
4description:
4description:
5 This package provides type-level sets (no duplicates, sorted to provide a normal form) via 'Set' and type-level
5 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.
8 Described in the paper \"Embedding effect systems in Haskell\" by Dominic Orchard
8 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.
11− Here is a brief example:
11+ Here is a brief example for finite maps.:
14 > import Data.Type.Map
14 > import Data.Type.Map
16− > foo :: Set '["x" :-> Int, "z" :-> Int, "w" :-> Int]
16+ > foo :: Map '["x" :-> Int, "z" :-> Int, "w" :-> Int]
17 > foo = Ext ((Var :: (Var "x")) :-> 2) $
17 > foo = Ext ((Var :: (Var "x")) :-> 2) $
18 > Ext ((Var :: (Var "z")) :-> 4) $
18 > Ext ((Var :: (Var "z")) :-> 4) $
19 > Ext ((Var :: (Var "w")) :-> 5) $
19 > Ext ((Var :: (Var "w")) :-> 5) $
22− > bar :: Set '["y" :-> Int, "w" :-> Int]
22+ > bar :: Map '["y" :-> Int, "w" :-> Int]
23 > bar = Ext ((Var :: (Var "y")) :-> 3) $
23 > bar = Ext ((Var :: (Var "y")) :-> 3) $
24 > Ext ((Var :: (Var "w")) :-> 1) $
24 > Ext ((Var :: (Var "w")) :-> 1) $
27− > -- foobar :: Set '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
27+ > -- foobar :: Map '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
28 > foobar = foo `union` bar
28 > foobar = foo `union` bar
30 The 'Set' type for 'foobar' here shows the normalised form (sorted with no duplicates).
30 The 'Set' type for 'foobar' here shows the normalised form (sorted with no duplicates).
@@ -34,11 +34,31 @@ description:
34 > [(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)]
34 > [(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)]
36 Thus, we see that the first value paired with the \"w\" variable is dropped.
36 Thus, we see that the first value paired with the \"w\" variable is dropped.
37+ For sets, here is an example:
39+ > import GHC.TypeLits
40+ > import Data.Type.Set
41+ > type instance Cmp (Natural n) (Natural m) = CmpNat n m
43+ > data Natural (a :: Nat) where
45+ > S :: Natural n -> Natural (n + 1)
47+ > -- foo :: Set '[Natural 0, Natural 1, Natural 3]
48+ > foo = asSet $ Ext (S Z) (Ext (S (S (S Z))) (Ext Z Empty))
50+ > -- bar :: Set '[Natural 1, Natural 2]
51+ > bar = asSet $ Ext (S (S Z)) (Ext (S Z) (Ext (S Z) Empty))
53+ > -- foobar :: Set '[Natural 0, Natural 1, Natural 2, Natural 3]
54+ > foobar = foo `union` bar
56+ Note the types here are all inferred.
38license: BSD3
58license: BSD3
39license-file: LICENSE
59license-file: LICENSE
40category: Type System, Data Structures
60category: Type System, Data Structures
41−copyright: 2013-14 University of Cambridge
61+copyright: 2013-16 University of Cambridge
42author: Dominic Orchard
62author: Dominic Orchard
43maintainer: Dominic Orchard
63maintainer: Dominic Orchard
44stability: experimental
64stability: experimental