Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.

fj
Class F2W<A,B,C>

java.lang.Object
  extended by fj.F2W<A,B,C>
All Implemented Interfaces:
F<A,F<B,C>>, F2<A,B,C>

public final class F2W<A,B,C>
extends Object
implements F2<A,B,C>, F<A,F<B,C>>

A wrapper for functions of arity 2, that decorates them with higher-order functions.


Method Summary
static
<A,B,C> F2W<A,B,C>
$$(F<A,F<B,C>> f)
          Wraps a given function, decorating it with higher-order functions.
static
<A,B,C> F2W<A,B,C>
$$(F2<A,B,C> f)
          Wraps a given function, decorating it with higher-order functions.
 F2W<Array<A>,Array<B>,Array<C>> array()
          Promotes this function to a function on Arrays.
 FW<A,F<B,C>> curryW()
          Curries this wrapped function to a wrapped function of arity-1 that returns another wrapped function.
 FW<B,C> f(A a)
          Partial application.
 C f(A a, B b)
          Function application.
 F2W<B,A,C> flip()
          Flips the arguments of this function.
 F2W<Iterable<A>,Iterable<B>,IterableW<C>> iterable()
          Promotes this function to a function on Iterables.
 F2W<List<A>,List<B>,List<C>> list()
          Promotes this function to a function on Lists.
 F2W<NonEmptyList<A>,NonEmptyList<B>,NonEmptyList<C>> nel()
          Promotes this function to a function on non-empty lists.
 F2W<Option<A>,Option<B>,Option<C>> option()
          Promotes this function to a function on Options.
 F2W<Promise<A>,Promise<B>,Promise<C>> promise()
          Promotes this function to a function on Promises.
 F2W<Set<A>,Set<B>,Set<C>> set(Ord<C> o)
          Promotes this function to a function on Sets.
 F2W<Stream<A>,Stream<B>,Stream<C>> stream()
          Promotes this function to a function on Streams.
 F2W<Tree<A>,Tree<B>,Tree<C>> tree()
          Promotes this function to a function on Trees.
 FW<P2<A,B>,C> tuple()
          Uncurries this function to a function on tuples.
 F2<A,B,C> unwrap()
          Returns the undecorated function.
 F2W<Array<A>,Array<B>,Array<C>> zipArray()
          Promotes this function to zip two arrays, applying the function lock-step over both Arrays.
 F2W<Iterable<A>,Iterable<B>,Iterable<C>> zipIterable()
          Promotes this function to zip two iterables, applying the function lock-step over both iterables.
 F2W<List<A>,List<B>,List<C>> zipList()
          Promotes this function to zip two lists, applying the function lock-step over both lists.
 F2W<NonEmptyList<A>,NonEmptyList<B>,NonEmptyList<C>> zipNel()
          Promotes this function to zip two non-empty lists, applying the function lock-step over both lists.
 F2W<Set<A>,Set<B>,Set<C>> zipSet(Ord<C> o)
          Promotes this function to zip two sets, applying the function lock-step over both sets.
 F2W<Stream<A>,Stream<B>,Stream<C>> zipStream()
          Promotes this function to zip two streams, applying the function lock-step over both streams.
 F2W<Tree<A>,Tree<B>,Tree<C>> zipTree()
          Promotes this function to zip two trees, applying the function lock-step over both trees.
 F2W<TreeZipper<A>,TreeZipper<B>,TreeZipper<C>> zipTreeZipper()
          Promotes this function to zip two TreeZippers, applying the function lock-step over both zippers in all directions.
 F2W<Zipper<A>,Zipper<B>,Zipper<C>> zipZipper()
          Promotes this function to zip two zippers, applying the function lock-step over both zippers in both directions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

unwrap

public F2<A,B,C> unwrap()
Returns the undecorated function.

Returns:
The undecorated function that this wrapper wraps.

f

public C f(A a,
           B b)
Function application.

Specified by:
f in interface F2<A,B,C>
Parameters:
a - The A to transform.
b - The B to transform.
Returns:
The result of the transformation.

f

public FW<B,C> f(A a)
Partial application.

Specified by:
f in interface F<A,F<B,C>>
Parameters:
a - The A to which to apply this function.
Returns:
The function partially applied to the given argument.

curryW

public FW<A,F<B,C>> curryW()
Curries this wrapped function to a wrapped function of arity-1 that returns another wrapped function.

Returns:
a wrapped function of arity-1 that returns another wrapped function.

$$

public static <A,B,C> F2W<A,B,C> $$(F2<A,B,C> f)
Wraps a given function, decorating it with higher-order functions.

