News for hackers. Stuff that matters.
Re:Swift Functors, Applicatives, and Monads in Pictures by mokagio on Tuesday July 14, 2015 @05:38PM (#9888244)
Ahahah, that might be true :) Although because those concepts comes from category theory, i.e. https://en.wikipedia.org/wiki/Functor and there's more to it than just "it defines" map, keeping the "academic" name seems fair enough.
Re:Swift Functors, Applicatives, and Monads in Pictures by jameshart on Tuesday July 14, 2015 @06:43PM (#9888567)
The problem is that the category-theory view of functors and monads and monoids completely dominates the literature.

Imagine if, when you first started programming, and you wanted to do something with numbers, and you found out that in your programming language, the way you did that was to use something they called "Integers" (I know, right? ridiculous). So you google "Integers" and you find https://en.wikipedia.org/wiki/Integer, which helpfully tells you

"In elementary school teaching, integers are often intuitively defined as the disjoint union of the (positive) natural numbers, the singleton set whose only element is zero, and the negations of natural numbers."[1]

And you get the impression that to add a couple of numbers together you're actually going to have to understand cardinality and group theory and so on.

That's kind of where we are with monads, with the insistence on the academic language.

Though it does suggest that I could have fun by persuading beginning programmers that to really grok text processing they need to start off with a thorough grounding in string theory.

[1] I checked with my son, who goes to elementary school. I'm not sure he even knows what a disjoint union is. I'll have to have words with the teacher.

Re:Swift Functors, Applicatives, and Monads in Pictures by TillE on Tuesday July 14, 2015 @08:49PM (#9889075)
I'd forgotten how spectacularly academic Wikipedia's math articles are. It actually seems a little better than it used to be, but for example good luck learning what the hell a quaternion is by reading the Wikipedia article, even if you have sufficient background to understand and use them in practice. The German article is much better.
Re:Swift Functors, Applicatives, and Monads in Pictures by jameshart on Tuesday July 14, 2015 @09:04PM (#9889127)
Right. You don't want to try to learn something mathematical from the Wikipedia article on it - Quaternions are a great example. The trouble with most of the writing about monads is that it's all at the level of the opening paragraph of a Wikipedia math article.

We have to do better at finding a way to teach this stuff.

Re:Swift Functors, Applicatives, and Monads in Pictures by mdup on Wednesday July 15, 2015 @07:55AM (#9890819)
When I started using quaternions for rotations, which -- if we're honest -- is the #1 practical applications, I had much more success building my intuition around this Wikipedia section:

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotati...

Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @12:29PM (#9892268)
> The trouble with most of the writing about monads is that it's all at the level of the opening paragraph of a Wikipedia math article.

IME, that's not at all true; most of the theory-heavy sources I've seen are explicitly framed as alternatives to the large body of intuitionist tutorials that avoid theory almost entirely, focusing on a few popular applications (usually, collections and IO.)

Re:Swift Functors, Applicatives, and Monads in Pictures by Ivanov on Tuesday July 14, 2015 @08:57PM (#9889102)
Being able to use something and knowing the whys are two different things. Many people know Calculus(practice), but not many know Real Analysis(theory behind Calculus, the academical bit).

"In mathematics, the quaternions are a number system that extends the complex numbers."

Naturals are a subset of integers. Integers are a subset of rationals. Rational are a subset of reals. Reals are a subset of complex numbers. The latter are a subset of quaternions. It's not difficult to construct each number system. If you look inside any undergrad math textbook, you'll find exact same writing style showcased in the Wikipedia article on quaternions.

Re:Swift Functors, Applicatives, and Monads in Pictures by LimpWristed on Tuesday July 14, 2015 @08:00PM (#9888923)
You're over-exaggerating :) From the wiki link, the very first definition works just fine. In fact, I don't see anything about unions, disjointedness in there. Certainly, no group theory. You don't need to know how to construct, count(cardinality) or know the properties of integers(number/group theory) to know what they are for the purposes of programming. No, there's no cabal making everything more difficult than it needs to be ;D I think wiki always gets unfairly maligned for this sort of thing.
Re:Swift Functors, Applicatives, and Monads in Pictures by corysama on Tuesday July 14, 2015 @06:10PM (#9888411)
Are there any nice, one-step-at-a-time introductions to Haskell that stick to lowly, commonplace English rather than insisting that "just a monoid in the category of endofunctors" is universally preferable because technically it technically is technically more technically correct?
Re:Swift Functors, Applicatives, and Monads in Pictures by chongli on Tuesday July 14, 2015 @06:25PM (#9888484)
I haven't read it but you might want to check out coolsunglasses'[0] book, Haskell Programming from first principles[1]. He wrote it specifically for people who have no background in this stuff.

[0] https://news.ycombinator.com/user?id=coolsunglasses [1] http://haskellbook.com/

Re:Swift Functors, Applicatives, and Monads in Pictures by wetmore on Wednesday July 15, 2015 @03:49AM (#9890209)
Nobody insists "monoid in the category of endofunctors" is universally preferable. It's a joke.

What you'll usually see people insist is to describe monads by their operations, rather than through metaphor. That is, a monad is a type parametrized by some other type, with the following two functions:

1) return :: a -> m a 2) (>>=) :: m a -> (a -> m b) -> m b

such that three laws hold:

a) return x >>= f == f x b) m >>= return == m c) (m >>= f) >>= g == m >>= (\x -> f x >>= g)

For monads in Haskell, this is the technically correct definition.

That said, most people will tell you the best way to understand monads is to look at a few basic monad instance implementations (Maybe, Either a) and program with them, slowly learning new instances.

Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @12:17PM (#9892154)
Cleaning up the parent's formatting as I think it's too late for them to edit. Content is unchanged:

That is, a monad is a type parametrized by some other type, with the following two functions:

    1) return :: a -> m a
    2) (>>=) :: m a -> (a -> m b) -> m b
such that three laws hold:

    a) return x >>= f == f x
    b) m >>= return == m
    c) (m >>= f) >>= g == m >>= (\x -> f x >>= g)
Re:Swift Functors, Applicatives, and Monads in Pictures by merijnv on Wednesday July 15, 2015 @05:11AM (#9890390)
To be fair, I don't know a single person that explains things using

> "just a monoid in the category of endofunctors"

In fact, even among people who DO know the category theory necessary to understand this expression it's considered a very obtuse and useless explanation. Especially in the context of Haskell.

As for good readable introductions, I consider Wadler's paper "Monads for Functional Programming" to actually be a pretty good introduction. Another good intro is "You Could Have Invented Monads! (And Maybe You Already Have.)" http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...

Re:Swift Functors, Applicatives, and Monads in Pictures by ucarion on Tuesday July 14, 2015 @07:51PM (#9888887)
To add to chongli's suggestion, I learned Haskell (and had a great time doing it) from "Learn You a Haskell": http://learnyouahaskell.com/