Partiality *

Controversial? Perhaps; Opinionated? Certainly.

LiveScript: Haskell flavoured Javascript

Derived from [Coco]( and very like [CoffeeScript]( Even comes with it's own prelude.
[LiveScript]( and its related []( aren't exactly [Roy]( or [PureScript]( but do bring in much needed Haskell flavour to JavaScript. No strong static types here; just some syntax, like currying, pattern matching etc., to mitigate some of the pain and boilerplate in the Javascript land.
## Past {#past}
There was a time when `Ecmascript` on the server side was a big part of how I earnt my living, much before the present `node.js` server side popularity. I still remember all those type hints done as embedded comments. These comments helped maintain sanity when LOC breached a certain boundary.

A simple but contrived version is the following greet function.

function /*String*/ greet( /*String*/ name) {
    return "Hello, " + name + "!"
They are still needed but the boilerplate is minimal.

# greet :: String -> String
greet = (name) -> "Hello #name!"

Compare it to some equivalent code in `Scala`; though in practice it isn't equivalent because it captures the types and therefore the compiler will disallow a class of possible misuses.

def greet : String => String = name => s"Hello $name"
def greet2 = (name:String) => s"Hello $name"

Ah, yes! there are also the typed brothers-in-arms like [Dart]( and [TypeScript]( etc. but they aren't as good as Haskell, OCAML or Scala when it comes to type-systems and the boilerplate isn't reduced either. Flame anyone?

## Missing parts {#missing-parts}

How to set up Livescript and prelude on the client side isn't described anywhere. I had to pull in bits and pieces and do some trial and error to make things work in the end. The following part of an HTML document is where the magic happens.

<script type="text/ls" src=""></script>
<script src=""></script>
<script src="//"></script>

It is a conscious decision to push everything to the client, i.e. there is no compile-to-js on the server side etc. The Livescript custom-script is sent, as is, to the client/browser and is interpreted after the Livescript is loaded.

The '' is next.

console ?.log 'LiveScript up'
{map, fold1} = require 'prelude-ls'
console.log(fold1 (+), [1 to 3])
# if jquery is available
#$ \h1 .find \img .prop \src, "bla"

console ?.log \end

This blog also uses Livescript. In order to try and beat the 1000ms for-mobile barrier we don't interpret Livescript in the browser. Instead we use grunt to compile, combine and minify the resulting Javascript.

## Frequent pain points or Gotchas {#gotchas}

Here are a few of the bits that annoyed every now and then.

1. `#` is for comments and for string interpolation.Combine that with css id selectors and you end up in trouble.

2. Function declaration and function application of parameter-less functions. Define `reset` and then call it `reset`. No! it has to be `reset()`.

3. If-statements without parentheses results in some unexpected behaviour.

On the whole, `Livescript` has been a better experience than `Coffeescript`.

## Further Reading {#readings}

### Presentation {#presentation}

* [Functional programming in JavaScript ecosystem](

### Blog {#blog}

* [Functional Programming in JavaScript using LiveScript and](
* [Functional Programming in JavaScript using LiveScript - Part 2](
* [10 Reasons to Switch from CoffeeScript to LiveScript](