Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created December 1, 2010 09:05
Show Gist options
  • Save debasishg/723209 to your computer and use it in GitHub Desktop.
Save debasishg/723209 to your computer and use it in GitHub Desktop.
scala> import scalaz._
import scalaz._
scala> import Scalaz._
import Scalaz._
scala> import net.debasishg.domain.trade.Trades._
import net.debasishg.domain.trade.Trades._
// a Map for trade attributes
scala> val t1 = Map("account" -> "a-123", "instrument" -> "google", "refNo" -> "r-123", "market" -> "HongKong", "unitPrice" -> "12.25", "quantity" -> "200")
t1: scala.collection.immutable.Map[java.lang.String,java.lang.String] = Map((quantity,200), (market,HongKong), (refNo,r-123), (account,a-123), (unitPrice,12.25), (instrument,google))
// get a Trade out of it
scala> val trd1 = makeTrade(t1)
trd1: Option[net.debasishg.domain.trade.Trades.Trade] = Some(Trade(a-123,google,r-123,HongKong,12.25,200))
// map .. Scala style
scala> (((trd1 map forTrade) map taxFees) map enrichWith) map netAmount
res0: Option[scala.math.BigDecimal] = Some(3307.5000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment