3 ms·
I don't know Scala, but Phantom Types look like they only encode the state at the type level, but don't prevent you from copying e.g. the closed door before ope
by yorwba 9y ago
I don't know Scala, but Phantom Types look like they only encode the state at the type level, but don't prevent you from copying e.g. the closed door before opening it, which would be undesirable if the state transition corresponds to a side effect.
Linear types can guarantee that the object participating in a state transition is not reused, which prevents accidentally referring to invalidated data.
- mcguire 9y agoThis, exactly. You can use phantom types to mark the difference between bound and unbound sockets, but you need the linear type system to prevent the unbound value from being used again.