Created
June 27, 2012 16:41
-
-
Save Shadowfiend/3005301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A structural type for an expression that has a getFirst and a getSecond method | |
* which both return a Symbols.Type. | |
*/ | |
type TwoPartExpression = { | |
def getFirst : Symbols.Type | |
def getSecond : Symbols.Type | |
} | |
/** | |
* Determines the type of the given two part expression's operands. | |
* | |
* If the types are divergent, throws an exception. | |
*/ | |
def expressionType(expression:TwoPartExpression) : Symbols.Type = { | |
val (firstType, secondType) = (expression.getFirst, expression.getSecond) | |
if (firstType == secondType) | |
firstType | |
else | |
throw new Exception(...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment