[Haskell-cafe] Re: Positive integers

Daniel McAllansmith dagda at xtra.co.nz
Sun Mar 26 16:04:08 EST 2006


On Friday 24 March 2006 16:16, Ben Rudiak-Gould wrote:
> Daniel McAllansmith wrote:
> > I can see the domain bounds check would be a problem in theory, but in
> > practice doesn't the type enforce that?  Keeping Word positive costs
> > nothing because it just overflows.  Wouldn't it be much the same?
>
> If you're planning wraparound semantics then you're better off with Int
> indexes. 

I wasn't really _planning_ wrap around semantics.
More just making the point that saying the cost of using Word is greater than 
the cost of using Int, due to the bounds checking required, seems unfair.
I see your point about quick detection of bad indices, though I'd still rather 
have the type document the fact that only positive integers are expected.

Daniel


More information about the Haskell-Cafe mailing list