Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active February 18, 2017 22:50
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/a61ac574c6c3069d2d08 to your computer and use it in GitHub Desktop.
Save JoshCheek/a61ac574c6c3069d2d08 to your computer and use it in GitHub Desktop.
Learning Elm

Learning Elm

What is it? (20 min)

Glance through a few of the examples, maybe 5 or so, to see what kinds of things Elm is doing, what domains they're in, what the code looks like, what other people think Elm is.

You're going for exposure and big big high-level vision here.

Bootstrapping syntax (1 hour)

  1. Open the online editor and put this in it, then compile it and make sure you see it show up.

    import Html exposing (text)
    
    main =
      text "Hello, World!"
  2. Make a cheatsheet (it'll be empty right now :P)

  3. Open the Elm Syntax

  4. Go through the syntax, in the following manner

  • Look at the example, read it, try to make sense of it.
  • Run it in the online editor to make sure it works.
  • Make a prediction that should be true if you understand it
  • Edit the example to try your prediction out
  • If you're right, document what you figured out in your cheatsheet, along with the example code to do it.

Synthesis: Organize your cheatsheet (20 min)

Organize your cheatsheet consolidating ideas, or breaking them apart, as is necessary. You want to remove irrelevant code from the examples (the smaller your example, the better it is!)

Do this constantly! You go out and try a new thing to find ideas that you can bring back into your cheatsheet.

Relating to existing knowledge: JS examples (1 hour)

Do the same thing you did for the syntax examples, but this time for the From JavaScript examples. Someone thought those 20ish things were important enough to separate out on their own page, So they've done a lot of work for you, go add that knowledge in your cheatsheet!

Build a low-resolution map of this world: docs (20 min)

Skim the list of docs topics, clicking and scanning the ones that seem interesting. What words are you seeing, how might they map to the stuff you figured out in the cheatsheet? Edit your cheatsheet, addign topic links, and a short description of why they seem related.

Don't read them, just associate them. You're building your model and understanding. Yes, pieces will be wrong, that's necessary!

Refactor your cheatsheet as you go :P It integrates new knowledge with existing knowledge. Since nothing exists except by how it relates to other things, This is a much much faster way of learning and it leads to much deeper insights.

Basic competence: Go Through the core examples

Go to the core examples. Go through each one, run them to see what they do. Then read what they say, try tweaking it in ways that you're able to predict (can you add an item to a list, change a colour, make it spin in the other direction?). As you learn information, continue integrating it into your cheatsheet.

Small proof of knowledge! (1-2 hours)

Glance through a few of the examples from HTML and Visuals sections. See what kinds of things people are doing. Pick your own small example, that is similar to the kinds of things you've seen there, but not exactly the same. You want examples you can reference for context. Maybe a text field where you can enter a number and it puts that many circles on the screen.

Keep it small, you don't care about this project, it's you're integrating your model with the real world. Keep it similar to the examples you saw, there's a lot of unknowns for you at this point, so reduce their ability to trip you up by sticking near something you can reference.

Amend your cheat sheet as necessary.

Rung on a ladder: Linked List waypoint (1-2 hours)

Go through my Ruby waypoint on linked lists. Watch my video then do them yourself until you can do it from start to finish without looking and without making an error. I wrote them all in a functional style. Repeat the Ruby linked list waypoint (you want to be able to do this in just a few minutes, if not, you need to practice it until you have it down cold).

Dip into the paradigm: Build a linked list (1-2 hours)

First do the waypoint (should be just a few minutes at this point). Then translate what you did in the waypoint to Elm: First, just try to get it working. Then put some piece of data into the list like numbers that represent the radii of circles, iterate over your list and draw the circles.

If yours aren't written using elm's builtin lists, then refactor what you did to them. If yours aren't written using pattern matching, then refactor what you did to use pattern matching.

Cementing the knowledge: repeat the lists (20 min - 2 hours)

Look at your working linked list example, noting anything you think is likely to trip you up. Now open a new document and do it from scratch. If you get stuck, reference your working example, until you get past the stuck point, then repeat that part you got stuck on until you are past it without referencing your document. Do this twice.

Repeat the waypoint. Then repeat the Elm linked list unitl you can do it from start to finish without reference or error.

Expand your horizon: BST (1-8 hours)

If you don't know what a Binary Search Tree (BST) is, search for a 5-15 minute video about it. Avoid ones that talk about a list vs a node (you can translate from it, but it's the wrong paradigm, so could undermine you while you're volatile), prefer instead ones where everything is a node, but some nodes are empty (they might call this a "null node" or "leaf"). As you watch the video, think about how it is similar to a linked list, and how it is different from a linked list.

Do the BST challenges You can use my solutions as a reference for when you get stuck.

Let me know

If you get this far, let me know and I'll add more to the document.

Notes for myself if you do:

  • block challenges
  • Corey Haines has several talks / books
  • That gist where I built lisp in Ruby, using just lambdas (except for where I cheated)
  • building enumearble
  • The brain destroyer
  • Maybe Replicate one of the games
  • Maybe elm architecture tutorial
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment