O'Reilly logo

Programming Elm by Jeremy Fairbank

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Get Lazy

If you’ve ever wanted a reward for laziness, this section is for you. You will discover eager and lazy evaluation and how each impacts performance. You will use elm-benchmark and lazy design patterns to dramatically improve the performance of a function. Along the way, you will learn about thunks and the Dict type.

As you continue examining Rescue Me’s codebase, you encounter a new feature to track dogs that know tricks. Rescue Me represents dogs with a record type and tricks with a custom type.

 type​ ​Trick
  = ​Sit
  | ​RollOver
  | ​Speak
  | ​Fetch
  | ​Spin
 
 
 type​ ​alias​ ​Dog​ =
  { name : ​String
  , tricks : ​List​ ​Trick
  }

You find a getDog function that looks questionable.

 getDog ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required