Skip to content

Expose Js_(null|undefined|null_undefined).from_opt in mli #1062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions jscomp/others/js_null_undefined.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,7 +17,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
Expand All @@ -28,8 +28,9 @@ external return : 'a -> 'a t = "%identity"
external test : 'a t -> bool = "js_is_nil_undef"
external empty : 'a t = "undefined" [@@bs.val]

(** we did not add [bind] yet, since the return value is
(** we did not add [bind] yet, since the return value is
ambiguous and [to_opt] depends on {!Js_primitive}
*)
val bind : 'a t -> ('a -> 'b [@bs]) -> 'b t
val iter : 'a t -> ('a -> unit [@bs]) -> unit
val from_opt : 'a option -> 'a t
1 change: 1 addition & 0 deletions jscomp/runtime/js_null.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ external empty : 'a t = "null" [@@bs.val]

val bind : 'a t -> ('a -> 'b [@bs]) -> 'b t
val iter : 'a t -> ('a -> unit [@bs]) -> unit
val from_opt : 'a option -> 'a t
9 changes: 5 additions & 4 deletions jscomp/runtime/js_undefined.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
Expand All @@ -17,17 +17,18 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type + 'a t = 'a Js.undefined
type + 'a t = 'a Js.undefined
external to_opt : 'a t -> 'a option = "js_from_def"
external return : 'a -> 'a t = "%identity"
external test : 'a t -> bool = "js_is_undef"
external empty : 'a t = "undefined"
external empty : 'a t = "undefined"
[@@bs.val]

val bind : 'a t -> ('a -> 'b [@bs]) -> 'b t
val iter : 'a t -> ('a -> unit [@bs]) -> unit
val from_opt : 'a option -> 'a t
14 changes: 12 additions & 2 deletions lib/js/js_null.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ function iter(x, f) {
}
}

exports.bind = bind;
exports.iter = iter;
function from_opt(x) {
if (x) {
return x[0];
}
else {
return null;
}
}

exports.bind = bind;
exports.iter = iter;
exports.from_opt = from_opt;
/* No side effect */
14 changes: 12 additions & 2 deletions lib/js/js_null_undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ function iter(x, f) {
}
}

exports.bind = bind;
exports.iter = iter;
function from_opt(x) {
if (x) {
return x[0];
}
else {
return undefined;
}
}

exports.bind = bind;
exports.iter = iter;
exports.from_opt = from_opt;
/* No side effect */
14 changes: 12 additions & 2 deletions lib/js/js_undefined.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ function iter(x, f) {
}
}

exports.bind = bind;
exports.iter = iter;
function from_opt(x) {
if (x) {
return x[0];
}
else {
return undefined;
}
}

exports.bind = bind;
exports.iter = iter;
exports.from_opt = from_opt;
/* No side effect */