Skip to content

Instantly share code, notes, and snippets.

@everson
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save everson/66080d49aebd9f45474e to your computer and use it in GitHub Desktop.
Save everson/66080d49aebd9f45474e to your computer and use it in GitHub Desktop.
scalaz.Tag
import scalaz._
import Scalaz._
val isThisCool: Boolean @@ CoolStuff = Tag(true)
def requiresCoolStuff(in: Boolean @@ CoolStuff) = in
// type checks
requiresCoolStuff(isThisCool)
if(isThisCool) "still act as bool" else "oops"
/*
<console>:22: error: type mismatch;
found : Boolean(true)
required: scalaz.@@[Boolean,CoolStuff]
(which expands to) Boolean with AnyRef{type Tag = CoolStuff}
requiresCoolStuff(true)
*/
requiresCoolStuff(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment