25
4

3 回答 3

13

I agree that Scalaz is mostly undocumented. The problem is that it collects a lot of advanced concepts from Haskell (and the underlying mathematics) and documenting them all in detail would become writing a whole book about functional programming (and mathematics). So I believe Scalaz's approach is:

  • If you know and need some concept from functional programming prepared for Scala, you'll most likely find it here.
  • If you don't know it, you'll have to learn it elsewhere.

Let's have a look at your example: If you know Kleisli categories and how every monads gives rise to one, the definition is quite self-contained. If you don't, then KleisliCategory has no use for you anyway.

(In my experience, Haskell is better for learning advanced concepts from functional programming. While Scala is far better than Java, it still drags around Java's OO/imperative heritage that clutters things a bit.)


Considering the Unicode symbols. Looking at sources it seems that they're used only as a syntactic sugar or at least they have a non-Unicode counterpart:

def ☆[M[_], A, B](f: A => M[B]): Kleisli[M, A, B] = kleisli(f)
def η[F[_]](implicit p: Pure[F]): F[A] = pure
def cokleisli[W[_], A, B](f: W[A] => B): Cokleisli[W, A, B] = ★(f)

So you can go without them, if you want.

Still, I'm not sure if having them in Scalaz is a good idea. It could make the code impossible to read for someone who lacks the proper fonts. I'd rather prefer pure ASCII symbols.

于 2012-10-21T07:42:57.523 回答
7

A place to start is to read Learn You a Haskell which covers many concepts.

Watch Chris Marshall's (@oxbow_lakes) scalaz talks: http://skillsmatter.com/expert/scala/chris-marshall

Get a copy of Functional Programming in Scala from Manning written by some of the authors of scalaz.

I have a couple of small examples on my blog http://www.casualmiracles.com/blog/

I would say there is even easier places to start with scalaz than validation, which is the various enrichments on Option like ~foo which returns the value contained in the option or the 'zero' for the options's type (0 for numbers, empty string for String etc).

I forgot about a very detailed series of articles called Learning Scalaz at http://eed3si9n.com/

于 2012-10-21T11:09:45.370 回答
5

As with any open-source project, the only really true and acceptable answer to "Why isn't their better documentation?" is "Because no one has written it yet. You are free to volunteer."

(I honestly have no idea whether this answer will result in upvotes or downvotes. Interesting experiment.)

于 2012-10-21T22:06:02.087 回答