Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Last active May 22, 2024 10:02
Show Gist options
  • Save garybernhardt/122909856b570c5c457a6cd674795a9c to your computer and use it in GitHub Desktop.
Save garybernhardt/122909856b570c5c457a6cd674795a9c to your computer and use it in GitHub Desktop.

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@eduardoleon
Copy link

@Profpatsch I would've just given him the type Bool.

@garybernhardt Any singleton is as good as any other. They're isomorphic.

@garybernhardt
Copy link
Author

garybernhardt commented Aug 31, 2016

@eduardoleon Integers are a set of values containing 5 and others. Strings are a set of values containing "hi" and others. HighFive is the set of values {5, "hi"}, and each of those values also exists within one of the Integer and String sets. A value taken from HighFive is exactly equal to the same value taken from Integer or String, can be compared against it, etc.

This is not an idea that's directly expressible in Haskell; or, as far as I know, in any actual type system. People have told me that it's expressible in TypeScript, but I'm skeptical.

This example is clearly confusing. But, interestingly, the only people who have objected to it have shown that they know an ML-descended language. I suspect that people with no formalities to fall back on pass right over it without a problem. There are sets of values. Some sets intersect with other sets. It's not a big deal.

Of course, all of this is arguing the color that we should paint a yak at the bottom of a rabbit hole. This is the introductory paragraph of a 3,500-word article; a paragraph that contains no details about any formal mathematical system or software system.

@EvgenyOrekhov
Copy link

@garybernhardt It should be add instead of f in this Haskell example:

f :: Num a => a -> a -> a
add x y = x + y

@garybernhardt
Copy link
Author

@EvgenyOrekhov Nice catch, thanks!

@stereobooster
Copy link

There is Complexity Zoo. Does anybody aware of similar resource for type systems?

@JeroenDeDauw
Copy link

Is there a list of languages by type system power like the one at the end of this gist, but then with more languages? There is the Comparison of programming languages by type system on Wikipedia, though this does not have the categorization used in the gist and cannot really be sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment