News for hackers. Stuff that matters.
Re:Please Don't Learn Category Theory (2013) by rtfeldman on Wednesday January 15, 2014 @05:06PM (#7066521)
> the people who designed Haskell decided they weren’t going to pretend they didn’t use math

This is almost certainly the decision that has kept the most people from successfully learning Haskell.

If you write "Appendable", many programmers go "oh, okay, got it." If you write "Monoid", many programmers go "yeeeah, I don't know if I have time to learn all this."

This is either a perfectly acceptable cost of avoiding redefining the wheel, or a cautionary tale for future language developers, depending on your perspective.

Re:Please Don't Learn Category Theory (2013) by cscheid on Wednesday January 15, 2014 @05:23PM (#7066619)
But "Appendable" is a terrible way to describe what a monoid is. Some of the really cool tricks in the way abstractions in Haskell match mathematical notions come from extending the abstractions beyond what you would expect. For example, integers under sum are monoids; naturals under the maximum operation too. And so is the "over" operator from computer graphics. All of these find applicability as general monoids in Haskell, but you'd have a hard time calling them "Appendable". All of these just need a binary operation that's associative and with an identity element.

The same thing happens for functors and monads: their use come from the properties they respect. And if you accept that abstractions will be defined as a set, some operations, and some algebraic laws respected by those operations, well, then, you arrived at abstract algebra, and you might as well use the right terms.

Re:Please Don't Learn Category Theory (2013) by joe_the_user on Wednesday January 15, 2014 @06:37PM (#7067030)
Jeesh,

I have an MA in mathematics but without knowing category theory, it has been opaque to me till just now that the monoids discussed around Haskel are the same beast I briefly dealt with in abstract algebra. Indeed, only by looking up monoid and appendable did this become semi-evident.

The Haskellians don't even help you out enough to point towards ordinary abstract but instead send you all the way to category theory with sign-posts along the way.

The abstract structure monoid may not really be fully described by appendable but it's a leg-up. The objects in object-orientation get extended by convenience but the term object still helps the learner feel like they've got something concrete.

Re:Please Don't Learn Category Theory (2013) by cscheid on Wednesday January 15, 2014 @06:48PM (#7067079)
First hit on google for "Haskell Wiki Monoid" was this: http://www.haskell.org/haskellwiki/Monoid

Lots of examples there, including a post by Dan Piponi that says, right at the beginning, "In Haskell, a monoid is a type with a rule for how two elements of that type can be combined to make another element of the same type. To be a monoid there also needs to be an element that you can think of as representing 'nothing' in the sense that when it's combined with other elements it leaves the other element unchanged. "

I don't know how you can construe that as "The Haskellians don't even help you out enough to point towards ordinary abstract but instead send you all the way to category theory with sign-posts along the way."

Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @06:46PM (#7067074)
There are fabulously useful monoids that aren't - in terms of intuition - appending anything at all. For instance, (Sum Integer, Max Integer)
Re:Please Don't Learn Category Theory (2013) by rtfeldman on Wednesday January 15, 2014 @06:55PM (#7067107)
Nevertheless, if you're a programmer with no particular exposure to that sort of math (which is to say, the overwhelming majority of programmers), saying "this function takes a Monoid" is as useful as saying "this function takes a Foogblort."

Saying "this function takes an Appendable" conveys useful information.

It's a matter of priorities. If your priority is using the correct mathematical term, you necessarily sacrifice clarity to newcomers. Hence, fewer newcomers.

...of course, not that Haskell as a language has ever strived to attract newcomers!

Re:Please Don't Learn Category Theory (2013) by yohanatan on Wednesday January 15, 2014 @05:35PM (#7066701)
I think Combinable is more appropriate as 'append' pertains to only one of many associative binary operations.
Re:Please Don't Learn Category Theory (2013) by cscheid on Wednesday January 15, 2014 @05:45PM (#7066776)
What about a group? Is that combinable too? Monoid is short, precise, and googlable. Which also happens to be the case with group, monad, functor, etc. Why invent new vocabulary?

Have you noticed how little sense the words "class", "struct", "union", "object" make to someone who hasn't programmed before? It's just that we got used to them.

Re:Please Don't Learn Category Theory (2013) by lmm on Wednesday January 15, 2014 @08:43PM (#7067511)
Classes, unions and objects are all everyday words. I knew them from mathematics and everyday life before I ever used them in programming.
Re:Please Don't Learn Category Theory (2013) by axman6 on Wednesday January 15, 2014 @07:53PM (#7067328)
I've considered Reducable, but I'm not sure that makes much sense either (such as when using a -> a as a monoid, you're not really reducing them). Combinable doesn't work because you're not necessarilly combining the values (Max and 0 for example doesn't really combine, it selects). So it is my conclusion that Monoid is a perfectly good name because that's exactly what a monoid is: something with an associative operator and a value which is the identity for the operator:

    (&&), True
    (||), False
    (+), 0 -- addition
    (*), 1 -- multiplication
    (++), [] -- concatenation of lists
    max, minBound -- maximum
    (.), id -- function composition and the identity function id x = x
    
there are all monoids, it's such a simple concept that high school students could understand it within 10 minutes, and yet people whinge for calling it what it is. Good programmers are not people who are turned away by terms they don't know this easily.
Re:Please Don't Learn Category Theory (2013) by yohanatan on Monday January 20, 2014 @02:21AM (#7088036)
Oh yea, I completely agree. There's no reason to be afraid of the terminology. I was just suggesting that Combinable seems a closer fit than Appendable for the general case (although, as you and others have pointed, even it falls short).
Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @06:05PM (#7066872)
AssociativeCombinableWithIdentity

... but I would rather learn what a "monoid" is, than type that out every time.

Re:Please Don't Learn Category Theory (2013) by codeflo on Wednesday January 15, 2014 @05:34PM (#7066693)
I also think that there's a clash of naming conventions going on. Programmers are used to name types for their values are, as in "4 is an Int", or even abstractly, "4 is Serializable". Haskell conforms to this convention with type and class names like "Int", "String", or "Num". But classes with names like Monoid don't conform to that, as 4 is not "a Monoid". The set of integers with + is a monoid, but that's a property of the type itself, not of its values. (Edit: And don't get me started about "IO". What's "an IO" even supposed to be?)
Re:Please Don't Learn Category Theory (2013) by Chattered on Wednesday January 15, 2014 @06:14PM (#7066915)
And similarly, the list [1,2,3,4] is not a monad, and that's why "flatmappable" isn't a sensible alternative to "monad", as Bracha recently suggested.

Though some have argued that this confusion indicates a hole in our vocabulary:

http://blog.plover.com/prog/haskell/monad-terminology.html

Re:Please Don't Learn Category Theory (2013) by codeflo on Wednesday January 15, 2014 @08:31PM (#7067465)
Great link, that's about what I'm getting at. MJD states it more clearly than I could.
Re:Please Don't Learn Category Theory (2013) by nbouscal on Wednesday January 15, 2014 @06:21PM (#7066954)
You noted a pattern in how programmers name types, and then complain that the naming of a type class doesn't conform to that pattern. Of course 4 isn't a Monoid, rather, Sum is a Monoid.

As for IO, the best way to read it would be as an "IO action", which is what much of the literature refers to it as. Yes, this isn't trivial to understand, but IO in Haskell isn't trivial, and you can avoid the formalism if needed until once you understand things a bit better.

Re:Please Don't Learn Category Theory (2013) by codeflo on Wednesday January 15, 2014 @08:34PM (#7067475)
I'm fine with Haskell using a different convention if there actually is one.

And your other explanation proves my point: If an "IO" instance is best described as an "IO Action", then why is the type not called "IOAction"?

Re:Please Don't Learn Category Theory (2013) by nbouscal on Wednesday January 15, 2014 @08:42PM (#7067508)
Because not everyone loves excessive verbosity.
Re:Please Don't Learn Category Theory (2013) by codeflo on Wednesday January 15, 2014 @09:10PM (#7067614)
Well, it's you who said that "IO action" is the best description, not me. I personally wouldn't consider 8 characters excessive for a type that's imported into your program's namespace by default. Especially considering that you would hardly ever have to explicitly write that in Haskell.

Then again, my code doesn't have to fit into 20-character research paper columns.

Re:Please Don't Learn Category Theory (2013) by nbouscal on Wednesday January 15, 2014 @09:16PM (#7067629)
I was responding to your question, in which you were asking what "an IO" was. You seem to have some kind of a grudge against Haskell. I'm not going to argue with you about it. You're welcome to continue programming in Java for as long as you'd like.
Re:Please Don't Learn Category Theory (2013) by codeflo on Wednesday January 15, 2014 @09:37PM (#7067704)
I'm only arguing about naming conventions here -- I probably wasn't clear enough about that. I know what the IO type constructor does. My point was merely that if no one ever says "getChar is an IO", then maybe its type shouldn't be called IO.

For all of Haskell's beautiful concepts, it does have some flaws. I think that overly cute (and, as I explained, sometimes inconsistent) names are one of them, because that's at often odds with readability. Haskell's identifiers are not Perl-level bad, but they are not shining examples of clarity either.

I hope I didn't offend you with this. I don't actually think we'd disagree much if we had discussed this face-to-face.

Re:Please Don't Learn Category Theory (2013) by nbouscal on Thursday January 16, 2014 @10:43AM (#7069968)
Nope, no offense taken at all. I just disagree with the verbosity approach to writing software. You referred a couple of times to the name as a "description", but there's a big difference between names and descriptions. They serve different roles. IO is a good concise name, and if someone wants to know more about it, they can go read its description in the Haddocks or other supplementary texts.

People don't say "getChar is an IO", but they (when typing) would probably say that "getChar is an IO ()", or when speaking "getChar is of type IO unit". Reading it as "IO action" is useful pedagogically, to answer questions like "what is an IO?", but typing out IOAction every time is annoying and unnecessary. Especially because then MonadIO would have to become MonadIOAction, which is just silly.

One of the worst trends in contemporary software engineering is to conflate names and descriptions, so you end up with absurdities like SimpleBeanFactoryAwareAspectInstanceFactory or InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonPainter* . Yes, I'm picking on Java and these are extreme examples, but it's just the exact same principle applied to a much greater extent.

*Found in Spring and JDK, respectively.

Re:Please Don't Learn Category Theory (2013) by chongli on Wednesday January 15, 2014 @05:51PM (#7066810)
The problem with analogies is that they only work in one direction on the abstract<->concrete spectrum. It's perfectly fine to talk about lists under the append operation as an example of a monoid. It makes no sense whatsoever to try to reverse that relationship because not all monoids have anything remotely analogous to appending.

This principle applies to pretty much all ways of categorizing objects. We can say that dogs are an example of mammals but to turn around and call all mammals "doglikes" or "doggables" would be silly.

Re:Please Don't Learn Category Theory (2013) by yongjik on Wednesday January 15, 2014 @05:33PM (#7066680)
Kinda off-topic, but I also have to say "appendable" is a terrible choice. It would mean that those objects (or variables, or whatever) support efficient appending operation, which is usually not the case.

(Sorry, I couldn't get over the fact that appending a character to a string (or a list) is O(N) operation in Haskell.)

Now, if you named them "prependable", then maybe...

Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @06:07PM (#7066880)
"Max 3 <> Max 5" isn't really appending or prepending, though.
Re:Please Don't Learn Category Theory (2013) by Perseids on Wednesday January 15, 2014 @05:44PM (#7066762)
And maybe it is a tale promoting more theoretical computer science in the education of programmers. For example monoids should be familiar because the states of a minimal DFAs are essentially the elements of the syntactic monoid [1] of the accepted language and the transition function is essentially the monoid operation.

[1] https://en.wikipedia.org/wiki/Syntactic_monoid

Re:Please Don't Learn Category Theory (2013) by anaphor on Wednesday January 15, 2014 @05:23PM (#7066617)
It's not really Appendable though, because e.g. you can write a Monoid instance for various number-y things like Sum and Product.
Re:Please Don't Learn Category Theory (2013) by srl on Wednesday January 15, 2014 @05:27PM (#7066648)
And you could write an Appendable instance for them as well, it would just fly in the face of what the word "append" means to most people. (Nitpick, of course.)
Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @06:08PM (#7066886)
Sure, but is that more understandable than using "monoid"?
Re:Please Don't Learn Category Theory (2013) by chilldream on Wednesday January 15, 2014 @06:51PM (#7067087)
Don't know enough to know that the current name is optimal, but at least "Monoid" correctly says to the initiated "you don't understand this yet." "Appendable" lies to you and says "you understand this" even if you don't.
Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @07:56PM (#7067349)
"Monoid" also has the advantage of being very searchable. First result on Google (from a private browser window) is the Wikipedia page with the snippet "In abstract algebra, a branch of mathematics, a monoid is an algebraic structure with a single associative binary operation and an identity element". DDG gives similar results, though the Doctor Who aliens are higher up...
Re:Please Don't Learn Category Theory (2013) by lmm on Wednesday January 15, 2014 @08:46PM (#7067525)
Yes. If I've got used to the idea that lists are appendable and then someone tells me I can "append" two numbers by adding them and that will fit the interface... yeah, that makes sense. It might be a bit confusing on the way, but better to use a term that covers the most common case than a term that's completely alien.
Re:Please Don't Learn Category Theory (2013) by runT1ME on Wednesday January 15, 2014 @05:54PM (#7066823)
Appendable is more akin to a semi-group than a monoid though, no?
Re:Please Don't Learn Category Theory (2013) by dllthomas on Wednesday January 15, 2014 @06:48PM (#7067081)
Yes, "appendable" to me doesn't imply the existence of an identity.
Re:Please Don't Learn Category Theory (2013) by rtfeldman on Wednesday January 15, 2014 @06:47PM (#7067077)
Yes, but the point stands. :)
Re:Please Don't Learn Category Theory (2013) by Dewie on Wednesday January 15, 2014 @06:10PM (#7066899)
If this is all it takes to turn people away, then I would say that the problem is that those people have an irrational fear of mathematics. At that level, it's not about having a tool that is too abstract or difficult, or not being gifted at abstract thinking; it's about those people having a conditioned knee-jerk reaction to math-sounding things.

Mathematics is hard, at least for me, but I have accepted that I have to get over my preconceived notions and at least try to look beyond the jargon. And these are mere names, not "let's cook up an ad-hoc notation and heavily overload and abuse it in places because 'the meaning is obvious from the context'...". this is only a question about choosing name A, or name B. I can't imagine it will get any harder by choosing either of them.

At least Haskell clearly states, with it's esoteric naming; "what you are about to get into is quite strange, and quite different from anything you've probably encountered in programming before." And if they can't look beyond scary-sounding words, maybe that kind of programming is not for them - and in that case, it's good that they found out straight away - or maybe they need to work on their own phobias.