[ANN] Scalaz 6.0

59 views
Skip to first unread message

Jason Zaugg

unread,
Jun 8, 2011, 11:34:21 AM6/8/11
to sca...@googlegroups.com, scala-user
Scalaz [1] is a library for functional programming in Scala,
comprising Type Classes, purely functional data structures, general
purpose algorithms, and a minimal concurrency library.

The Scalaz team is proud to announce the release of Scalaz 6.0, for
Scala 2.8.1 and 2.9.0.1. For details of what's new, and links to the
downloads and API documentation, see the release notes [2].

Thanks to all the contributors for the myriad improvements in this
release; and to the users of the library who have provided feedback
and interesting discussions on the mailing lists.

BTW, I will be presenting a session on Scalaz at Scala eXchange [3] next week.

-jason

[1] http://scalaz.org
[2] http://code.google.com/p/scalaz/wiki/Scalaz6
[3] http://skillsmatter.com/event/scala/scala-exchange-2011

Martin S. Weber

unread,
Jun 8, 2011, 11:42:10 AM6/8/11
to scala...@googlegroups.com, Jason Zaugg
On 06/08/11 11:34, Jason Zaugg wrote:
> Scalaz [1] is a library for functional programming in Scala,
> comprising Type Classes, purely functional data structures, general
> purpose algorithms, and a minimal concurrency library.
>
> The Scalaz team is proud to announce the release of Scalaz 6.0, for
> Scala 2.8.1 and 2.9.0.1. For details of what's new, and links to the
> downloads and API documentation, see the release notes [2].

...which reminds me:

from http://code.google.com/p/scalaz/

"Type Classes
[...]
A Monoid type class and (so many!) implementations"

Uhm.. Is there any way to see from the scaladoc which implementations Monoid
has? In other words, I don't want to see the linear supertypes of a
class/trait in the scaladoc, I want to see its implementations. Something that
good old javadoc is doing for eeeeeeeeeeeeeeooooooooons.

I can't see it, please help me remove my blindness.

Thanks in advance,

-Martin

Jason Zaugg

unread,
Jun 8, 2011, 11:55:01 AM6/8/11
to Martin S. Weber, scala...@googlegroups.com

Scaladoc does show "Known Subclasses", but for finding Monoid
instances this doesn't help. These are usually pieced together
implicitly by Monoid.monoid [1], from a Semigroup [2] and Zero [3].

I usually find it easiest to read the sources to look for these
things, we have hyperlinked versions online. [4]

-jason

[1] http://scalaz.github.com/scalaz/scalaz-2.9.0-1-6.0/doc/#scalaz.Monoid$
[2] http://scalaz.github.com/scalaz/scalaz-2.9.0-1-6.0/doc/#scalaz.Semigroup$
[3] http://scalaz.github.com/scalaz/scalaz-2.9.0-1-6.0/doc/#scalaz.Zero
[4] http://scalaz.github.com/scalaz/scalaz-2.9.0-1-6.0/doc.sxr/

Daniel Sobral

unread,
Jun 8, 2011, 11:57:23 AM6/8/11
to Martin S. Weber, scala...@googlegroups.com, Jason Zaugg

And so is Scaladoc. I find it curious that it doesn't show any
implementation -- probably because they are all anonymous classes. I'd
look at the implicits defined by scalaz.Scalaz.


--
Daniel C. Sobral

I travel to the future all the time.

Jason Zaugg

unread,
Jun 8, 2011, 12:32:39 PM6/8/11
to Martin S. Weber, scala-user
On Wed, Jun 8, 2011 at 6:02 PM, Martin S. Weber <martin...@nist.gov> wrote:
> You mean you grep for each way a Monoid could come to life? Looking at the
> sources of, say, Monoid itself doesn't tell me anything about its
> implementations. And, some portalfs aside, I can't grep the online sources
> either (yes yes I know I can download it, I just don't understand the value
> of the hyperlinked sources online for this kind of problem -- please
> enlighten me).

Type class instances M[T] are usually defined in the companion object
of M or T. Look at the sources/scaladoc for these in the first
instance. You need to know a bit about the structure of Scalaz to know
to look in Semigroup/Zero; but once you know the pattern you can apply
it to other type classes.

