Vlad Patryshev | 1 Aug 2009 03:43
Picon
Gravatar

is ∃f monadic?!

Hi,


I never thought of it before, but it seems like ∃f functor is actually monadic (making it pretty legal for Scala Set to be covariant, in a way). Can anybody please say I am wrong?

--
Thanks,
-Vlad
Parth Malwankar | 1 Aug 2009 03:46
Picon

Re: compiler exception java.lang.reflect.InvocationTargetException while using scalatest with maven

I have uploaded the sample project here:
http://www.parthm.org/foo.tar.gz

Untarring and running "mvn test" should produce the same error.

Some more details in case it matters:
[~]% java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu10)
OpenJDK Client VM (build 14.0-b08, mixed mode, sharing)
[~]% mvn -version
Maven version: 2.0.9
Java version: 1.6.0_0
OS name: "linux" version: "2.6.28-14-generic" arch: "i386" Family: "unix"

I am on ubuntu 9.04.

"mvn -X test" show the plugin version to be
"org.scala-tools:maven-scala-plugin:2.11"
Full output: http://pastebin.com/m23589560

Also, I noticed that the doc command doesn't see to
be working with this version of the plugin.

[foo]% mvn scala:doc
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'scala'.
[INFO] org.apache.maven.plugins: checking for updates from scala-tools.org
[INFO] org.codehaus.mojo: checking for updates from scala-tools.org
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Required goal not found: scala:doc in
org.scala-tools:maven-scala-plugin:2.11
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Sat Aug 01 07:13:10 IST 2009
[INFO] Final Memory: 4M/7M
[INFO] ------------------------------------------------------------------------
[foo]%

On Sat, Aug 1, 2009 at 2:43 AM, Kevin
Wright<kev.lee.wright <at> googlemail.com> wrote:
> Odd... any chance you can post the full maven output?
>
> Also, nice use of pastebin there! I've never seen the site before but can
> see myself using it a lot in the future :)
>
>
> On Fri, Jul 31, 2009 at 3:30 PM, Parth Malwankar <parth.malwankar <at> gmail.com>
> wrote:
>>
>> On Fri, Jul 31, 2009 at 7:34 PM, Kevin
>> Wright<kev.lee.wright <at> googlemail.com> wrote:
>> > I can confirm that
>> > org.scala_tools.maven.executions.MainHelper
>> > is a class from maven-scala-plugin
>> >
>> > What version of the plugin are you using?
>> >
>> >
>>
>> Thanks Kevin.
>> I used "mvn archetype:generate" to generate the project right now (the
>> trace
>> is from a test project I generated just before the mail to narrow down
>> the error).
>> So I suppose its using the default version (2.10?).
>> Is there a way for me to check this?
>>
>> I have posted the generated pom.xml here: http://pastebin.com/f4fb6eca4
>>
>> You are right, this exception seems to be from the plugin.
>> A little further down in the full exception trace[1] it says:
>>
>> Caused by: java.lang.Error: Unknown type: ()java.lang.Class
>>        at scala.tools.nsc.Global.abort(Global.scala:153)
>>        at
>> scala.tools.nsc.backend.icode.TypeKinds$class.toTypeKind(TypeKinds.scala:453)
>>        at scala.tools.nsc.backend.icode.ICodes.toTypeKind(ICodes.scala:21)
>>
>> I got mixed up between the two.
>>
>> Regards,
>> Parth
>> [1] http://pastebin.com/f29b5b6ad
>>
>>
>> >
>> > On Fri, Jul 31, 2009 at 2:40 PM, Parth Malwankar
>> > <parth.malwankar <at> gmail.com>
>> > wrote:
>> >>
>> >> Hello,
>> >>
>> >> I am somewhat new to maven and scalatest so I may be doing
>> >> something wrong here and would appreciate any help.
>> >>
>> >> I created a scala project using maven-scala-plugin.
>> >> In order to added a test using scalatest I added the following
>> >> dependency to pom.xml:
>> >>
>> >>    <dependency>
>> >>      <groupId>org.scala-tools.testing</groupId>
>> >>      <artifactId>scalatest</artifactId>
>> >>      <version>0.9.5</version>
>> >>      <scope>test</scope>
>> >>    </dependency>
>> >>
>> >> And the simple test below:
>> >>
>> >> package foo
>> >>
>> >> import org.scalatest.Suite
>> >>
>> >> class FooTest extends Suite {
>> >>  def testFooA() {
>> >>    val foo = 1
>> >>    assert(foo === 1)
>> >>  }
>> >>
>> >>  def testFooB() {
>> >>    val foo = 1
>> >>    assert(foo === 1)
>> >>  }
>> >> }
>> >>
>> >> Running "mvn test" now produces the following error:
>> >>
>> >> java.lang.reflect.InvocationTargetException
>> >>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> >>        at
>> >>
>> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> >>        at
>> >>
>> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> >>        at java.lang.reflect.Method.invoke(Method.java:616)
>> >>        at
>> >>
>> >> org.scala_tools.maven.executions.MainHelper.runMain(MainHelper.java:105)
>> >>
>> >> Full trace here: http://pastebin.com/f29b5b6ad
>> >>
>> >> I am on scala 2.7.5.
>> >>
>> >> Thanks,
>> >> Parth
>> >
>> >
>
>

