Live data from Hacker News

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

news.ycombinator.com

71–80 of 112 posts

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

#71
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.

You're welcome. I like to think its more than that though. I recognize Spark as FP built app but its a rarity among thousands of large mainstream applications. Do you have many non-trivial examples of applications written in a functional style?

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

#72
post #48

Earlier quoted context omitted.

OCaml functors come from Standard ML, which predates Haskell. And you can definitely use them to implement HKTs — they are comparable in expressiveness to single-parameter typeclasses.

I use OCaml at work ~every day, and HKTs (to the extent they can be expressed at all, using HOMs) are so unwieldy that I have never run across them in production code. In Haskell, they are both easy and routine. So I’m approximating this with “no HKTs in OCaml”.

HKTs indeed aren't a common pattern in OCaml, but first-class modules and similar patterns are common enough in Core. Your statement was that the type system was not powerful enough to express them at all. Whether or not it's practical is a bit different :)

You also said that their use of "functor" was probably the result of being French vs English, when I pointed out that in fact it came from Standard ML, which is a British design. Moreover, the creators of Haskell originally built typeclasses as an extension to Standard ML (1980s), and Functor was added in the same version of Haskell that Monad was (1.3, roughly 1998).

The connection between ML functors (specifically the interface/signature) and typeclasses in Haskell is relatively clear, if you understand how they both work. I don't disagree that typeclasses are more general, but modules have their appeal as well. I'm pretty excited to see where Backpack ends up in Haskell, personally.

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

#73

Earlier quoted context omitted.

To be fair, the term "map" comes from math [0], and so at the time these functions were created, there weren't other good naming choices. Mappable and Functor are just about as opaque as each other if you don't know what mapping is. Though now that FP concepts are mainstream, I think there is a good case to offer some friendlier, more familiar names: Functor -> Mappable Applicative -> Pairable Monad -> Thenable [0]:…

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.

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

#74
post #72

Earlier quoted context omitted.

I use OCaml at work ~every day, and HKTs (to the extent they can be expressed at all, using HOMs) are so unwieldy that I have never run across them in production code. In Haskell, they are both easy and routine. So I’m approximating this with “no HKTs in OCaml”.

HKTs indeed aren't a common pattern in OCaml, but first-class modules and similar patterns are common enough in Core. Your statement was that the type system was not powerful enough to express them at all. Whether or not it's practical is a bit different :) You also said that their use of "functor" was probably the result of being French vs English, when I pointed out that in fact it came from Standard ML, which is a…

[deleted]

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

#75
post #72

Earlier quoted context omitted.

I use OCaml at work ~every day, and HKTs (to the extent they can be expressed at all, using HOMs) are so unwieldy that I have never run across them in production code. In Haskell, they are both easy and routine. So I’m approximating this with “no HKTs in OCaml”.

HKTs indeed aren't a common pattern in OCaml, but first-class modules and similar patterns are common enough in Core. Your statement was that the type system was not powerful enough to express them at all. Whether or not it's practical is a bit different :) You also said that their use of "functor" was probably the result of being French vs English, when I pointed out that in fact it came from Standard ML, which is a…

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.

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

#78
post #72

Earlier quoted context omitted.

HKTs indeed aren't a common pattern in OCaml, but first-class modules and similar patterns are common enough in Core. Your statement was that the type system was not powerful enough to express them at all. Whether or not it's practical is a bit different :) You also said that their use of "functor" was probably the result of being French vs English, when I pointed out that in fact it came from Standard ML, which is a…

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.

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

#79

Earlier quoted context omitted.

To be fair, the term "map" comes from math [0], and so at the time these functions were created, there weren't other good naming choices. Mappable and Functor are just about as opaque as each other if you don't know what mapping is. Though now that FP concepts are mainstream, I think there is a good case to offer some friendlier, more familiar names: Functor -> Mappable Applicative -> Pairable Monad -> Thenable [0]:…

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.

> Giving descriptive names just harms intuition building in the long run.

Citation needed

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

#80
post #8

Most of the jargon denotes straightforward definitions. Pick the top-most frequent three terms, e.g. monad, monoid, applicative, write down the definition + a small example on a card, lather rinse repeat a few times and you're golden. Edit. For example, let's take 'catamorphism'. Read the Wikipedia entry [0] and it's a seemingly never ending jungle of more and more abstract terms. Homomorphism, initial algebra, F-alg…

> Read the Wikipedia entry [0] and it's a seemingly never ending jungle of more and more abstract terms. Yup, category theory is often called "general abstract nonsense" precisely because it manages to talk about many disparate parts of math (or programming!) in a way that purposely avoids any reference to the specific. To usefully interpret the above, you specifically need to know that your domain often uses the cat…

I like the way you frame CT. Never got too deep down this rabbit hole, the terminology is just too atrocius. I wonder though how useful it is in practice. It is easier for me to take a formula and generalize it among one dimension at a time as the needs arise, see the catamorphism example above. As opposed to correctly divine 5-10-15 very specific concretizations of an uber-abstract scheme to arrive to the same result. Echoes of premature abstraction.

Perhaps the world lacks CT for dummies. Teach it in primary school. New Math was not aggressive enough ;)

Post reply on HN