Skip to content

Instantly share code, notes, and snippets.

View oxbowlakes's full-sized avatar

Christopher Marshall oxbowlakes

View GitHub Profile
object ReferenceDirective extends Enumeration {
val Replace, DoNotReplace = Value
def replace: Value = Replace
def doNotReplace: Value = DoNotReplace
}
import java.util.concurrent.atomic._
import scalaz._
/**
package gsa.domain.scala.dan
import scalaz.Leibniz.===
import scalaz._
import Scalaz._
import gsa.shared.scala._ //gets you Date, Instant types
/**
* We wish to use a DomainService to get a snapshot of our domain (e.g. Books and SubBusinessUnits).
object OptionGolf {
import scalaz._
import Scalaz._
val moviel = Map("title" -> "South Park",
"user" -> "Terrence",
"rating" -> "3")
val incompleteMovie = Map("name" -> "Jaws")
@oxbowlakes
oxbowlakes / range.scala
Created December 6, 2010 22:28
Range class for ranges [a, b], (a, b), (a, b], [a, b) where (a and b) may be unbounded
package test
import scalaz._
import Scalaz._
import test.IRange.Increment
sealed trait Limit[+Z] {
def open : Boolean
def bound : Option[Z]
final def closed = !open
@oxbowlakes
oxbowlakes / ScalaSolarizedDark.xml
Created June 20, 2011 13:13
ScalaSolarizedDark.xml
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="OxbowSolarizedDark" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.2" />
<option name="EDITOR_FONT_SIZE" value="13" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="ADDED_LINES_COLOR" value="" />
<option name="ANNOTATIONS_COLOR" value="2b36" />
<option name="ANNOTATIONS_MERGED_COLOR" value="" />
<option name="CARET_COLOR" value="dc322f" />
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Server VM, Java 1.6.0_18).
Type in expressions to have them evaluated.
Type :help for more information.
scala> type Tagged[U] = { type Tag = U }
defined type alias Tagged
scala> type @@[T, U] = T with Tagged[U]
defined type alias $at$at
@oxbowlakes
oxbowlakes / scala-interview1.scala
Last active October 1, 2015 08:48
Scala interview questions
object GOption {
def some[A](a: A): GOption[A] = new GOption[A] {
def cata[B](n: => B, s: A => B): B = sys.error("Implement me")
}
def none[A]: GOption[A] = new GOption[A] {
def cata[B](n: => B, s: A => B): B = sys.error("Implement me")
}
}
trait GOption[+A] {
@oxbowlakes
oxbowlakes / imperial-monoid.scala
Created March 13, 2012 12:53
Monoid example
trait Monoid[A] {
def identity: A
def mplus(a1: A, a2: A): A
}
object Monoid {
implicit val IntMonoid = new Monoid[Int] {
def identity = 0
def mplus(a1: Int, a2: Int) = a1 + a2
}
@oxbowlakes
oxbowlakes / imperial-position.scala
Created March 13, 2012 12:54
Position example (using monoid)
object Positions {
trait Investment
trait Position {
def investment: Investment
def tradingPnL: Option[Double]
def inventoryPnL: Option[Double]
final def totalPnL = inventoryPnL → tradingPnL
}
import Monoid._
@oxbowlakes
oxbowlakes / lens-example-tradingday.scala
Created April 24, 2012 10:05
Lens/State Example to remove repetition
object TradingDays extends App {
import scalaz._
import Scalaz._
case class Trade(sym: String, trader: String, qty: Int)
case class TradingDay(symbols: Map[String, SymDay] = Map.empty)
object TradingDay {