Functional Programming in Java 8

Functional Programming made easy!

Since Java 8 it is possible to use a more functional approach of programming in Java. Java isn’t a functional language, but sometimes a closure is just much better than an anonymous class. Some concepts of functional programming are still missing and if you are used to a functional style you often can’t express what you want because some things are just too cumbersome in Java.

I made a collection of helper classes and specialized functional types to help you write functional code in Java. This is more for educational purposes than for actual projects. There are not enough unit tests and Javadoc is mostly missing. But most methods are self explanatory if you know FP.

The project is hosted on github: https://github.com/claudemartin/Functions

Some of the Features:

  • curry / uncurry / to [bi|tri|quad] fn
  • n-tuples (n ∈ [2,3,4])
  • partial application
  • zip / upzip
  • exception and null handling
    • sneaky exceptions
    • to null / default value
    • to “Maybe” (holds result or exception)
    • to Optional
    • or else …
  • cached functions
  • synchronized functions
  • sequences

Note: This doesn’t support recursive closures. You can combine it with “Recursive”, my other project for functional programming in Java.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s