FunctionalJ - a library for Functional Programming in Java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

FunctionalJ - a library for Functional Programming in Java

Graham Klyne-2
A colleague alerted me to this, which I thought might be of interest here:

  http://www.theserverside.com/news/thread.tss?thread_id=38430

(I have already found that my Haskell experiences have influenced my Python
programming;  maybe there's also hope for my Java?)

#g

--
Graham Klyne
For email:
http://www.ninebynine.org/#Contact

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: FunctionalJ - a library for Functional Programming in Java

Bjorn Bringert-2
Graham Klyne wrote:
> A colleague alerted me to this, which I thought might be of interest here:
>
>   http://www.theserverside.com/news/thread.tss?thread_id=38430
>
> (I have already found that my Haskell experiences have influenced my Python
> programming;  maybe there's also hope for my Java?)

I've haven't seen this before, thanks!

I wrote a similar library, Higher-Order Java (HOJ), a few years ago:

http://www.cs.chalmers.se/~bringert/hoj/

My library is less polished but seems to have more static typing. It
uses parametrized classes (as introduced in Java 1.5) to achieve this.

FunctionalJ seems to lack static typing, for example map has the type:

List map(Function p_function, List p_list)

In HOJ, it has this type:

<A,B> Iterator<B> map(Fun<A,B> f, Iterator<? extends A> xs)


In the end, I never published anything about this, since it seems too
cumbersome to use in practice. A simple lambda expressions requires a
lot of typing overhead. This function from the Pizza paper [1]:

fun boolean(char c) {
       n++; return '0' <= c && c < '0' + r;
     }

becomes this in HOJ:

new Fun<Character,Boolean> () {
          public Boolean apply (Character c) {
             n++;
             return '0' <= c && c < '0' + r;
          }
       }

/Björn

[1] Pizza into Java: Translating Theory into Practice, M. Odersky and P.
Wadler, 1997
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe