> People have complained about the lack of documentation for Scalaz, but what
I've found myself craving, quite terribly, is a *course* in it
Hi Justin,
We (scalaz) are working on a book as well as material for a course. Hopefully
we'll have something to show you by the end of the year.
Rúnar
We (scalaz) are working on a book as well as material for a course. Hopefullywe'll have something to show you by the end of the year.
;-)
I can say that I have also poured many hours into reverse-engineering
Scalaz trying to understand the concepts behind the library. The
file-names alone imply a daunting reading list.
Although a book/course is fantastic, in the mean time something as
simple as a few A/B examples would greatly help.
Example A: Problem X with solution written in traditional idiomatic
Scala (+ optionally Java stuff thrown in there)
<series of intervening transformative steps>
Example B: Problem X with solution expressed in terms of functionality
obtained from the Scalaz library
--
Jim Powers
If its written like the Iteratees intro then I see some very cool
learning and "aha" moments ahead. I had a fuzzy warm feeling about
what I wanted from them and that post clinched it for me, a question
or two on the scalaz list and I now have a lovely xmlpull system based
on iteratees.
If Jason is participating in this then I'm happy to review chunks over
beers (paypal beer tokens could also be provided for those not living
in Züri :-) )
--
Tony Morris
http://tmorris.net/
If you look into it, you will also notice that parts of this material
are ported to Scala.
My personal opinion is that it is somewhere near impossible to use Scala
to come to understand functional programming and advanced programming
concepts. I wish it weren't true, but repeated experience has taught me
to accept otherwise.
Same here, except I haven't tried (yet?) to learn Scalaz at all, but have some difficulty
to grasp the glimpses of (advanced?) functional programming I see here and there.
> It's rich in jargon -- and worse, rich in symbols that
> I have no idea how to pronounce (it is just plain harder to learn a symbol if I can't
> verbalize it)
Here, I can give a trick, perhaps.
I searched scalaz samples, and took the first link in Google:
http://scalaz.googlecode.com/svn/continuous/latest/browse.sxr/scalaz/example/ExampleArrow.scala.html#22697
At least the code is clean, with some syntax highlighting and, more importantly,
hyperlinks on all identifiers.
I see the symbol ★ which I can identify (with BabelMap) as \u2605 and which I can name per
its Unicode name, BLACK STAR.
But I can also click on it, go to
http://scalaz.googlecode.com/svn/continuous/latest/browse.sxr/scalaz/Cokleisli.scala.html#25504
and see it has an alias:
def cokleisli[W[_], A, B](f: W[A] => B): Cokleisli[W, A, B] = ★(f)
So, if I understand correctly, we should name this operator "cokleisli".
(I hope I got it right...)
Now, if you have a static version of the code (plain text editor, on paper...), there is
more trouble...
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
My personal opinion is that it is somewhere near impossible to use Scala
to come to understand functional programming and advanced programming
concepts.
I teach advanced programming concepts for my employer, voluntarily and
occasionally at tertiary institutions. I use haskell for teaching and
recently open-sourced (BSD3) the material that I use.
https://bitbucket.org/dibblego/haskell-course/
My personal opinion is that it is somewhere near impossible to use Scala
to come to understand functional programming and advanced programming
concepts. I wish it weren't true, but repeated experience has taught me
to accept otherwise.
My personal opinion is that it is somewhere near impossible to use Scala
to come to understand functional programming and advanced programming
concepts. I wish it weren't true, but repeated experience has taught me
to accept otherwise.
Assuming that your goal is to explore pure functional programming (and
without debating whether or not this is a worthy goal), it's clear
that a language like Haskell, which doesn't have language features
extraneous to this approach, can provide a more focussed learning
environment.
But personally, I've certainly learnt a lot about functional
programming through Scalaz; and through Functional Java before it. So
it's certainly possible! But I know that I'm only scratching the
surface, and some language imposed barriers do prevent convenient
exploration of more advanced topics.
=Type Inference=
The type inferencer in Scala has a lot more work to do that its
Haskell counterpart, thanks to subtyping. Higher Kinded types (e.g.
List rather than List[Int]) can be inferred in some circumstances
since Scala 2.8. But there are cases when you have to explicitly
provide the type arguments. As I've slowly digested the excellent
"Essence of the Iterator Pattern", I've tried to implement part of the
Word Count example in Scalaz [1]. But the essense of the example is
quickly obscured by explicit type arguments!
=Implicit Search=
There have been a few papers written about the way that Scala can
encode type classes with implicit parameters. But none deeply address
the conflicts that arise with using type classes and subtyping in
combination.
* type classes are resolved based on the static type, and can defy
expectations based on polymorphic dispatch. What should this return?
implicitly[Equal[Iterable[Int]]].===(LinkedHashSet(1, 2),
LinkedHashSetSet(2, 1))
* contravariant implicit search prefers Ordering[Any] over Ordering[X]
=Strict-by-default Evaluation=
Many algorithms are elegantly expressed in a lazy evaluation model.
Scala provides optional laziness, indeed I just implemented LazyOption
in Scalaz. But the default evaluation mode is pervasive, and it's hard
to push the boundaries of lazy evaluation through your program. For
example, using LazyOption#map [2] we can:
val opt = LazyOption.some[Int](error(""))
LazyOption.some(error("")).map(_ => 0) // LazySome(0)
But not:
implicitly[Functor[LazyOption[Int]].fmap(opt, _ => 0)
It's just a toy example, and by no means motivates the usefulness of
lazy evaluation. But it does show that to support laziness for this
type, we would need to change the the signature of Functor, and all
the implementations thereof. Similar issues exist for Stream in
collection: it's a lazy structure that always feels awkward in a
strict world.
Do these problems signal design failures in Scala? Not at all, as
Martin wrote, becoming a perfect place for the Haskell-like functional
programming wasn't in it's charter. Lazy evaluation isn't generally
agreed to be superior, and brings it's own set of problems, and
doesn't work well on the JVM, so it's hard to criticise the direction
Scala chose here.
It's actually fairly amazing that Scala allows us to go as far as we
do in this direction! I'm hopeful that some of the issues with
implicits and type inference can be mitigated in the future.
-jason
[1] https://github.com/scalaz/scalaz/blob/master/example/src/main/scala/scalaz/example/WordCount.scala#L11
[2] https://github.com/scalaz/scalaz/blob/master/core/src/main/scala/scalaz/LazyOption.scala#L21
or, say, CAL if we're stuck on the JVM.
http://en.wikipedia.org/wiki/Quark_Framework#CAL
sincerely.
Let's face it: If classical FP was so great for component-based programming, it would have taken the world over by now. But fact is it hasn't.
What's more, the real-world programs I have seen in Haskell left me unimpressed in what concerns their modularity and composability (not the small examples; they are beautiful, but they tend to be hard to scale). That's my impression from what I have seen, but YMMV. In any case, FP is no silver bullet here; it makes it harder than necessary to do recursive dependencies, partial abstractions, or first class components that can be wired at run-time. You can do all that, and some people have fun doing it, but at least for my eyes it's just too hard.
Again, YMMV. If you enjoy exploring this new branch of FP (there are many others), by all means do so. You'll learn a lot. But don't feel inferior or left out if you decide it's not for you.
--
Tony Morris
http://tmorris.net/
I first started teaching functional programming with Scala in 2007. I
have become quite convinced that Scala alone does not give you this
required understanding to any satisfactory degree. That is to say, I
have tried with different students, teachers and tools and it is
consistently repeatable that Scala is the culprit in slowing progress
down. I know a few of my students from around 2008/2009 lurk on these
mailing lists, but probably won't speak up because they are quiet --
perhaps they can offer their point of view though. In any case, I can
point to countless examples of this manifesting itself.
In any case, I don't think it was ever intended for Scala to be used to
teach functional programming. However, I once thought I could exploit
Scala's other design goals (Java-like syntax, compile to .class, etc.),
but I have been forced to change my mind that this is possible.
I first started teaching functional programming with Scala in 2007. Ihave become quite convinced that Scala alone does not give you this
required understanding to any satisfactory degree. That is to say, I
have tried with different students, teachers and tools and it is
consistently repeatable that Scala is the culprit in slowing progress
down. I know a few of my students from around 2008/2009 lurk on these
mailing lists, but probably won't speak up because they are quiet --
perhaps they can offer their point of view though. In any case, I can
point to countless examples of this manifesting itself.
Thanks,
Eric
On Thursday, March 17, 2011, Kristian Domagala
PHP didn't has major marketing (AFAIK) but spread because of these "qualities".
Point certainly taken. I was going to mention things like PHP, Ruby, Python, etc., but the setup for my questions was already unwieldy and long.
--
Jim Powers
Taking over the world is certainly not a criterion for technical quality,
On Fri, Mar 18, 2011 at 12:05 PM, Philippe Lhoste <Phi...@gmx.net> wrote:Taking over the world is certainly not a criterion for technical quality,Huh? I think that your email led me to the opposite conclusion. PHP won (and is winning) market share because of a pure technical quality - (1) it is easy to deploy, even with shared hosting (2) it is easy to convert static HTML pages to php, so that you very rapidly take a designed HTML webpage and shove there some minor dynamic content.
The fact that it's a bad language is a compromise, they made a very simple language so that it'll be easy to port it and to support backwards compatibility. With a more advance language like scala, porting it to other platforms is a much more complicated task.
I hate PHP with passion, but I chose it many times for clients because it is dead-easy to deploy, and it is so portable and backward compatible that they'll be able to run it forever wherever they want. I had a customer with a rails-based website which broke every other Monday since her shared-ISP upgraded their rails stack and everything broke. She didn't care how monadic the website design was, she just wanted never to look at the website design again after it is complete.
This is an important point that many people miss. The technical quality of the pure language is rarely the technical quality you should notice. Bad language with a third party libraries that you really need, is way better than excellent language where you'll have to re-implement it yourself, or too choose one of many half-baked libraries.