Another tool is the REPL, run implicitly[Monoid[String]] to check if
something is defined.

-jason

Heiko Seeberger

unread,
Jun 8, 2011, 1:45:19 PM6/8/11
to sca...@googlegroups.com, scala-user
Congrats! Great stuff.
What a pity I will miss your talk (Scala eXchange).

Heiko


--
You received this message because you are subscribed to the Google Groups "scalaz" group.
To post to this group, send email to sca...@googlegroups.com.
To unsubscribe from this group, send email to scalaz+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scalaz?hl=en.




--

Heiko Seeberger
Twitter: hseeberger
Blog: heikoseeberger.name
Company: Typesafe - Enterprise-Grade Scala from the Experts


Kevin Wright

unread,
Jun 8, 2011, 2:07:08 PM6/8/11
to sca...@googlegroups.com, scala-user
On 8 June 2011 18:45, Heiko Seeberger <heiko.s...@googlemail.com> wrote:
Congrats! Great stuff.
What a pity I will miss your talk (Scala eXchange).

Heiko


What! You wont be there?



--
Kevin Wright

gtalk / msn : kev.lee...@gmail.com
mail: kevin....@scalatechnology.com
vibe / skype: kev.lee.wright
quora: http://www.quora.com/Kevin-Wright
twitter: @thecoda

"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra

Ben Hutchison

unread,
Jun 9, 2011, 12:42:19 AM6/9/11
to Martin S. Weber, scala...@googlegroups.com, Jason Zaugg
On Thu, Jun 9, 2011 at 1:42 AM, Martin S. Weber <martin...@nist.gov> wrote:
> "Type Classes
> [...]
> A Monoid type class and (so many!) implementations"
>
> Uhm.. Is there any way to see from the scaladoc which implementations Monoid
> has? In other words, I don't want to see the linear supertypes of a
> class/trait in the scaladoc, I want to see its implementations.

Thats a good point. In typeclass-based code, typeclass instances are
close analogs to subclasses in object-oriented code.

Just as Scaladoc lists only "all known subclasses" in a given body of
code, surely it would be possible (in theory) to find and list "all
known typeclass instances" accessible from static/object scopes in
some given code?

-Ben

Ittay Dror

unread,
Jun 9, 2011, 2:00:59 AM6/9/11
to scala...@googlegroups.com, Jason Zaugg
A typeclass instance is always a subclass of the typeclass trait. So why
isn't it listed in scaladoc?


Ittay

Ben Hutchison

unread,
Jun 9, 2011, 2:20:16 AM6/9/11
to Ittay Dror, scala...@googlegroups.com, Jason Zaugg
On Thu, Jun 9, 2011 at 4:00 PM, Ittay Dror <ittay...@gmail.com> wrote:
> A typeclass instance is always a subclass of the typeclass trait. So why
> isn't it listed in scaladoc?

Yes, it will be listed, but not in the most useful place.

Eg Typeclass Equiv[Foo] is a subclass of Equiv, but so is Equiv[Bar].

But its when you have a Foo that you want to know all instances of
Equiv defined for Foos. Ie From Foo, find any/all Equiv[Foo], and from
Bar, find any/all Equiv[Bar].

-Ben

Ittay Dror

unread,
Jun 9, 2011, 3:03:10 AM6/9/11
to Ben Hutchison, scala...@googlegroups.com, Jason Zaugg
I tried seeing all subclasses of Monoid and scaladoc doesn't list any

Tony Morris

unread,
Jun 9, 2011, 3:06:38 AM6/9/11
to scala...@googlegroups.com
Consider:

implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
...
}

