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
...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
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/
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.
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
--
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.
Congrats! Great stuff.What a pity I will miss your talk (Scala eXchange).Heiko
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
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
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/
I use:
scala -Xprint:typer -e 'implicitly[Monoid[List[String]]'
REPL integration for this would be outstanding.
-jason
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
Doesn't this mean there's an anonymous subclass of Monoid?
Tony Morris wrote:
On 09/06/11 17:03, Ittay Dror wrote:
I tried seeing all subclasses of Monoid and scaladoc doesn't list anyConsider:
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. SoYes, it will be listed, but not in the most useful place.
why
isn't it listed in scaladoc?
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
implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
...
}
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
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.
Doesn't this mean there's an anonymous subclass of Monoid?Consider:
implicit def x[a]: Monoid[List[A]] = new Monoid[List[A]] {
...
}
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
I've never had any luck using non-ASCII characters in Windows XP
console, or java terminal programs launched within.
-jason