GenCompress.dcl 733 Bytes
Newer Older
Camil Staps's avatar
Camil Staps committed
1
definition module Data.GenCompress
2

Camil Staps's avatar
Camil Staps committed
3 4
import StdGeneric
from Data.Maybe import :: Maybe
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

:: BitVector :== {#Int}

:: CompressSt

generic gCompress a :: !a -> *CompressSt -> *CompressSt
derive gCompress Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}

generic gCompressedSize a :: a -> Int
derive gCompressedSize Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}

generic gUncompress a :: (u:CompressSt -> ((Maybe a),u:CompressSt))
derive gUncompress Int, Real, Bool, Char, String, UNIT, PAIR, EITHER, CONS, FIELD, OBJECT, [], {}, {!}

compress :: !a -> BitVector | gCompressedSize{|*|} a & gCompress{|*|} a
uncompress :: (BitVector -> Maybe a) | gUncompress{|*|} a