Skip to content

Instantly share code, notes, and snippets.

@gszeliga
Last active August 29, 2015 14:16
Show Gist options
  • Save gszeliga/18844ba168e42c4f11d2 to your computer and use it in GitHub Desktop.
Save gszeliga/18844ba168e42c4f11d2 to your computer and use it in GitHub Desktop.
object HipsterRules {
import com.covariantblabbering.builder.ApplicativeStyleWithExceptions._
def facialHairStyle(hair: String) = {
if(hair.toLowerCase.contains("beard")) Continue(hair)
else Failure(new Exception("You need to make vikings envious with any bushy or scraggly beard"))
}
def tshirt(style: String) = {
if(style.toLowerCase.contains("v-neck")) Continue(style)
else Failure(new Exception("C'mon! We need to see some traces of your belly button"))
}
def acceptedBands(band: String) = {
val acceptedBands = List("fleet foxes", "sun kil moon", "neutral milk hotel")
acceptedBands find(_ == band.toLowerCase) map(Continue(_)) getOrElse Failure(new Exception(s"Do you still listen to '$band'? That name is not even poetic and/or ironic"))
}
def acceptedHobbies(hobbie: String) = {
val acceptedHobbies = List("knitting", "urban beekeepin", "taxidermy")
acceptedHobbies find(_ == hobbie.toLowerCase) map(Continue(_)) getOrElse Failure(new Exception(s"Nobody does '$hobbie' anymore today. Don't you got any friends around?"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment