[ ] Exposed public functions but not used anywhere.
[ ] match ... with _ as x -> ....
[ ] Algebraic data types
[ ] With single constructor
[x] #26
and jump_stmt = None | Break | Continue | Return of v_value
[ ] Naming: capitalized snake case looks weird
[ ] Warn about type names with quotes.
[ ] Booleans
[x] An action that panics on if true then ...
[x] if ... then true else false
[ ] Strings
[x] Expression ... ^ ... ^ ... may not be efficient
[ ] Matching
[ ] | Foo x when x = true -> ... ~~~> | Foo true -> ....
[x] #13
match scru with
| (a,b) -> rhs
into
let (a,b) = scru in rhs
[ ] Match on bool when scrutinee starts with not
match not (if_object (get_var_ctx_from_ctx i env).value) with
| true -> ....
| false -> ....
[x] Rewrite fun e -> match e with ... to function ... if possible
[ ] Propose function here too
(fun l ->
match l with
| [ ty ] -> ty
| _ -> t_tuple l)
[ ] #27
[ ] | Return rexpr_o -> ( match rexpr_o with ... )
[ ] Recommend or-patterns when possible
[ ] Detect same RHSes
match MapString.find_opt id env9 with
| None -> return (MapString.add id v env9)
| Some _ -> return (MapString.add id v env9) in
See also #42
[ ] Recommend nested matching
| EConst x ->
(match x with
| CInt _ -> return (Subst.empty, TInt)
| CBool _ -> return (Subst.empty, TBool)
| CString _ -> return (Subst.empty, TString))
match stmts with
| s :: st -> (
match s with
| RETURN ret_e -> (
match ret_e with
| LITERAL CVOID -> is_correct_void st (r && true)
| _ -> is_correct_void st (r && false))
| _ -> is_correct_void st r)
| _ -> r
match n with
| "malloc" -> (
match vals with
| ...)
| "free" -> (
match vals with
| ...)
| "sizeof" -> (
match vals with
| ...)
| "main" -> ...
[ ] Exceptions
[x] failwith
[ ] Using of List.hd_exn may be error-prone
[ ] Matching with _ exception
[x] Catching Failure _ exception
[ ] Suggest function name with _exn suffix when function can throw an exception.
match ... with _ as x -> ....
and jump_stmt = None | Break | Continue | Return of v_value
if true then ...
if ... then true else false
... ^ ... ^ ...
may not be efficient[ ] Matching
[ ]
| Foo x when x = true -> ...
~~~>| Foo true -> ....
[x] #13
into
[ ] Match on bool when scrutinee starts with
not
[x] Rewrite
fun e -> match e with ...
tofunction ...
if possiblefunction
here too[ ] #27
[ ]
| Return rexpr_o -> ( match rexpr_o with ... )
[ ] Recommend or-patterns when possible
[ ] Detect same RHSes
See also #42
[ ] Recommend nested matching
failwith
List.hd_exn
may be error-prone_
exceptionFailure _
exception_exn
suffix when function can throw an exception.[ ] Records
{ key = fkey; foo = _; bar = _ }
to{ key = fkey; _ }
[ ] Rewrite '{ field=field; ... }' but maybe it is not possible and ocamlformat should do it
[ ] Discourage clashing fields, which require explicit type annotation
[ ] Monads
[ ] #48
It looks like patterns like
(fun arg1...argN -> IDENT arg1 ... argN)
suites and only them... :: [ ... ]
smell badlet ctx = ctx in ...
return @@ Vchar v
we should probably recommend parenthesis>>= fun ident -> return ident
andfun (ctx', pls) -> return (ctx', pls)
... :: [ ... ]
smells bad(t' :: ts') @ acc
smells bad. Proposet' :: (ts' @ ac)
[@@deriving sexp]
introduce code with assignments.concat_map
filter_map
List.to_seq [ eff ]
=>Seq.return eff
Rewritefun cd -> let f ... = (* no use of cd *) in ...
tolet f ... = ... in fun cd -> ...
print_string ...
should belet () = ...
@@
вreturn @@ Nil
return @@ (x+y)
return @@ (get_var_ctx_from_ctx i e_env).value
{| ... |}
when a normal string literal has too many '\n'(cram (deps ....)
(fun (ptrn, _) -> ptrn)
->fst