<div dir="auto">I think non-wrapping Word should be a different type or two. I'm quite fond of the ring laws myself. For many practical purposes, Word64 can stand in for Natural. A non-wrapping variant (newtype, perhaps?) might be useful. Another occasionally useful one is Word63, which is good for bounds-checked operations.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021, 7:53 AM Ben Franksen <<a href="mailto:ben.franksen@online.de">ben.franksen@online.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 01.03.21 um 17:45 schrieb Johannes Waldmann:<br>
> let's fight Int.<br>
<br>
I'm in.<br>
<br>
> In a lot of code I write (for research, teaching, production),<br>
> a lot of numbers are in fact natural numbers -<br>
> because I am counting (e.g., number of elements in a collection)<br>
> or pointing into what I just counted (e.g., Data.Set.elemAt).<br>
> <br>
> But Haskell's "most natural" type is - Int.<br>
> At least that's my impression from current usage in libraries<br>
> and teaching examples (see functions length, replicate, ... ).<br>
> <br>
> I've developed a horror<br>
> of reading and writing "length something :: Int".<br>
<br>
Same here.<br>
<br>
> If I want to live risky (no checks) I could use Data.Word.<br>
<br>
I think Data.Word is not so bad. Does it come with a guarantee that<br>
maxBound=2^n-1 and all operations being treated module 2^n, for some<br>
natural number n? That would be fine for most applications I guess.<br>
<br>
It would be nice if one could change the semantics of under- or overflow<br>
for Data.Word with a compiler flag, e.g. so that it throws an exception.<br>
<br>
> That's all fine and dandy - until I call some library function...<br>
<br>
I would support a move Int->Word in all libraries where that makes sense.<br>
<br>
But I doubt it will happen.<br>
<br>
Cheers<br>
Ben<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>