FunctionalGroovy

FunctionalGroovy enhances FunctionalJava for Groovy

License

License

GroupId

GroupId

com.github.mperry
ArtifactId

ArtifactId

functionalgroovy-core
Last Version

Last Version

0.8
Release Date

Release Date

Type

Type

jar
Description

Description

FunctionalGroovy
FunctionalGroovy enhances FunctionalJava for Groovy
Project URL

Project URL

https://github.com/mperry/functionalgroovy
Source Code Management

Source Code Management

https://github.com/mperry/functionalgroovy.git

Download functionalgroovy-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.mperry/functionalgroovy-core/ -->
<dependency>
    <groupId>com.github.mperry</groupId>
    <artifactId>functionalgroovy-core</artifactId>
    <version>0.8</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.mperry/functionalgroovy-core/
implementation 'com.github.mperry:functionalgroovy-core:0.8'
// https://jarcasting.com/artifacts/com.github.mperry/functionalgroovy-core/
implementation ("com.github.mperry:functionalgroovy-core:0.8")
'com.github.mperry:functionalgroovy-core:jar:0.8'
<dependency org="com.github.mperry" name="functionalgroovy-core" rev="0.8">
  <artifact name="functionalgroovy-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.mperry', module='functionalgroovy-core', version='0.8')
)
libraryDependencies += "com.github.mperry" % "functionalgroovy-core" % "0.8"
[com.github.mperry/functionalgroovy-core "0.8"]

Dependencies

compile (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.functionaljava : functionaljava jar 4.4
org.codehaus.groovy : groovy-all jar 2.4.4
org.functionaljava : functionaljava-quickcheck jar 4.4

Project Modules

There are no modules declared in this project.

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:

@GrabResolver('https://oss.sonatype.org/content/groups/public')
@Grab('com.github.mperry:functionalgroovy-core:0.5.1-SNAPSHOT')
@Grab('org.functionaljava:functionaljava:4.1')

import com.github.mperry.fg.*

1.to(5).each {
    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

Versions

Version
0.8
0.7
0.6
0.5
0.3