Skip to content

Instantly share code, notes, and snippets.

@chanwit
Created March 6, 2011 14:33
Show Gist options
  • Select an option

  • Save chanwit/857332 to your computer and use it in GitHub Desktop.

Select an option

Save chanwit/857332 to your computer and use it in GitHub Desktop.
A Type-safe Monad that combines Node and List<Node> written in Groovy++
package org.korat.ast
class SomeNode {
List<Node> data
String getText() { data[0].text }
String getType() { data[0].type }
List<Node> getChild() { data[0].child }
SomeNode getUnresolvedProperty(String name) {
return data[0].getUnresolvedProperty(name)
}
SomeNode getAt(int i) {
return new SomeNode(data: [data[i]])
}
String toString() {
return "#" + data[0].toString()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment