Skip to content

Instantly share code, notes, and snippets.

@andyscott
Created April 17, 2014 20:39
Show Gist options
  • Save andyscott/11010224 to your computer and use it in GitHub Desktop.
Save andyscott/11010224 to your computer and use it in GitHub Desktop.
trait Magnetic[T] {
protected sealed trait TagMag
type Magnet = T @@ TagMag
protected implicit def tag(value: T) = Tag[T, TagMag](value)
def apply(mag: Magnet): T = mag
}
object CreateDescriptor extends Magnetic[CreateDescriptor] {
implicit def default(unit: Unit): Magnet = CreateDescriptor(None, AssetDescriptorRecord())
implicit def fromUser(user: ProfilePair): Magnet = CreateDescriptor(Some(user), AssetDescriptorRecord())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment