Combining / Concatenating Two PathSet

瀏覽次數:25 次
跳到第一則未讀訊息

Randall R Schulz

未讀,
2013年3月14日 下午2:42:252013/3/14
收件者: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

未讀,
2013年3月14日 下午2:46:182013/3/14
收件者:scala-i...@googlegroups.com

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

jesse....@gmail.com

未讀,
2013年3月14日 下午3:01:522013/3/14
收件者: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

未讀,
2013年3月14日 下午3:03:342013/3/14
收件者: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

未讀,
2013年3月14日 下午3:06:312013/3/14
收件者: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
 
--
回覆所有人
回覆作者
轉寄
0 則新訊息