Skip to content

Commit

Permalink
Remove Logic.inji from the API
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii.Kosarev a.k.a. Kakadu <Dmitrii.Kosarev@pm.me>
  • Loading branch information
Dmitrii.Kosarev a.k.a. Kakadu authored and Dmitrii.Kosarev a.k.a. Kakadu committed Jan 31, 2025
1 parent 684ae81 commit dd9d1fe
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 47 deletions.
4 changes: 2 additions & 2 deletions camlp5/pa_ocanren.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let rec fix_term e =
| _ ->
<:expr< $e1'$ $fix_term e2$ >>
in
<:expr< OCanren.inji $fixed$ >>
<:expr< OCanren.inj $fixed$ >>

| _ ->
(match e with
Expand All @@ -92,7 +92,7 @@ let rec fix_term e =
| _ ->
(* everything else *)
(match ctor e with
| Some e -> <:expr< OCanren.inji $e$ >>
| Some e -> <:expr< OCanren.inj $e$ >>
| _ -> e
)

Expand Down
2 changes: 1 addition & 1 deletion ppx/distrib/ppx_distrib_expander.ml
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ let process_main ~loc rec_ (base_tdecl, tdecl) =
else (
let name cd = mangle_construct_name cd.pcd_name.txt in
let make_stri prim_pat add_args rhs =
[%stri let [%p prim_pat] = [%e add_args [%expr OCanren.inji [%e rhs]]]]
[%stri let [%p prim_pat] = [%e add_args [%expr OCanren.inj [%e rhs]]]]
in
match base_tdecl.ptype_kind with
| Ptype_variant cds ->
Expand Down
4 changes: 2 additions & 2 deletions regression/test010.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ open OCanren
open OCanren.Std
open Tester

let (!) = inji
let (!!) = inji
let (!) = inj
let (!!) = inj
let g123 x = conde [x === !1; x === !2; x === !3]
let g12 x = (g123 x) &&& (x =/= !3)
let gxy x y = (g123 x) &&& (g123 y)
Expand Down
4 changes: 2 additions & 2 deletions regression_ppx/test001.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ open OCanren
open Tester

module _ = struct
[%%distrib
[%%ocanren_inject
type nonrec 'a t =
| Z
| S of 'a
Expand All @@ -20,7 +20,7 @@ module _ = struct
end

module _ = struct
[%%distrib
[%%ocanren_inject
type nonrec 'a t =
| None
| Some of 'a
Expand Down
20 changes: 10 additions & 10 deletions regression_ppx/test001.t
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt self)) ) )

let z () = OCanren.inji Z
let z () = OCanren.inj Z

let s _x__001_ = OCanren.inji (S _x__001_)
let s _x__001_ = OCanren.inj (S _x__001_)
end

let run_peano_exn n = run_r prj_exn (GT.show ground) n
Expand Down Expand Up @@ -74,9 +74,9 @@
<..> chain
(OCanren.Reifier.zed (OCanren.Reifier.rework ~fv:(fmapt ra))) )

let none () = OCanren.inji None
let none () = OCanren.inj None

let some _x__005_ = OCanren.inji (Some _x__005_)
let some _x__005_ = OCanren.inj (Some _x__005_)
end

let run_option n =
Expand Down Expand Up @@ -128,9 +128,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt ra self)) ) )
let nil () = OCanren.inji []
let nil () = OCanren.inj []
let cons _x__009_ _x__010_ = OCanren.inji (_x__009_ :: _x__010_)
let cons _x__009_ _x__010_ = OCanren.inj (_x__009_ :: _x__010_)
end
let __ : ('a -> string) -> ('a logic as 'b) -> string = GT.show logic
Expand Down Expand Up @@ -189,13 +189,13 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt OCanren.reify)) ) )
let forward _x__016_ = OCanren.inji (Forward _x__016_)
let forward _x__016_ = OCanren.inj (Forward _x__016_)
let backward _x__017_ = OCanren.inji (Backward _x__017_)
let backward _x__017_ = OCanren.inj (Backward _x__017_)
let unload _x__018_ = OCanren.inji (Unload _x__018_)
let unload _x__018_ = OCanren.inj (Unload _x__018_)
let fill _x__019_ = OCanren.inji (Fill _x__019_)
let fill _x__019_ = OCanren.inj (Fill _x__019_)
end
end
Expand Down
4 changes: 2 additions & 2 deletions regression_ppx/test004.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ module _ = struct
Env.Monad.return foo))
;;

let z () = OCanren.inji Z
let succ _x__001_ = OCanren.inji (S _x__001_)
let z () = OCanren.inj Z
let succ _x__001_ = OCanren.inj (S _x__001_)
end

let run_peano n = run_r reify (GT.show logic) n
Expand Down
16 changes: 8 additions & 8 deletions regression_ppx/test006.t
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt OCanren.reify (Std.List.reify self))) ) )

let symb _x__001_ = OCanren.inji (Symb _x__001_)
let symb _x__001_ = OCanren.inj (Symb _x__001_)

let seq _x__002_ = OCanren.inji (Seq _x__002_)
let seq _x__002_ = OCanren.inj (Seq _x__002_)
end
end

Expand Down Expand Up @@ -501,9 +501,9 @@
(fmapt OCanren.reify Gterm.reify
(Std.List.reify (Std.Pair.reify OCanren.reify self)) ) ) ) )
let closure _x__008_ _x__009_ _x__010_ = OCanren.inji (Closure (_x__008_, _x__009_, _x__010_))
let closure _x__008_ _x__009_ _x__010_ = OCanren.inj (Closure (_x__008_, _x__009_, _x__010_))
let val_ _x__011_ = OCanren.inji (Val _x__011_)
let val_ _x__011_ = OCanren.inj (Val _x__011_)
end
end
Expand Down Expand Up @@ -633,7 +633,7 @@
OCanren.Reifier.fix (fun _ ->
OCanren.reify <..> chain (OCanren.Reifier.zed (OCanren.Reifier.rework ~fv:fmapt)) )

