Show HN: Learn Functional Programming Using Haskell
lambdaschool.com
lambdaschool.com
One big fat clue that I wish I had been given when I was starting to try to figure it out on my own back in the 90's is that Haskell is kind of loaded up with syntactic sugar, beneath which is a relatively small core language that might be an easier point of entry into the language.
To be specific: infix operators, sections, multi-argument functions, partial application, 'where' clauses, multiple definitions of the same function with different patterns, implicit braces and semicolons inferred from layout, 'do' statements, if/then/else, [lists] -- all of these, and probably more, are great to use, but they all boil down to something like
func = \arg -> let { ... } in case arg of { pat | guards -> f x y; ... }
and perhaps fully grokking these essential constructs before moving on to using them indirectly through all the layers of pretty syntax would have helped me understand all those features better.ADDENDUM to forestall my inevitable hog-piling by pedants: yes, I know that 'let' isn't strictly essential, and I neglected to mention record fields, record updates, type classes, &c. Sorry. And I know that the Haskell standards have always defined higher-level constructs in terms of a core language. My point is that, at least for me, Haskell might have been easier had I been exposed to just that core language at first.
Also see my other comment here which mentions the process we used: https://news.ycombinator.com/item?id=12214430
The book covers so much because wanted it to work for people who
1. Weren't necessarily familiar with FP or at all, or in some cases, programming period.
2. Would be able to apply Haskell or learn more advanced concepts on their own after working through the book.
#2 required covering much more of the intermediate stuff than any of the existing books available.
I wrote the book because of the problems detailed in this blog post with the pre-existing materials: http://bitemyapp.com/posts/2014-12-31-functional-education.h...
For instance, intuitively state traversals or using product monoids for folding lists seem to have tons of real world applications that I've been looking for something to solve, but I find it still takes lots of exploration.
This is the approach we take in our book, Haskell Programming from First Principles. (http://haskellbook.com/) The book starts with a _brief_ introduction to lambda calculus and builds on what the reader knows incrementally. You can see in our chapter listing: http://haskellbook.com/progress.html what order we do things in. Importantly, it's not just show & tell. The book has _a lot_ of exercises and detailed explanation for the concepts covered.
I'd worked with and taught quite a few people before starting the book, in addition to maintaining a fairly popular guide (https://github.com/bitemyapp/learnhaskell) for learning Haskell and helping people working through the recommended materials. Further, my coauthor on the book was completely new to programming when she began working with me. What we cover and in how much detail is influenced by working with her, our ~10 deep-dive reviewers, and the over 1,300 emails of feedback/questions we've gotten from readers.
What I did in the book is based on that experience and data. If I could've written less and still solved the same problems, I would've. Maybe a future edition will be shorter after we refactor some things.
Here are some other resources to learn Haskell:
1. Learn You a Haskell for Great Good - http://learnyouahaskell.com/ - can read the text for free online
2. UVa Student Taught Haskell Course - http://shuklan.com/haskell/
3. Learning Haskell - http://learn.hfm.io/
4. Haskell Programming - http://haskellbook.com/
A question for the author - did you review the other learning materials (i.e. competition or maybe complement(s)) and find discrepancies that made you want to create a better learning resource or were you primarily motivated by how awesome of an experience you had learning Haskell and the desire to share that with others?
I almost called this a “crash course in Haskell” but I didn’t like what “crash” connotes. I just really want to get people into the practicalities of what’s important as quickly as possible.
Non the less, the more options the better. And of course I do not know how you do your course. Naturally I wish you best of luck: that your students may succeed in mastering the subject :)
Not true, with infinite options there are infinite bad options.
What's their reasoning? I didn't find this on the page you linked.
I don't think that it would be impossible to do a "crash course" in Haskell well, but it's certainly harder than doing the same in e.g. Python, simply because the language will flout so many expectations/assumptions that developers would be able to make in other languages.
Has the course material been created? Are you the only instructor?
Is your intention to provide more resources on functional programming (in other languages perhaps) considering you've created the "Lambda School" instead of the "Haskell School"?
A lot of the material has been created, but it takes a long time and lot of synthesis - a lot of feedback-receiving and iterating from others who are learning Haskell. I am the only instructor who will be speaking/recording videos, but I’m working with several others to fine tune the course.
And our intention is to provide a lot more resources, not only on functional programming, but on many elements and aspects of what I consider “advanced computing,” or “ongoing developer education.”
I followed along its first edition last year and it was very good. Sure, the instructors had a really thick french accent and the videos had some outdated sound effects and animations, but the concept were well presented. That said, the selling point of this mooc was the high quality of the exercises, which were rather hard, but quite rewarding and very well thought out. By week 2 or 3 you had to implement complex algorithms and functions, eg. a database class or heap's algorithm. Highly recommended.
For Haskellers coming to SML, there's "A Crash Course on ML Modules"[1] which does a nice job of explaining things in the opposite direction.
Are there any resources like this out there that discuss how best to break down and write modular Haskell programs?
[1]: http://jozefg.bitbucket.org/posts/2015-01-08-modules.html
(update: I realized the original article I linked to wasn't the one I thought it was!)
[1] http://plv.mpi-sws.org/backpack/ [2] https://ghc.haskell.org/trac/ghc/wiki/Backpack
More basically, just think "everywhere I would open a module, instead I can take a parameterized record of functions" (and furthermore, if a datatype uniquely determines that record, I can associate a typeclass to that datatype). There are limitations to this, but in fewer circumstances than you'd think -- mainly about sort of cross-modularity (aka the expression problem).
There was a very nice discussion on lennart's blog about this in 2008, with a problem posed and some partial solutions (read bottom post to top):
> We have basically packaged up the dictionary and unpack it ourselves to get access to the operations. It's not pleasant, but it works.
Would you say this method of using multi-parameter type classes and packaging/unpackaging related operations in a record is "idiomatic"? I admittedly haven't browsed all that much Haskell code, but I feel like I don't see it used that frequently.
the other relevant work in a broader sense that I should mention is regarding effectful contexts where idiomatically you declare a subclass of monad with the relevant operations, then instantiate it via the mtl or some other means, so you can swap out the IO backed "real" one or various harnesses or add in logging layers, etc.
finally, i guess i should add that as a rule of thumb i've noticed that purity and laziness both help provide ways to give "modular separation of concerns" directly. in particular, the most obvious thing we can do is just have each function do one thing to a bit of data, and produce a different bit of data and that's innately modular. but when we're interleaving IO (for example with mutable datastructures) and concerned with _when_ computation happens (in a strict setting), then it feels we're paying for this too much because we get big intermediate structures. but if you get the knack of just using pure lazy structures directly, you can sort of "amortize out" the computation cost in a nice way and also the space cost (as conceptually some big data structures become produced "on demand"). of course if you get it wrong, blammo :-)
Some things are more or less convenient in one system or the other.
I wouldn't object to having both! I believe that's what the purpose of the Backpack project is.
The ML approach is better for this use case, but the Haskell approach can do the same with a bit more verbosity.
I am happy this looks like some decent videos will finally produced for haskell
But variety is good, different strokes for different folks.
It isn't just a waste of time, I just can't learn effectively when the information is presented at the wrong pace.
Have you tried using VLC for the bookmarking and frame-by-frame hot keys? I exclusively use VLC for watching educational videos, so I can tweak the playback speed to my needs, and also jump backwards easily to have material repeated.
One day we may have video players that watch our faces and body language to intelligently guess the best pace of playback, and note the sections where we are confused for future study.
Did you know about this app for controlling speed of any HTML5 video element https://chrome.google.com/webstore/detail/video-speed-contro... ?
I've recently started experimenting with uploading videos (math tutorials) to youtube already at 1.5x speed. I think my lessons become much more interesting, but some people said they really hate the 1.5x speed, and prefer to watch me talk slowly, so I don't know if 1.5x should be the default...
Do you know other people who like to watch technical videos at 1.5x and 2x, or are we the exception?
> Curious, what speed do you normally use? 2x? more than 2x?
It varies greatly depending on how fast the person talks normally, the difficulty/newness of the subject matter, and the way they phrase their sentences (useless filler words, or densely meaningful?)
There are some videos where the person talks fast enough (on a topic new to me, without filler words) for me to listen comfortably at 1.0.
At the other extreme if they talk exceptionally slowly, use lots of filler words, and the topic is easy or something I'm familiar with I may push it past 3.0. Also, if I'm reviewing videos I've already studied.
With foreign languages I may slow it down to 0.7 or so.
> Do you know other people who like to watch technical videos at 1.5x and 2x, or are we the exception?
I just assumed everyone does this at some point in time, unless it hadn't occurred to them.
I mean, we all skim books that we've already studied, don't we? Refreshing our memory and looking for things we need to revisit (at normal reading speed)? Wouldn't everyone also want to 'skim' the videos they've already watched instead of re-watching at normal speed?
But i also think its much more exhausting. I play the video tutorials when i am in bed before i sleep (or while sleeping :) ). They are way more relaxed, i don't have to pay that much attention. For me most of the time its a tradeoff between learning a bit and learning nothing. I also get excited from watching the videos and can start doing toy-projects. And while books are a good way to get a gasp of the language, it think the only way to really learn a language is to use it. Thats one similarity between programming languages and "real" foreign languages.
It was for me at least. As a front-end dev I'm not always able to use Haskell day-to-day but I've found ways to use Purescript.
In many ways, PureScript is actually a better version of Haskell (e.g., with extensible records). But it's currently very focused on front-end development, and it's missing amazing Haskell features like STM. So outside of front-end stuff it's not nearly as practical to use as Haskell.
> Unlike Haskell, Elm has no support for higher-kinded types, and thus cannot provide generic abstractions for many common operations.[20] For example, there is no generic map, apply, fold, or filter function. Instead, such names are used prefixed by their module, such as List.map and Dict.map. [1]
And from the above source link:
> You can't define higher-kinded things like Functor/Applicative/Monad/Foldable and do dictionary-passing style for ad-hoc polymorphism in Elm. [2]
But personally, I haven't tried Elm yet so I can't comment. I'm not sure I want to invest in learning a whole new language/framework just to do front-end work. By learning PureScript I can transfer the same knowledge/experience coding in that language to the backend when using Haskell. Much like Clojurescript and a lesser extent Node.js. While Elm is limited to front-end use.
[1] https://en.wikipedia.org/wiki/Elm_(programming_language)#Lim...
do you mean "frontend" ?
Elm is a niche platform without applications outside of front-end (AFAIK).
Congrats on releasing your course though.
Here are some interesting starting points:
https://github.com/facebook/Haxl - A Haskell library that simplifies access to remote data, such as databases or web-based services.
https://github.com/koalaman/shellcheck - ShellCheck, a static analysis tool for shell scripts
https://github.com/simonmichael/hledger - The hledger command-line and web-based accounting tool, a Haskell rewrite of ledger.
https://github.com/facebook/flow - Adds static typing to JavaScript to improve developer productivity and code quality.
https://github.com/coq/coq - Coq is a formal proof management system. It provides a formal language to write mathematical definitions, executable algorithms and theorems together with an environment for semi-interactive development of machine-checked proofs.
It is interesting that most (interactive) proof systems (e.g. Isabelle and Coq) are written in ML, I think it is probably historical. AFAIK most theorem proving research is done in Europe and ML has always been more popular there (however it seems to change in recent years, and FP courses switch to Haskell - however my school e.g. switched from OCaml to Haskell to OCaml in their FP course).
> My biggest problem with pure FP languages is a lack of interesting projects
The list included projected written in pure FP languages.
Not only COQ, Flow is also written in OCaml.
- an IRC bot (will get you into threading, network programming etc) or a;
- CMS starting with just basic blog functionality (i.e. authentication, talking to database to store posts etc)
The first can usually be done with just the standard libraries or at least some of the smaller ones, and the latter will get you into web programming and usually involve bigger frameworks, such as Yesod (what I'd go with), Snap, Servant etc.
Also, both of those types of projects are pretty well covered tutorial-wise.
I know a bunch of startups building in Haskell, it's just not that obvious from a google search.
The goal of this course is to keep the content pretty restricted to the few, main concepts that are used over and over again and to gain experience with practice and real examples.
Hope that helps.
Why would you drive a beginner towards Haskell and make some many "Haskell for beginners tutorials" instead of OCaml or F# (even Scala fi you're into JVM...) which gives you the same features but slightly more practical (usable records, ability to be impure and imperative when you want etc., some kind of oop-style feature for when they really fit the way you want to model a problem, less "string madness", no "forced verbose" syntax with repeating names of things to type them etc.). Plus friendly new cool tools/skins for them: https://facebook.github.io/reason/ , https://github.com/bloomberg/bucklescript etc.
I agree it seems true, I did learn a lot while struggling to learn Haskell for a bit and hurting in the process, but... why?
No they do not. Haskell's powerful typeclass system, advanced (kind) polymorphism, etc. are not available in those languages. Ocaml doesn't even support proper monads. Laughably, it doesn't even support HKTs! Not sure how Scala and F# fare in that regard.
>usable records,
A reasonable complaint about the core language, but essentially solved by lenses.
>ability to be impure and imperative when you want
Haskell has the ability to be pure and imperative when you want. You just can't lie about what you're doing.
> some kind of oop-style feature
Which features?
>string madness
I never understood this complaint. Three string types, plus lazy variants, is quite manageable. They are all very well-suited for a particular set of tasks, and I'm thankful the Haskell community doesn't shoehorn too much stuff into a single string type. Haskell cleanly solves the encoding problem, which many languages kind of sweep under the rug.
> no "forced verbose" syntax with repeating names of things to type them
No idea what in the world you are talking about. FWIW, Haskell is by far the least verbose language I have ever used. Every token has semantic significance. No waste.
I'm aware of the algebraic type system, can you elaborate on what you mean "by advanced (kind) polymorphism"?
Edit: This formatted poorly on HN. See here: https://gist.github.com/anonymous/3925f5e58d8647e6d82a3b2084...