Skip to content

Conversation

@wojciechdomin
Copy link
Contributor

@wojciechdomin wojciechdomin commented Dec 14, 2025

This PR will add :t directive to REPL.
It will become possible to print type scheme of expression without evaluating it.
For example:

> :t flip;;
(a ->> b ->> c) -> b -> a ->> c
> :t id;;
a -> a
> :t (handler effect x / r => r () end);;
handler E of (a ->> Unit) with [_] b ->> b

@wojciechdomin wojciechdomin marked this pull request as ready for review December 22, 2025 00:17
Copy link
Collaborator

@Foxinio Foxinio left a comment

Choose a reason for hiding this comment

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

The changes look promising, and I believe they will get to what we want from this PR, but it's not it just yet.

As I understood it, the goal was to implement capability to look up schemes as they are in they are kept in the environment. So for example when I enter:

> :t List.hdErr ;;

I should get the information about what arguments the function expects, what it returns, but also what are it's named parameters. Instead I get following output:

fatal error: Cannot resolve an implicit parameter ~onError
   | :t List.hdErr ;;
   |         ^^^^^
   | 

The idea is to not only return reconstructed type of an expression, but to expect an identifier, lookup it's scheme in the environment and print that.

Another problem with this approach is that all the work is done in the type inference section. While it is simple, it misses out on all the information inferred about effects. Since fram's main appeal are effects, this is unsatisfactory.

let () = open_cbrackets := !open_cbrackets - 1 in
YaccParser.CBR_CLS
}
| ":t" { YaccParser.DIR_TYPE }
Copy link
Collaborator

Choose a reason for hiding this comment

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

While this is correct, I'm not sure if there isn't a more general approach that will be useful in future extensions of this mechanism.
We should discuss that on the meeting

| Raw.REPL_Dir directive ->
begin match directive with
| Directive_Type e ->
let def = make_nowhere (Lang.Surface.DReplDir(Type_Directive (Desugar.tr_expr e))) in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please keep number of characters on a line under 80

@wojciechdomin wojciechdomin marked this pull request as draft December 22, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants