Steve's Roc Apps roc-apps on GitHub

Safari Ride: a tour of a real Roc program

Safari Ride is a small Roc program with a lot to look at. In this book, we read it with you.

Contents

  1. The big picture
  2. 1Introduction
    1. Run it yourself
  3. 2One page
  4. 3The problem
  5. 4Platforms, packages and modules
  6. 5Types
    1. Distance pins down a number
    2. A billboard spells out its fields and its choices
    3. Plain records lay out the road
    4. A type variable carries every kind
    5. One record captures the whole ride
    6. The tour keeps the past
    7. Types come first
  7. 6Functions
    1. A function is a value
    2. A body is one expression
    3. An annotation states the contract
    4. A method belongs to its type
    5. Every function has this shape
  8. One frame
  9. 7Things
    1. A billboard stands in for an animal
    2. A species record names the animal
    3. A function picks the calves
    4. Every kind returns a sprite
  10. 8Tag unions: billboard critters
    1. A tag union lists every case
    2. A match handles every case
    3. A nominal type sets its tags apart
    4. A tag carries a value
    5. Elephants, mostly
  11. 9Shapes
    1. A triangle
    2. A rectangle
  12. 10Lists and map: a far tree
    1. Eight tiers
    2. Tops and bottoms
    3. Freezing the tiers
    4. A triangle for each tier
    5. Painting the tree
    6. What you're missing
  13. 11The pipeline
    1. Placed
    2. Sighted
    3. Rendered
    4. One list
  14. 12Where clauses: asking a kind
    1. A kind from the inside
    2. One function for every kind
    3. The compiler checks each call
    4. Asking for a height
    5. Names that say what they're for
  15. 13Errors as tag unions
    1. An answer that can fail
    2. A test on top
    3. Where the refusals stop
    4. Try or crash
  16. Nature
  17. 14The sky and the grass
    1. The top of the sky
    2. The horizon
    3. The fade
    4. The grass
  18. 15Mountains
    1. Directions
    2. A range
    3. Across the screen
    4. Back to front
  19. Man-made
  20. 16The road
    1. A segment's ground
    2. Along a segment
    3. At a bend
  21. 17Rails
    1. From path to quads
    2. Bars and posts
  22. 18Radio towers
    1. Where a tower stands
    2. Over the horizon
    3. Rods
  23. Critters that stand still
  24. 19Herds
    1. Cows
    2. Pigs
  25. Motion
  26. 20Immutable values: a flip book
    1. Turning back
    2. What a moment holds
  27. 21Records
  28. 22Pure functions and effects
    1. The keys
  29. 23Opaque types: the clock
    1. A moment and a length
    2. The module
    3. Two invariants
    4. Tests
  30. 24The ride instant
    1. One step
    2. Carried and derived
  31. The passage of time
  32. 25The beacons
    1. Three rules
    2. Which beacon, and when
    3. The phase
    4. The brightness
    5. A disc, or a refusal
  33. 26The setting sun
    1. The sun goes down
    2. In view, or out of view
    3. The sky darkens
    4. The horizon warms
    5. Going backward
  34. Vehicles
  35. 27The rider
    1. The rider's step
    2. Deciding
    3. One step of physics
    4. The end of a segment
    5. The picture leans too
  36. 28The throttle
  37. 29Variables and loops: rehearsal
    1. Where the rehearsals start
    2. A coast
    3. Twelve tries
    4. Why rehearsing is safe
  38. 30The rider's gaze
    1. Get the types right
    2. The look
    3. Turning the head
    4. The depth of a look
    5. Gawking
    6. The first pig
  39. 31The truck
    1. The whole job
    2. The body's shape
    3. Shape, placement, projection
    4. The headlights
    5. The brake lights
  40. 32The truck's motion
    1. A tease, carried out by physics
    2. Carried from step to step
    3. Get the types right
    4. The functions
  41. Critter motion
  42. 33The cat
    1. One step carried
    2. When it starts
    3. Where it has got to
    4. What it looks like
    5. A timeline
    6. Into the frame
  43. 34The bird
    1. The same plan
    2. Its poses
    3. Its path
    4. Finding its trees
    5. Into the frame
  44. 35What a cat does to the rider
    1. Hold the throttle
    2. Look
  45. Under the hood
  46. 36The math layer
    1. Round the bends
    2. To the rider
    3. Through the pinhole
    4. Cutting at the near plane
  47. 37Proving it
    1. A fixture is a value
    2. The frame hash
    3. Sums in order
    4. Three more proofs
    5. Tests beside the code
    6. Crashes that check
    7. The page itself
  48. 38The platform
    1. An app is a value
    2. What the platform calls
    3. The person watching
    4. The host
    5. A frame is a list
  49. 39Zooming back out
    1. Four things carried
    2. One step, in order
    3. Where each thing comes from
  50. Appendices
  51. Appendix: the patterns
  52. Appendix: list functions
  53. Appendix: what catches you out
  54. Appendix: glossary
  55. Appendix: index
    1. Roc concepts
    2. Animation concepts
    3. Safari Ride's design
  56. Credits