Conversation
Shoyunchap/lib/ast.mli
Outdated
| (** Binding scope: whether a `let` lives at the top level (no body) or inside an | ||
| expression (has body). **) | ||
| type var_scope = | ||
| | LocalVar |
There was a problem hiding this comment.
Constructor 'LocalVar' has no documentation attribute
Shoyunchap/lib/interpret.ml
Outdated
| fun fuel -> | ||
| match List.assoc_opt x env with | ||
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in | ||
| let* v_rhs = eval env' rhs in | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| (* builtin fix *) | ||
| let builtin_fix : value = | ||
| BuiltinVal | ||
| (fun f -> |
There was a problem hiding this comment.
Using function is recommended
Shoyunchap/lib/interpret.mli
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/ast.ml
Outdated
|
|
||
| (** Copyright 2021-2025, Kakadu and contributors **) | ||
|
|
||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) |
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/ast.mli
Outdated
|
|
||
| (** Copyright 2021-2025, Kakadu and contributors **) | ||
|
|
||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) |
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/ast.mli
Outdated
| (** Binding scope: whether a `let` lives at the top level (no body) or inside an | ||
| expression (has body). **) | ||
| type var_scope = | ||
| | LocalVar |
There was a problem hiding this comment.
Constructor 'LocalVar' has no documentation attribute
Shoyunchap/lib/ast.mli
Outdated
| expression (has body). **) | ||
| type var_scope = | ||
| | LocalVar | ||
| | GlobalVar |
There was a problem hiding this comment.
Constructor 'GlobalVar' has no documentation attribute
Shoyunchap/lib/ast.mli
Outdated
| (** Primitive constants. Only ints carry payload; `Unit` is a placeholder for | ||
| statements and unused branches. **) | ||
| type const = | ||
| | Int of int |
There was a problem hiding this comment.
Constructor 'Int' has no documentation attribute
Shoyunchap/lib/interpret.ml
Outdated
| fun fuel -> | ||
| match List.assoc_opt x env with | ||
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in | ||
| let* v_rhs = eval env' rhs in | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| (* builtin fix *) | ||
| let builtin_fix : value = | ||
| BuiltinVal | ||
| (fun f -> |
There was a problem hiding this comment.
Using function is recommended
Shoyunchap/lib/interpret.mli
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/ast.ml
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/ast.mli
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/interpret.ml
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| fun fuel -> | ||
| match List.assoc_opt x env with | ||
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| let env' = (name, cell) :: env in | ||
| (* Start with a dummy cell so the body of rhs can refer to itself. *) | ||
| let* v_rhs = eval env' rhs in | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.mli
Outdated
|
|
||
| (** Mutable cells are kept so `let rec` and `fix` can allocate a placeholder | ||
| before evaluating the RHS and later update it. *) | ||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/ast.ml
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/ast.mli
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/interpret.ml
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| fun fuel -> | ||
| match List.assoc_opt x env with | ||
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| let env' = (name, cell) :: env in | ||
| (* Start with a dummy cell so the body of rhs can refer to itself. *) | ||
| let* v_rhs = eval env' rhs in | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.mli
Outdated
|
|
||
| (** Mutable cells are kept so `let rec` and `fix` can allocate a placeholder | ||
| before evaluating the RHS and later update it. *) | ||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/ast.ml
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/ast.mli
Outdated
| @@ -0,0 +1,72 @@ | |||
| (** Copyright 2021-2025, Kakadu and contributors **) | |||
|
|
|||
| (** SPDX-License-Identifier: LGPL-3.0-or-later **) | |||
There was a problem hiding this comment.
First item in file should be a documentation comment with copyright information. For example:
(** Copyright 2021-2022, Winnie Pooh et al. *)
Shoyunchap/lib/interpret.ml
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| fun fuel -> | ||
| match List.assoc_opt x env with | ||
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| let env' = (name, cell) :: env in | ||
| (* Start with a dummy cell so the body of rhs can refer to itself. *) | ||
| let* v_rhs = eval env' rhs in | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.mli
Outdated
|
|
||
| (** Mutable cells are kept so `let rec` and `fix` can allocate a placeholder | ||
| before evaluating the RHS and later update it. *) | ||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | ClosureVal of name * expression * env | ||
| | BuiltinVal of (value -> value eval) | ||
|
|
||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | None -> Error (Unbound_variable x) | ||
| | Some cell -> | ||
| (* Dereference the placeholder produced by let rec / fix. *) | ||
| Ok (!cell, fuel) |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| | Rec -> | ||
| (* recursive binding *) | ||
| let cell = ref UnitVal in | ||
| let env' = (name, cell) :: env in |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.ml
Outdated
| (* Dummy cell lets the RHS call itself (or be captured) during evaluation. *) | ||
| let* v_rhs = eval env' rhs in | ||
| (* Update the placeholder with the computed value, keeping sharing intact. *) | ||
| cell := v_rhs; |
There was a problem hiding this comment.
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 references 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.
Shoyunchap/lib/interpret.mli
Outdated
| (** Environment entries are mutable on purpose: `let rec`/`fix` need a placeholder | ||
| cell that is filled after evaluating the RHS, so a `(name * value ref)` list | ||
| models that operationally. *) | ||
| and env = (name * value ref) list |
There was a problem hiding this comment.
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 references 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.
|
Документация и тестовое покрытие (86.51%) должны скоро появиться. https://kakadu.github.io/fp25/docs/Shoyunchap https://kakadu.github.io/fp25/cov/Shoyunchap 2026-01-16 23:00 |
|
Linter report from 2026-01-16 23:01, for mini language Shoyunchap |
Implementation of basic miniML interpreter
Author: Rafael Shoyucnhap