Skip to content

Arzhaev - #32

Open
InfernalKn1ght wants to merge 12 commits into
Kakadu:masterfrom
InfernalKn1ght:dev-sign
Open

Arzhaev#32
InfernalKn1ght wants to merge 12 commits into
Kakadu:masterfrom
InfernalKn1ght:dev-sign

Conversation

@InfernalKn1ght

Copy link
Copy Markdown

Type inference
boolean operators

Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>
Signed-off-by: InfernalKn1ght <arzhaev.dmitry@yandex.ru>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

Comment thread Arzhaev/lib/tests.ml
@@ -0,0 +1,227 @@
[@@@ocaml.text "/*"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File 'Arzhaev/lib/tests.ml' doesn't have corresponding .mli interface

Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/lib/interpreter.ml
Comment thread Arzhaev/lib/interpreter.ml
{ vars = StrSet.to_list (get_set env ty); ty }
;;

let rec infer env exp =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

| _ -> fail ITypeError
;;

let infer_toplevel env tl =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

Comment thread Arzhaev/lib/utils.ml
type 'a t = 'a StringMap.t

let empty = StringMap.empty
let lookup x env = StringMap.find_opt x env

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eta reduction proposed. It's recommended to rewrite 'fun x ->
fun env ->
StringMap.find_opt x
env' as 'StringMap.find_opt'

Comment thread Arzhaev/lib/utils.ml
Comment thread Arzhaev/lib/utils.ml

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/lib/interpreter.ml
| _ -> fail (RNotAFunction vfun)
;;

let eval_toplevel env tl =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

Comment thread Arzhaev/lib/parser.ml
{ vars = StrSet.to_list (get_set env ty); ty }
;;

let rec infer env exp =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

| _ -> fail ITypeError
;;

let infer_toplevel env tl =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

Comment thread Arzhaev/lib/utils.ml
Comment thread Arzhaev/lib/utils.ml
Comment thread Arzhaev/lib/utils.ml
@github-actions

Copy link
Copy Markdown

Документация и тестовое покрытие (90.67%) должны скоро появиться.

https://kakadu.github.io/fp25/docs/Arzhaev

https://kakadu.github.io/fp25/cov/Arzhaev

2026-04-25 11:05

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zanuda-linter report

Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/bin/REPL.ml
Comment thread Arzhaev/lib/interpreter.ml
| _ -> fail (RNotAFunction vfun)
;;

let eval_toplevel env tl =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

Comment thread Arzhaev/lib/parser.ml
{ vars = StrSet.to_list (get_set env ty); ty }
;;

let rec infer env exp =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

| _ -> fail ITypeError
;;

let infer_toplevel env tl =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

Comment thread Arzhaev/lib/utils.ml
Comment thread Arzhaev/lib/utils.ml
Comment thread Arzhaev/lib/utils.ml
helper (String.length s - 1) []
;;

let get_next_letter c =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using function is recommended

@github-actions

Copy link
Copy Markdown

Linter report from 2026-04-25 11:06, for mini language Arzhaev

File "bin/REPL.ml", lines 21-22, characters 4-3:
21 | ....mutable dump_parsetree : bool
22 |   ;............................
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "bin/REPL.ml", line 22, characters 4-31:
22 |   ; mutable initial_steps : int
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Using mutable data structures for teaching purposes is usually discouraged. Replace Hashtables by standard tree-like maps or consider Hash-Array Mapped Tries (HAMT). Use mutable `ref`erences and mutable structure fields only if it is really required. In all places where it is needed indeed, describe in a comment why it is needed there.
File "lib/interpreter.ml", line 88, characters 10-19:
88 | let run f st = f st
               ^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun st -> f st' as 'f'
File "lib/interpreter.ml", lines 184-203, characters 22-24:
184 | ......................tl =
185 |   match tl with
186 |   | TopExpr e ->
187 |     let* v = eval env e in
188 |     return (env, VExpr v)
...
200 |     in
201 |     let env'' = Table.extend x v' env in
202 |     return (env'', VLet (x, v'))
203 |   | _ -> fail REvalError
Alert zanuda-linter: Using `function` is recommended
File "lib/parser.ml", line 198, characters 13-37:
198 |   and factor input = func_apply input
                   ^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun input -> func_apply input' as 'func_apply'
File "lib/tests.ml", line 15, characters 17-25:
15 |   | PFailed _ -> failwith "parse error"
                      ^^^^^^^^
Alert zanuda-linter: Using `failwith` (or `assert false`) usually is a clue that a corner case is not being handled properly. To report errors we recommend using error monad instead. In princliple, these construction are OK for temporary work-in-progress code, but in release they should be eliminated
File "lib/typeInference.ml", line 99, characters 10-19:
99 | let run f st = f st
               ^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun st -> f st' as 'f'
File "lib/typeInference.ml", lines 113-117, characters 23-57:
113 | .......................tree =
114 |   match tree with
115 |   | TVar x -> tv = x
116 |   | TGround _ -> false
117 |   | TArrow (l, r) -> check_occur tv l || check_occur tv r
Alert zanuda-linter: Using `function` is recommended
File "lib/typeInference.ml", lines 211-218, characters 22-67:
211 | ......................ty =
212 |     match ty with
213 |     | TVar x as tv ->
214 |       (match Table.contains_value { vars = []; ty = tv } env with
215 |        | false -> StrSet.add x StrSet.empty
216 |        | true -> StrSet.empty)
217 |     | TGround _ -> StrSet.empty
218 |     | TArrow (l, r) -> StrSet.union (get_set env l) (get_set env r)
Alert zanuda-linter: Using `function` is recommended
File "lib/typeInference.ml", lines 214-216, characters 6-30:
214 | ......(match Table.contains_value { vars = []; ty = tv } env with
215 |        | false -> StrSet.add x StrSet.empty
216 |        | true -> StrSet.empty)
Alert zanuda-linter: Match is redundant. It's recommended to rewrite it as 
                     'if Table.contains_value { ty = tv; vars = [] } env
                      then StrSet.empty
                      else StrSet.add x StrSet.empty'
File "lib/typeInference.ml", lines 223-288, characters 18-24:
223 | ..................exp =
224 |   match exp with
225 |   | EConst e ->
226 |     (match e with
227 |      | IConst _ -> return (TGround GInt)
...
285 |     let sch = generalize env' tv in
286 |     let* e2' = infer (Table.extend x sch env') e2 in
287 |     sub_walk e2'
288 |   | _ -> fail ITypeError
Alert zanuda-linter: Using `function` is recommended
File "lib/typeInference.ml", lines 291-312, characters 23-24:
291 | .......................tl =
292 |   match tl with
293 |   | TopExpr e ->
294 |     let* ty = infer env e in
295 |     let* ty' = sub_walk ty in
...
309 |     let sch = generalize env ty' in
310 |     let env'' = Table.extend x sch env in
311 |     return (env'', RLet (x, sch))
312 |   | _ -> fail ITypeError
Alert zanuda-linter: Using `function` is recommended
File "lib/utils.ml", line 25, characters 13-45:
25 |   let lookup x env = StringMap.find_opt x env
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun x -> fun env -> StringMap.find_opt x env' as 
                     'StringMap.find_opt'
File "lib/utils.ml", line 26, characters 13-46:
26 |   let extend x ty env = StringMap.add x ty env
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Alert zanuda-linter: Eta reduction proposed. It's recommended to rewrite 
                     'fun x -> fun ty -> fun env -> StringMap.add x ty env' as 
                     'StringMap.add'
File "lib/utils.ml", lines 65-68, characters 20-12:
65 | ....................c =
66 |   match c with
67 |   | 'a' .. 'y' -> Char.chr (Char.code c + 1)
68 |   | _ -> 'a'
Alert zanuda-linter: Using `function` is recommended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant