Skip to content

Toplevel expression is expected to have unit type #6

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

Open
jcsherin opened this issue Feb 5, 2021 · 2 comments
Open

Toplevel expression is expected to have unit type #6

jcsherin opened this issue Feb 5, 2021 · 2 comments

Comments

@jcsherin
Copy link
Contributor

jcsherin commented Feb 5, 2021

You encounter this error (in chapter 2) before the unit type is introduced. Introduce the underscore binding to which you can assign values, you do not care about. This will solve the compiler error.

Also better explain why this is a compilation error in the first place. Explain the term toplevel expression.

@stevez
Copy link

stevez commented Mar 20, 2022

I found a quick solution is assigning the result to a variable, then the error will be disappeared, like this
let x = Js.Array.map(tupleToString, languagesAndAuthors)

@seho-dev
Copy link

let addCoordinates = (~x, ~y) => x + y
let a = addCoordinates(~x=1, ~y=2)

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

3 participants