Try Haskell: An interactive tutorial in your browser (tryhaskell.org)
There's a lot more potential for this project (adding a CodeMirror editor with "loadable" code, allowing uploading of tutorials like a pastebin... but a tutorialbin, asking exercise questions which are then quickcheck'd, etc.), but I like to incrementally add and then get feedback.
For newbies to Haskell I would like your feedback/comments, if you have any. I'm hoping to reach fresh Haskell newbies here on Hacker News for an unbiased experience.
I asked a non-programmer friend to try it out a while ago and got some invaluable feedback. Send it to your friends, just to see how far they get! Post what they say! Anyone who's read something like Rocket Surgery Made Easy will be familiar with how invaluable feedback is.
I am also interested in hearing about general ideas on what you think would just be cool to see.
If you want to let me know about bugs please post them here: http://github.com/chrisdone/tryhaskell/issues Granted there are some browser/OS oddities but I can only test on so many! Bugfixes welcome! PM me on github.
Cheers!
42 comments
[ 3.3 ms ] story [ 95.4 ms ] threadThere's a lot more potential for this project (adding a CodeMirror editor with "loadable" code, allowing uploading of tutorials like a pastebin... but a tutorialbin, asking exercise questions which are then quickcheck'd, etc.), but I like to incrementally add and then get feedback.
For newbies to Haskell I would like your feedback/comments, if you have any. I'm hoping to reach fresh Haskell newbies here on Hacker News for an unbiased experience.
I asked a non-programmer friend to try it out a while ago and got some invaluable feedback. Send it to your friends, just to see how far they get! Post what they say! Anyone who's read something like Rocket Surgery Made Easy will be familiar with how invaluable feedback is.
I am also interested in hearing about general ideas on what you think would just be cool to see.
If you want to let me know about bugs please post them here: http://github.com/chrisdone/tryhaskell/issues Granted there are some browser/OS oddities but I can only test on so many! Bugfixes welcome! PM me on github.
Cheers!
The syntax
is not obvious to me, and the tutorial doesn't explain what each piece of the new syntax means, and quickly moves on to something new in step 8.Only through experimentation, I find:
So I gather the let is equivalent to: But without parens, line breaks or semicolons I have difficulty determining where one expression ends and another begins.Plus, the arbitrary shortening of "first" to "fst" doesn't help, and should probably be clarified.
You seem to only check the return value to determine when to skip to the next step in the tutorial, since in step10, you want me to type:
But it skips ahead when I play around and return True from a different expression:Common Lisp (and MzScheme) users can use first (and second, and third...) and rest, and probably should do so when using simple lists.
Actually it just checks the type of the result on that step! I'll do a syntactic check to make sure you have to type it out in that step.
Thanks for the feedback, I'll fix this today!
I think the lack of any sort of typographical indication of when one expression ends is really a Haskell issue, not an issue with the tutorial, though perhaps newlines could be inserted for readability. (Or does Haskell care where newlines appear?)
I've read a number of Haskell tutorials in the past, and despite having no problem with a variety of syntax types, including C-family, Lisp-family, and even having done some coding in ML way back when, I find the Haskell syntax really hard to read.
I don't think this is something a tutorial can "fix", per se, but it'd be nice if there was a tutorial that took this into account and explained how to actually decompose Haskell code without just throwing code snippets at you and hoping that you'll intuit their meaning. "Haskell Parsing for Humans" is what I want. The part at the beginning of this tutorial where it explains numbers, strings, lists and tuples is actually a good start, but "let", "=", and "in" are never explained, nor is "fst".
Cheers!
Explaining the let syntax only after the user has had to use it once felt a bit funny to me, though I guess that's the pattern of the rest of the tutorial. I'm one of those people who tends to learn more from references than tutorials, so that might be saying more about my learning style than your tutorial.
Is there a way to bind variables? I can do things like "let a = 3 in a", but it seems that no state is stored between expressions?
Hey Paul, that's correct; there's no state stored between expressions. It's planned that there be a text editor where you can put top-level definitions, kinda similar to DrScheme, if you know of it. You may notice parts of the tutorial that would've been better (e.g. having to write `let .. in ..`) with state between expressions. I will rewrite those once this is implemented.
> It's planned that there be a text editor where you can put top-level definitions
Good to hear, I like the way Dr. Scheme does it and it makes for a good learning environment.
It works pretty well at keeping crazy stuff out. Hopefully you added some sort of limiter to your page... but if you haven't, this is a great start.
Nice UI & stuff, though. Seems to work pretty well. It would be nice, like paulgb said, to be able to enter a block of code and execute it. I know this currently behaves a lot like ghci, but it would be nice to test larger sections of code.
Also cool job with the lessons. Sure it's pretty light, but it provides a good, quick introduction.
I think you might want to look at how Opera handles keydown and keypress events in Javascript. I had a similar problem working on my own project a few days ago.
So a simple solution might be to add the following to the keypress function "if(e.altKey) return;". I've tested this locally and it works for me, but don't know if it might interfere with other keyboard layouts.
I will try applying this patch and let you know.
I'd suggest you either do "if(e.altKey)return;" or "if(e.altKey && e.ctrlKey)return;". Both work for me.
EDIT: Hm, my suggested changes work in Opera, but they break Chrome... This is driving me crazy.
Tada!
Type something in the console and hit enter. Then type "link" and hit enter. Or type "link :t id >=> id".
How's that for a slice of fried gold?
2. Inverted contrast of instruction text makes it hard to move the eyes from tutorial to command window and back.
3. There isn't actually enough explanation for what's going on. For example here "let villain = (28,"chirs") in fst villain" it's never explained what the actual syntax is. Which is where I stopped reading.
4. You have a hint that tells you how to get to current page. But I am already on the current page! What I need instead is a shortcut to get to previous page.
2. I haven't heard that complaint yet! I can try lightening it up in the stylesheet.
3. I hope that's not throughout the tutorial. That one has been flagged up (my non-programmer friend had no idea what it meant, but even he persevered! Shame on you! >_-), and I knew it when I wrote it; the basic issue is there is no support for saving variables in the session state for later re-call, so you have to write out your "let x = .. in .." expression every time. As mentioned in other posts, hopefully with the introduction of loading code, this problem will be solved and I can rewrite that part of the tutorial.
4. I added that hint by request, people want to know how to get back to where they were. I can add a 'back' command and mention it within that sentence, perhaps?
Thanks for your feedback, nicely laid out and constructive!
I'm very impressed with your follow-trough however, and I think you will do quite well for that. It's similar to how a cruise missile can adjust the trajectory, and thus is infinitely more precise than a ballistic projectile. Good luck.
let villain = (28,"chirs") in fst villain
is a big turnoff.
Otherwise it is the languages fault, not yours. Sad that issues like keyword naming and syntax is often not taken seriously enough by language authors. Popularity really puts languages under a constrain of development towards the intuitive.
Would you agree with me that we need a very transparent and human readable super-language, that other languages can be easily translated into? This way it can exist exclusively for the definition of algorithms and learning purposes. This way speed and re-usability will never be an issue, and developers of this language won't need to keep its weaknesses for the sake of forward compatibility.
I suppose if you want a super-language, you would have a language which starts from very simple constructs and one straight-forward way to define new syntax and semantics to fit a given problem, within that language itself; so that for any given problem, someone can read the solution, and if they don't know the syntax/semantics, they can read the definition which is in turn written in this really simple language. Lisp is mostly ideal for this.