Open brabalan opened 7 years ago
This does not work: some functions may return something of non res
type (for instance a string after a conversion), but may also throw (in that case they contain a res
type with an abort restype
). This can be seen in if_spec
that uses if_abort
.
let if_abort o k =
match o with
| Coq_out_div -> k ()
| Coq_out_ter (s0, r) ->
if restype_compare r.res_type Coq_restype_normal
then (fun s m -> Debug.impossible_with_heap_because __LOC__ s m; Coq_result_impossible)
s0
("[if_abort] received a normal result!")
else k ()
let if_spec w k =
if_result_some w (fun sp ->
match sp with
| Coq_specret_val (s0, a) -> k s0 a
| Coq_specret_out o -> if_abort o (fun x -> res_out o))
Alternative suggestion: replace the specret
constructors as follows
type 't specret =
| Normal of state * 't [@f state, res]
| Abnormal of out [@f out]
Since our functions never have different return types and we no longer have
Coq_out_div
, we can flattenspecret
intoresultof
. Concretely,resultof
becomesWe no longer need
specres
, andresult
is simply ares resultof
.