This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// References | |
// - http://jim-mcbeath.blogspot.com/2008/11/scala-type-infix-operators.html | |
// | |
// | |
// Notes: | |
// - a generic type op[T1, T2] can be written T1 op T2 | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// References | |
// - http://stackoverflow.com/questions/3427345/what-do-and-mean-in-scala-2-8-and-where-are-they-documented | |
// - http://stackoverflow.com/questions/2603003/operator-in-scala | |
// - https://gist.github.com/retronym/229163 | |
// - http://debasishg.blogspot.com/2010/08/using-generalized-type-constraints-how.html#sthash.GKfUGq9p.dpuf | |
// - http://www.scala-lang.org/old/node/4041.html | |
// - https://groups.google.com/forum/#!searchin/scala-user/generic$20type$20constraint/scala-user/mgx9-TUapQo/tiN6x818dKsJ | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// References | |
// Ordering case classes: http://meta.plasm.us/posts/2013/10/13/ordering-case-classes/ | |
// Tuple Ordering available up to 9 arity - https://github.com/scala/scala/blob/v2.10.2/src/library/scala/math/Ordering.scala#L358 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Semigroup with a associative binary method `append`, subject | |
// to semigroup laws | |
// | |
// A Semigroup in type F must satisfy two laws: | |
// - closure: ∀ a, b in F, append(a, b) is also in F. This is | |
// enforced by the type system | |
// - associativity: ∀ a, b, c in F, the following equation holds | |
// => append(append(a, b), c) = append(a, append(b , c)) | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// References: | |
// - http://www.tikalk.com/java/type-safe-builder-scala-using-type-constraints/ | |
// - http://www.blumenfeld-maso.com/2011/05/statically-controlling-calls-to-methods-in-scala/ | |
// - http://dcsobral.blogspot.com/2009/09/type-safe-builder-pattern.html | |
// - http://blog.rafaelferreira.net/2008/07/type-safe-builder-pattern-in-scala.html | |
// - http://jim-mcbeath.blogspot.com/2009/09/type-safe-builder-in-scala-part-4.html | |
// - http://villane.wordpress.com/2010/03/05/taking-advantage-of-scala-2-8-replacing-the-builder/ | |
// - http://debasishg.blogspot.com/2010/08/using-generalized-type-constraints-how.html#sthash.GKfUGq9p.dpuf | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Show typeclass parameterized on a concrete type | |
// | |
trait Show[A] { | |
def show(a: A): String | |
} | |
object Show { | |
implicit object StringShow extends Show[String] { | |
def show(s: String) = s"*$s*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/twitter/util/blob/master/util-app/src/main/scala/com/twitter/app/Flag.scala | |
// Type class / Typeclass / Type traits | |
// References | |
// - http://www.haskell.org/haskellwiki/Typeclassopedia | |
// - http://www.haskell.org/wikiupload/8/85/TMR-Issue13.pdf | |
// - https://github.com/channingwalton/typeclassopedia | |
// - http://ropas.snu.ac.kr/~bruno/papers/TypeClasses.pdf | |
// - http://debasishg.blogspot.com/2010/06/scala-implicits-type-classes-here-i.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/5328007/why-doesnt-option-have-a-fold-method | |
// See scalaz option cata() | |
// | |
// fold[B](ifEmpty: => B)(f: A => B): B | |
http://www.blumenfeld-maso.com/2010/01/scala-word-of-the-day-catamorphism/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.fasterxml.jackson.core.{JsonGenerator, JsonToken, JsonParser, JsonFactory} | |
import com.fasterxml.jackson.databind._ | |
val mapper = new ObjectMapper | |
val jsonFactory = new JsonFactory(mapper) | |
val content = | |
""" | |
{ | |
"name" : "Watership Down", | |
"location" : { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.{Map ⇒ JMap} | |
import java.util.{List ⇒ JList} |