
Teaching Haskell to a 10 year old: Day 1 - lelf
https://superginbaby.wordpress.com/2015/04/08/teaching-haskell-to-a-10-year-old-day-1/
======
nnq
What Haskell is mission in order to be more learnable by _anyone_ imho is
_sane_ error messages.

The simplest example I can think of is typing _foldl + 100 [1, 2, 5]_ in the
repl by mystake instead of _foldl (+) 100 [1, 2, 5]_ and getting an error
message that starts like _Could not deduce (Num ([t0] - > (b -> a -> b) -> b
-> [a] ->..._.

...instead, it should fking yell at you that you gave some wrongly typed
arguments to the function (+), and you'd instantly realize what's wrong:
"...but I'm not trying to call + ...oops, forgot the parentheses around it.
fixed!". Also, auto-currying in ML-family languages probably doesn't help with
making meaningful error messages easy to implement because it gives more
variants for what the user could have meant (besides making type signatures
10x harder to read and making implementing named arguments or optional
arguments with default values close to impossible... if they could have just
used a postfix $ after the function name as currying-trigger, but no, they've
had to use this for some more error-prone and hard to read "syntax sugar"
because making people just type a few more parentheses would've been too
Lisp-y for the haskellers taste...).

~~~
octatoan
I don't think this is as easy as you make it seem. A whole bunch of problems
in typing and deduction are undecidable in the general case. (Don't know about
this one, but just saying.)

Also, you seem a little aggressive toward "Haskellers". I'm sure you didn't
mean to be! :)

~~~
nnq
The thing with "undecidable in the general case" is that 80% if the time you
can just heuristically guess an be right. Most bugs are shallow. Typos,
forgetting operators etc. And even if the guess is just plain wrong, I think
that a wrong simple guess is most of the time better at nudging the learner in
the direction of fixing the mistake than an incomprehensible type deduction
explanation... And if it's not you can always have it under some kind of
"details". And no, I don't think this is "a job for the IDE"... this would be
Java-think :)

...and that't the thing, when _guessing_ what's actually wrong, syntax can
help a lot. Things like having the equivalent of an auto-curry-on-off toggle
at the syntactic level, would make guessing at least 50% easier. And other
little things too. I think ML-lamnguages tend to shoot themselves in the foot
here. C-like syntax has a clear advantage when it comes to enabling guessing
and heuristics.

