Guest User

Untitled

a guest
Oct 11th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment