Remix.run Logo
Hackbraten 2 days ago

Maybe I'm spoiled by TypeScript but this is how I'd do it in a structural typing system:

    type ConstrainedByW =
    | { w: false, x: false }
    | { w: true, x: bool }
    
    type ConstrainedByY =
    | { x: bool, y: false, z: bool }
    | { x: true, y: true, z: false }
    
    type ProgramState = ConstrainedByW & ConstrainedByY
jandrese 2 days ago | parent [-]

Yes, but certainly you can see how even a toy example with just 4 booleans is already getting complicated?

Hackbraten 2 days ago | parent [-]

It's certainly complicated. But not WTF-level complicated.

Complexity is both subjective and relative. Allowing invalid states in your model is going to complicate things, too.

I wouldn't mind having this example in production. It will scale just fine with the number of booleans.