tfausak / flow

:droplet: Write more understandable Haskell.
https://hackage.haskell.org/package/flow
MIT License
198 stars 10 forks source link

Confusing / misleading prop examples? #14

Closed glebec closed 6 years ago

glebec commented 6 years ago
\x -> (x |> f) == f x
\x -> (x |> f |> g) == g (f x)

These two examples from the docs are easily misconstrued, IMHO. The intent, and syntactically this is correct, is to show that "for any x, (x |> f) == f x. But when I first saw these, I momentarily read this as equating the thing to the right of the == (that is, f x) to the entire left half of the expression (\x -> (x |> f)), which is of course incorrect.

Now, that could be because I personally am not very familiar with how prop works in Haddock, and I also didn't know offhand how op precedence interacts with the lambda abstraction arrow, which perhaps most Haskellers would know implicitly. I also struggled to find any convention or documentation for prop after an admittedly short time searching.

OTOH, if I made this error, I think it is conceivable that others might too. Since the code is entirely correct, I don't know that this needs to change — feel free to close this issue — but if the intent of documentation is to clarify, then perhaps this would be an improvement:

\ x -> ((x |> f) == f x)
\ x -> ((x |> f |> g) == g (f x))

I am sorry that it is more verbose. If I could know better how Haddock prop works then perhaps I can propose a better revision.

glebec commented 6 years ago

…on second thought I'm just going to preemptively close this. The more I think about it, the more I think it's not a true issue with the project, and more just an issue with me parsing the text incorrectly. :-P