You're never going to see this "subclass" of Monoid, but you could come
to know that there exists an implicit value of the type Monoid[List] in
scope. One way to do this would be, at the REPL >
implicitly[Monoid[List[A]] // does this type-check?

It would be nice to know from where the implicit came from and I suppose
that is what -Xlog-implicits is for.


--
Tony Morris
http://tmorris.net/


Jason Zaugg

unread,
Jun 9, 2011, 3:54:48 AM6/9/11
to tmo...@tmorris.net, scala...@googlegroups.com
On Thu, Jun 9, 2011 at 9:06 AM, Tony Morris <tonym...@gmail.com> wrote:
> It would be nice to know from where the implicit came from and I suppose
> that is what -Xlog-implicits is for.

I use:

scala -Xprint:typer -e 'implicitly[Monoid[List[String]]'

REPL integration for this would be outstanding.

-jason

Ittay Dror

unread,
Jun 9, 2011, 4:51:18 AM6/9/11
to tmo...@tmorris.net, Tony Morris, scala...@googlegroups.com

Tony Morris wrote:

> On 09/06/11 17:03, Ittay Dror wrote:
>> I tried seeing all subclasses of Monoid and scaladoc doesn't list any
>>
>> Ben Hutchison wrote:
>>
>>> On Thu, Jun 9, 2011 at 4:00 PM, Ittay Dror<ittay...@gmail.com> wrote:
>>>> A typeclass instance is always a subclass of the typeclass trait. So
>>>> why
>>>> isn't it listed in scaladoc?
>>> Yes, it will be listed, but not in the most useful place.
>>>
>>> Eg Typeclass Equiv[Foo] is a subclass of Equiv, but so is Equiv[Bar].
>>>
>>> But its when you have a Foo that you want to know all instances of
>>> Equiv defined for Foos. Ie From Foo, find any/all Equiv[Foo], and from
>>> Bar, find any/all Equiv[Bar].
>>>
>>> -Ben
> Consider:
>
> implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
> ...
> }

Doesn't this mean there's an anonymous subclass of Monoid?

Maybe I assumed wrongly that scaladoc does things different than
javadoc. If so, perhaps it can be modified to use the presentation
compiler. Then it could get all subclasses of a class and maybe also
instances for context bounds.

Ittay

Kevin Wright

unread,
Jun 9, 2011, 4:58:05 AM6/9/11
to Ittay Dror, tmo...@tmorris.net, Tony Morris, scala...@googlegroups.com
On 9 June 2011 09:51, Ittay Dror <ittay...@gmail.com> wrote:


Tony Morris wrote:

On 09/06/11 17:03, Ittay Dror wrote:
I tried seeing all subclasses of Monoid and scaladoc doesn't list any

Ben Hutchison wrote:

On Thu, Jun 9, 2011 at 4:00 PM, Ittay Dror<ittay...@gmail.com>   wrote:
A typeclass instance is always a subclass of the typeclass trait. So
why
isn't it listed in scaladoc?
Yes, it will be listed, but not in the most useful place.

Eg Typeclass Equiv[Foo] is a subclass of Equiv, but so is Equiv[Bar].

But its when you have a Foo that you want to know all instances of
Equiv defined for Foos. Ie From Foo, find any/all Equiv[Foo], and from
Bar, find any/all Equiv[Bar].

-Ben
Consider:

implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
    ...
}
Doesn't this mean there's an anonymous subclass of Monoid?

Maybe I assumed wrongly that scaladoc does things different than javadoc. If so, perhaps it can be modified to use the presentation compiler. Then it could get all subclasses of a class and maybe also instances for context bounds.


Oh yes... The ability to show anonymous subclasses in Scaladoc would be amazingly useful.

 
Ittay


You're never going to see this "subclass" of Monoid, but you could come
to know that there exists an implicit value of the type Monoid[List] in
scope. One way to do this would be, at the REPL>
implicitly[Monoid[List[A]] // does this type-check?

It would be nice to know from where the implicit came from and I suppose
that is what -Xlog-implicits is for.


Matthew Pocock

unread,
Jun 9, 2011, 5:28:32 AM6/9/11
to Ittay Dror, tmo...@tmorris.net, Tony Morris, scala...@googlegroups.com
Consider:

implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
    ...
}
Doesn't this mean there's an anonymous subclass of Monoid?


An interesting more general case would be:

implicit def x[A, X[_]](implicit ma: Monoid[A]): Monoid[X[A]]  = new Monoid[X[A]] { ... }

for some restricted X.

