I don't know Haskell but this looks like Phantom Types in Scala.
Can anyone who knows both languages enlighten us ?
More on Scala Phantom types here https://gigiigig.github.io/tlp-step-by-step/phantom-types.ht...
Can anyone who knows both languages enlighten us ?
More on Scala Phantom types here https://gigiigig.github.io/tlp-step-by-step/phantom-types.ht...
Linear types can guarantee that the object participating in a state transition is not reused, which prevents accidentally referring to invalidated data.
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.
That's not the interesting part, though. It's the linear types that are giving the guarantees here, and linear type systems are rare.
data State = Unbound | Bound | Listening | …
data Socket (s :: State)
(s :: State) is a phantom type, yes.