Haskell functions for Javascript by Ariel Flesler

These are Haskell's functions ported to javascript.

Some are missing and some don't behave exactly the same.

You can try them with a console (firebug or others).


All functions can be curried!!

All list(array) functions do work on regular strings:

filter( isVowel, 'hey how are you' ) == 'eoaeou';
take( 5, 'abcdefghi' ) == 'abcde';
maximum( 'ajcdbe' ) == 'j';

The function length is called length'

Most functions work on objects/maps, the same way as on arrays.


To use operator functions:

hs['+']( 1, 2 ) == 3;
map( hs['**'](2), [1,2,3,4] ) == [2,4,8,16];

hs is a function itself, is specially useful to call operators:

hs('+', 1, 2) == 3;
map( hs('**', 2), [1,2,3,4] ) == [2,4,8,16];

hs._ works the same as hs but flips the 2 arguments"

map( hs._('**', 2), [1,2,3,4] ) == [1,4,9,16];
filter( hs._('>', 2), [1,2,3,4] ) == [3,4];