This page is no longer maintained — Please continue to the home page at www.scala-lang.org

:power mode questions

3 replies
paulbutcher
Joined: 2010-03-08,
User offline. Last seen 10 weeks 5 days ago.

I'm trying to get my head around :power mode, and I'm nearly there, but clearly missing something.

In this message, for example, PaulP made use (I guess?) of :power mode to illustrate how appliedType works:

http://groups.google.com/group/scala-internals/msg/ea7e9fd016a7986b

When I try to do the same, this is what I get:

> Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> :power
> ** Power User mode enabled - BEEP BOOP SPIZ **
> ** :phase has been set to 'typer'. **
> ** scala.tools.nsc._ has been imported **
> ** global._ and definitions._ also imported **
> ** Try :help, vals., power. **
>
> scala> def f[A, B](x: Int, a: A, b: B): (Int, A, B) = (x, a, b)
> f: [A, B](x: Int, a: A, b: B)(Int, A, B)
>
> scala> f _
> res0: (Int, Nothing, Nothing) => (Int, Nothing, Nothing) =
>
> scala> res0.info
> res2: $r.power.global.Type = [-T1, -T2, -T3, +R]java.lang.Object with ScalaObject{def $init$(): Unit; def apply(v1: T1,v2: T2,v3: T3): R; def curried: T1 => T2 => T3 => R; def curry: T1 => T2 => T3 => R; def tupled: (T1, T2, T3) => R; override def toString(): java.lang.String}
>
> scala> appliedType(res0.info, List(AnyClass.tpe, AnyClass.tpe, AnyClass.tpe))
> :31: error: type mismatch;
> found : $r.power.global.Type
> required: $r.global.Type
> appliedType(res0.info, List(AnyClass.tpe, AnyClass.tpe, AnyClass.tpe))
> ^
>

What am I missing?

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: paul [at] paulbutcher [dot] com
AIM: paulrabutcher
Skype: paulrabutcher

adriaanm
Joined: 2010-02-08,
User offline. Last seen 31 weeks 4 days ago.
Re: :power mode questions

This should work better in a nightly. Otherwise, import intp.global, so that the dependent type stars align. I don't have a keyboard around right now, nor a repl, but I sent a repl transcript to this list recently, something about constructing trees. Maybe that can help too. --a

On 19 Dec 2011, at 14:24, Paul Butcher wrote:

> I'm trying to get my head around :power mode, and I'm nearly there, but clearly missing something.
>
> In this message, for example, PaulP made use (I guess?) of :power mode to illustrate how appliedType works:
>
> http://groups.google.com/group/scala-internals/msg/ea7e9fd016a7986b
>
> When I try to do the same, this is what I get:
>
>> Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
>> Type in expressions to have them evaluated.
>> Type :help for more information.
>>
>> scala> :power
>> ** Power User mode enabled - BEEP BOOP SPIZ **
>> ** :phase has been set to 'typer'. **
>> ** scala.tools.nsc._ has been imported **
>> ** global._ and definitions._ also imported **
>> ** Try :help, vals., power. **
>>
>> scala> def f[A, B](x: Int, a: A, b: B): (Int, A, B) = (x, a, b)
>> f: [A, B](x: Int, a: A, b: B)(Int, A, B)
>>
>> scala> f _
>> res0: (Int, Nothing, Nothing) => (Int, Nothing, Nothing) =
>>
>> scala> res0.info
>> res2: $r.power.global.Type = [-T1, -T2, -T3, +R]java.lang.Object with ScalaObject{def $init$(): Unit; def apply(v1: T1,v2: T2,v3: T3): R; def curried: T1 => T2 => T3 => R; def curry: T1 => T2 => T3 => R; def tupled: (T1, T2, T3) => R; override def toString(): java.lang.String}
>>
>> scala> appliedType(res0.info, List(AnyClass.tpe, AnyClass.tpe, AnyClass.tpe))
>> :31: error: type mismatch;
>> found : $r.power.global.Type
>> required: $r.global.Type
>> appliedType(res0.info, List(AnyClass.tpe, AnyClass.tpe, AnyClass.tpe))
>> ^
>>
>
>
> What am I missing?
>
> --
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> MSN: paul [at] paulbutcher [dot] com
> AIM: paulrabutcher
> Skype: paulrabutcher
>

paulbutcher
Joined: 2010-03-08,
User offline. Last seen 10 weeks 5 days ago.
Re: :power mode questions

On 19 Dec 2011, at 22:18, Adriaan Moors wrote:
> This should work better in a nightly. Otherwise, import intp.global, so that the dependent type stars align.

Sorry Adriaan, I'm still struggling with this :-(

I've tried the most recent 2.10.0 nightly, and I get almost identical behaviour to 2.9.1.final:

> Welcome to Scala version 2.10.0.r26094-b20111201020254 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> :power
> ** Power User mode enabled - BEEP BOOP SPIZ **
> ** :phase has been set to 'typer'. **
> ** scala.tools.nsc._ has been imported **
> ** global._ and definitions._ also imported **
> ** Try :help, vals., power. **
>
> scala> def f[A, B](x: Int, a: A, b: B) = (x, a, b)
> f: [A, B](x: Int, a: A, b: B)(Int, A, B)
>
> scala> f _
> res0: (Int, Nothing, Nothing) => (Int, Nothing, Nothing) =
>
> scala> appliedType(res0.info, List(AnyRef.tpe, AnyRef.tpe))
> :31: error: type mismatch;
> found : $r.power.global.Type
> required: $r.intp.global.Type
> appliedType(res0.info, List(AnyRef.tpe, AnyRef.tpe))
> ^
>
> scala> appliedType((f _).info, List(AnyRef.tpe, AnyRef.tpe))
> :30: error: type mismatch;
> found : $r.power.global.Type
> required: $r.intp.global.Type
> appliedType((f _).info, List(AnyRef.tpe, AnyRef.tpe))
> ^

I've tried importing intp.global, intp.global._, and various other combinations, but clearly haven't stumbled upon the correct star alignment :-(

Sorry for being dense.

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: paul [at] paulbutcher [dot] com
AIM: paulrabutcher
Skype: paulrabutcher

adriaanm
Joined: 2010-02-08,
User offline. Last seen 31 weeks 4 days ago.
Re: :power mode questions

It's not you, it's the repl. Unfortunately, not all compiler data structures are selected on the same global internally (this is hard to fix, btw), so you'll need to cast to the type selected on the expected global. --a

On 20 Dec 2011, at 17:10, Paul Butcher wrote:

> On 19 Dec 2011, at 22:18, Adriaan Moors wrote:
>> This should work better in a nightly. Otherwise, import intp.global, so that the dependent type stars align.
>
> Sorry Adriaan, I'm still struggling with this :-(
>
> I've tried the most recent 2.10.0 nightly, and I get almost identical behaviour to 2.9.1.final:
>
>> Welcome to Scala version 2.10.0.r26094-b20111201020254 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
>> Type in expressions to have them evaluated.
>> Type :help for more information.
>>
>> scala> :power
>> ** Power User mode enabled - BEEP BOOP SPIZ **
>> ** :phase has been set to 'typer'. **
>> ** scala.tools.nsc._ has been imported **
>> ** global._ and definitions._ also imported **
>> ** Try :help, vals., power. **
>>
>> scala> def f[A, B](x: Int, a: A, b: B) = (x, a, b)
>> f: [A, B](x: Int, a: A, b: B)(Int, A, B)
>>
>> scala> f _
>> res0: (Int, Nothing, Nothing) => (Int, Nothing, Nothing) =
>>
>> scala> appliedType(res0.info, List(AnyRef.tpe, AnyRef.tpe))
>> :31: error: type mismatch;
>> found : $r.power.global.Type
>> required: $r.intp.global.Type
>> appliedType(res0.info, List(AnyRef.tpe, AnyRef.tpe))
>> ^
>>
>> scala> appliedType((f _).info, List(AnyRef.tpe, AnyRef.tpe))
>> :30: error: type mismatch;
>> found : $r.power.global.Type
>> required: $r.intp.global.Type
>> appliedType((f _).info, List(AnyRef.tpe, AnyRef.tpe))
>> ^
>
>
> I've tried importing intp.global, intp.global._, and various other combinations, but clearly haven't stumbled upon the correct star alignment :-(
>
> Sorry for being dense.
>
> --
> paul.butcher->msgCount++
>
> Snetterton, Castle Combe, Cadwell Park...
> Who says I have a one track mind?
>
> http://www.paulbutcher.com/
> LinkedIn: http://www.linkedin.com/in/paulbutcher
> MSN: paul [at] paulbutcher [dot] com
> AIM: paulrabutcher
> Skype: paulrabutcher
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland