
Those would remain in Data.Int and Data.Word. -Edward On Wed, Aug 13, 2014 at 8:04 PM, Carter Schonwald < carter.schonwald@gmail.com> wrote:
wait the proposal wasn't for including Intx and Wordx in prelude? ('cause I'd support that strongly! )
On Wed, Aug 13, 2014 at 7:25 PM, John Lato
wrote: On Wed, Aug 13, 2014 at 4:05 PM, Evan Laforge
wrote: On Wed, Aug 13, 2014 at 3:06 PM, Ben Millwood
wrote: `length :: [a] -> Word` (or things of that ilk) would be even more of a mistake, because type inference will spread that `Word` everywhere, and `2 - 3 :: Word` is catastrophically wrong.
This is a pretty convincing argument for me. I have in the past used Word for things that seemed like they should always be positive, and pretty quickly reverted back to a signed type. All you need is a subtraction anywhere and the chance of underflow is very high. And, as Ben said, it's easy for the "always positive" type to wind up in a domain where subtraction is valid due to type inference. The principled thing might be to make that a different type, but in practice that can be a lot of hassle so it often doesn't happen (do you use NonEmpty everywhere possible? always have separate types for absolute and relative measures? sometimes it's not worth the clutter).
I agree it would be wrong to have `length` return a Word unconditionally, but I don't think it's a mistake in general to have that option available (i.e. genericLength). It just means that the programmer is taking on some responsibilities manually instead of leveraging the type system, but sometimes that's the only way to get the desired performance. Besides, nobody is actually proposing that `length` return a Word, so I don't find this argument relevant to the proposal.
Relatively weak +1 from me (I'm more enthusiastic about exporting the entirely of Intx/Wordx types via the prelude).
John L.
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries