orc.ast.extended.pattern
Class Pattern
java.lang.Object
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
Pattern
public Pattern()
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
-