-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into kant/newmsbuildsdk
- Loading branch information
Showing
7 changed files
with
498 additions
and
537 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,51 @@ | ||
module DivAction | ||
|
||
let repr (a : Type) () : Type = | ||
let repr (a : Type) : Type = | ||
unit -> Dv a | ||
|
||
let return (a : Type) (x : a) : repr a () = | ||
let return (a : Type) (x : a) : repr a = | ||
fun () -> x | ||
|
||
let bind (a b : Type) (v : repr a ()) (f : (a -> repr b ())) : repr b () = | ||
let bind (a b : Type) (v : repr a) (f : (a -> repr b)) : repr b = | ||
fun () -> f (v ()) () | ||
|
||
total | ||
reifiable | ||
reflectable | ||
layered_effect { | ||
ID : a:Type -> eqtype_as_type unit -> Effect | ||
with repr = repr; | ||
return = return; | ||
bind = bind | ||
effect { | ||
ID (a:Type) | ||
with {repr; return; bind} | ||
} | ||
|
||
let lift_pure_nd (a:Type) (wp:pure_wp a) (f:(eqtype_as_type unit -> PURE a wp)) : | ||
Pure (repr a ()) (requires (wp (fun _ -> True) /\ (forall p1 p2. (forall x. p1 x ==> p2 x) ==> wp p1 ==> wp p2))) | ||
(ensures (fun _ -> True)) | ||
Pure (repr a) (requires (wp (fun _ -> True) /\ (forall p1 p2. (forall x. p1 x ==> p2 x) ==> wp p1 ==> wp p2))) | ||
(ensures (fun _ -> True)) | ||
= fun _ -> | ||
let r = f () in | ||
r | ||
|
||
sub_effect PURE ~> ID = lift_pure_nd | ||
|
||
val fix : #a:_ -> #b:_ -> ((a -> ID b ()) -> (a -> ID b ())) -> (a -> ID b ()) | ||
val fix : #a:_ -> #b:_ -> ((a -> ID b) -> (a -> ID b)) -> (a -> ID b) | ||
let fix #a #b f = | ||
let reified : (a -> Dv b) -> (a -> Dv b) = | ||
fun g x -> | ||
let reflected_g : (a -> ID b ()) = | ||
let reflected_g : (a -> ID b) = | ||
fun x -> ID?.reflect (fun () -> g x) | ||
in | ||
reify (f reflected_g x) () | ||
in | ||
let rec fixed : (a -> Dv b) = | ||
fun x -> reified fixed x | ||
in | ||
let reflected : a -> ID b () = | ||
let reflected : a -> ID b = | ||
fun x -> ID?.reflect (fun () -> fixed x) | ||
in | ||
reflected | ||
|
||
[@@expect_failure] | ||
let rec bad_div (x:int) : ID int () = bad_div x | ||
let rec bad_div (x:int) : ID int = bad_div x | ||
|
||
let good_div : int -> ID int () = fix #int #int (fun f x -> f x) | ||
let good_div : int -> ID int = fix #int #int (fun f x -> f x) | ||
|
||
let test (x:int) : Dv int = reify (good_div x) () |
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
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
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
Oops, something went wrong.