Introduction to Elm, v2

Type Annotations Exercise

Richard Feldman

Richard Feldman

Vendr, Inc.
Introduction to Elm, v2

Check out a free preview of the full Introduction to Elm, v2 course

The "Type Annotations Exercise" Lesson is part of the full, Introduction to Elm, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Students add type annotations to the page they've built in the previous exercises.

Preview
Close

Transcript from the "Type Annotations Exercise" Lesson

[00:00:00]
>> Richard Feldman: Excellent, let's hop over to the exercise. Go over to the exercise for part four and open it up. So for this exercise we're not actually going to open the browser, we're just going to take the stuff we did in the previous exercise and add annotations to it.

[00:00:19]
So in the read me it says, no need to open index.html in your browser this time, the exercise is only about compiling. So we're gonna open main.elm in our editor. And what we'll see here is we've got a bunch of to do's that essentially have to do with type annotations, and that's all.

[00:00:35]
So we're not actually changing any of the logic here, we're just sort of adding documentation to what we already did. So this first one is about creating a type alias. So we've got this sort of nested all articles list that's got a bunch of different fields in it.

[00:00:49]
We're gonna break that out and give it a type alias called articles. So this can just become list article. And the remainder of the TODOs have to do with adding annotations to existing top level declarations. So this initial model will add something that says initial model colon and then the type.

[00:01:05]
And then we'll do that several other times throughout the exercise.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now