Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Functional Groovy

Functional Groovy is a library for doing functional programming (FP) in Groovy. It is a Groovy extension module for Functional Java (FJ), adding Groovy idioms and new FP constructs in Groovy.

Features includes:

  • FunctionalJava based
  • Enhances FunctionalJava for Groovy as a Groovy extension module
  • Groovy Quickcheck style property testing (specification based testing)
  • Monad library using a minimal monad implementation (unit/flatMap)
  • Monadic functions added to the standard Java List
  • Monad comprehensions (dynamically typed)
  • Lenses
  • Reader, Writer and State monads
  • A simple IO type
  • Y Combinator

The project has some cloud build servers I used to experiment with including:

I have written an initial blog post on Groovy Null Handling using Bind, Comprehensions and Lift covering:

  • some introductory material on functional programming in Groovy
  • how to begin using the Functional Groovy library
  • handling nulls by binding through the Option type, monadic comprehensions and monadic lifting

The full list of related posts are:

To start using the library add the dependency com.github.mperry:functionalgroovy-main:0.5.1-SNAPSHOT to your Gradle project. A simple test script to get going (test.groovy) is:


import com.github.mperry.fg.* {
    println it

Run this script using groovy test.groovy.

This project uses:

  • JDK 8
  • Gradle 1.11
  • Groovy 2.3.2
  • Functional Java 4.1
  • Intellij Community Edition 13.1

I have added a list of open issues so feel free to contribute. Some ways of contributing are:

  • adding new functionality
  • adding tests
  • adding FP in Groovy examples
  • adding FunctionalGroovy usage examples

Functional Groovy is divided into four components: core, main, demo, java8 and consume.

  • Core enhances Functional Java with Groovy idioms
  • Main adds new functionality
  • Demo includes examples of FP in Groovy and usage of this library
  • Java8 includes enhancements related to Java 8 types (e.g. Optional).
  • Consume shows how to include FunctionalGroovy in your project


Functional programming in Groovy






No releases published


No packages published