Skip to content

Instantly share code, notes, and snippets.

@afsalthaj
Last active April 11, 2018 07:37
Show Gist options
  • Save afsalthaj/15663f83cbaadd9e56c83501be635767 to your computer and use it in GitHub Desktop.
Save afsalthaj/15663f83cbaadd9e56c83501be635767 to your computer and use it in GitHub Desktop.
import scalaz.syntax.std.option._
import scalaz.{@@, Show, Tag}
import scalaz.syntax.show._
trait Tagger[A] {
sealed trait Marker
final type Type = A @@ Marker
def apply(a: A): Type = Tag[A, Marker](a)
def unapply(tagged: Type): Option[A] = unwrapped(tagged).some
def unwrapped(tagged: Type): A = Tag.unwrap(tagged)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment