
Functional Programming in JavaScript using LiveScript and prelude.ls - 0x1997
http://gkz.github.com/LiveScript/blog/functional-programming-in-javascript-using-livescript-and-prelude-ls.html
======
jhickner
I really like the coffeescript + haskell feel. I always miss haskell's '$' for
function application and '.' for composition. LiveScript has both (<| and .).

Check out the "10 LiveScript one-liners to impress your friends" post. Great
stuff: [http://gkz.github.com/LiveScript/blog/livescript-one-
liners-...](http://gkz.github.com/LiveScript/blog/livescript-one-liners-to-
impress-your-friends.html)

------
petitmiam
LiveScript is an interesting choice of name. JavaScript was officially called
LiveScript back in Netscape Navigator 2.0 beta.

~~~
GeZe
Yes, it's an inside joke for those who know JavaScript well.

------
coenhyde
This is fantastic! I love that it has currying and composing. I'm going to
switch from CoffeeScript to LiveScript.

------
riffraff
why use

    
    
        map (-> it.length > x), list
        map (call \toUpperCase), 'haha'
    
    

for functions with only one free variable?

IMHO it would be prettier to have something like scala's _

    
    
        map (_.length > x), list
        map (_.toUpperCase), 'haha'
    

i.e. automatically build a closure when _ is used eithout the need for
additional anonymous function syntax

~~~
quarterto
They discussed this, and decided: a) partially-applied operators fills some of
the gap, and b) they're far too complicated to implement.

<https://github.com/gkz/LiveScript/issues/19>
[https://github.com/taku0/placeholder_syntax_for_coffeescript...](https://github.com/taku0/placeholder_syntax_for_coffeescript/blob/master/src/placeholder.coffee)

~~~
riffraff
ah, thanks, I missed partially applied operators. But then, it seems easy to
do it with single method calls too, e.g.

    
    
        map (.length) x
    

rather than

    
    
        map (call \length) x
    

does not fit more complex usage, but it's a tiny improvement I'd think

~~~
GeZe
This is an interesting idea - I will look into it. It does not seem to
conflict with the current syntax. Thanks for the suggestion!

------
ne0codex
Interesting, but I strongly dislike the use of whitespace indentation for new
statements/segments of code,

it

    
    
       will
    
             get  
                 tedious  
    
                       when
                             you
                                  are
                                      nesting
                                               multiple
                                                        blocks
                                                               of 
        code.
    

And I like it when Xcode highlights the brackets/parenthesis because it's just
easier to pick up ( and ) and { and } from a line of text.

~~~
wffurr

      If {
          Your {
              Code {
                  Is {
                      That {
                          Nested {
                          }
                      }
                  }
              }
          }
      }
    

Then you at not using the functional programming constructs available to you
and have poorly decomposed code. Deep nesting is a major code smell.

------
chii
have you heard of <http://roy.brianmckenna.org/> ? Its basically haskell in
javascript.

~~~
GeZe
Yes, I am aware - it is an interesting project. However, it's a couple of
steps farther away from JavaScript than I would want to work with.

~~~
pufuwozu
Author of Roy here. Would love to hear more about how/where you think it's too
far away from JavaScript. I'm trying to avoid that feeling :)

brian@brianmckenna.org

(also, I'm writing an untyped typeclassopedia for use in my compiler - I'll be
releasing it soon - definitely feel that'd be a complement to prelude.ls)

~~~
pdelgallego
Hi Brian,

I was looking forward to see your presentation in SpainJS next month, but I
might not be able to make it.

Is there any of your roy talks online or any gentle introduction to roy
besides roy.brianmckenna.org?

~~~
pufuwozu
You can checkout my JSConf talk at:
<http://brianmckenna.org/files/presentations/jsconf-roy/> \- hopefully the
video will be posted soon

I wrote an article about it for IEEE's Internet Computing magazine:
<http://brianmckenna.org/blog/roy_ieee>

I've also started writing an introduction but it has been shelved while I work
on making the typesystem sound.

Hopefully I'll see you at SpainJS if you make it :)

------
egeozcan
I'm a JavaScript fan and I'm impressed. Still feel like a bit overwhelmed with
so many new ideas though. By the way, does LiveScript (the name really makes
me smile and even giggle) support source maps? see
[http://www.html5rocks.com/en/tutorials/developertools/source...](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)
for more info

------
adrusi
while it's a great language, and I was a fan of coco for a while, my
experience with coco was that it was like a ghost town and I was one of the
only users.

~~~
GeZe
Coco is amazing. To avoid becoming a "ghost town", I have made LiveScript much
more compatible with CoffeeScript, easing transitions. I have invested time
into making a decent website, and have now composed a couple of blog posts
promoting LiveScript. Already several people have written projects in
LiveScript: [https://github.com/gkz/LiveScript/wiki/Projects-using-
LiveSc...](https://github.com/gkz/LiveScript/wiki/Projects-using-LiveScript) I
hope with my continued efforts that the scenario you describe can be avoided.

~~~
egeozcan
I think what you did is great but a very important missing thing is syntax
highlighting for ls files on GitHub. Maybe you can make a pull to their
Linguist? <https://github.com/github/linguist>

