[scala] slightly more substantive question...

View: New views
4 Messages — Rating Filter:   Alert me  

[scala] slightly more substantive question...

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Scalads and lasses,

...i hope! ;-)

Twice now i have run into the situation where i want a self type that is the combination of some traits i have defined. Obviously, i can get around this by defining a trait that mixes the traits i need. However, we're in a functional language. i'd like some type combinators, please. Are these beasties available?

Example.

trait Mumble {
// stuff and nonsense
...
}

trait Frotz {
// sound and fury
...
}

trait MimbleWimble {
   self : Mumble + Frotz =>
   // signifying ... ?
   ...
}

Best wishes,

--greg

--
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105

+1 206.650.3740

http://biosimilarity.blogspot.com

Re: [scala] slightly more substantive question...

by Jorge Ortiz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try:

trait MimbleWimble {
   self : Mumble with Frotz =>
   ...
}


On Mon, Jul 21, 2008 at 1:58 PM, Meredith Gregory
<lgreg.meredith@...> wrote:

> Scalads and lasses,
>
> ...i hope! ;-)
>
> Twice now i have run into the situation where i want a self type that is the
> combination of some traits i have defined. Obviously, i can get around this
> by defining a trait that mixes the traits i need. However, we're in a
> functional language. i'd like some type combinators, please. Are these
> beasties available?
>
> Example.
>
> trait Mumble {
> // stuff and nonsense
> ...
> }
>
> trait Frotz {
> // sound and fury
> ...
> }
>
> trait MimbleWimble {
>    self : Mumble + Frotz =>
>    // signifying ... ?
>    ...
> }
>
> Best wishes,
>
> --greg
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 806 55th St NE
> Seattle, WA 98105
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com

Re: [scala] slightly more substantive question...

by Meredith Gregory :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jorge,

Doh!

Cheers.

Do we have any other combinators?

Best wishes,

--greg

On Mon, Jul 21, 2008 at 12:04 PM, Jorge Ortiz <jorge.ortiz@...> wrote:
Try:

trait MimbleWimble {
  self : Mumble with Frotz =>
  ...
}


On Mon, Jul 21, 2008 at 1:58 PM, Meredith Gregory
<lgreg.meredith@...> wrote:
> Scalads and lasses,
>
> ...i hope! ;-)
>
> Twice now i have run into the situation where i want a self type that is the
> combination of some traits i have defined. Obviously, i can get around this
> by defining a trait that mixes the traits i need. However, we're in a
> functional language. i'd like some type combinators, please. Are these
> beasties available?
>
> Example.
>
> trait Mumble {
> // stuff and nonsense
> ...
> }
>
> trait Frotz {
> // sound and fury
> ...
> }
>
> trait MimbleWimble {
>    self : Mumble + Frotz =>
>    // signifying ... ?
>    ...
> }
>
> Best wishes,
>
> --greg
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 806 55th St NE
> Seattle, WA 98105
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com



--
L.G. Meredith
Managing Partner
Biosimilarity LLC
806 55th St NE
Seattle, WA 98105

+1 206.650.3740

http://biosimilarity.blogspot.com

[scala] Re: slightly more substantive question...

by Stefan Zeiger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Meredith Gregory wrote:

 > trait MimbleWimble {
 >    self : Mumble + Frotz =>

This should do the trick:

        trait MimbleWimble {
           self : Mumble with Frotz =>

--
Stefan Zeiger | http://szeiger.de | http://novocode.com

LightInTheBox - Buy quality products at wholesale price