<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">You might want to revisit the following paper by Colin Runciman -:<div><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">author = {Colin Runciman},</span><br style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">    title = {What About the Natural Numbers},</span><br style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">    journal = {Computer Languages},</span><br style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">    year = {1989},</span><br style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">    volume = {14},</span><br style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">    pages = {181--191}</span><br></div><div><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px">It  makes  similar points and fills out details ...</span></div><div><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><br></span></div><div><a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.56.3442">http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.56.3442</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:9.75px"><br></span></div><div><br></div><div>regards</div><div>David</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 2, 2021 at 2:56 PM Johannes Waldmann <<a href="mailto:johannes.waldmann@htwk-leipzig.de">johannes.waldmann@htwk-leipzig.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Dear Cafe,<br>
<br>
<br>
thanks for ideas and arguments.<br>
<br>
<br>
> [Ben Franksen] I would support a move Int->Word in all libraries<br>
> where that makes sense.<br>
<br>
I find it hard to think of a library where that does NOT make sense...<br>
<br>
<br>
The following is somewhat related but actually orthogonal:<br>
I mentioned that numbers often arise as cardinalities<br>
(so they are natural, by definition) and serve as pointers.<br>
The next step is then: pointer type safety. Vincent Hanquez' Foundation<br>
<a href="https://hackage.haskell.org/package/foundation-0.0.25" rel="noreferrer" target="_blank">https://hackage.haskell.org/package/foundation-0.0.25</a>  defines<br>
<br>
class (IsList c, Item c ~ Element c) => Collection c where<br>
  length :: c -> CountOf (Element c)<br>
class ( ... Collection c) => Sequential c where<br>
  take :: CountOf (Element c) -> c -> c<br>
<br>
with   newtype CountOf ty (and there's also   newtype Offset ty)<br>
<br>
I tend to agree. The phantom type argument for CountOf<br>
would catch errors like adding the number of students<br>
to the number of exercises (in my application).<br>
<br>
(Well and the next step after that would be to have<br>
the size of the collection in the (dependent) type as well.)<br>
<br>
Current implementation is  newtype CountOf ty = CountOf Int<br>
and the author adds (and that was also the point I was making)<br>
"Int is a terrible backing type which is hard  to get away from,<br>
considering that GHC/Haskell are mostly using  this for [counting<br>
and] offset. Trying to bring some sanity by a lightweight wrapping."<br>
<br>
<br>
NB: I found out about this from Michael Snoyman's<br>
(very much entertaining, and too much true)<br>
<a href="https://www.snoyman.com/blog/2020/12/haskell-bad-parts-3/" rel="noreferrer" target="_blank">https://www.snoyman.com/blog/2020/12/haskell-bad-parts-3/</a><br>
<br>
<br>
Best regards, J.W.<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" 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><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>David Duke</div><div>Emeritus Professor of Computer Science</div><div>School of Computing University of Leeds UK</div><div><a href="mailto:E%3Aduke.j.david@gmail.com" target="_blank">E:duke.j.david@gmail.com</a></div><div>W:<a href="https://engineering.leeds.ac.uk/staff/334/Professor_David_Duke" target="_blank">https://engineering.leeds.ac.uk/staff/334/Professor_David_Duke</a></div></div></div></div></div></div></div></div></div>