Combining / Concatenating Two PathSet

25 views
Skip to first unread message

Randall R Schulz

unread,
Mar 14, 2013, 2:42:25 PM3/14/13
to scala-i...@googlegroups.com
Hello,

I would like to take two PathSet and join / concatenate them prior to applying take(n: Int) and then toSeq.

How can I do that? The code I have won't compile because of a type mismatch:

  val batchPaths =
    trashDirs.foldLeft(PathSet[Path]()) { (pathSet, trashPath: Path) =>
      val
eligible = eligibleInDir(trashPath, perDirLimit)
      newlyEncountered ++= namesToTrack
      pathSet ++ eligible
    }


The compiler complains thusly about the line shown in red above:

[error]  found   : scalax.file.PathSet[scalax.file.Path]
[error]  required: scalax.file.BasicPathSet[scalax.file.Path]
[error]           pathSet ++ eligible
[error]                   ^




Randall Schulz

Randall R Schulz

unread,
Mar 14, 2013, 2:46:18 PM3/14/13
to scala-i...@googlegroups.com

I should have said that eligibleInDir returns PathSet[Path].

jesse....@gmail.com

unread,
Mar 14, 2013, 3:01:52 PM3/14/13
to scala-i...@googlegroups.com
I will take a look but that looks like a bug to me.  I probably have some invariance wrong or perhaps the BasicPathSet signature is leaking out but shouldn’t be leaking.
 
As a workaround can you cast the BasicPathSet to a PathSet?
 
Could you fill out this code snippet and put it on a Github issue?  That will make it easier for me to debug.
 
Thanks,
 
Jesse
--
 
---
You received this message because you are subscribed to the Google Groups "Scala Incubator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-incubat...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Randall R Schulz

unread,
Mar 14, 2013, 3:03:34 PM3/14/13
to scala-i...@googlegroups.com
An update:

If I do this, the code compiles:

val emptyPathSet: PathSet[Path] = PathSet[Path]()
val batchPaths =
    trashDirs.foldLeft(
emptyPathSet) { (pathSet, trashPath) =>
      val
eligible = eligibleInDir(trashPath, perDirLimit)

jesse....@gmail.com

unread,
Mar 14, 2013, 3:06:31 PM3/14/13
to scala-i...@googlegroups.com
oh of course that makes sense.  It is the expectation you are setting at the beginning of the foldLeft.  the factory method PathSet[PathSet]() must return something of type BasicPathSet[Path].  (It shouldn’t)  I probably have to explicitely state the return type.  I will take a look at that.
 
From: Randall R Schulz
Sent: ‎March‎ ‎14‎, ‎2013 ‎8‎:‎03‎ ‎PM
To: scala-i...@googlegroups.com
Subject: Re: Combining / Concatenating Two PathSet
 
--
Reply all
Reply to author
Forward
0 new messages