Skip to content

Commit

Permalink
Deprecate Exp.function_ in favour of Exp.function_cases going forward
Browse files Browse the repository at this point in the history
  • Loading branch information
patricoferris committed Aug 19, 2024
1 parent 94b912e commit 6871aac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ast/ast_helper_lite.ml
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,16 @@ module Exp = struct
let constant ?loc ?attrs a = mk ?loc ?attrs (Pexp_constant a)
let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_let (a, b, c))

let function_ ?loc ?attrs ?loc_location cases =
let function_cases ?loc ?attrs ?loc_location cases =
let loc_locations =
match loc_location with Some l -> l | None -> !default_loc
in
mk ?loc ?attrs
(Pexp_function ([], None, Pfunction_cases (cases, loc_locations, [])))

(* TODO: In ppxlib 0.36.0 this should be changed to be a constructor of Pexp_function *)
let function_ = function_cases

let fun_ ?loc ?attrs a b c d =
let pparam_desc = Pparam_val (a, b, c) in
let body = Pfunction_body d in
Expand Down
14 changes: 14 additions & 0 deletions ast/ast_helper_lite.mli
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,23 @@ module Exp : sig
pattern ->
expression ->
expression
(** [fun lbl guard pat expr] constructs a function with arity 1. *)

val function_ :
?loc:loc -> ?attrs:attrs -> ?loc_location:loc -> case list -> expression
[@@ocaml.deprecated "Use function_cases instead"]
(** [function_ cases] creates a new expression that represents
[function c1 -> e1 | c2 -> e2 ...].
@deprecated Use {! function_cases} for this behaviour. In OCaml 5.2 the AST
changed to represent [fun x ->] and [function ...] using the same AST node.
[function_] will change in the ppxlib 0.36.0 to construct this AST node.
*)

val function_cases :
?loc:loc -> ?attrs:attrs -> ?loc_location:loc -> case list -> expression
(** [function_ cases] creates a new expression that represents
[function c1 -> e1 | c2 -> e2 ...]. *)

val apply :
?loc:loc ->
Expand Down

0 comments on commit 6871aac

Please sign in to comment.