pellucidanalytics/datomisca — pull request #10 by mandubian (2013-02-15 14:39:35+00:00)
Title: draft proposition to enhance DRef pattern matching

This `DRef` pattern matching is a problem because of `Either[Keyword, DId]`

Now we write:

```scala
DRef(ns / "bar") match {
case DRef(Left(kw)) => ...
case DRef(Right(kw)) => ...
}
```

It's quite hard to modify it because we can't a single extractor managing `Keyword` and `DId`.

I have already added 3 methods to `DRef`

`.toId` which returns an Id or throws an `Exception`
`.toKeyword` which returns a `Keyword` or throws an `Exception`
`.toEither` which returns the either

So we could write
```scala
DRef(ns / "bar").toEither match {
case Left(kw) => ...
case Right(kw) => ...
}
```
The last thing I see right now is to create 2 extractor objects in DRef object: IsKeyword and IsId and we could write:

```scala
DRef(ns / "bar") match {
case DRef.IsKeyword(kw) if kw == KW(":foo/bar") => ...
case DRef.isId(id) => ...
}
```

Your mind?