Viktor Klang | 1 Aug 2009 18:16
Picon

Re: [scala] is ∃f monadic?!



On Sat, Aug 1, 2009 at 3:43 AM, Vlad Patryshev <vpatryshev <at> gmail.com> wrote:
Hi,

I never thought of it before, but it seems like ∃f functor is actually monadic (making it pretty legal for Scala Set to be covariant, in a way). Can anybody please say I am wrong?

You're wrong?
Happy?
 

--
Thanks,
-Vlad



--
Viktor Klang

Rogue Scala-head

Blog: klangism.blogspot.com
Twttr: viktorklang
Ingo Maier | 1 Aug 2009 19:14
Picon
Picon
Favicon

Re: [swing] Mouse events not working

1.) you should listenTo(mouse.clicks, mouse.moves). See

https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/swing/test/LinePainting.scala

2.) if you don't care about modifiers, you should do:

case MouseEntered(c,p,_) => ...

3.) that's a pretty old version you are using. Try trunk or a nightly 
first to see whether a bug has been fixed in the meanwhile.

Ingo

On 7/31/09 11:31 AM, qwerky wrote:
> Scala 2.7.4, Java SE 1.6.0-12b04, Debian Lenny
>
> Mouse events not catching in BoxPanel reactions, but resize event works :
>
> class Document(t:(String)=>String, logger:Logged) extends SplitPane with
> IntrospectableAttributes {
>      orientation = Orientation.Vertical
>      resizeWeight = 0.2
>
>      leftComponent = new BoxPanel(Orientation.Vertical) {
>          reactions += {
>              case ComponentResized(s) =>
>                  println("Resized")
>              case MouseEntered(c,p,AWTEvent.MOUSE_MOTION_EVENT_MASK) =>
>                  println("Entered")
>              case MouseClicked(s,p,AWTEvent.MOUSE_EVENT_MASK,c,false) =>
>                  println("Clicked")
>              case _ =>
>          }
>      }
>      rightComponent = new BoxPanel(Orientation.Vertical)
> }
>
> What wrong ?
>

Meredith Gregory | 1 Aug 2009 22:10
Picon
Gravatar

Re: [scala] Re: [scala] is ∃f monadic?!

Vlad,

To identify a monad you to say at least what the category is and the action of the endofunctor. Is the category the one in which the objects are formulae and the morphisms are proofs? Already that's a bit problematic. Maybe the objects are pairs (formula,variable)? Anyway, once you say what the set up is, you only need to supply the unit and mult natural isomorphisms and then check coherence.

More formally, a monad is a triple consisting of

  • an endofunctor, T : C -> C
  • a natural transformation unit : C -> TC
  • a natural transformation mult : TTC -> TC
You need to check that
  • T mult ; mult = mult T; mult
    • if T is an analog of a compositing operation, this is the analog of associativty
  • unit T; mult = T unit; mult
    • if T is an analog of a compositing operation, this is the analog of specifying an identity element
Your job, should you chose to accept it, is to say what the category, unit and mult are -- since you've already given the candidate endofunctor -- and check those conditions. You might find this reference helpful.

Best wishes,

--greg

On Sat, Aug 1, 2009 at 9:16 AM, Viktor Klang <viktor.klang <at> gmail.com> wrote:


On Sat, Aug 1, 2009 at 3:43 AM, Vlad Patryshev <vpatryshev <at> gmail.com> wrote:
Hi,

I never thought of it before, but it seems like ∃f functor is actually monadic (making it pretty legal for Scala Set to be covariant, in a way). Can anybody please say I am wrong?

You're wrong?
Happy?
 

--
Thanks,
-Vlad



--
Viktor Klang

Rogue Scala-head

Blog: klangism.blogspot.com
Twttr: viktorklang



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com
qwerky | 1 Aug 2009 23:07
Picon

Re: [swing] Mouse events not working


Ingo Maier-3 wrote:
> 
> 1.) you should listenTo(mouse.clicks, mouse.moves). See
> https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/swing/test/LinePainting.scala
> 
maybe Mouse.clicks, Mouse.moves ? i can't find where mouse.clicks,
mouse.moves, keys located...

--

-- 
View this message in context: http://www.nabble.com/-swing--Mouse-events-not-working-tp24753614p24772700.html
Sent from the Scala mailing list archive at Nabble.com.

Blair Zajac | 2 Aug 2009 00:58
Favicon

[ANNOUNCE] Scala Migrations 0.9.0

Scala Migrations is a library to manage upgrades and rollbacks to 
database schemas.  Migrations allow a source control system to manage 
together the database schema and the code using the schema.  It is 
designed to allow multiple developers working on a project with a 
database backend to design schema modifications independently, apply the 
migrations to their local database for debugging and when complete, 
check them into a source control system to manage as one manages normal 
source code.  Other developers then check out the new migrations and 
apply them to their local database.  Finally, the migrations are used to 
migrate the production databases to the latest schema version.

The package is based off Ruby on Rails Migrations and in fact shares the 
exact same schema_migrations table to manage the list of installed 
migrations.  The Scala Migrations library is written in Scala and makes 
use of the clean Scala language to write easy to understand migrations, 
which are also written in Scala.  Scala Migrations provides a database 
abstraction layer that allows migrations to target any supported 
database vendor.

http://code.google.com/p/scala-migrations/
http://scala-migrations.googlecode.com/files/scala-migrations-0.9.0.jar

As a personal note, this is one of the first projects we got to 
open-source at Sony.  It took six months of work by the technical and 
legal teams at Imageworks, which is part of Sony Pictures, to go all the 
way to Sony Japan to get buyoff and approval for this.  Hopefully we'll 
see more projects in the future being open-sourced.

A sample Scala migration looks like

class Migrate_20081118201742_CreatePeopleTable
   extends Migration
{
   def up() : Unit =
   {
     createTable("people") { t =>
       t.varbinary("pk_people", PrimaryKey, Limit(16))
       t.varbinary("pk_location", Limit(16), NotNull)
       t.integer("employee_id", Unique)
       t.integer("ssn", NotNull)
       t.varchar("first_name", Limit(255), NotNull,
                 CharacterSet(Unicode))
       t.char("middle_initial", Limit(1), Nullable,
              CharacterSet(Unicode))
       t.varchar("last_name", Limit(255), NotNull, CharacterSet(Unicode))
       t.timestamp("birthdate", Limit(0), NotNull)
       t.smallint("height", NotNull, Check("height > 0"))
       t.smallint("weight", NotNull, Check("weight > 0"))
       t.integer("vacation_days", NotNull, Default("0"))
       t.bigint("hire_time_micros", NotNull)
       t.decimal("salary", Precision(7), Scale(2), Check("salary > 0"))
       t.blob("image")
     }

     addIndex("people", "ssn", Unique)

     addForeignKey(on("people" -> "pk_location"),
                   references("location" -> "pk_location"),
                   OnDelete(Cascade),
                   OnUpdate(Restrict))

     addCheck(on("people" -> "vacation_days"), "vacation_days >= 0")
   }

   def down() : Unit =
   {
     dropTable("people")
   }
}

