Link to Hindley-Milner notation explanation
See original GitHub issueI’m trying to understand some of the method definitions… specifically, what does “~>” mean in the Hindley-Milner notation (is it even Hindley-Milner notation? Got this from Brian Lonsdorf’s https://drboolean.gitbooks.io/mostly-adequate-guide/content/ch7.html).
E.g.
concat :: Semigroup a => a ~> a -> a
Here’s what I understand:
AFAIK, this notations usually describes functions. The only thing I started out knowing about this notation before doing some research was that it’s input1 -> input2 -> … -> inputN -> output.
In any case, concat
is not a function, it’s a method - there’s an example in the doc: s.concat(b)
.
So concat
is a method on an object of “type” Semigroup (i.e. this object implements Semigroup’s interface).
In concat
’s definition, ‘a’ is an object which is of type Semigroup because of “Semigroup a =>” part. This is one of the things I didn’t know upon first landing on the Fantasy Land doc page and later found out from Brian’s book. I landed on the Fantasy Land doc page many times without knowing this (just mentioning in case anyone wants to know some of the issues beginners like myself may have on first encounters with fantasy-land).
Then the definition continues with: “a ~> a -> a”
But concat
only actually takes one input, from the e.g. s.concat(b)
. So a reasonable explanation for “~>” is that it means something like “yes LHS is an argument but via dot notation, not passing it in as an argument” - or something like that.
In any case, could someone please add a link in the README to an explanation of this notation for people who are not familiar with it (or Haskell, or Category theory)?
Many thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:7 (7 by maintainers)
Top GitHub Comments
https://sanctuary.js.org/#types provides an explanation, @justin-calleja. We should link to this section or include something similar in the FL readme itself.
If I’ve forgotten about that, then we should definitely have a bit about it stating the fact!