[Haskell-cafe] FunctionalJ - a library for Functional Programming in Java

Bjorn Bringert bringert at cs.chalmers.se
Wed Jan 11 08:03:57 EST 2006

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:


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) {
             return '0' <= c && c < '0' + r;


[1] Pizza into Java: Translating Theory into Practice, M. Odersky and P. 
Wadler, 1997

More information about the Haskell-Cafe mailing list