Parameters:
f - The function to wrap.
Returns:
The wrapped function.

$$

public static <A,B,C> F2W<A,B,C> $$(F<A,F<B,C>> f)
Wraps a given function, decorating it with higher-order functions.

Parameters:
f - The function to wrap.
Returns:
The wrapped function.

flip

public F2W<B,A,C> flip()
Flips the arguments of this function.

Returns:
A new function with the arguments of this function flipped.

tuple

public FW<P2<A,B>,C> tuple()
Uncurries this function to a function on tuples.

Returns:
A new function that calls this function with the elements of a given tuple.

array

public F2W<Array<A>,Array<B>,Array<C>> array()
Promotes this function to a function on Arrays.

Returns:
This function promoted to transform Arrays.

promise

public F2W<Promise<A>,Promise<B>,Promise<C>> promise()
Promotes this function to a function on Promises.

Returns:
This function promoted to transform Promises.

iterable

public F2W<Iterable<A>,Iterable<B>,IterableW<C>> iterable()
Promotes this function to a function on Iterables.

Returns:
This function promoted to transform Iterables.

list

public F2W<List<A>,List<B>,List<C>> list()
Promotes this function to a function on Lists.

Returns:
This function promoted to transform Lists.

nel

public F2W<NonEmptyList<A>,NonEmptyList<B>,NonEmptyList<C>> nel()
Promotes this function to a function on non-empty lists.

Returns:
This function promoted to transform non-empty lists.

option

public F2W<Option<A>,Option<B>,Option<C>> option()
Promotes this function to a function on Options.

Returns:
This function promoted to transform Options.

set

public F2W<Set<A>,Set<B>,Set<C>> set(Ord<C> o)
Promotes this function to a function on Sets.

Parameters:
o - An ordering for the result of the promoted function.
Returns:
This function promoted to transform Sets.

stream

public F2W<Stream<A>,Stream<B>,Stream<C>> stream()
Promotes this function to a function on Streams.

Returns:
This function promoted to transform Streams.

tree

public F2W<Tree<A>,Tree<B>,Tree<C>> tree()
Promotes this function to a function on Trees.

Returns:
This function promoted to transform Trees.

zipArray

public F2W<Array<A>,Array<B>,Array<C>> zipArray()
Promotes this function to zip two arrays, applying the function lock-step over both Arrays.

Returns:
A function that zips two arrays with this function.

zipIterable

public F2W<Iterable<A>,Iterable<B>,Iterable<C>> zipIterable()
Promotes this function to zip two iterables, applying the function lock-step over both iterables.

Returns:
A function that zips two iterables with this function.

zipList

public F2W<List<A>,List<B>,List<C>> zipList()
Promotes this function to zip two lists, applying the function lock-step over both lists.

Returns:
A function that zips two lists with this function.

zipStream

public F2W<Stream<A>,Stream<B>,Stream<C>> zipStream()
Promotes this function to zip two streams, applying the function lock-step over both streams.

Returns:
A function that zips two streams with this function.

zipNel

public F2W<NonEmptyList<A>,NonEmptyList<B>,NonEmptyList<C>> zipNel()
Promotes this function to zip two non-empty lists, applying the function lock-step over both lists.

Returns:
A function that zips two non-empty lists with this function.

zipSet

public F2W<Set<A>,Set<B>,Set<C>> zipSet(Ord<C> o)
Promotes this function to zip two sets, applying the function lock-step over both sets.

Parameters:
o - An ordering for the resulting set.
Returns:
A function that zips two sets with this function.

zipTree

public F2W<Tree<A>,Tree<B>,Tree<C>> zipTree()
Promotes this function to zip two trees, applying the function lock-step over both trees. The structure of the resulting tree is the structural intersection of the two trees.

Returns:
A function that zips two trees with this function.

zipZipper

public F2W<Zipper<A>,Zipper<B>,Zipper<C>> zipZipper()
Promotes this function to zip two zippers, applying the function lock-step over both zippers in both directions. The structure of the resulting zipper is the structural intersection of the two zippers.

Returns:
A function that zips two zippers with this function.

zipTreeZipper

public F2W<TreeZipper<A>,TreeZipper<B>,TreeZipper<C>> zipTreeZipper()
Promotes this function to zip two TreeZippers, applying the function lock-step over both zippers in all directions. The structure of the resulting TreeZipper is the structural intersection of the two TreeZippers.

Returns:
A function that zips two TreeZippers with this function.

Copyright 2008 - 2009 Tony Morris, Runar Bjarnason, Tom Adams, Brad Clow, Ricky Clarkson, Nick Partridge, Jason Zaugg

This software is released under an open source BSD licence.