I didn't mean to be agressive, I love the concepts behind Haskell... this is
why I hate the "little things" that ruin it and make it almost unusable for
average "don't make me think too much right now" type developers (like me
after some sleep deprivation or a couple of beers or during a "this bug needs
to be fixed by yesterday morning" sprint :) ).

------
bbcbasic
I think he will have a harder time not having not studied algebra (yet?).

Maybe it would help to explain why in regular maths + and * have similar
properties. For example they both return the same result regardless of order
of parameters. They are both conform to ((a <op> b) <op> c) = (a <op> (b <op>
c))

Where <op> can be + or *. Now we are getting a bit abstract but keeping it
kind of concrete, without using scary terms like 'associativity'.

And once he is used to abstractions he may find Haskell easier.

I was lucky to study Maths at Uni, so to me Haskell makes a lot of sense.
Although the foldr/foldl/applictive/monad stuff is a mind bender I have to
admit, but well worth persisting.

------
Viktoras25
Son: “Well. Hm. If the function is the (+), then you first apply that to the
1. So…..you have something like (1 +)? And now you apply that to the 2? And
then you get the final answer?”

Seriously? He grabbed the idea just like this? Am I that old and stupid, that
partial application didn't seem to me that easy? Or is currying what kids
learn in a kindergarten these days? Sorry for my ranting, I'm just really
amazed. A humanity went a long way to understanding such quite abstract
conceptions as number 0 (as absence of something). And at 10 years kids, i
think, are still learning by seeing, touching, playing. So concluding a much
more abstract idea seems really fantastic.

------
pbhjpbhj
I don't know Haskell at all, the ~"all functions only have one argument"
concept interests me.

>"had an easy time explaining how (2 * 3) really is two functions, each with
one argument and one result, and he drew it out on paper nicely" //

So, like you pass the multiply function an argument which is a list (2, 3). Or
is it more like you pass the multiply function the first operand (2 in this
case) and it returns a function multiply-by-2 which you pass the second
operand? The latter seems like it would get sub-optimal pretty quickly. Mind
you surely here the compiler produces the same sort of assembly [repeated
addition here] making it just a way to abstract around an alternate mental
model.

I've just looked at
[https://wiki.haskell.org/Currying](https://wiki.haskell.org/Currying), could
someone walk through how something like arcsin(0) works - that's probably a
bad example - something that takes a single variable input but has multiple
solutions (returns n.π in this case, but say sqrt or an anagram function or
...)?

I'm sure you can tell I'm not a computer scientist, not even a programmer ...

~~~
spion
It returns the multiply-by-2 function. This turns out to be super useful

    
    
      map (* 2) [1, 2, 3]
    

will take that function and apply it to each element in the list [1,2,3].

~~~
pbhjpbhj
That map function looks a lot like it has 2 arguments, a function and an
operand array (ie a list)??

~~~
Sniffnoy
Again, it works the same way. The map function takes the argument (*2) and
returns a function, which is then applied to the list.

~~~
pbhjpbhj
Seems like a semantic gloss, but then at some level I suppose higher level
computing languages are all a semantic gloss.

Thanks for the responses - I'm now almost as knowledgeable as a 10 yo prior to
being instructed in the subject at hand.

------
AnimalMuppet
Sounds like the big issue she's going to keep running into is that a 10-year-
old doesn't really do abstractions well (and doesn't have the background to do
abstract algebra yet), whereas Haskell expects a certain familiarity with
abstraction.

It could be, though, that showing things in concrete, and then introducing the
abstractions, is the right approach to teaching Haskell for nearly everyone,
not just 10-year-olds...

~~~
zzalpha
_whereas Haskell expects a certain familiarity with abstraction._

I'm curious why you think Haskell is unique in this regard.

I mean, sure, if you want to understand why things like Monads exist, I agree,
that fundamentally means grokking some pretty deep abstractions.

But I don't know that you _need_ to understand those abstractions to use and
appreciate Haskell... maybe to fully use and fully appreciate it, but I
wouldn't expect that of a 10 year old to begin with, in part because I
wouldn't necessarily expect that of an adult either.

~~~
AnimalMuppet
Yes, I had things like monads in mind, but also currying, and higher-order
functions, and I could probably think up a couple more if I tried.

True, all languages require abstractions. But it seems to me that Haskell is
more abstract than most. That's it's strength, in fact. But it seems to me
that it also creates something of a mismatch when trying to teach it to a
10-year-old.

~~~
zzalpha
Huh... weird, I don't really think of currying as much of an abstraction. I
mean, if you're going to be rigorous about it, maybe, but you can cheat and
explain it as partial function application, which gets you 99% of the way
there, and I think is pretty easy to explain.

Higher order functions are certainly a bit trickier, but you could explain
them in specific contexts (as with 'map') without needing to deal immediately
in generalizations, which probably makes it a lot easier to explain.

~~~
platz
I assume then you'd expect him to learn about polymorphism, inheritance,
classes, the 'static' keyword, and virtual functions if this was an OO
language, if these kinds of things are on the table, right?

I'm sure there aren't truckloads of evidence of beginners having problems with
those concepts.

~~~
chowells
In all honesty, inheritance, classes, the 'static' keyword, and virtual
functions are all harder than anything in Haskell. They're all _weird_ ad-hoc
concepts without simple underlying mathematical concepts. That's rather unlike
Haskell, where the underlying math is usually very simple, if more abstract
than most people are used to.

~~~
seanmcdirmid
That is very subjective. For example, Lisp has a very simple grammar, yet many
people find the minimalism complicated in how it manifests in paren heavy
code. Likewise, Haskell's reliance on abstract mathematics is definitely going
to turn many people off to it. "It's just math" is often taken as a negative,
not a positive (depending on the person).

Natural language is built around all sorts of non mathematical ad hoc
concepts, yet we seem to use it just fine. Of course, it might not be the best
way to talk to the computer, but it is definitely "accessible."

~~~
jesstaa
Most people don't know their natural language as well as they'd need to know
it to accurately and unambiguously describe things. The only reason natural
languages are even useable is because the human interpreting them has a huge
amount of context to infer the meaning from and do error correction with.

The reason programming languages exist is to simplify the language used to
describe things so they can be interpreted without too much additional context
and unambiguously.

~~~
seanmcdirmid
You aren't wrong. But there is a good reason objects remain popular even if
they aren't ideal by any means. With objects, you get to rely on your built in
metaphor capabilities of natural language, your ability to think ad hoc. Now,
that gets you into trouble quickly because the computer isn't human, but it
shouldn't be a big mystery why OO remains popular. Haskell makes imprecise ad
hoc thinking hard to encode, because well..eat your vegetables, they are good
for you!

------
octatoan
Your son is lucky. That's all I'll say. :)

