question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Link to Hindley-Milner notation explanation

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
davidchamberscommented, Jan 30, 2017

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.

2reactions
SimonRichardsoncommented, Jan 30, 2017

If I’ve forgotten about that, then we should definitely have a bit about it stating the fact!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hindley–Milner type system - Wikipedia
A Hindley–Milner (HM) type system is a classical type system for the lambda calculus with parametric polymorphism. It is also known as Damas–Milner...
Read more >
A reckless introduction to Hindley-Milner type inference
Several months ago I gave a talk at work about Hindley-Milner type inference. ... To give three examples of such languages3:.
Read more >
17. The Hindley-Milner Type System - YouTube
This time I walk you through the (in)famous Hindley - Milner type system, which underpins type checking in Haskell, ML, and many other ......
Read more >
What is Hindley-Milner? - Stack Overflow
Hindley-Milner is a restriction of System F, which allows more types but which requires annotations by the programmer. Share.
Read more >
What part of Milner-Hindley do you not understand?
This is the role of the ⊑ operator, which is unfortunately not explained in this notation. This is confusing for people not used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found