Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method functions in type-check mode #57

Open
ppolesiuk opened this issue Apr 10, 2024 · 0 comments
Open

Method functions in type-check mode #57

ppolesiuk opened this issue Apr 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@ppolesiuk
Copy link
Member

Method functions (method fn foo) cannot be used without any parameter.

> (+) ;;
<stdin>:1:1-3: fatal error: Variable (+) is registered as method add and cannot be used without argument

However, it would make sense to allow them provided that they are in type-check mode, when type type is an arrow with a neutral type on argument position. The motivating example is a sum of elements of a list:

let sum (xs : List Int) = xs.foldl (+) 0

or writing a code like in Eval.ml:

let extern_map =
  [ "dbl_addInt",      int_binop ( + );
    "dbl_subInt",      int_binop ( - );
    "dbl_mulInt",      int_binop ( * );
    "dbl_divInt",      int_binop ( / );
  ...
@ppolesiuk ppolesiuk added the enhancement New feature or request label Apr 10, 2024
@ppolesiuk ppolesiuk mentioned this issue Jan 13, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant