reset a3, kut Charlie ;)
[tt2015.git] / a3 / code / Generics / GenCompress.dcl
diff --git a/a3/code/Generics/GenCompress.dcl b/a3/code/Generics/GenCompress.dcl
new file mode 100644 (file)
index 0000000..b0d251b
--- /dev/null
@@ -0,0 +1,19 @@
+definition module GenCompress\r
+\r
+import StdGeneric, StdMaybe\r
+\r
+:: BitVector :== {#Int}\r
+\r
+:: CompressSt\r
+\r
+generic gCompress a :: !a -> *CompressSt -> *CompressSt\r
+derive gCompress Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}\r
+\r
+generic gCompressedSize a :: a -> Int\r
+derive gCompressedSize Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}\r
+\r
+generic gUncompress a :: (u:CompressSt -> ((Maybe a),u:CompressSt))\r
+derive gUncompress Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}\r
+\r
+compress :: !a -> BitVector | gCompressedSize{|*|} a & gCompress{|*|} a\r
+uncompress :: (BitVector -> Maybe a) | gUncompress{|*|} a\r