5 ms·
Makes me cringe to hear someone say `|>` is the `pipe operator`. If you're thinking operators your probably doing it wrong in functional programming. It's sim
by arianvanp 13y ago
Makes me cringe to hear someone say `|>` is the `pipe operator`.
If you're thinking operators your probably doing it wrong in functional programming.
It's simply another higher-order function that enables function composition. g |> f = λx → f (g (x))
edit: My reasoning might be really flawed as I have no idea if erlang/elixr can define functions that look like `operators` and therefore don't know if `|>` is built in. Yet, you shouldn't assume |> is some magical thing, but respect it as a higher-order function in my opinion.
- _pmf_ 13y ago> If you're thinking operators your probably doing it wrong in functional programming. Stating that the creator of Erlang is doing FP wrong is a bold statement.
- jacquesm 13y ago> Makes me cringe to hear someone say Do you have an inkling of who the 'someone' is in this case? Let me help you, in case you don't: http://en.wikipedia.org/wiki/Joe_Armstrong_%28programming%29 http://en.wikipedia.org/wiki/Joe_Armstrong_%28programming%29
- arianvanp 13y agoI'm not going to change the way I speak based on who I am speaking to. fine, accuse me of speaking wrongly by telling me why and i'll accept it. I made a bit of a bold statement, an I appreciate people correcting me appropiatly by giving me valid reasons why my statement is wrong. But basing your argument on an appeal to authority is just a logical falacy and is annoying.
- jacquesm 13y agoWhen in a hole, stop digging.
- rdtsc 13y ago> But basing your argument on an appeal to authority is just a logical falacy(sic) and is annoying. But you are also making statements full of adjectives and subjective descriptions such "makes me cringe" and "probably doing it wrong". That is quite a bit of flair for someone expecting logical and nice refutation of their own statements. If you jump in the middle of the discussion, throwing around "you're wrong, you're wrong, you're wrong" at everyone then don't be surprised you get replies that are equally accusatory and harsh. BTW I still don't see what is really so cringe-worthy in calling it an operator. It is just syntactic sugar. Call it green tomatoes if you want. Joe calls it an operator. I understand what Joe means. It is like yelling at someone talking about function default arguments and saying "ha! bit it is all assembler underneath, all this is wrong, it is just registers and pointers!".
- evilduck 13y agoAnd when someone says that the original author of Erlang is speaking wrong about a basic mechanism of... Erlang, I don't think there's going to be many objective responses, probably more pointing and laughing.
- davidw 13y agoIt's not a basic mechanism of Erlang, but Elixir.
- evilduck 13y agoI'm not well versed in either language, but from the examples provided in the TFA it looks to me like the capability/mechanism of the operator appears to exist in Erlang and Prolog, while the operator syntax itself is only in Elixir.
- jasonwocky 13y agoIt's not an appeal to authority. It's Bayesian probability. P(author_doing_fp_wrong) < P(author_doing_fp_wrong | author_invented_erlang)
- chc 13y agoNot sure if you got your sign backwards or if this is a really nerdy burn on Erlang.
- jasonwocky 13y agodamn! sign backwards! /blush
- abraininavat 13y agoEven with your operator fixed, this is still bull. This only only instructive if you have zero external knowledge regarding the context. Since we can read Joe Armstrong's words, and since we can read arianvanp's objection, and since most of us have brains, we can and should do a lot better than "bayesian probability".
- saraid216 13y ago> basing your argument on an appeal to authority is just a logical falacy This is incorrect. An appeal to an authority is a valid argument. The fallacy is an appeal to a false authority. When you make a statement like "it makes me cringe", you are making an appeal to your own authority. Cringe-worthiness has nothing to do with reasoning or logic: it's only relevant if your opinion matters, and your opinion only matters if you're (1) the audience of the argument or (2) an authority. If you do not claim to be an authority, you are dismissing your own argument: you acknowledge its own fallaciousness. https://en.wikipedia.org/wiki/Argument_from_authority https://en.wikipedia.org/wiki/Argument_from_authority
- arianvanp 13y agoI have to disagree on this one. Even if you appeal to a True authority, you're just moving the onus to the one you're arguing with. You're not giving a valid argument, but ask your opponent to go find a counterargument himself. I think many eod consider that a fallacy.
- saraid216 13y ago> Even if you appeal to a True authority, you're just moving the onus to the one you're arguing with. You're not giving a valid argument, but ask your opponent to go find a counterargument himself. This is always the case, though. If I say, "Fish need water, fish are good, so we should provide water," you have to independently verify my claims yourself or choose to accept the assertion. No claim is exempt from this. > I think many eod consider that a fallacy. Sorry, I don't know what an "eod" is. Unless you mean "end of day", in which case you're making an argument from popularity which, I'm sure you know, is a fallacious argument because popularity isn't a valid authority for determining whether or not something is a fallacy.
- abraininavat 13y agoBlah blah blah. Knowing about logical fallacies can be instructive for the skeptical among us, but often bringing them in every-day discussions is pedantic. Regardless of whether the statement was an appeal to authority, regardless of whether Joe Armstrong or arianvanp are "true authorities" or if that's even objectively determinable, regardless of whether we consider inductive arguments as persuasive... regardless of all that.. we have brains. You can see what Joe Armstrong wrote. You can pick up Erlang and Elixir and use them yourself. You can see what arianvanp wrote. Some of us (excepting jacquesm, of course) have the capacity to use our own brains to consider the validity of the arguments at hand without having to resort to the lazy inductive argument that Joe Armstrong is smart about Erlang and therefore is probably right. If you have a brain, use it instead of checking it in at the door.
- abraininavat 13y agoWhy has this comment not been voted out of existence? If arianvanp is wrong it's because he's wrong. If his way of phrasing things is uncalled for or downright rude, then it's uncalled for or downright rude. But it doesn't matter if it was Joe Armstrong, Albert Einstein, or Sloth Fratelli who he is responding to. See masklinn's response for how to avoid stupid responses like this one. Or kvb's. Or even rtdsc's.
- jacquesm 13y ago> Why has this comment not been voted out of existence? Because when you make a bunch of rude and unfounded accusations against not 'an' authority in the field but 'the' authority in the field you come across as not having done your homework. It would be like telling PG what hackernews is supposed to be (I think we've had that one) or to tell Abelson why he doesn't understand the basics about lisp or scheme. At some point appeals to authority are perfectly ok, not every dumb point made in an insulting and rude way needs to be refuted by textbook rules. And really, not being aware who the players are and attempting to play the game is a-ok with me, just make sure that you have your t's crossed and your i's dotted when you do and nobody will call you out for making a fool of yourself. And yes, it does matter whether it is Joe Armstrong or not, and how matters regardless of who it is.
- abraininavat 13y agoBecause when you make a bunch of rude and unfounded accusations against not 'an' authority in the field but 'the' authority in the field you come across as not having done your homework But why? In the same situation but talking to a non-expert, do you magically come across as having done your homework? What's wrong with telling Abelson he doesn't understand the basics about lisp? Are these people infallible? Does your hero-worship allow for all-knowing experts to sometimes forget shit? Does senility factor into the equation, or do we drop to our knees at every utterance until they die?
- upthedale 13y agoBut he isn't 'the' authority in FP, simply 'an' authority. And this particular thread seems to be more grounded in discussing FP concepts than Erlang. I had a similar thought when reading the article, unaware to who wrote it... I wondered how currying and the like factored into the language, and thought that comparing |> to unix pipes was a big simplification. And whilst this simplification might be intentional for the article's purpose of giving an overview, it instead read - to me at least prior to realising who the author was - like the author was not fully informed on its use in other FP languages.
- masklinn 13y ago> If you're thinking operators your probably doing it wrong in functional programming. I'm sorry but that simply makes no sense. Yes, many FP languages have custom & customizable operators. They still have built-in operators which are actual operators for real. And there are also FP languages which do not have custom & customizable operators. Erlang is one of the latter. > My reasoning might be really flawed as I have no idea if erlang/elixr can define functions that look like `operators` It can not.
- kvb 13y agoThe word "operator" need not imply "a built-in construct"; instead it's often used to describe a name made up of symbols, which is how it appears to be used here. In F#, for instance, where |> is used frequently because it improves type inference, it is defined in the standard library as `let (|>) x f = f x` (note that the definition you give is actually for the related (>>) operator). Would you claim that someone is "doing it wrong" because they call (+) the "addition operator"?
- arianvanp 13y agoye you're right. (|>) = flip ($) now I come to think of it.
- rdtsc 13y agoYes, my functional programming is holier than thine.
- jlouis 13y agoTwo points: * Erlang, nor Elixir, has currying. And they can't define their own infix identifiers/operators. This severely limits the way the language works, and you need built in support. * the |> notion is not even a higher-order combinator in Elixir. It is a special-case built-in you cannot redefine. I agree with you that this is a bad design decision if you are to evolve the Erlang language :P
- arianvanp 13y agoYou're probably the only one who got my point. That's not because others were stupid, but because of my horrible formulation.
- jeremyjh 13y agoElixir does have currying/partial application. I can say: plus_one = &1 + 1 Enum.map [1,2,3], plus_one
- jerf 13y agoPartial application and currying are not the same thing. (That's not a value judgment, they're just different things.) That's partial application.
- DannoHung 13y agoPersonally, I'm just not sure what the association with monads is supposed to be. Shouldn't Joe Armstrong know what function composition is when he sees it? (Although it is really weird that it slots into the first argument position.)
- zem 13y agoslotting into the first argument position is not weird, it's the functional idiom for the pattern "take a single value and apply a sequence of transforms (some of which have side inputs) to it". in an object-oriented language it would be foo = bar.f(args).g(args).h(args) where bar is being "piped" through the functions f, g, and h.
- fusiongyro 13y agoI suspect Joe is referring to the fact that when you desugar "do notation" you arrive at basically a lot of function composition: do x <- f y <- g return $ h (x + y) becomes f >>= (\x -> g >>= (\y -> return (h (x+y)))) I don't think Joe does a lot of Haskell, so I'm not sure his vision of monads matches up with a Haskeller's though. For me, the fact that monadic do-notation desugars this way is less meaningful than that a monad is anything that supplies the functions bind and return with the necessary types. After all, not every block introduced by "do" is an SSA-friendly looking series of assignments leading up to some function call.