git.iko.soy/type-level-sets
on master help sign in
documentation
0466aa7Dominic Orchard
README+8−10
@@ -3,34 +3,32 @@ subsets, and split sets. Also included is a "mapping" type constructor that pair
3sets of variable-type pairs, which is used in the paper "Embedding effect systems in Haskell" (Dominic Orchard,
3sets of variable-type pairs, which is used in the paper "Embedding effect systems in Haskell" (Dominic Orchard,
4Tomas Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf>) to embed effect sets.
4Tomas Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf>) to embed effect sets.
5
5
6−Here is some example code!
6+A full example can be seen in 'example.hs'. Here is a shorter version:
7
7
8−<code>
9 {-# LANGUAGE DataKinds, TypeOperators #-}
8 {-# LANGUAGE DataKinds, TypeOperators #-}
10
9
11 import Data.Type.Set
10 import Data.Type.Set
12
11
13− -- foo :: Set '["x" :-> Integer, "z" :-> Integer]
12+ -- foo :: Set '["x" :-> Int, "z" :-> Int]
14 foo = Ext ((Var :: (Var "x")) :-> 2) $
13 foo = Ext ((Var :: (Var "x")) :-> 2) $
15 Ext ((Var :: (Var "z")) :-> 4) $
14 Ext ((Var :: (Var "z")) :-> 4) $
16− Empty
15+ Empty
17
16
18− -- bar :: Set '["y" :-> Integer, "w" :-> Integer]
17+ -- bar :: Set '["y" :-> Int, "w" :-> Int]
19 bar = Ext ((Var :: (Var "y")) :-> 3) $
18 bar = Ext ((Var :: (Var "y")) :-> 3) $
20 Ext ((Var :: (Var "w")) :-> 1) $
19 Ext ((Var :: (Var "w")) :-> 1) $
21 Empty
20 Empty
22
21
23− -- foobar :: Set '["w" :-> Integer, "x" :-> Integer, "y" :-> Integer, "z" :-> Integer]
22+ -- foobar :: Set '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
24 foobar = foo `union` bar
23 foobar = foo `union` bar
25−</code>
26
24
25+Note, that 'foobar' shows the sorted
27−Note, the type signatures are commented out here as they can be inferred.
26+the type signatures are commented out here as they can be inferred.
28Example execution:
27Example execution:
29
28
30−<code>
31 *Main> foobar
29 *Main> foobar
32 {(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)}
30 {(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)}
33−</code>
31+
34
32
35
33
36
34