Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HowThePipeOperatorIsDefined #93

Open
KingKnecht opened this issue Jan 29, 2020 · 5 comments
Open

HowThePipeOperatorIsDefined #93

KingKnecht opened this issue Jan 29, 2020 · 5 comments

Comments

@KingKnecht
Copy link

Would be nice to tell newbies, that F# will make an Infix-operator out of (|>). I was thinking ~30min about the black magic that is going on with the given definition:

let (|>) x f =
      f x

How can x (the list in the example) ever be on the left side of the function |>?

@ChrisMarinos
Copy link
Owner

Hmmm, that's a good point. On one hand, I think it's actually great that you spent 30 minutes thinking about the the black magic since the goal of the koans is to spur that sort of thinking. However, I can also see where it might feel like you're lacking the information to tie all the pieces together.

I'm good with adding a note about the infix if you think it would be helpful. However, I'm curious- did the 30 minutes feel more like you were wrapping your head around a new concept, or did it more feel like you were cheated when you figured out the infix part?

@KingKnecht
Copy link
Author

Because I already read about currying I read about that again, in hope this would solve the problem. But no, couldn't see how that could help me. Then I googled operators, because the title of the koan is "HowThePipeOperatorIsDefined". Didn't want to google Pipe directly .Then I stumbled upon infix operators. Tataa, there it was. Gave me mixed feelings. Happy to understand why it works, a bit angry because it's trivial if you know about the special behavior.
I think most newbies will not even recognize the miracle. They see x and f get reversed, oh cool, that explains it. But if you really think about it, it explains nothing.

I think (custom) infix-operators are a big thing in F# and worth to be mentioned in the koan. How to force people to recognize the problem, I don't know. Maybe a koan about (+)? Used as infix and prefix operator?

@KingKnecht
Copy link
Author

Thinking more about it: The definition of the pipe-operator given in the example is not the point why it works. If the koan should explain why it works, the infix-stuff is mandatory.

@vilinski
Copy link

@KingKnecht can you elaborate a short helpful note, explaining it to you in the way you understand it now? If yes - don't hesitate to make a PR or write a comment.

@sambeckingham
Copy link

Just ran through the Koans myself and didn't even clock the infix/prefix definition part. Went back and looked after reading this issue.

We could probably create an AboutOperators.fs because people from outside of the dotnet ecosystem might not be aware that you can override or implement your own operators, which is useful to know with F# as frameworks like Suave have their own operators like >=>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants