Showing posts with label Filter. Show all posts
Showing posts with label Filter. Show all posts

Saturday, 2 June 2012

Rework: Monads in Scala - 4


Monadic Zero


Do U remember second state of Response - Marvelous?
If we represent Marvelous via Answer with null inside - it's not enough, than we can translate Marvelous into Answer - ignoring it's Essentials - that is error:

    val box = new Answer[Any](null)
    val func:(Any)=>Int = (in) => 5
    val res = box map func // Produces Answer(5)

Expected behavior, that is described via The First Zero Law: Identity

     mzero map/flatMap f = mzero