@@ -14,8 +14,7 @@ let add_type env x e = List.Assoc.add ~equal:equal_ray env.types x e
1414
1515let get_type env x = List.Assoc. find ~equal: equal_ray env.types x
1616
17- let rec map_sgen_expr env ~f : sgen_expr -> (sgen_expr , err ) Result. t =
18- function
17+ let rec map_sgen_expr env ~f : sgen_expr -> (sgen_expr , err ) Result. t = function
1918 | Raw g -> Raw (f g) |> Result. return
2019 | Id x when is_reserved x -> Ok (Id x)
2120 | Id x -> begin
@@ -127,7 +126,9 @@ and eval_sgen_expr ~notyping (env : env) :
127126 end
128127 end
129128 | Union es ->
130- let * eval_es = List. map ~f: (eval_sgen_expr ~notyping env) es |> Result. all in
129+ let * eval_es =
130+ List. map ~f: (eval_sgen_expr ~notyping env) es |> Result. all
131+ in
131132 let * mcs = Ok eval_es in
132133 Ok (List. concat mcs)
133134 | Exec e ->
@@ -146,13 +147,13 @@ and eval_sgen_expr ~notyping (env : env) :
146147 end
147148 | Focus e ->
148149 let * eval_e = eval_sgen_expr ~notyping env e in
149- ( eval_e |> remove_mark_all |> focus) |> Result. return
150+ eval_e |> remove_mark_all |> focus |> Result. return
150151 | Kill e ->
151152 let * eval_e = eval_sgen_expr ~notyping env e in
152- ( eval_e |> remove_mark_all |> kill |> focus) |> Result. return
153+ eval_e |> remove_mark_all |> kill |> focus |> Result. return
153154 | Clean e ->
154155 let * eval_e = eval_sgen_expr ~notyping env e in
155- ( eval_e |> remove_mark_all |> clean |> focus) |> Result. return
156+ eval_e |> remove_mark_all |> clean |> focus |> Result. return
156157 | Process [] -> Ok []
157158 | Process (h :: t ) ->
158159 let * eval_e = eval_sgen_expr ~notyping env h in
@@ -167,26 +168,23 @@ and eval_sgen_expr ~notyping (env : env) :
167168 acc |> remove_mark_all |> clean |> focus |> Result. return
168169 | _ ->
169170 let origin = acc |> remove_mark_all |> focus in
170- eval_sgen_expr ~notyping env
171- (Focus (Exec (Union [ x; Raw origin ])))
172- )
171+ eval_sgen_expr ~notyping env (Focus (Exec (Union [ x; Raw origin ]))) )
173172 in
174173 res |> Result. return
175174 | Subst (e , Extend pf ) ->
176175 let * eval_e = eval_sgen_expr ~notyping env e in
177- (List. map eval_e ~f: (map_mstar ~f: (fun r -> gfunc pf [ r ])))
178- |> Result. return
176+ List. map eval_e ~f: (map_mstar ~f: (fun r -> gfunc pf [ r ])) |> Result. return
179177 | Subst (e , Reduce pf ) ->
180178 let * eval_e = eval_sgen_expr ~notyping env e in
181- ( List. map eval_e
182- ~f:
183- (map_mstar ~f: (fun r ->
184- match r with
185- | StellarRays. Func (pf', ts)
186- when StellarSig. equal_idfunc (snd pf) (snd pf')
187- && List. length ts = 1 ->
188- List. hd_exn ts
189- | _ -> r ) ) )
179+ List. map eval_e
180+ ~f:
181+ (map_mstar ~f: (fun r ->
182+ match r with
183+ | StellarRays. Func (pf', ts)
184+ when StellarSig. equal_idfunc (snd pf) (snd pf')
185+ && List. length ts = 1 ->
186+ List. hd_exn ts
187+ | _ -> r ) )
190188 |> Result. return
191189 | Subst (e , SVar (x , r )) ->
192190 let * subst = subst_vars env (x, None ) r e in
@@ -202,8 +200,7 @@ and eval_sgen_expr ~notyping (env : env) :
202200 match eval_e with
203201 | [ Marked { content = [ r ]; bans = _ } ]
204202 | [ Unmarked { content = [ r ]; bans = _ } ] ->
205- r |> expr_of_ray |> Expr. sgen_expr_of_expr
206- |> eval_sgen_expr ~notyping env
203+ r |> expr_of_ray |> Expr. sgen_expr_of_expr |> eval_sgen_expr ~notyping env
207204 | _ -> failwith " error: only rays can be evaluated." )
208205
209206and expr_of_ray = function
@@ -234,8 +231,7 @@ let rec eval_decl ~typecheckonly ~notyping env :
234231 | Some e -> eval_decl ~typecheckonly ~notyping env (Show e)
235232 end
236233 | Show (Raw mcs ) ->
237- mcs |> remove_mark_all
238- |> string_of_constellation |> Stdlib. print_string;
234+ mcs |> remove_mark_all |> string_of_constellation |> Stdlib. print_string;
239235 Stdlib. print_newline () ;
240236 Stdlib. flush Stdlib. stdout;
241237 Ok env
@@ -257,8 +253,7 @@ let rec eval_decl ~typecheckonly ~notyping env :
257253 | Run e ->
258254 let _ = eval_sgen_expr ~notyping env (Exec e) in
259255 Ok env
260- | Expect (_x , _mcs ) -> Ok { objs = [] ; types = [] }
261- (* TODO *)
256+ | Expect (_x , _mcs ) -> Ok { objs = [] ; types = [] } (* TODO *)
262257 | Use path ->
263258 let path = List. map path ~f: string_of_ray in
264259 let formatted_filename = String. concat ~sep: " /" path ^ " .sg" in
0 commit comments