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

[TS] Code generation error #16

Open
sharpvik opened this issue Mar 3, 2024 · 1 comment
Open

[TS] Code generation error #16

sharpvik opened this issue Mar 3, 2024 · 1 comment

Comments

@sharpvik
Copy link

sharpvik commented Mar 3, 2024

The following derw code defines a lambda of type string -> string.

main: string -> string
main = \name -> `Hello ${name}`

Running derw compile on this results in the following output:

function main(_0: string): string {
    return function(name: any) {
        return `Hello ${name}`;
    };
}

which declares that main is a string -> string but in reality, main: string -> any -> string as is evident from the code.

However, using the regular function notation like so

main: string -> string
main name = `Hello ${name}`

fixes the problem:

function main(name: string): string {
    return `Hello ${name}`;
}
@eeue56
Copy link
Owner

eeue56 commented Mar 8, 2024

Thanks for trying Derw out! Lambdas are currently aren't type-checked, though I think fixing it for this specific case makes sense. It's possible to see if the value is a lambda, and if args are missing, they get passed on. Though I would say the general style of Derw is to be explicit with arguments rather than going down the point-free road, so there's also a case for just having it be a compile error to be missing an argument. I'll have a think about it!

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

No branches or pull requests

2 participants