Last active
October 6, 2016 14:51
-
-
Save ghulette/fd4df8c7c0400136c74d5d3df7a23a72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type value = int | |
type ptr = value ref | |
type st = unit | |
type 'a imp = | |
| New of value * (ptr -> 'a imp) | |
| Read of ptr * (value -> 'a imp) | |
| Write of ptr * value * 'a imp | |
| While of (st -> bool) * unit imp * 'a imp | |
| Return of 'a | |
let rec interp = function | |
| New (v,k) -> fun () -> let p = ref v in interp (k p) | |
| Read (p,k) -> let v = !p in interp (k v) | |
| Write (p,v,k) -> p := v; interp k |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment