Skip to content

Instantly share code, notes, and snippets.

@mdekstrand
Created January 12, 2013 18:19
Show Gist options
  • Save mdekstrand/4519727 to your computer and use it in GitHub Desktop.
Save mdekstrand/4519727 to your computer and use it in GitHub Desktop.
Code for path-dependent type post.
trait InfoNeed {
type DataType
/** Get the web request to fetch data */
def request: WebRequest[DataType]
/** Get the neighbors from some fetched data (to determine new nodes to visit) */
def neighbors(data: DataType): Traversable[Node]
/** Save the data to the data store. */
def save(store: DataStore, data: DataType)
}
def fetch[T](req: WebRequest[T]): Result[T]
def process(need: Need) {
val req = need.request
val res = fetch(req)
// now we save the data
res match {
case Good(data) => need.save(store, data)
/* error cases */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment