@@ -1,5 +1,5 @@
11name: type-level-sets
2−version: 0.7
2+version: 0.8.0.0
33synopsis: 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
@@ -8,32 +8,37 @@ description:
88 Described in the paper \"Embedding effect systems in Haskell\" by Dominic Orchard
99 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 for finite maps.:
11+ Here is a brief example for finite maps:
1212 .
1313 >
1414 > import Data.Type.Map
1515 >
16− > foo :: Map '["x" :-> Int, "z" :-> Int, "w" :-> Int]
17− > foo = Ext ((Var :: (Var "x")) :-> 2) $
18− > Ext ((Var :: (Var "z")) :-> 4) $
19− > Ext ((Var :: (Var "w")) :-> 5) $
20− > Empty
16+ > -- Specify how to combine duplicate key-value pairs for Int values
17+ > type instance Combine Int Int = Int
18+ > instance Combinable Int Int where
19+ > combine x y = x + y
20+ >
21+ > foo :: Map '["x" :-> Int, "z" :-> Bool, "w" :-> Int]
22+ > foo = Ext (Var :: (Var "x")) 2
23+ > $ Ext (Var :: (Var "z")) True
24+ > $ Ext (Var :: (Var "w")) 5
25+ > $ Empty
2126 >
2227 > bar :: Map '["y" :-> Int, "w" :-> Int]
23− > bar = Ext ((Var :: (Var "y")) :-> 3) $
24− > Ext ((Var :: (Var "w")) :-> 1) $
25− > Empty
28+ > bar = Ext (Var :: (Var "y")) 3
29+ > $ Ext (Var :: (Var "w")) 1
30+ > $ Empty
2631 >
27− > -- foobar :: Map '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
32+ > -- foobar :: Map '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Bool]
2833 > foobar = foo `union` bar
2934 .
30− The 'Set' type for 'foobar' here shows the normalised form (sorted with no duplicates).
35+ The 'Map' type for 'foobar' here shows the normalised form (sorted with no duplicates).
3136 The type signatures is commented out as it can be infered. Running the example we get:
3237 .
3338 > >>> foobar
34− > [(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)]
39+ > {w :-> 6, x :-> 2, y :-> 3, z :-> True}
3540 .
36− Thus, we see that the first value paired with the \"w\" variable is dropped.
41+ Thus, we see that the values for \"w\" are added together.
3742 For sets, here is an example:
3843 .
3944 > import GHC.TypeLits
@@ -64,9 +69,9 @@ maintainer: Dominic Orchard
6469stability: experimental
6570build-type: Simple
6671cabal-version: >= 1.6
67−tested-with: GHC == 7.10.3
72+tested-with: GHC >= 8.0.1
6873
69−extra-source-files: example.hs
74+extra-source-files: example.hs, example2.hs
7075
7176
7277source-repository head