godzsa godzsa - 1 month ago 14
Javascript Question

Is there a fully functional paradigm language that transpiles to JavaScript?

Is there a language which transpiles to JavaScript (like TypeScript, CoffeScript etc.) and is almost purely functional (like Haskell, Erlang, F#)?

I know there are libraries which helps maintain immutability (Underscore), and there are a lot of cool array functions and lambdas in ES6. But what I'm looking for is a functional like syntax and transpiler for it, so I can write functional JavaScript with not much effort.

Answer

Check out Scala.js, Elm or PureScript.

Other languages include ClojureScript (Clojure) and Funscript (F#)

Of those, I've only really used Scala.js and Elm, both of which work extremely well in my opinion.

Currying

In Elm and PureScript functions are curried by default. In Scala Currying can be done very easily by using multiple parameter lists:

def curried(param1: Int)(param2: Int): Int = ...