Skip to content

Commit a41ccd2

Browse files
committed
Fixed rules violations, more than just my own, and tests
1 parent fc261ba commit a41ccd2

File tree

7 files changed

+36
-17
lines changed

7 files changed

+36
-17
lines changed

core/lib.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ let string_op impl pure : located_primitive * Types.datatype * pure =
6262

6363
let numeric_op impli implf purei puref : located_primitive * Types.datatype * pure =
6464
(`PFun (fun _ args -> match args with
65-
| [x; y] ->
65+
| [x; y] ->
6666
(match (x,y) with
6767
| (`Int _, `Int _) -> Lwt.return (`Int (impli (Value.unbox_int x) (Value.unbox_int y)))
6868
| (`Float _, `Float _) -> Lwt.return (`Float (implf (Value.unbox_float x) (Value.unbox_float y)))
69-
| _ -> raise (runtime_type_error "type error in numeric operation"))
69+
| _ -> raise (runtime_type_error "type error in numeric operation"))
7070
| _ -> raise (internal_error "arity error in numeric operation"))),
7171
datatype "(a::Numeric, a) -> a",
7272
F2 (fun l r -> match (l, r) with
@@ -260,13 +260,13 @@ let env : (string * (located_primitive * Types.datatype * pure)) list = [
260260

261261
"^^", string_op ( ^ ) PURE;
262262

263-
(* moved abs to make use of ad hoc ability,
264-
ideally there could be a way to bootstrap prelude similar to #786 *)
263+
(* moved abs to make use of ad hoc ability,
264+
ideally there could be a way to bootstrap Prelude similar to #786 *)
265265
"abs",
266266
(p1 (fun n -> match n with
267267
| `Int _ -> Value.box_int ( let x = (Value.unbox_int n) in if x > 0 then x else -x )
268268
| `Float _ -> Value.box_float ( let x = (Value.unbox_float n) in if x > 0.0 then x else -.x )
269-
| _ -> raise (runtime_type_error ("Cannot computer absolute value: " ^ Value.string_of_value n))),
269+
| _ -> raise (runtime_type_error ("Cannot computer absolute value: " ^ Value.string_of_value n))),
270270
datatype "(a::Numeric) -> a",
271271
PURE);
272272

@@ -763,7 +763,7 @@ let env : (string * (located_primitive * Types.datatype * pure)) list = [
763763
(p1 (fun n -> match n with
764764
| `Int _ -> Value.box_int (- (Value.unbox_int n))
765765
| `Float _ -> Value.box_float (-. (Value.unbox_float n))
766-
| _ -> raise (runtime_type_error ("Cannot negate: " ^ Value.string_of_value n))),
766+
| _ -> raise (runtime_type_error ("Cannot negate: " ^ Value.string_of_value n))),
767767
datatype "(a::Numeric) -> a",
768768
PURE);
769769

core/transformSugar.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let type_binary_op env tycon_env =
6868
| Name "!" -> TyEnv.find "Send" env
6969
| Name "+"
7070
| Name "*"
71-
| Name "/"
71+
| Name "/"
7272
| Name "^" -> datatype "(a::Numeric, a) -> a"
7373
| Name n -> TyEnv.find n env
7474

core/typeSugar.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2021,9 +2021,9 @@ let type_binary_op pos ctxt =
20212021
Function (Types.make_tuple_type [a; a], eff, Primitive Primitive.Bool),
20222022
Usage.empty)
20232023
| Name "!" -> add_empty_usages (Utils.instantiate ctxt.var_env "Send")
2024-
| Name "+"
2025-
| Name "*"
2026-
| Name "/"
2024+
| Name "+"
2025+
| Name "*"
2026+
| Name "/"
20272027
| Name "^" -> add_empty_usages (datatype "(a::Numeric, a) -> a")
20282028
| Name n ->
20292029
try

lens/lens_format.mli

+6-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ val pp_comma : unit fmt_fn
1616

1717
(** Format a list as comma separated values.
1818
19-
Example: {[
19+
Example:
20+
{[
2021
Format.asprintf "%a" (Format.pp_comma_list Format.pp_print_int) [5, 6, 7]
2122
]}
2223
@@ -26,7 +27,8 @@ val pp_comma_list : 'a fmt_fn -> 'a list fmt_fn
2627

2728
(** Format a list of string as comma separated values.
2829
29-
Example: {[
30+
Example:
31+
{[
3032
Format.asprintf "%a" Format.pp_comma_string_list ["hello", "world"]
3133
]}
3234
@@ -39,7 +41,8 @@ val pp_newline_list : 'a fmt_fn -> 'a list fmt_fn
3941

4042
(** Pad a string so it has [length] characters.
4143
42-
Example: {[
44+
Example:
45+
{[
4346
Format.asprintf "%a - %s"
4447
(Format.pp_padded ~length:8 Format.pp_print_string) "hello" "world"
4548
]}

lens/phrase.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ module Grouped_variables : sig
199199
200200
Example:
201201
202-
When called on the set `{ A; A B; C D; }` with the cols `A B`, the
202+
When called on the set `{! A; A B; C D; }` with the cols `A B`, the
203203
result is false because `A B` only occurs in groups without further
204204
variables. If it is called with cols `C`, then it returns true, because
205205
the group `C D` contains the column `D` in addition to the column `C`. *)

tests/numeric-operations.tests

+16
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,19 @@ stdout : inf : Float
8282
Float division by zero [2]
8383
(-1.0) / 0.0
8484
stdout : -inf : Float
85+
86+
Large floating-point numbers
87+
1.0e308 + 1.0e308
88+
stdout : inf : Float
89+
90+
Small floating-point numbers
91+
1.0e-308 + 1.0e-308
92+
stdout : 2e-308 : Float
93+
94+
Additive identity
95+
5 + 0
96+
stdout : 5 : Int
97+
98+
Multiplicative identity
99+
5.0 * 1.0
100+
stdout : 5.0 : Float

tests/unit/ir/schinks.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ val fun_t :
7575
?effects:Types.row t -> Types.typ t list -> Types.typ t -> Types.typ t
7676

7777
(** Syntactic sugar for fun_t.
78-
a .-->{e} b becomes Function(a,e,b).
78+
a .-->{!e} b becomes Function(a,e,b).
7979
This operator is left-associative, use parantheses when nesting! *)
8080
val ( .-->{} ) : Types.typ t list -> Types.row t -> Types.typ t -> Types.typ t
8181

82-
(** Equivalent to {}-> in Links' syntactic sugar for function types
82+
(** Equivalent to \{\}-> in Links' syntactic sugar for function types
8383
Shorthand for closed function types (using tuple for parameters) *)
8484
val fun_ct : Types.typ t list -> Types.typ t -> Types.typ t
8585

8686
(** alias for fun_ct *)
8787
val ( |--> ) : Types.typ t list -> Types.typ t -> Types.typ t
8888

89-
(** Equivalent to {}~> in Links' syntactic sugar for function types *)
89+
(** Equivalent to \{\}~> in Links' syntactic sugar for function types *)
9090
val wild_fun_ct : Types.typ t list -> Types.typ t -> Types.typ t
9191

9292
(** alias for wild_fun_ct *)

0 commit comments

Comments
 (0)