I'm trying to have a JavaScript event listener be called with an unknown number of arguments and then call a curried function using those arguments one by one. This is the foreign module code: ...
Yeah. It's a bummer that for public libs, ES6 syntax is still discouraged in order to support the 6% of people who haven't updated their browsers. https://dev.caniuse.com/arrow-functions
The arrow syntax is so much nicer for FFI and maps much better to PS code. Maybe we'll be able to make the jump with the ES Modules conversion.
Oh, right. There are some bits of ES6 that are allowed. Kinda unclear what the limits are though. For example, I believe there's some weirdness with using arrows to return () that should otherwise be allowed.
The compiler will accept some ES6 (essentially, whatever is supported by the version of the Haskell package language-javascript that the compiler depends on), but out of convention PS libs don't use ES6 in order to ensure that they can be used without a bundling step. That doesn't prevent you from using things like arrow functions in your code, though!
I don't know why language-javascript fails to parse try { ... } catch { ... } and instead requires try { ... } catch (e) { ... } -- probably just convenience -- but that's the reason the compiler requires it.
why does
throw a parsing error when in foreign modules?
you need to use
catch (...)
Is that ES6 syntax? I believe it only supports ES5 syntax. https://github.com/purescript/purescript/issues/3272
oh, didn't know arrow functions were ES5
Yeah. It's a bummer that for public libs, ES6 syntax is still discouraged in order to support the 6% of people who haven't updated their browsers. https://dev.caniuse.com/arrow-functions
The arrow syntax is so much nicer for FFI and maps much better to PS code. Maybe we'll be able to make the jump with the ES Modules conversion.
wait no, arrow functions are ES6 :thinking: but the compiler doesn't complain
Oh, right. There are some bits of ES6 that are allowed. Kinda unclear what the limits are though. For example, I believe there's some weirdness with using arrows to return
()
that should otherwise be allowed.The compiler will accept some ES6 (essentially, whatever is supported by the version of the Haskell package
language-javascript
that the compiler depends on), but out of convention PS libs don't use ES6 in order to ensure that they can be used without a bundling step. That doesn't prevent you from using things like arrow functions in your code, though!I don't know why
language-javascript
fails to parsetry { ... } catch { ... }
and instead requirestry { ... } catch (e) { ... }
-- probably just convenience -- but that's the reason the compiler requires it.