orc.ast.extended.pattern
Class Pattern

java.lang.Object
  extended by orc.ast.extended.pattern.Pattern
Direct Known Subclasses:
AsPattern, CallPattern, ConsPattern, ListPattern, LiteralPattern, NilPattern, PublishPattern, TuplePattern, VariablePattern, WildcardPattern

public abstract class Pattern
extends java.lang.Object

Base interface for the abstract syntax of patterns. Patterns exist only in the extended abstract syntax. They desugar into a series of operations which terminate in variable bindings.

Author:
dkitchin

Field Summary
protected static Argument CONS
           
protected static Argument EQUAL
           
protected static Argument HEAD
           
protected static Argument IF
           
protected static Argument ISCONS
           
protected static Argument ISNIL
           
static Argument ISNONE
           
static Argument ISSOME
           
protected static Argument NONE
           
protected static Argument NOT
           
protected static Argument SOME
           
protected static Argument TAIL
           
 
Constructor Summary
Pattern()
           
 
Method Summary
 Expression bind(Expression f, Expression g)
           
abstract  Expression bind(Var u, Expression g)
           
static Expression filter(Expression e)
          Filter an expression by piping its publications through isSome.
static Expression ifexp(Expression test, Expression tc, Expression fc)
           
static Expression lift(java.util.List<Expression> es)
          Lifted application of a site to a list of optional arguments.
 Expression match(Expression f)
           
abstract  Expression match(Var u)
           
static Expression opbind(Expression f, Var t, Expression g)
          Create an expression computing a monadic bind for options.
 boolean strict()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IF

protected static Argument IF

NOT

protected static Argument NOT

SOME

protected static Argument SOME

NONE

protected static Argument NONE

ISSOME

public static Argument ISSOME

ISNONE

public static Argument ISNONE

CONS

protected static Argument CONS

ISCONS

protected static Argument ISCONS

ISNIL

protected static Argument ISNIL

HEAD

protected static Argument HEAD

TAIL

protected static Argument TAIL

EQUAL

protected static Argument EQUAL
Constructor Detail

Pattern

public Pattern()
Method Detail

match

public abstract Expression match(Var u)
Parameters:
f - The source expression for values to be matched
Returns:
A new expression publishing, for each publication !v of f,
 some(v')       if p(v) => v' 
 none           if p(v) => _|_
 

bind

public abstract Expression bind(Var u,
                                Expression g)

match

public Expression match(Expression f)

bind

public Expression bind(Expression f,
                       Expression g)

strict

public boolean strict()

ifexp

public static Expression ifexp(Expression test,
                               Expression tc,
                               Expression fc)

lift

public static Expression lift(java.util.List<Expression> es)
Lifted application of a site to a list of optional arguments. If every argument evaluates to some(vi), then the result is some(C(v1,...,vn)). If any argument evaluates to none, the result is none. lift(e1...en) = ( some(s1, ... , sn) .. > none()

opbind

public static Expression opbind(Expression f,
                                Var t,
                                Expression g)
Create an expression computing a monadic bind for options. I'd really rather be using Haskell here.

opbind(f,t,g) = f >s> ( (isSome(s) >t> g) >u> some(u) | isNone(s) >> none )


filter

public static Expression filter(Expression e)
Filter an expression by piping its publications through isSome. Values some(v) will publish v, values none will be ignored.

Parameters:
e -