daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait Domain{
  2.  
  3.    type  Read[A] = Reader[BoundsProblem, A]
  4.    type Result[A] = EitherT[Read, String, A]
  5.  
  6.     def stepSize( s: State, direction: Direction): Result[Double] //depends on an injected context, can fail
  7.     def takeStep( s: State, dir: Direction, stepSize: Double): Read[Variable] //depends on context, can't fail
  8.     def calculate(x: Variable): (Double, Gradient) //context-independent, can't fail
  9.  
  10.      //doesn't compile:
  11.    def iteration(s: State, dir: Direction) =  for{
  12.           tee <- stepSize(s, dir)
  13.          x <- takeStep(s, dir, tee)
  14.           r <- calculate(x)
  15.       } yield  r
  16.  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top