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 ...

Get Programming Elm now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.