Mikhail Vorozhtsov | 11 Oct 08:06 2012
Picon

ANN: data-dword: Long binary words from short ones

Hi.

I'm pleased to announce my new little library, data-dword[1]. It 
provides Template Haskell utilities for defining binary word data types 
from low and high halves, e.g.

data Word96 = Word96 Word32 Word64 -- strictness is configurable
data Int96 = Int96 Int32 Word64

-- All instances are fully implemented (including `quotRem`, etc)
instance Bounded, Enum, Eq, Integral, Num, Ord, Read,
          Real, Show, Ix, Bits, Hashable

-- Extra bit-manipulating functions, unwrapped addition and
-- multiplication, etc.
instance BinaryWord, DoubleWord

-- Rewrite rules for converting to/from the standard integral types
{-# RULES "fromIntegral/..." ... #-}

The library comes with a pretty thorough test suite (that ATM has some 
failures on x86-32 due to bug #7233[2] in the base library).

[1] http://hackage.haskell.org/package/data-dword
[2] http://hackage.haskell.org/trac/ghc/ticket/7233
Henning Thielemann | 11 Oct 13:09 2012
Picon

Re: ANN: data-dword: Long binary words from short ones


On Thu, 11 Oct 2012, Mikhail Vorozhtsov wrote:

> I'm pleased to announce my new little library, data-dword[1]. It provides 
> Template Haskell utilities for defining binary word data types from low and 
> high halves, e.g.
>
> data Word96 = Word96 Word32 Word64 -- strictness is configurable
> data Int96 = Int96 Int32 Word64

What is the advantage over 'largeword' which does the same with plain 
Haskell 98?

http://hackage.haskell.org/package/largeword
Mikhail Vorozhtsov | 11 Oct 13:55 2012
Picon

Re: ANN: data-dword: Long binary words from short ones

On 10/11/2012 06:09 PM, Henning Thielemann wrote:
>
> On Thu, 11 Oct 2012, Mikhail Vorozhtsov wrote:
>
>> I'm pleased to announce my new little library, data-dword[1]. It
>> provides Template Haskell utilities for defining binary word data
>> types from low and high halves, e.g.
>>
>> data Word96 = Word96 Word32 Word64 -- strictness is configurable
>> data Int96 = Int96 Int32 Word64
>
> What is the advantage over 'largeword' which does the same with plain
> Haskell 98?
>
> http://hackage.haskell.org/package/largeword
1) Control over strictness of the halves
2) Signed types
3) Extra instances/operations
4) Probably faster, due to specialization/inlining/rewrite rules.
5) Test suite

Gmane