let t x y = OCanren.inji (T {x; y})
let t x y = OCanren.inj (T {x; y})
end
end

Expand Down Expand Up @@ -761,7 +761,7 @@
OCanren.Reifier.fix (fun _ ->
OCanren.reify <..> chain (OCanren.Reifier.zed (OCanren.Reifier.rework ~fv:fmapt)) )

let make_t x y = OCanren.inji {x; y}
let make_t x y = OCanren.inj {x; y}
end
end

Expand Down Expand Up @@ -960,9 +960,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt OCanren.reify (Std.List.reify self))) ) )

let symb _x__021_ = OCanren.inji (Symb _x__021_)
let symb _x__021_ = OCanren.inj (Symb _x__021_)

let seq _x__022_ = OCanren.inji (Seq _x__022_)
let seq _x__022_ = OCanren.inj (Seq _x__022_)
end
end

Expand Down
8 changes: 4 additions & 4 deletions regression_ppx/test007.t
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt OCanren.reify (Std.List.reify self))) ) )
let symb _x__001_ = OCanren.inji (Symb _x__001_)
let symb _x__001_ = OCanren.inj (Symb _x__001_)
let seq _x__002_ = OCanren.inji (Seq _x__002_)
let seq _x__002_ = OCanren.inj (Seq _x__002_)
end
let rec inhabit_list el xs =
Expand Down Expand Up @@ -674,9 +674,9 @@
(Std.List.reify (OCanren.Std.Pair.reify OCanren.reify Scheme.reify))
Scheme.reify ) ) ) )

let val_ _x__008_ = OCanren.inji (Val _x__008_)
let val_ _x__008_ = OCanren.inj (Val _x__008_)

let closure _x__009_ _x__010_ = OCanren.inji (Closure (_x__009_, _x__010_))
let closure _x__009_ _x__010_ = OCanren.inj (Closure (_x__009_, _x__010_))
end

let (_ : injected) = val_ (Scheme.symb !!"a")
Expand Down
4 changes: 2 additions & 2 deletions regression_ppx/test008.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
OCanren.reify
<..> chain (OCanren.Reifier.zed (OCanren.Reifier.rework ~fv:(fmapt ra self))) )
let cons _x__001_ _x__002_ = OCanren.inji (Cons (_x__001_, _x__002_))
let cons _x__001_ _x__002_ = OCanren.inj (Cons (_x__001_, _x__002_))
end
end
Expand Down Expand Up @@ -58,7 +58,7 @@
OCanren.reify
<..> chain (OCanren.Reifier.zed (OCanren.Reifier.rework ~fv:(fmapt ra OCanren.reify))) )
let make_t name v = OCanren.inji {name; v}
let make_t name v = OCanren.inj {name; v}
end
let () =
Expand Down
4 changes: 2 additions & 2 deletions regression_ppx/test009.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt OCanren.reify OCanren.reify)) ) )

let lInt _x__001_ = OCanren.inji (LInt _x__001_)
let lInt _x__001_ = OCanren.inj (LInt _x__001_)

let lBool _x__002_ = OCanren.inji (LBool _x__002_)
let lBool _x__002_ = OCanren.inj (LBool _x__002_)
end
end

Expand Down
6 changes: 3 additions & 3 deletions regression_ppx/test011.t
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
(OCanren.Reifier.zed
(OCanren.Reifier.rework
~fv:(fmapt rtarg self OCanren.reify)))))
let array _x__001_ = OCanren.inji (Array _x__001_)
let var _x__002_ = OCanren.inji (Var _x__002_)
let array _x__001_ = OCanren.inj (Array _x__001_)
let var _x__002_ = OCanren.inj (Var _x__002_)
end
end
include
Expand Down Expand Up @@ -91,5 +91,5 @@
(chain
(OCanren.Reifier.zed
(OCanren.Reifier.rework ~fv:(fmapt (JType.reify self))))))
let typ _x__010_ = OCanren.inji (Typ _x__010_)
let typ _x__010_ = OCanren.inj (Typ _x__010_)
end
3 changes: 1 addition & 2 deletions src/core/Logic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ let from_logic = function

type 'a ilogic

external inji : 'a -> 'a ilogic = "%identity"
let inj = inji
external inj : 'a -> 'a ilogic = "%identity"

let (!!) = inj

Expand Down
5 changes: 1 addition & 4 deletions src/core/Logic.mli
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ end
(** [inj x] injects [x] into logical [x]. *)
val inj : 'a -> 'a ilogic

(** A synonim to [inj].
@deprecated Use {!(!!)} instead. *)
val inji : 'a -> 'a ilogic
(* TODO: If we expose that [inj] is identity, will it work faster? *)

(** A synonym for {!inj} (for non-parametric types). *)
val (!!) : 'a -> 'a ilogic
Expand Down
6 changes: 3 additions & 3 deletions src/std/Option.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ let prj_exn : 'a 'b. ('a, 'b) Reifier.t -> ('a groundi, 'b ground) Reifier.t =
let reify_option = reify
let prj_exn_option = prj_exn

let some x = Logic.inji (Some x)
let none () = Logic.inji None
let some x = Logic.inj (Some x)
let none () = Logic.inj None

let option = function None -> none () | Some x -> Logic.inji (Some (x))
let option = function None -> none () | Some x -> some x

0 comments on commit dd9d1fe

Please sign in to comment.