Hi,
type _ spec =
| [] : 'a spec
| (::) : (string * (unit -> 'state) * ('proto -> 'state -> 'payload)) * (string * (unit -> 'state2) * ('proto -> 'state2 -> 'payload)) spec -> (string * (unit -> 'state -> 'state2) * ('proto -> 'state -> 'state2 -> 'payload)) spec
So it is a list of identifiers (string
), a internal state production function (unit -> 'state
) and a function which takes some input data (same for every list entry), its specific state and produces a an output data (same for every list entry) ('proto -> 'state -> 'payload
). I can get it sort of to type but I don’t know how to write a function to process these. I’m not even sure my ‘::’ implementation is actually correct because I am still confused on how GADTs work.