alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (cyclics-pos.scala)

This example Scala source code file (cyclics-pos.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

a, a, abs, abs, b, constr, constr, constrof, elem, elem, iterable, iterabletemplate, param, t

The Scala cyclics-pos.scala source code

trait Param[T]
trait Abs { type T }
trait Cyclic1[A <: Param[A]]    // works
trait Cyclic2[A <: Abs { type T <: A }]   
trait Cyclic3 { type A <: Abs { type T = A } }    
trait Cyclic4 { type A <: Param[A] }   // works
trait Cyclic5 { type AA <: Abs; type A <: AA { type T = A } }    


trait IterableTemplate {
  type Elem
  type Constr <: IterableTemplate
  type ConstrOf[A] = Constr { type Elem = A }
  
  def iterator: Iterator[Elem]
  
  def map [B] (f: Elem => B): ConstrOf[B]
  
  def foreach(f: Elem => Unit) = iterator.foreach(f)
}


trait Iterable[A] extends IterableTemplate { self =>
  type Elem 
  type Constr <: Iterable[A] { type Constr <: Iterable.this.Constr }
}

Other Scala examples (source code examples)

Here is a short list of links related to this Scala cyclics-pos.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.