Git Product home page Git Product logo

functionaljava's Introduction

Functional Java

Build Status

logo 600x144

Functional Java is an open source library facilitating functional programming in Java. The library implements numerous basic and advanced programming abstractions that assist composition oriented development. Functional Java also serves as a platform for learning functional programming concepts by introducing these concepts using a familiar language.

The library is intended for use in production applications and is thoroughly tested using the technique of automated specification-based testing with ScalaCheck. Functional Java is compiled with Java 8 targeting Java 7 bytecode. The use of lambdas within the project are backported with the Retro Lambda library, supporting Java versions 5 to 8.

Functional Java provides abstractions for the following types:

  • Basic Data Structures - total and partial functions, products, unit, option, unbiased and right biased unions (either and validation).

  • Immutable Collections - array, list, vector, stream, set, map, finger tree, heterogenous list.

  • Other Abstractions - monoid, semigroup, natural, random number generator, reader, writer, state, input/output, parser, zipper, specification based testing, actors, concurrency and type conversion.

URLs

Important URLs for the project are:

Downloading

The recommended way to download and use the project is through your build tool.

The Functional Java artifact is published to Maven Central using the group org.functionaljava with two published artifacts:

  • the core library (functionaljava)

  • Java 8 specific support (functionaljava-java8)

The latest version is 4.3. This can be added to your Gradle project by adding the dependencies:

compile "org.functionaljava:functionaljava:4.3"
compile "org.functionaljava:functionaljava-java8:4.3"

and in Maven:

<dependency>
    <groupId>org.functionaljava</groupId>
    <artifactId>functionaljava</artifactId>
    <version>4.3</version>
</dependency>
<dependency>
    <groupId>org.functionaljava</groupId>
    <artifactId>functionaljava-java8</artifactId>
    <version>4.3</version>
</dependency>

Building

FunctionalJava uses the Retro Lambda project to backport Java 8 lambdas to Java 7 bytecode. This requires access to both JDK 7 and 8. The build system requires the environment variables JAVA7_HOME and JAVA8_HOME to refer to the appropriate directories.

Building is done using Gradle 2.2.1. In the root directory run:

./gradlew

This will download the Gradle build tool and necessary dependencies and build FunctionalJava.

Features

A more complete description of the features mentioned above are:

  • Basic Data Structures

    • Functions with arity 1 to 8 (fj.F).

    • Functions with arity 0 to 8 that can produce exceptions (fj.Try).

    • Functions with arity 0 to 8 that have a void return (fj.Effect).

    • Functions with arity 0 to 8 that have a void return and can throw an exception (fj.TryEffect).

    • Products with arity 1 to 8 (fj.P).

    • Unit type (fj.Unit).

    • Optional value - type-safe null (fj.data.Option).

    • Disjoint union data type - compositional exception handling (fj.data.Either).

    • Validation - right biased compositional exception handling (fj.data.Validation).

  • Immutable Collections

    • Array wrapper (fj.data.Array).

    • Immutable, in-memory singly linked list (fj.data.List).

    • Immutable lazy singly linked list (fj.data.Stream).

    • A package (fj.data.fingertrees) providing 2-3 finger trees for a functional representation of persistent sequences, supporting access to the ends in amortized O(1) time.

    • Type-safe heterogeneous list (fj.data.hlist) for lists of elements of differing types without sacrificing type-safety.

    • Immutable set implementation using a red/black tree (fj.data.Set).

    • Immutable multi-way tree - aka rose tree (fj.data.Tree).

    • Immutable tree-map using a red/black tree implementation (fj.data.TreeMap).

  • Other Abstractions

    • Monoid (fj.Monoid).

    • Semigroup (fj.Semigroup).

    • Natural number data type (fj.data.Natural).

    • Random number generator using a linear congruential generator (fj.LcgRng).

    • Reader, Writer and State monads (fj.data.Reader,fj.data.Writer, fj.data.State).

    • Input/Output monad for abstracting IO (fj.IO).

    • Monadic parser combinators for writing parsers by combining smaller parsers using composition.

    • Conversion of data types to/from standard Java types.

    • Conversion between FunctionalJava and Java 8 specific types.

    • Configurable equality and hash-code for HashMap and HashSet.

    • Zipper implementations for streams and trees.

    • Automated specification-based testing framework (fj.test).

    • Fully operational Actors for parallel computations (fj.control.parallel) and layered abstractions such as parallel-map, map-reduce, parallel-zip.

License

The Functional Java license uses the BSD 3 license (3-clause license) available at https://en.wikipedia.org/wiki/BSD_licenses.

functionaljava's People

Contributors

mperry avatar tonymorris avatar amarpotghan avatar retronym avatar runarorama avatar dobesv avatar magro avatar xuwei-k avatar martinseeler avatar gneuvill avatar rickyclarkson avatar pawelkrupinski avatar daneko avatar pbzdyl avatar ms-tg avatar knutwalker avatar samreid avatar blendmaster avatar gpampara avatar arichiardi avatar gliptak avatar gregrow avatar jbgi avatar pelotom avatar etorreborre avatar rxxg avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.