diff --git a/docs/src/main/tut/datatypes/state.md b/docs/src/main/tut/datatypes/state.md index 1dc328c8d0..10f9682133 100644 --- a/docs/src/main/tut/datatypes/state.md +++ b/docs/src/main/tut/datatypes/state.md @@ -282,8 +282,8 @@ So, let's model our typed door: import cats.Eval import cats.data.IndexedStateT -def open: IndexedStateT[Eval, Open.type, Closed.type, Unit] = IndexedStateT.set(Closed) -def close: IndexedStateT[Eval, Closed.type, Open.type, Unit] = IndexedStateT.set(Open) +def open: IndexedStateT[Eval, Closed.type, Open.type, Unit] = IndexedStateT.set(Open) +def close: IndexedStateT[Eval, Open.type, Closed.type, Unit] = IndexedStateT.set(Closed) ``` We can now reject, at compile time, sequences of `open` and `close` that are invalid: @@ -305,3 +305,11 @@ val valid = for { ``` Note that the inferred type of `valid` correctly models that this computation can be executed only with an initial `Closed` state. + +```tut:book:fail +valid.run(Open) +``` + +```tut:book +valid.run(Closed) +``` \ No newline at end of file