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

Scala example source code file (tcpoly_overloaded.scala)

This example Scala source code file (tcpoly_overloaded.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

bound, int, list, mlist, monad, mytype, rbound, rbound, rcontainer, rcontainer, result, result, t, t

The Scala tcpoly_overloaded.scala source code

trait Monad[T <: Bound[T], MyType[x <: Bound[x]], Bound[_]] {
  def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],  
              Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
              (f: T => Result[S]): Result[S] 
  def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],  
              Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
              (f: T => Result[S], foo: String): Result[S] 
  def flatMap[S <: Bound[S]]
              (f: T => MyType[S], foo: Int): MyType[S]
}

trait Test {
  def moo: MList[Int]
  class MList[T](el: T) extends Monad[T, List, Any] {
    def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],  
            Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
            (f: T => Result[S]): Result[S] = error("foo")
    def flatMap[S <: RBound[S], RContainer[x <: RBound[x]], RBound[_],  
            Result[x <: RBound[x]] <: Monad[x, RContainer, RBound]]
            (f: T => Result[S], foo: String): Result[S]  = error("foo")
    def flatMap[S]
            (f: T => List[S], foo: Int): List[S]  = error("foo")              
  }
  val l: MList[String] = moo.flatMap[String, List, Any, MList]((x: Int) => new MList("String"))
}

Other Scala examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.