try catch - PureScript

Welcome to the Functional Programming Zulip Chat Archive. You can join the chat here.

Mason Mackaman

why does

try {
    // stuff
} catch {
    // stuff
}

throw a parsing error when in foreign modules?
you need to use catch (...)

miles

Is that ES6 syntax? I believe it only supports ES5 syntax. https://github.com/purescript/purescript/issues/3272

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: ...
Mason Mackaman

oh, didn't know arrow functions were ES5

miles

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.

Mason Mackaman

wait no, arrow functions are ES6 :thinking: but the compiler doesn't complain

miles

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.