Permalink
Browse files

fix FreeUsage example bug. Int.MinValue.abs is negative

  • Loading branch information...
1 parent f470cd7 commit 2f43966b36407636d82aaf9a2ef0d9075d1829a9 @xuwei-k xuwei-k committed Feb 5, 2017
Showing with 1 addition and 1 deletion.
  1. +1 −1 example/src/main/scala/scalaz/example/FreeUsage.scala
@@ -41,7 +41,7 @@ object FreeUsage extends App {
def setSeed(seed: Long) = Free.liftF(RngOp.SetSeed(seed))
// You can of course derive new operations from the primitives
- def nextNonNegativeInt = nextInt.map(_.abs)
+ def nextNonNegativeInt = nextInt.map(n => if(n == Int.MinValue) 0 else n.abs)
def choose[A](h: A, tl: A*) = nextIntInRange(tl.length + 1).map((h +: tl).apply)
// Natural transformation to (Random => A)

0 comments on commit 2f43966

Please sign in to comment.