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

List vs Array advice for beginners #432

Open
arnau opened this issue Aug 26, 2018 · 0 comments
Open

List vs Array advice for beginners #432

arnau opened this issue Aug 26, 2018 · 0 comments
Labels

Comments

@arnau
Copy link

arnau commented Aug 26, 2018

Hello,

I've been reading the documentation specially the interop section as I'm just starting to play with Reason and I have to interact with Javascript a lot.

I ended up running node to test my explorations and I got trapped into a non-obvious situation. This is the problem I faced:

I had a function in Reason such as:

let length = (xs: list(string)): int => List.length(xs)

And I used like that in node:

> require('./lib/js/src/Test.bs.js').length([])
1

I didn't expect this at all, so I tried:

> require('./lib/js/src/Test.bs.js').length(["foo"])
1

At this point I was totally lost. I spent some (too much) time re-reading the docs and I couldn't figure out the problem. After that, I asked on Discord and the answer was "don't use functions that expect lists from javascript, use arrays". Fair enough.

I guess that this issue is to suggest to add advice on that or more generally how to guard yourself from javascript-land when you are writing code in Reason and toying with it in node.

@davesnx davesnx added the fix label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants