1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
let _ = List.map ~f:(( + ) (M.f x))
let id x = x
let plus a ?(b = 0) c = a + b + c ;;
id (plus 1) ~b:1 ;;
(* The version above does not type-check, while the version below does
type-check, and should not be formatted to the above. See
https://caml.inria.fr/mantis/view.php?id=7832 for explanation on the
type-checking (and dynamic semantics) distinction. *)
(id (plus 1)) ~b:1
let ( !!! ) a ~b = a + b
let _ = ( !!! ) a b
let _ = ( !!! ) ~b
let _ = !!!!a b d
let _ = ( + ) a b c d
let cartesian_product l1 l2 =
List.concat (l1 |> List.map (fun v1 -> l2 |> List.map (fun v2 -> (v1, v2))))
let cartesian_product' long_list_one long_list_two =
List.concat
( long_list_one
|> List.map (fun v1 -> long_list_two |> List.map (fun v2 -> (v1, v2))) )
let whatever a_function_name long_list_one some_other_thing =
List.map
(fun long_list_one_elt ->
do_something_with_a_function_and_some_things a_function_name
long_list_one_elt some_other_thing )
long_list_one
let whatever_labelled a_function_name long_list_one some_other_thing =
ListLabels.map long_list_one ~f:(fun long_list_one_elt ->
do_something_with_a_function_and_some_things a_function_name
long_list_one_elt some_other_thing )
let eradicate_meta_class_is_nullsafe =
register ~id:"ERADICATE_META_CLASS_IS_NULLSAFE"
~hum:"Class is marked @Nullsafe and has 0 issues"
(* Should be enabled for special integrations *) ~enabled:false Info Eradicate (* TODO *)
~user_documentation:""
let eradicate_meta_class_is_nullsafe =
register ~id:"ERADICATE_META_CLASS_IS_NULLSAFE"
~hum:(* Should be enabled for special integrations *)
"Class is marked @Nullsafe and has 0 issues"
(* Should be enabled for special integrations *)
~enabled:false Info
[@@@ocamlformat "indicate-multiline-delimiters=closing-on-separate-line"]
let cartesian_product' long_list_one long_list_two =
List.concat
(long_list_one
|> List.map (fun v1 -> long_list_two |> List.map (fun v2 -> (v1, v2)))
)
let whatever a_function_name long_list_one some_other_thing =
List.map
(fun long_list_one_elt ->
do_something_with_a_function_and_some_things a_function_name
long_list_one_elt some_other_thing
)
long_list_one
let whatever_labelled a_function_name long_list_one some_other_thing =
ListLabels.map long_list_one ~f:(fun long_list_one_elt ->
do_something_with_a_function_and_some_things a_function_name
long_list_one_elt some_other_thing
)
;;
(a - b) () ;;
((a - b) [@foo]) ()
let _ = M.(loooooooooooooooooooooong + loooooooooooooooooong)
let _ =
M.(
loooooooooooooooooooooong + loooooooooooooooooong
+ llllllllllloooooooooooooooooonnnnnnnnnnnnnggggggggggg
)
let _ =
i'm_a_function loooooooooooong
(loooooooooooong looooooooooooooong loooooooooooooong
[loooooooooong; loooooooooooong; loooooooooooooooooooooong]
)
let f (x :: y) = x
let f (* xx *) ((* aa *) x (* bb *) :: (* cc *) y (* dd *)) (* yy *) = x
|