package monocle

import monocle.function.SafeCast._
import monocle.syntax.prism._
import org.specs2.scalaz.Spec

class SafeCastExample extends Spec {

  "safeCast creates a Prism from Int to Char" in {
    safeCast[Int, Char].getOption(65)   shouldEqual Some('A')
    safeCast[Int, Char].reverseGet('a') shouldEqual 97

    // with some syntax sugar
    (65 <-? safeCast[Int, Char] getOption) shouldEqual Some('A')
  }

  "safeCast creates a Prism from String to Int" in {
    safeCast[String, Int].getOption("352") shouldEqual Some(352)
    safeCast[String, Int].reverseGet(8921) shouldEqual "8921"
    safeCast[String, Int].getOption("")    shouldEqual None
  }

  "With safeCast[String,Int] one could map a String with an Int => Int function." in {
    safeCast[String, Int].modify("1024", _ * 2) shouldEqual "2048"
  }

  "safeCast creates a Prism from String to Boolean" in {
    safeCast[String, Boolean].getOption("true") shouldEqual Some(true)
    safeCast[String, Boolean].reverseGet(false) shouldEqual "false"
  }

 // idem for all other instances of SafeCast

}

package monocle

import monocle.function.SafeCast._
import monocle.syntax.prism._
import org.specs2.scalaz.Spec

class SafeCastExample extends Spec {

  "safeCast creates a Prism from Int to Char" in {
    safeCast[Int, Char].getOption(65)   shouldEqual Some('A')
    safeCast[Int, Char].reverseGet('a') shouldEqual 97

    // with some syntax sugar
    (65 <-? safeCast[Int, Char] getOption) shouldEqual Some('A')
  }

  "safeCast creates a Prism from String to Int" in {
    safeCast[String, Int].getOption("352") shouldEqual Some(352)
    safeCast[String, Int].reverseGet(8921) shouldEqual "8921"
    safeCast[String, Int].getOption("")    shouldEqual None
  }

  "safeCast creates a Prism from String to Boolean" in {
    safeCast[String, Boolean].getOption("true") shouldEqual Some(true)
    safeCast[String, Boolean].reverseGet(false) shouldEqual "false"
  }

 // idem for all other instances of SafeCast

}

--- 
+++ 
@@ -20,6 +20,10 @@
     safeCast[String, Int].getOption("")    shouldEqual None
   }
 
+  "With safeCast[String,Int] one could map a String with an Int => Int function." in {
+    safeCast[String, Int].modify("1024", _ * 2) shouldEqual "2048"
+  }
+
   "safeCast creates a Prism from String to Boolean" in {
     safeCast[String, Boolean].getOption("true") shouldEqual Some(true)
     safeCast[String, Boolean].reverseGet(false) shouldEqual "false"
Add an interesting String<->Int prism modify example.
