1 May 2008 03:12
crashing the compiler with a recursive method
Aaron Harnly <scala <at> lists.harnly.net>
2008-05-01 01:12:16 GMT
2008-05-01 01:12:16 GMT
...and I'm not sure where else to turn. Can anyone either:
(a) figure out why this crashes the compiler
(b) figure out a non-compiler-crashing way to express this
or (c) tell me why this is a terrible idea and not what I should be
doing at all.
---
Very brief background, which can be skipped if you'd rather just grok
code:
1. I have a "format" type F which can be decomposed to yield an item
(of the same type), and a remainder.
In a very simple example, a string like "a,b,c" can be decomposed to
"a" and "b,c"; "b,c" can be decomposed to "b" and "c"; and of course
"c" cannot be decomposed any further.
2. I have a "container" type S, which is a higher-kinded type, to
which items can be added.
Obvious example is List; you can add "a" to Nil with "a" :: Nil to get
List("a").
I'm trying to express a method which "pumps" the format type into an
instance of the container type, until the first type is empty. But the
compiler crashes when I use a recursive call decomposeIntoContainer:
---
object HigherTypeArgh
{
trait SequenceFormat[F]
(Continue reading)
RSS Feed