Live data from Hacker News

Ask HN: How to be fluent in functional language speak?

news.ycombinator.com

91–100 of 112 posts

Re: Ask HN: How to be fluent in functional language speak?

#91
post #89

Earlier quoted context omitted.

I can't think of any way for 1 * 1 to be concatenation. I think the point GP was making is that a monoid has something to do with a function f that takes two arguments a and b where there is a single value for b such that f(a, special_value) == a. I think. As someone who doesn't really understand FP concepts I would probably call those functions "functions that can sensibly be used in a call to array.reduce"

It doesn't need to have a perfect metaphor for all possible cases, just something you can picture in an instant: 'behaves like a concating variable length box sequences'. It's a mnemonic / learning aid, not a formal spec. But I can stretch it :) +: concat marbles sequence * : concat prime factors sequence ++: concat box sequence For * , it can also be reduced to + via logarithms. I just don't have a good metaphor for…

> I just don't have a good metaphor for '+ over reals' this morning.

Skimming through my thesaurus, I found a word for it: "Totalize".

Re: Ask HN: How to be fluent in functional language speak?

#92
post #82

Earlier quoted context omitted.

concat?

I can't think of any way for 1 * 1 to be concatenation. I think the point GP was making is that a monoid has something to do with a function f that takes two arguments a and b where there is a single value for b such that f(a, special_value) == a. I think. As someone who doesn't really understand FP concepts I would probably call those functions "functions that can sensibly be used in a call to array.reduce"

> As someone who doesn't really understand FP concepts I would probably call those functions "functions that can sensibly be used in a call to array.reduce"

So reduceables?

Re: Ask HN: How to be fluent in functional language speak?

#93
post #78

Earlier quoted context omitted.

I definitely sufficiently hedged my original claim: > OCaml's type system is not powerful/expressive enough that (to use the given example) abstracting over type constructors is likely to ever come up. And I stand by that. It’s not likely to ever come up, even if it’s possible to kludge it. You’re right about the name though - it seems like the anomalous use of “functor” predates francophone intervention.

It's weird to call it anomalous ML came first in the programming sphere. What you said is that it's not powerful or expressive enough, but my impression was that they were both expressible in terms of System Fω, an understanding I would like to correct if it's wrong.

> It's weird to call it anomalous ML came first in the programming sphere.

Eilenberg and Lane introduced functors (in the sense more or less used by Haskell) in the 40s.

> my impression was that they were both expressible in terms of System Fω

This is not correct anymore - Fω is insufficient to describe GADTs. You need coercions and equality constraints as well.

It's also approximately as useful a claim as "the languages are equally powerful because they're both Turing complete".

I'm referring to practicability, not theoretical possibility (and I've clarified as much several times now).

Re: Ask HN: How to be fluent in functional language speak?

#94
post #73

Earlier quoted context omitted.

Giving descriptive names just harms intuition building in the long run. I've been writing Haskell for over 5 years and to this day when I see , , >>= in my code I don't substitute English words for them.

Was about to complain you can't google them, but I tried it and it worked. Huh. I guess you can google symbols now, even traditionally escapey-ones. News to me. mentalModel.update(). The query `python @` fails pretty hard though.

I tend to just query the repl when I don't know a symbol.

    :info (>=>)

Re: Ask HN: How to be fluent in functional language speak?

#95
post #82

Earlier quoted context omitted.

concat?

I can't think of any way for 1 * 1 to be concatenation. I think the point GP was making is that a monoid has something to do with a function f that takes two arguments a and b where there is a single value for b such that f(a, special_value) == a. I think. As someone who doesn't really understand FP concepts I would probably call those functions "functions that can sensibly be used in a call to array.reduce"

> "functions that can sensibly be used in a call to array.reduce"

You can use any function you want in a fold in Haskell. You're conflating two typeclasses, Monoids and Foldables, and restricting yourself to the function known in Haskell as foldMap.

Re: Ask HN: How to be fluent in functional language speak?

#96
post #14

Give up while you can. Immutable data classes and functional pipelines are great, everything else isn't worth it. Lots of people say FP is amazing but very few people use it in the real world because like you say, its unintelligible.

This comment is a textbook example of the Blub Paradox.

For the record, the Blub Paradox is wrong. It hinges on being able to rank computer languages on a one-dimensional axis labeled "power". It turns out that you can't actually do that.

For example, the Lisp people are sure they're looking down when they look at Haskell - no macros. But the Haskell people are also sure they're looking down when they look at Lisp - no decent type system. But if they're both looking down at the other, that's kind of a problem for the Blub Paradox.

Here's the other problem with it: I don't care about "power" in languages in any platonic sense; I care about power to write the specific program I'm trying to write. That includes the language's expressiveness, sure, but it also includes available libraries and the rest of the ecosystem, tutorials if there's parts I have to learn, the ability to find others who are proficient if the program is big enough to need a team, and so on. The power to write my specific program depends on the problem, not just on the language.

Re: Ask HN: How to be fluent in functional language speak?

#97
post #82

Earlier quoted context omitted.

concat?

I can't think of any way for 1 * 1 to be concatenation. I think the point GP was making is that a monoid has something to do with a function f that takes two arguments a and b where there is a single value for b such that f(a, special_value) == a. I think. As someone who doesn't really understand FP concepts I would probably call those functions "functions that can sensibly be used in a call to array.reduce"

You've definitely got the right intuition.

"associative": (a + b) + c == a + (b + c)

"binary": f a b == a `f` b == a + b where f is addition

"identity element": the "empty" value which when paired with a second value, returns the second value as is

Re: Ask HN: How to be fluent in functional language speak?

#98

If you are coming from imperative land (more specifically C++) then nothing beats articles and videos by Dr. Bartosz Milewski: https://bartoszmilewski.com/2014/10/28/category-theory-for-p... https://www.youtube.com/watch?v=I8LbkfSSR58&list=PLbgaMIhjbm... https://www.youtube.com/playlist?list=PLbgaMIhjbmElia1eCEZNv... https://www.youtube.com/playlist?list=PLbgaMIhjbmEn64WVX4B08...

[deleted]

Re: Ask HN: How to be fluent in functional language speak?

#99

Question to all the functional programming experts: When OOP got introduced people started building all these elaborate object hierarchies and design patterns only to find out after a while that simpler is better and most features should be used rarely or never. Is there also a risk with FP too that people fall a little too much in love with “elegant” code only to find out later that maybe simpler is better? Reading…

The two that I can personally thing of are using higher order functions unnecessarily (i.e. sometimes it is better just to use a boolean flag rather than handing in a callback) and too much indirection (though honestly I see this more in languages like Java than functional languages).

Re: Ask HN: How to be fluent in functional language speak?

#100

Earlier quoted context omitted.

You run the risk of being lynched by the Haskell mob, with talk like that. But I agree, in principle. The hardcore “sound types” crowd believes that anybody using dynamic types is doomed. I must not have the same problems they do. First class functions; closures; higher order functions; partial function application, seasoned with the occasional variadic vs fixed arity function, and I’m good. One can learn the other 9…

> The hardcore “sound types” crowd believes that anybody using dynamic types is doomed. What they believe is that "dynamic types" is a misnomer, and if you think your program is checking dynamic types, it is in fact doing runtime pattern matching over a variant record. There's nothing wrong with pattern matching and variant records; but conflating them with types is just nutty, and using them pervasively as part of t…

I suppose that you mean that it should be "checking types dynamically", rather than "checking dynamic types"?
Post reply on HN