Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait Domain{
- type Read[A] = Reader[BoundsProblem, A]
- type Result[A] = EitherT[Read, String, A]
- def stepSize( s: State, direction: Direction): Result[Double] //depends on an injected context, can fail
- def takeStep( s: State, dir: Direction, stepSize: Double): Read[Variable] //depends on context, can't fail
- def calculate(x: Variable): (Double, Gradient) //context-independent, can't fail
- //doesn't compile:
- def iteration(s: State, dir: Direction) = for{
- tee <- stepSize(s, dir)
- x <- takeStep(s, dir, tee)
- r <- calculate(x)
- } yield r
- }
Add Comment
Please, Sign In to add comment