News for hackers. Stuff that matters.
Re:Haskell's kind system: a primer by almostdeadguy on Thursday October 18, 2018 @08:45AM (#18247816)
The advantage is you basically don't have to think about the provenance of data (in this example what state is a connection in? was it closed before being given to me? etc.). It allows the compiler to ensure the user of this code can't perform operations that lead to error states by allowing the programmer to express the state transitions of a connection in their function declarations, as the provided example shows:

  newConnection     :: Address           -> Connection Closed
  openConnection    :: Connection Closed -> Connection Open
  closeConnection   :: Connection Open   -> Connection Closed
  connectionAddress :: Connection s      -> Address
From a readability perspective, I would love this, it's effectively a state machine diagram explained by your function types.

There are no comments on this comment yet.