Skip to content

Instantly share code, notes, and snippets.

View perty's full-sized avatar
😎

Per Lundholm perty

😎
View GitHub Profile
@perty
perty / Main.elm
Created February 17, 2019 06:59
Demonstrate a state machine in Elm that make impossible state TRANSITIONS impossible
module Main exposing (main)
{-
Can we make impossible state transtions impossible as impossible state can be impossible?
An order has this state machine: Initial -> { Processing, Cancelled }, Processing -> {Cancelled, Shipping},
Shipping -> {Shipped, Lost}. So end states are Cancelled, Shipped and Lost.
Let's see if can make the compiler catch when trying to cancel an order that is shipping.