I'm not sure how you would document this, or even where, in the scaladoc/javadoc paradigm. Perhaps on Monoid, or the restriction of X. I'm not sure how this could be even tackled without something like a scala hoogle integrated with the scaladoc.

Matthew

--
Matthew Pocock
(0191) 2566550

Ben Hutchison

unread,
Jun 9, 2011, 7:31:52 AM6/9/11
to Martin S. Weber, scala...@googlegroups.com, Jason Zaugg
Some clarification & elaboration follows...

On Thu, Jun 9, 2011 at 2:42 PM, Ben Hutchison <brhut...@gmail.com> wrote:
In typeclass-based code, typeclass instances are
> close analogs to subclasses in object-oriented code.

The above statement was penned in haste and contains an error: rather,
typeclass instances are
analogs to *superclasses* (or mixin traits) in object-oriented code.

For example, if I have an instance Monoid[Foo], there is an
(imperfect) analogy to mixing in a Monoid trait to my Foo class in the
OO- style of composition. I.e. In both cases, I can operate upon over
Foo using the operations defined by Monoid.

>
> Just as Scaladoc lists only "all known subclasses" in a given body of
> code, surely it would be possible (in theory) to find and list "all
> known typeclass instances" accessible from static/object scopes in
> some given code?

As it was probably unclear, by "static/object scope" above, I meant
"global scope". Ie typeclass instances defined in scala objects, and
thus accessible without being in any particular sub-context.

Anyway, on consideration, I think the problem of documenting
typeclasses is rather different to subclasses. Typeclasses are
available within some context or scope, whereas a subclass is always a
subclass regardless of scope. When one asks "what typeclasses are
defined?", the question is posed relative to a location in code, as
its affected by current package, imports and enclosing expressions.

This means, in terms of Scaladoc, that we cant give /one/ complete
answer to what typeclasses are available for a given type, as the
answer varies from line to line in the code. Probably though,
reporting all those importable from a global scope would still be very
useful.

-Ben

Dave

unread,
Jun 9, 2011, 8:16:42 AM6/9/11
to scala-user
Great library. I also like the support for math symbols although REPL
and the Windows 7 Console is not displaying them well.
In the REPL I have for the "kleisli" (star symbol ☆) a question mark
(?) and in the Windows console when I copy this utf-8 character it
looks like a small square.
This also happens with the "any" (∃) symbol. I know there is an issue
with Windows displaying certain utf-8 characters well, but is it
possible to make the REPL display them right? The displayed question
mark in the REPL is accepted by the REPL so it is just a displaying
thing.

package kleisli2
import scalaz._
import scalaz.Scalaz._

object Main extends App {

val f = ☆((n: Int) => if (n % 2 == 0) None else Some((n +
1).toString))
val g = ☆((s: String) => if (List(3, 7) ∃ (_ == s.length)) None
else Some("[" + s + "]"))
val h = ☆((s: String) => if (s == "[8]") None else Some("<" + s +
">"))

// Kleisli composition
(List(7, 78, 98, 99, 100, 102, 998, 999, 10000) map (f >=> g >=> h
apply _)) assert_=== List(None, None, None, None, None, None, None,
Some("<[1000]>"), None)


println((List(7, 78, 98, 99, 100, 102, 998, 999, 10000) map (f >=>
g >=> h apply _)))
println((List(7, 78, 98, 99, 100, 102, 998, 999, 10000) map ((f
>=> g) >=> h apply _)))
println((List(7, 78, 98, 99, 100, 102, 998, 999, 10000) map (f >=>
(g >=> h) apply _)))
println("should all be equal")
println("List(None, None, None, None, None, None, None,
Some(<[1000]>), None)")
}

Jason Zaugg

unread,
Jun 9, 2011, 8:30:44 AM6/9/11
to Dave, scala-user
On Thu, Jun 9, 2011 at 2:16 PM, Dave <dave.mah...@hotmail.com> wrote:
> Great library. I also like the support for math symbols although REPL
> and the Windows 7 Console is not displaying them well.

I've never had any luck using non-ASCII characters in Windows XP
console, or java terminal programs launched within.

-jason

Reply all
Reply to author
Forward
0 new messages