cs3110 / textbook

The CS 3110 Textbook, "OCaml Programming: Correct + Efficient + Beautiful"
Other
720 stars 132 forks source link

Missing small step rules for Core OCaml #134

Closed cionx closed 8 months ago

cionx commented 1 year ago

The small step rules for Core OCaml have the following entries for fst and snd:

https://github.com/cs3110/textbook/blob/7b131977bcd587151bd700cd38ae83e72748a7fd/src/chapters/interp/substitution.md?plain=1#L939-L941

But we have no rules for fst (e1, e2) and snd (e1, e2) when one of the two entries e1 and e2 is not a value. I guess that in the quoted code sample, v1 and v2 should be e1 and e2 instead.

clarksmr commented 8 months ago

Thank you!

To be consistent with OCaml, we need to evaluate the subexpression e in fst e (sim. snd) fully to a value. So I added two rules:

fst e --> fst e'
  if e --> e'

snd e --> snd e'
  if e --> e'

While leaving the existing rules unchanged.

I believe that resolves the issue, but if I've missed something, please reopen.