~~~
akurilin
Having found out in person how superginbaby teaches her kids, I realized just
how primitive my upbringing was many years ago :)

------
actsasbuffoon
I struggled to learn Haskell in my early thirties. I think your son has a
bright future.

~~~
iamthepieman
Most of my problems with Haskell are related to getting rid of patterns and
habits from other languages that are deeply ingrained.

Assuming you have the mental models and internal language (which from the OP
seems like a ten year old just barely has) it seems like it would be easier to
learn Haskell at a younger age or at least before you learn any other
languages.

~~~
cronin101
I tutored Haskell to first-year students and I think the hardest part of
picking it up is understanding that previous expertise won't help until you
grok the distinctly new perspective with which you must approach problems.

I'm (somewhat) sceptical of the popular "Children inherently have the most
malleable minds" trope, to the grand annoyance of one neuroscientist friend; I
feel it's more an environmental factor stemming from fewer areas of
growth/stress to focus on and increased motivation as they lack the jack-of-
all-trades experience in similar areas to fall back on whenever they get
frustrated. I like to believe this since it motivates me to overcome those
limiting factors by adapting my work ethic, with the hope to continue learning
efficiently.

Back on topic, I feel that the best mindset with which to approach Haskell
(and many other new areas) is: "I don't get much right now, but that's OK. If
I keep working with what I know and expand that set by just a little every
day, it's bound to click and I will be able to look back on the entire journey
as worthwhile."

~~~
innguest
Well, you're not alone. I also think the "malleability" we see in children is
just because of the attributes of their existence: nothing to worry about,
nothing to do but play (and voluntary learning _is_ play) and so on.

And like you, I also use this to motivate me in Haskell. Little by little I
learn things I didn't know before. It takes me years but I do it at the pace I
choose. And why would Haskell be different from any other subject I learned as
an adult? Everything makes no sense in the beginning, then it's hard, then you
can kind of see what they're talking about, then you get some practice, and
before you know it you are equipped enough to dig into intermediate stuff and
then the advanced parts.

Was it not the Japanese that came up with Kaizen - continuous improvement? I
believe in that principle.

~~~
godfreythadon
I, too, live by Kaizen.

------
pbhjpbhj
>let double x = x * 2

vs.

>hasn’t had any algebra yet

He has now. ;0)>

Simple variable assignment is algebraic mind you so the assertion doesn't
match with the note of having studied some programming already. Functions are
algebraic too.

I'm guessing the parent here is thinking "he's not studied a formal course
specifically targeting a subject area referred to as algebra".

------
wz1000
CodeWorld[0] provides a nice graphical environment in which to learn Haskell.

[0]: [http://codeworld.info/](http://codeworld.info/)

------
renox
I'm curious, why Haskell? Children tend to like visual feedback (I know I did)
so Logo, Scratch would probably be more rewarding for him.

~~~
NoodleIncident
Because the kid asked about Haskell. This is explained in the first sentence
of the article.

------
c22
I never really knew what people were talking about when they mentioned
currying until I read this article.

------
dcre
> No, son, your mom just phrased the question badly.

Aaaaaand... I am an asshole. Thank you for reminding me.

~~~
malvosenior
Gender hypersensitivity is the new grammar nazi movement. It adds nothing to
any given conversation and only derails every thread it's mentioned in. Much
worse than grammar correction actually...

[EDIT]

Sadly my point is being proven. I REALLY wanted to hear about teaching Haskell
to 10 year olds but now we've got the same boring ass gender war going on that
never goes anywhere and is totally off topic. I wonder if you could delete
your comment before it gets too out of hand. At the very least try not to
bring it up next time.

~~~
Saavedro
Wow.

[EDIT]

The responses that amounted to "You did nothing wrong!" "We don't need to talk
about this!" were what made the thread heated -- outside of that it was just a
couple of posters realizing they made an incorrect assumption, what need was
there to _debate_ that?

~~~
malvosenior
sigh....

First of all he called himself an asshole for making that assumption. What
about others that made the same assumption but didn't feel the need to derail
the thread? Are they assholes too? Maybe people felt the need to chime in
since there was an insult implied and they wanted to make it clear that by
having the same assumptions about the author, they did nothing wrong.

Second, his post has NOTHING to do with the original article, it's just off
topic noise.

------
smenko
>> ...and just turned 10, has been nagging me for ages to teach him Haskell...

I'm guessing you would have taught your human(?) kid some human languages
first before he started nagging you (why you, he can read too, right?) to
teach him Haskell. I think you had a dream or sumping...

