Skip to content

Instantly share code, notes, and snippets.

View jestan's full-sized avatar

Jestan Nirojan jestan

View GitHub Profile
@jestan
jestan / gist:3692077
Created September 10, 2012 16:51 — forked from mtnygard/gist:2254147
Books I recommended today
@jestan
jestan / about.md
Created May 2, 2012 16:57 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@jestan
jestan / type-bounds.scala
Created April 19, 2012 16:00 — forked from retronym/type-bounds.scala
Tour of Scala Type Bounds
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@jestan
jestan / 3nightclubs.scala
Created February 25, 2012 08:21 — forked from oxbowlakes/3nightclubs.scala
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@jestan
jestan / ScalaEnum.scala
Created February 10, 2012 05:53 — forked from dadrox/ScalaEnum.scala
DIY Scala Enums (with optional exhaustiveness checking, name introspection, and boilerplate reverse lookup)
trait Enum { //DIY enum type
import java.util.concurrent.atomic.AtomicReference //Concurrency paranoia
type EnumVal <: Value //This is a type that needs to be found in the implementing class
def withName(name: String): Option[EnumVal] = values.find(_.name == name)
def withNameIgnoringCase(name: String): Option[EnumVal] = values.find(_.name.equalsIgnoreCase(name))
private def lazyName(requestingInstance: EnumVal): String = {
getClass().getMethods()