scalaz.Monad, and the family of related type classes, abstract some common functionality across a vast array of types. Scalaz provides general purpose functions that work for anyMonad; and you can write your own functions in the same fashion.
Without this abstraction, you are forced to write these functions for each new monadic type that you encounter, e.g. List, Parser, Option. This gets tedious!
Here are examples of a few provided functions, working with a couple monadic types. My favorite is sequence:
发布评论
评论(1)
scalaz.Monad
以及相关类型类系列,在大量类型中抽象了一些常见功能。 Scalaz 提供适用于任何Monad
的通用函数;你可以用同样的方式编写你自己的函数。如果没有这种抽象,您将被迫为遇到的每个新单子类型编写这些函数,例如
List
、Parser
、Option
。这变得乏味!以下是一些提供的函数的示例,可使用几种单子类型。我最喜欢的是
序列
:scalaz.Monad
, and the family of related type classes, abstract some common functionality across a vast array of types. Scalaz provides general purpose functions that work for anyMonad
; and you can write your own functions in the same fashion.Without this abstraction, you are forced to write these functions for each new monadic type that you encounter, e.g.
List
,Parser
,Option
. This gets tedious!Here are examples of a few provided functions, working with a couple monadic types. My favorite is
sequence
: