Skip to content

Step 2.1: Rich types ensure correctness#12

Open
ziimakc wants to merge 1 commit intomainfrom
2_1_type_safety
Open

Step 2.1: Rich types ensure correctness#12
ziimakc wants to merge 1 commit intomainfrom
2_1_type_safety

Conversation

@ziimakc
Copy link
Owner

@ziimakc ziimakc commented Feb 4, 2026

Resolves Step 2.1

Task

For the Post type described above, assume the following behavior in our application:

+-----+              +-------------+            +-----------+
| New |--publish()-->| Unmoderated |--allow()-->| Published |
+-----+              +-------------+            +-----------+
                           |                          |
                         deny()                    delete()
                           |       +---------+        |
                           +------>| Deleted |<-------+
                                   +---------+

Implement this behavior using [typestates idiom][3], so that calling delete() on New post (or calling deny() on Deleted post) will be a compile-time error.

Solution

Implemented task as described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant