sdnv-0.1.1: Self-delimiting numeric values encoding library

Safe HaskellSafe
LanguageHaskell2010

Numeric.SDNV

Synopsis

Documentation

data SDNV a Source #

Instances

Eq (SDNV a) Source # 

Methods

(==) :: SDNV a -> SDNV a -> Bool #

(/=) :: SDNV a -> SDNV a -> Bool #

Binary (SDNV a) Source # 

Methods

put :: SDNV a -> Put #

get :: Get (SDNV a) #

putList :: [SDNV a] -> Put #

encodeSDNV :: (Bits a, Integral a) => a -> SDNV a Source #

Encode a value into SDNV. Please note that encoding of variable length negative values such as of type Integer results in sign lost.

decodeSDNV :: (Bits a, Integral a) => SDNV a -> a Source #

Decode SDNV into an integral value. This function doesn't check SDNV integrity and size, and in certain cases may produce incorrect results. See safeDecodeSDNV.

safeDecodeSDNV :: (Bits a, Integral a) => SDNV a -> Maybe a Source #

Decode SDNV into an intergral value. This function uses isValidSDNV to detect incorrectly encoded SDNV, and to check for overflow in case of finite size types.

isValidSDNV :: forall a. (Bits a, Integral a) => SDNV a -> Bool Source #

Check SDNV correctness. Returns True if SDNV is correctly encoded and decoding will not result in an overflow for finite datatypes.