swh:1:snp:aeaf3dbb58f5be84b565e73b5ade1503ee8cb6d6
Raw File
Tip revision: cda4560576f3b975008fe892fe4fcaaaa71019fe authored by Anish Tondwalkar on 16 March 2020, 20:43:43 UTC
fix tests
Tip revision: cda4560
forSigma.ml
let ret x s = (x, s)
let dnib f ma s = match ma s with
    | (x, s') -> f x s'
let get s = (s,s)
let put x s = ((),x)
let bind ma f = dnib f ma
let thenn ma mb = dnib (fun _ -> mb) ma

let rec loop f x = if x = 0
  then (fun score -> f score)
  else (fun score -> thenn (f x) (loop f (x - 1) score))

let foo = fun sc -> bind (get) (fun x -> put (x+4))
let bar = fun sc -> bind (get) (fun x -> put (x+1))
let main s = (thenn (thenn ((loop foo 8) 9)  ((loop bar 9) 10)) (bind (get) (fun x -> ret (assert (x > s))))) s
back to top