Skip to content
Daniel Gronau edited this page Dec 15, 2017 · 4 revisions

Welcome to highJ

ATTENTION: highJ is currently undergoing a restructuring process, so the information in the wiki might be outdated.

ATTENTION: This project is experimental, it is not yet ready for production. A lot of bad things might happen:

  • Recursion is sometimes hard to avoid, which might lead to StackOverflowErrors
  • The code isn't very efficient, there might be excessive object creation going on
  • Lazy behavior might lead to unexpected results, as beginners often face in Haskell
  • The test coverage is not as good as it should be

HighJ tries to hack around Java's lack of higher order type polymorphism (a.k.a. "higher kinded types" in Scala). It translates several well known type-classes from Haskell (including Applicative, Monad and Foldable). However, the amount of generic declarations and Java's lack of first class function make sometimes even simple tasks overly verbose, so expect angle brackets, many, many angle brackets.

As Java's collection classes are not very useful in a functional setting, highJ uses its own versions (similar to Haskell's and functionaljava's collections). The design of the type-class hierarchy follows roughly Edward Kmett's excellent semigroupoids package.

So how does highJ code looks like?

//Example: foldl over a List

//the Foldable type-class instance for Lists
Foldable<List.µ> foldable = List.foldable;

//a list
List<String> strList = List.of("one", "two", "three");

//the call to foldl
String result = foldable.foldl(a -> b -> a + " + " + b, "zero", strList);

System.out.println(result);
//result is "zero + one + two + three"

I'm very interested in your feedback, and would be more than glad to hear if actually something useful grows out of this project. Have fun!

Clone this wiki locally