I've been playing around with scalaz-stream topics, and didn't understand how they worked. My first attempt was this:
(And note that this was supposed to be just a quick example; you certainly would end up with different threads publishing and subscribing to a topic.)
That had a few problems:
• Line 7-8: the type of out1 is Process[Task, String \/ Int]. Those are useful, but they're only part of the way towards what I needed. What I really wanted was to go from a process to a task to running the task.
• Line 11-13: again, I'm only part of the way there. Both of these produce Task[Unit], and they needed to be run.
So I asked for help on the scalaz mailing list, and Pavel Chlupáček pointed me in the right direction.
The working version is:
• Lines 6-8 produce a Task[IndexedSeq[String \/ Int]], one step further than in the first version (where the steps are process >> task >> run the task).
• Lines 10-12 actually run the task - and anything published before the attemptRun won't be seen by the subscriber.
• Line 19 stalls, waiting for the attemptRun to hook up the subscriber. (As the note says, I think this is only something you'd do for a demo).
• Lines 21-22 actually run the tasks they create
Saturday, May 17, 2014
Sunday, April 27, 2014
AndroidProguardScala 51 released - supports 2.11
I just released v 51 of AndroidProguardScala, the Eclipse plugin for Scala + Android development.
The release adds support for Scala 2.11 (including the 3.x.x and 4.x.x branches of the Scala IDE).
Install instructions are here.
The release adds support for Scala 2.11 (including the 3.x.x and 4.x.x branches of the Scala IDE).
Install instructions are here.
Saturday, January 4, 2014
Using ruby to explore scalaz
I've been poking around scalaz, and sometimes it's nice to just get a quick overview of the code using some simple ruby. I could write some code using asm to look at the bytecode, but it's usually faster for me to just use ruby on the source. I'm not looking for 100%-complete tested code here, it's more like a very fancy grep.
For example, I was curious about all the places that define functions starting with lift:
And then to read the output, I use a google spreadsheet:
Run with:
For example, I was curious about all the places that define functions starting with lift:
And then to read the output, I use a google spreadsheet:
Run with:
find * -name *.scala -type f -print0 | xargs -0 ruby lift.rb | pbcopy
pbcopy is the mac utility that copies stdout to the clipboard, so it's fast to run this from the command line, switch to the spreadsheet, and hit paste.
Subscribe to:
Posts (Atom)