3 ms·
As long as JS lacks partial application and the ability to define infix operators (for monadic `bind`, etc), it's always going to be ugly. Not that JS would be
by tempodox 8y ago
As long as JS lacks partial application and the ability to define infix operators (for monadic `bind`, etc), it's always going to be ugly. Not that JS would be a good language for that to begin with. We need a serious functional language that compiles to WASM.
- lucideer 8y ago> We need a serious functional language that compiles to WASM. Aren't there already a few? OCaml? What's "serious" in this context?
- TheAsprngHacker 8y agoReally? If OCaml has a compiler to Wasm, I’m not aware of it. I’m only aware that it compiles to JS (via js_of_ocaml or Bucklescript). Could I please have a link to the Wasm compiler if you have it? I read somewhere that an OCaml to LLVM compiler was attempted, but people had problems with the GC aspect. I don’t know if this claim is true, though.
- lucideer 8y ago> I once read that an OCaml to LLVM compiler was attempted, but people had problems with the GC aspect. I can’t confirm this claim though. I was thinking of the same, but I hadn't/haven't used it so you may be right it never came to fruition.
- sanderre 8y agoWhenever I manage to find time to hack on it: https://github.com/SanderSpies/ocaml/tree/wasm-backend https://github.com/SanderSpies/ocaml/tree/wasm-backend. It compiles to wasm object files and links files with LLVM's LLD. My current challenge is ensuring that the stdlib correctly translates to wasm. The C parts are not translated yet - which means: no gc, no exceptions, no tail calls.
- Tade0 8y ago"Lacks partial application"? What about: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... Meanwhile infix operators are just syntax sugar and can be emulated in other ways.
- beaconstudios 8y ago`Function.bind` is a fairly poor match to partial application because A) it will not execute the function if you provide enough arguments and B) it also binds `this`, meaning you have to pass NULL or some other value every time you use it. https://ramdajs.com/docs/#curry https://ramdajs.com/docs/#curry would be a better option, as JS' metaprogramming features actually do somewhat support partial application.
- Boulth 8y agoPureScript compiles to JS but it's quite readable JS: http://www.purescript.org/ http://www.purescript.org/
- k__ 8y agoHow come that PureScript feels so mathematical to me and Reason/OCaml don't? Aren't they both FP languages?
- chenglou 8y agoJust hard work. Making it look natural and pragmatic is a non-trivial discipline and dare I say, rather thankless work. (I’m assuming you meant to convey a slightly negative connotation through “mathematical”. Though I myself do like PS too)
- foxes 8y agoPeople are working on making Haskell compile to web assembly. [0] https://www.tweag.io/posts/2018-05-29-hello-asterius.html https://www.tweag.io/posts/2018-05-29-hello-asterius.html [1] https://github.com/tweag/asterius https://github.com/tweag/asterius