And to install all migrations on a database:

object Test
{
   def main(args: Array[String]) : Unit = {
     val driver_class_name = "org.postgresql.Driver"
     val vendor = Vendor.forDriver(driver_class_name)
     val migration_adapter = DatabaseAdapter.forVendor(vendor, None)
     val data_source: javax.sql.DataSource = ...
     val migrator = new Migrator(data_source, migration_adapter)

     // Now apply all migrations that are in the
     // com.imageworks.vnp.dao.migrations package.
     migrator.migrate(InstallAllMigrations,
                      "com.imageworks.vnp.dao.migrations",
                      false)
   }
}

Regards,
Blair

Vlad Patryshev | 2 Aug 2009 09:07
Picon
Gravatar

Re: [scala] Re: [scala] is ∃f monadic?!

Hi,


I know what a monad is; and yes, the issue is - which category. I was not talking about formulae and proofs, I meant a general elementary topos. It should be a good environment for modeling.

2009/8/1 Meredith Gregory <lgreg.meredith <at> gmail.com>
Vlad,

To identify a monad you to say at least what the category is and the action of the endofunctor. Is the category the one in which the objects are formulae and the morphisms are proofs? Already that's a bit problematic. Maybe the objects are pairs (formula,variable)? Anyway, once you say what the set up is, you only need to supply the unit and mult natural isomorphisms and then check coherence.

More formally, a monad is a triple consisting of
  • an endofunctor, T : C -> C
  • a natural transformation unit : C -> TC
  • a natural transformation mult : TTC -> TC
You need to check that
  • T mult ; mult = mult T; mult
    • if T is an analog of a compositing operation, this is the analog of associativty
  • unit T; mult = T unit; mult
    • if T is an analog of a compositing operation, this is the analog of specifying an identity element
Your job, should you chose to accept it, is to say what the category, unit and mult are -- since you've already given the candidate endofunctor -- and check those conditions. You might find this reference helpful.

Best wishes,

--greg


On Sat, Aug 1, 2009 at 9:16 AM, Viktor Klang <viktor.klang <at> gmail.com> wrote:


On Sat, Aug 1, 2009 at 3:43 AM, Vlad Patryshev <vpatryshev <at> gmail.com> wrote:
Hi,

I never thought of it before, but it seems like ∃f functor is actually monadic (making it pretty legal for Scala Set to be covariant, in a way). Can anybody please say I am wrong?

You're wrong?
Happy?
 

--
Thanks,
-Vlad



--
Viktor Klang

Rogue Scala-head

Blog: klangism.blogspot.com
Twttr: viktorklang



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com



--
Thanks,
-Vlad
Ingo Maier | 2 Aug 2009 09:40
Picon
Picon
Favicon

Re: [swing] Mouse events not working

This is on trunk. The Mouse object has been deprecated in favor of mouse 
there.

Ingo

On 8/1/09 11:07 PM, qwerky wrote:
>
>
> Ingo Maier-3 wrote:
>> 1.) you should listenTo(mouse.clicks, mouse.moves). See
>> https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/swing/test/LinePainting.scala
>>
> maybe Mouse.clicks, Mouse.moves ? i can't find where mouse.clicks,
> mouse.moves, keys located...
>

John Nilsson | 2 Aug 2009 10:45
Picon

Re: [ANNOUNCE] Scala Migrations 0.9.0

