Skip to content
0:00 / 0:00

#typesystems#naturalnumbers#haskell

What About the Natural Numbers? by José Manuel Calderón Trilla [PWLConf 2019]

PapersWeLove

23K subscribers • 34 videos on Hallway • Community channel

YouTube
  • One of the most-watched uploads on Papers We Love, a conference or university channel Hallway lists. Nobody has recommended it in the communities yet, so it ranks below community picks.
  • Presented by José Manuel Calderón Trilla, Research Scientist at Galois, Inc.
  • Linked in the descriptionpapers-we-love/pwlconf-info
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

4.1K views7 years ago

Programming languagesSoftware designLanguage design and type systemsFunctional programmingSimplicity and complexity

José Manuel Calderón Trilla discusses Colin Runciman's paper on using natural numbers instead of integers to make illegal states unrepresentable.

PWLConf 2019 Link: pwlconf.org/2019/jose-trilla/ Slides / Captions: github.com/papers-we-love/pwlconf-info/tree/master/2019/jose… What About the Natural Numbers? José Manuel Calderón Trilla, Research Scientist at Galois, Inc. 30 years ago Colin Runciman asked What About the Natural Numbers? Now, in 2019, we find ourselves in need of a successor to carry Runciman's banner. Despite major advances in type systems and the growing adoption of the slogan 'make illegal states unrepresentable', we often rely on Integers in cases where negative values have no meaning. Runciman's paper reminds us of a fact that we all know: the choice in types can change the nature of an API. Integers are often the default in many systems and APIs, often for no reason beyond programmer familiarity. In this talk we will argue two main points: that for many cases Natural numbers retain all of the positive aspects of the Integers with none of the negatives, and that when designing a system or an API we should constantly be asking ourselves "What about X?" References ------------------ What About the Natural Numbers by Colin Runciman (sciencedirect.com/science/article/pii/0096055189900040?via%3…) Biography ---------------- José Manuel Calderón Trilla studied Music Engineering Technology at the University of Miami before pursuing graduate work in Natural Computation (MSc) and Programming Languages (PhD) at the University of York in the UK. After his PhD work he became a Research Scientist at Galois, Inc. working mostly on Quantitative Information Flow, compilers, and abstract interpretation. His research interests are in parallel functional languages, DSLs, computer music (particularly the representation and manipulation of structures representing rhythm), and compilers. Playing music and baking bread are what occupy most of his time, though he has yet to find a way to combine the two hobbies. Twitter: twitter.com/josecalderon Site: jmct.cc/ DBLP: dblp.org/pers/hd/t/Trilla:Jos=eacute=_Manuel_Calder=oacute=n ----------------------------------------------------------------------------------------------------------- Video Sponsor: Comcast (jobs.comcast.com/) Captioning Sponsor: Two Sigma (twosigma.com/careers/) -----------------------------------------------------------------------------------------------------------

Why it's here

A top upload from a listed channel

Papers We Love is on Hallway's list of conference and university channels, and this upload is one of its most-watched talks or lectures. Nobody has recommended it in the communities yet, so it ranks below community picks.

Moments people linked to

u/Noughtmarein r/haskell • Mentions

On “Does anyone have a good analogy for understanding foldl and foldr for infinite lists?”

With your example of an infinite line of people, the most important question is who do you get the final answer from? The foldr function gets the final answer from the first person in the line, while foldl gets the final answer from the last person in the line. In an infinite line there is no last person, so foldl never gets an answer. You might now ask: how can the first person get an answer before everyone is done passing on the information? The answer to this is laziness. The first person gives small pieces of the answer directly when he gets enough information about it. That person doesn't have to wait until everyone is done. EDIT: as /u/darthminimall mentions, summing all the numbers…

u/Noughtmarein r/haskell • Mentions

On “Why using Int over Word is convention in Haskell?”

If we stop using signed integers then we should also stop using bounded integers, see: What About the Natural Numbers? by José Manuel Calderón Trilla.

u/Noughtmarein r/haskell • Mentions

On “Why do http libraries use Int for port numbers instead of Word16?”

I think the problem with 4 is that now every function has less static guarantees. Suddenly, a lot of functions that should only return natural numbers can also return negative integers. So, while 4 makes it slightly easier to notice bugs, it decreases the guarantees that you get about what kind of numbers are used. I would say that, especially for common libraries like the Prelude that are expected to be correct, stronger guarantees for users are often preferred to the slight improvement to the ability to notice bugs. Take for example the `length` function for lists. Have you ever seen anyone who checked that that function really returns a non negative integer? I haven't. We don't get that…

u/Noughtmarein r/haskell • Mentions

On “So long Surrogates: How we moved to UTF-8 in Haskell”

I think it would be nice if we had a high-level interface to text for people that don't care quite so much for performance. Having intuitive APIs that are hard to misuse is much more important than performance in my opinion. That's one of the reasons I like Haskell so much. Also, in this blog post, as I understand it, Channable discards code points and simply uses bytes to get the best performance. So, even if you do care about performance, you might not want to use code points. Funny that you bring up `Integer` as I am also of the opinion that we should actually be using proper natural numbers much more often. I guess someone could make a similar talk called "What about grapheme cluster…

u/ddellacostain r/haskell • Mentions

On “Library for natural numbers”

On a related note, folks here may find this interesting/entertaining: [video EDIT: this is a link to the talk "What About the Natural Numbers?" by José Manuel Calderón Trilla, and you can just check out the slides/see a transcript here if that's better.
5View on Reddit

u/pthierryin r/haskell • Mentions

On “replacements for !!”

I just realized my first attempt at `safeNth` would loop indefinitely given an infinite list and a negative integer… (easy to fix) Reminds me of the talk What about the natural numbers? I just saw a few days ago.