git.iko.soy/type-level-sets
on master help sign in
documentation
commit0466aa7d3a1a91c0a3619dab648f9342e55bb8ad authorDominic Orchard <dom.orchard@gmail.com> dateThu 11 Sep 2014, 14:50 (12 years ago) parent0e0cd44
1 file changed+8−10
README+8−10
README+8−10
@@ -3,34 +3,32 @@ subsets, and split sets. Also included is a "mapping" type constructor that pair
33sets of variable-type pairs, which is used in the paper "Embedding effect systems in Haskell" (Dominic Orchard,
44Tomas Petricek <http://www.cl.cam.ac.uk/~dao29/publ/haskell14-effects.pdf>) to embed effect sets.
55
6−Here is some example code!
6+A full example can be seen in 'example.hs'. Here is a shorter version:
77
8−<code>
98 {-# LANGUAGE DataKinds, TypeOperators #-}
109
1110 import Data.Type.Set
1211
13− -- foo :: Set '["x" :-> Integer, "z" :-> Integer]
12+ -- foo :: Set '["x" :-> Int, "z" :-> Int]
1413 foo = Ext ((Var :: (Var "x")) :-> 2) $
1514 Ext ((Var :: (Var "z")) :-> 4) $
16− Empty
15+ Empty
1716
18− -- bar :: Set '["y" :-> Integer, "w" :-> Integer]
17+ -- bar :: Set '["y" :-> Int, "w" :-> Int]
1918 bar = Ext ((Var :: (Var "y")) :-> 3) $
2019 Ext ((Var :: (Var "w")) :-> 1) $
2120 Empty
2221
23− -- foobar :: Set '["w" :-> Integer, "x" :-> Integer, "y" :-> Integer, "z" :-> Integer]
22+ -- foobar :: Set '["w" :-> Int, "x" :-> Int, "y" :-> Int, "z" :-> Int]
2423 foobar = foo `union` bar
25−</code>
2624
27−Note, the type signatures are commented out here as they can be inferred.
25+Note, that 'foobar' shows the sorted
26+the type signatures are commented out here as they can be inferred.
2827Example execution:
2928
30−<code>
3129 *Main> foobar
3230 {(Var :-> 1), (Var :-> 2), (Var :-> 3), (Var :-> 4)}
33−</code>
31+
3432
3533
3634