Unions and State

Model states and results as unions and narrow them safely: remote data, typed actions, optional values, validation and state machines.

  1. 01

    Describe Each State of Remote Data

    • easy
    • Code
  2. 02

    Assert a Value Is a Non-empty String

    • easy
    • Code
  3. 03

    Filter Logs by a Typed Level

    • easy
    • Code
  4. 04

    Describe Errors by Their Class

    • easy
    • Code
  5. 05

    Parse Keyboard Shortcuts into Typed Keys

    • easy
    • Code
  6. 06

    Reduce Todo Actions from a Typed Union

    • medium
    • Code
  7. 07

    Model an Optional Value with Some and None

    • medium
    • Code
  8. 08

    Parse JSON Safely into a Checked Shape

    • medium
    • Code
  9. 09

    Tell Cats from Dogs by Their Properties

    • medium
    • Code
  10. 10

    Charge a Fee per Payment Method

    • medium
    • Code
  11. 11

    Summarise an Event Log by Kind

    • medium
    • Code
  12. 12

    Route Requests Through a Handler per Method

    • medium
    • Code
    • Pro
  13. 13

    Type a Traffic Light State Machine

    • hard
    • Code
    • Pro
  14. 14

    Chain Validation Steps, Keeping Every Error Type

    • hard
    • Code
    • Pro
  15. 15

    Read Typed Values from Form Fields

    • hard
    • Code
    • Pro