Haskell / Frege <= <and = << associativity

According to Hoogle, the fixation <=< (composition of the Claysley monad or "left fish") and =<< (inverse monad-binding) is infixr 1 . If I look at them correctly, an expression like, say

 print <=< return =<< return "foo" 

must be invalid because it would be equivalent to equally invalid

 print <=< (return =<< return "foo") 

But for some reason, although the first expression seems to be invalid in Haskell, as expected, Frege does not seem to have complaints, and evaluates <=< to =<< .

I discovered this when I was messing around pointfree.io to figure out how to do something like

 foo >>= (bar <=< baz) 

point-free and he gave me

 bar <=< baz =<< foo 

which doesn’t look quite right, given the problems.

+5
source share
1 answer

Frege is similar to Haskell, but Frege is not Haskell. And in Frege, the corrections for these operators are different: =<< is infixr 2 and <=< - infixr 3 . Since <=< has a lower priority, bar <=< baz =<< foo naturally parsed as (bar <=< baz) =<< foo .

(In fact, =<< and <=< are of different types in Frege than in Haskell: instead of restricting to Monad they have Bind , where Bind is like Monad without pure / return .)


Yes, Frege describes itself as “Haskell for the JVM,” but they mean “Haskell” in the sense that Common Lisp is Lisp and the schema is Lisp and Clojure is Lisp. It is strange to see that Haskell is used in this way; it would be more normal to see a "Haskell-like language for the JVM" or something more powerful. But Frege is so similar that I understand why.


Also, you're right: it looks like an error in pointfree (a program that supports pointfree.io )! pointfree should generate Haskell code, not Frege, so the fact that this conversion is not valid means that it is doing the wrong thing.

+6
source

Source: https://habr.com/ru/post/1257805/


All Articles