Orbital library

Class Functionals.Hylomorphism

  extended by orbital.logic.functor.Functionals.Hylomorphism
All Implemented Interfaces:
java.io.Serializable, Function, Functor
Enclosing class:

public static class Functionals.Hylomorphism
extends java.lang.Object
implements Function, java.io.Serializable

Hylomorphism recursion functional scheme (envelope).

A hylomorphism is denoted by envelopes.

this = [[(c,f),(g,p)]] = |[(c,f),(g,p)]| = 〚(c,f),(g,p)〛

A hylomorphism corresponds to the composition of an anamorphism and a catamorphism.

[[(c,f),(g,p)]] = (|c,f|)|(g,p)|
So it is very much like an anamorphism except for basevalue c instead of nil, and f instead of list construction cons.

André Platzer
See Also:
Functionals.envelope(Object, BinaryFunction, Function, Predicate, Object), Meijer, E. and Fokkinga, M.M. and Paterson, R., Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire, FPCA91: Functional Programming Languages and Computer Architecture, pp. 124--144, volume 523, Lecture Notes in Computer Science, Springer-Verlag, 1991., Serialized Form

Nested Class Summary
Nested classes/interfaces inherited from interface orbital.logic.functor.Function
Nested classes/interfaces inherited from interface orbital.logic.functor.Functor
Field Summary
Fields inherited from interface orbital.logic.functor.Function
Constructor Summary
Functionals.Hylomorphism(java.lang.Object c, BinaryFunction f, Function g, Predicate p)
          Constructs a new hylomorphism [[(c,f),(g,p)]]:A→C.
Method Summary
 java.lang.Object apply(java.lang.Object a)
          [[(c,f),(g,p)]] a.
 boolean equals(java.lang.Object o)
 int hashCode()
 java.lang.String toString()
          Returns a string representation of the Functor.
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Constructor Detail


public Functionals.Hylomorphism(java.lang.Object c,
                                BinaryFunction f,
                                Function g,
                                Predicate p)
Constructs a new hylomorphism [[(c,f),(g,p)]]:A→C.

c - is an element ∈C that is the basevalue for p(a) = true.
f - is a binary function f:B||C→C.
g - is a function g:A→B||A that returns objects of type Pair.
p - is a predicate p⊆A saying whether to use the basevalue case.
Method Detail


public boolean equals(java.lang.Object o)
Description copied from interface: Functor

Note that functors will often provide intensional equality only, since the mathematical notion of extensional equality for functions and predicates is undecidable anyway (Proposition of Rice). Nevertheless implementations are encouraged to provide a larger subset of extensional equality as far as possible.

Specified by:
equals in interface Functor
equals in class java.lang.Object


public int hashCode()
Specified by:
hashCode in interface Functor
hashCode in class java.lang.Object


public final java.lang.Object apply(java.lang.Object a)
[[(c,f),(g,p)]] a.
hylo a = c ⇐ p(a)
= f(b, hylo(a')) ⇐ ¬p(a)
where (b, a') = g(a)
[[(c,f),(g,p)]] := hylo

Specified by:
apply in interface Function
a - value ∈A.
the value [[(c,f),(g,p)]] a ∈ C.


public java.lang.String toString()
Description copied from interface: Functor
Returns a string representation of the Functor.

This method is already provided in Object.toString(). If it is overwritten it should return a nice name for the functor.

Specified by:
toString in interface Functor
toString in class java.lang.Object
a nice name for the functor.

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.