Given that "It is not a goal of Scala Migrations to check and report
on the compatibility of a Scala Migrations specific feature with a
database."

What is the benefit of wrapping the SQL in all those methods instead
of just Strings?

BR,
John

On Sun, Aug 2, 2009 at 12:58 AM, Blair Zajac<blair <at> imageworks.com> wrote:
> Scala Migrations is a library to manage upgrades and rollbacks to database
> schemas.  Migrations allow a source control system to manage together the
> database schema and the code using the schema.  It is designed to allow
> multiple developers working on a project with a database backend to design
> schema modifications independently, apply the migrations to their local
> database for debugging and when complete, check them into a source control
> system to manage as one manages normal source code.  Other developers then
> check out the new migrations and apply them to their local database.
>  Finally, the migrations are used to migrate the production databases to the
> latest schema version.
>
> The package is based off Ruby on Rails Migrations and in fact shares the
> exact same schema_migrations table to manage the list of installed
> migrations.  The Scala Migrations library is written in Scala and makes use
> of the clean Scala language to write easy to understand migrations, which
> are also written in Scala.  Scala Migrations provides a database abstraction
> layer that allows migrations to target any supported database vendor.
>
> http://code.google.com/p/scala-migrations/
> http://scala-migrations.googlecode.com/files/scala-migrations-0.9.0.jar
>
> As a personal note, this is one of the first projects we got to open-source
> at Sony.  It took six months of work by the technical and legal teams at
> Imageworks, which is part of Sony Pictures, to go all the way to Sony Japan
> to get buyoff and approval for this.  Hopefully we'll see more projects in
> the future being open-sourced.
>
> A sample Scala migration looks like
>
> class Migrate_20081118201742_CreatePeopleTable
>  extends Migration
> {
>  def up() : Unit =
>  {
>    createTable("people") { t =>
>      t.varbinary("pk_people", PrimaryKey, Limit(16))
>      t.varbinary("pk_location", Limit(16), NotNull)
>      t.integer("employee_id", Unique)
>      t.integer("ssn", NotNull)
>      t.varchar("first_name", Limit(255), NotNull,
>                CharacterSet(Unicode))
>      t.char("middle_initial", Limit(1), Nullable,
>             CharacterSet(Unicode))
>      t.varchar("last_name", Limit(255), NotNull, CharacterSet(Unicode))
>      t.timestamp("birthdate", Limit(0), NotNull)
>      t.smallint("height", NotNull, Check("height > 0"))
>      t.smallint("weight", NotNull, Check("weight > 0"))
>      t.integer("vacation_days", NotNull, Default("0"))
>      t.bigint("hire_time_micros", NotNull)
>      t.decimal("salary", Precision(7), Scale(2), Check("salary > 0"))
>      t.blob("image")
>    }
>
>    addIndex("people", "ssn", Unique)
>
>    addForeignKey(on("people" -> "pk_location"),
>                  references("location" -> "pk_location"),
>                  OnDelete(Cascade),
>                  OnUpdate(Restrict))
>
>    addCheck(on("people" -> "vacation_days"), "vacation_days >= 0")
>  }
>
>  def down() : Unit =
>  {
>    dropTable("people")
>  }
> }
>
> And to install all migrations on a database:
>
> object Test
> {
>  def main(args: Array[String]) : Unit = {
>    val driver_class_name = "org.postgresql.Driver"
>    val vendor = Vendor.forDriver(driver_class_name)
>    val migration_adapter = DatabaseAdapter.forVendor(vendor, None)
>    val data_source: javax.sql.DataSource = ...
>    val migrator = new Migrator(data_source, migration_adapter)
>
>    // Now apply all migrations that are in the
>    // com.imageworks.vnp.dao.migrations package.
>    migrator.migrate(InstallAllMigrations,
>                     "com.imageworks.vnp.dao.migrations",
>                     false)
>  }
> }
>
> Regards,
> Blair
>
>


Gmane