SlideShare une entreprise Scribd logo
1  sur  44
Télécharger pour lire hors ligne
Scala	
  Domain	
  Modeling	
  
and	
  Architecture	
  
Experience	
  Report	
  
                           Hossam	
  Karim	
  
for {!
      !
      locus    Chromosome ⤞ Gene ⤞ Locus!
         if Locus    range!
!
     path    locus ⤞ Sequence ⤞ nucleotide!
        if nucleotide alignment (_ > 89)!
!
} yield path!
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
 
inputMessage >>= fasta >>= {   	
  
        case n: Nucleotide ⇒ !
          ("media" → "nucleotide") ~> n.giNumber   	
  
                                                 	
  
        case _: AminoAcid ⇒ !
          fail[String](!
             "Expected a ‘nucleotide’ Sequence")


                                                              	
  
        case _             ⇒ !


 	
   	
  
          fail[String](!
             "Expected a ‘single’ Sequence representation”)


 	
   	
  
   } >>= {

        for {

                                               	
   	
  
           	
  
          query ← meta.Sequence ⤞ meta.nucleotide


 	
  
               if meta.nucleotide.giNumber === _
        } yield query



   } >>= xml   	
  !
trait Message[A, H] {	
  
       val body: Validation[H, Option[A]]	
  
       val headers: H	
  
 }	
  
 	
  
 	
  
   trait MessageBuilder {	
  
         def build[A, H: Monoid](	
  
             body: Validation[H, Option[A]],    	
  
             headers: H): Message[A, H]	
  
   }	
  
trait Message[A, H] {	
  
       val body: Validation[H, Option[A]]	
  
       val headers: H	
  
 }	
  
 	
  
 	
  
   trait MessageBuilder {	
  
         def build[A, H: Monoid](	
  
             body: Validation[H, Option[A]],    	
  
             headers: H): Message[A, H]	
  
   }	
  
implicit def m2m[H]!
           (implicit builder: MessageBuilder, !
            monoid: Monoid[H]) =!
	
  
new Monad[({type λ[α] = Message[α, H]})#λ] {	
  
     	
  
     def pure[A](a: => A): Message[A, H] = . . .!
	
  
     def bind[A, B]!
          (a: Message[A, H], !
           f: (A) => Message[B, H]): Message[B, H] = . . .	
  
}	
  
def pure[A](a: => A) = !
   builder.build[A, H](Success(Option(a)), ∅[H])	
  	
  
def bind[A, B](!



                                                       	
   	
  
   m: Message[A, H], !
   f: (A) => Message[B, H]): Message[B, H] = {!
	
  
       val mb: Message[B, H] = m.body match {
              case Success(Some(value))   ⇒ f(value)


                                                                   	
  
              case Success(None)          ⇒!
                  builder.build[B, H](!
                      Success(Option.empty[B]), ∅[H])



                                                	
  
              case Failure(a)           ⇒!
                  builder.build[B, H](!
                      Failure(a), ∅[H] |+| a)



       	
                                                                 	
  
       }!
	
  
       builder.build[B, H](mb.body, m.headers |+| mb.headers)
}
implicit object BasicMessageBuilder extends MessageBuilder {         	
  
     def build[A, H: Monoid](!
       body: Validation[H, Option[A]], headers: H) =   	
  
       BasicMessage(body, headers)	
  
} 	
  
!
implicit object DiagnosisMessageBuilder extends!
    MessageBuilder {	
  
    def build[A, H: Monoid](!
       body: Validation[H, Option[A]], headers: H) =   	
  
       DiagnosisMessage(body, headers)   	
  
}	
  
 	
  
def body[A](value: A)(implicit builder: MessageBuilder) :!
      Message[A, HL] =     	
  
 builder.build(Success(Some(value)), List.empty[Header])      	
  
  	
  
    	
  
import Basic._!
//import Diagnosis._!
//import Transactional._!
!
         	
  
gene map {
  for (!
       e ← meta.Chromosome ⤞ meta.Gene !
            if meta.Gene.uuid === _.uuid!
  ) yield e     	
  
} >>= search           	
  
(genex <**> geney) (_ ++ _) >>=	
  
         header("media-type", "application/vnd.x.gene+json") >>= 	
  
           json	
  
 	
  
 	
  
for {	
  
       m        ← body(<gene xmlns="urn:model:gene:1.0">...</gene>)	
  
       gene ← xml(m)	
  
 } yield gene	
  
 	
  
 	
  
gene map {	
  
      for {	
  
          e ← meta.Gene ⤞ meta.Gene.uuid 	
  
                 if meta.Gene.uuid === _.uuid	
  
      } yield e	
  
} >>= search	
  	
  
import scalaz._!
import Scalaz._!
// profit!!
trait Resource {!
      val name: String!
} !
 	
  
trait Ontology extends Resource {!
      val nestingOntology: Option[Ontology]!
      val nestedOntology: List[Ontology]!
      val ownedType: List[Type]!
      val ownedRelation: List[Relation]!
}!
	
  
trait GraphResource {	
  
       this: Resource =>	
  
 }	
  
 	
  
 trait GraphVertex extends GraphResource {	
  
       this: Entity =>	
  
       val graphFeatures: List[PrimitiveFeature]	
  
       val master: Boolean	
  
       val rootToMasterEdge: GraphEdge with Relation	
  
       val masterToSelf: Option[GraphEdge with Relation] = None	
  
 }	
  
 	
  
 trait GraphEdge extends GraphResource {	
  
           this: Relation =>	
  
 }	
  	
  
trait RelationalResource {	
  
       this: Resource =>	
  
 }	
  
 	
  
 trait NamedRelationalResource          extends RelationalResource {	
  
       this: Resource =>	
  
       val relationalName: String	
  
 }	
  
 	
  
 	
  
 trait RelationalEntity extends NamedRelationalResource {	
  
       this: Entity =>	
  
 }	
  
 	
  
 trait RelationalCompositeFeature extends RelationalResource {	
  
       this: CompositeFeature =>	
  
       val mapping: Map[String, String]	
  
 }	
  
object Chromosome extends	
  
                        Entity	
  
                   with RelationalEntity!
           	
  	
  with GraphVertex	
  
                   with XmlElement {	
  
           self =>	
  
 	
  
           sealed trait ChromosomePart {	
  
                    val ownerType = self	
  
           }	
  
 	
  
           // Ontology Trait	
  
           val featuringType = self	
  
           val ownedFeature = chromatine :: Nil	
  
 	
  
           // XML Trait	
  
           val namespace = "urn:domain:chromosome:1.0"	
  
           val prefix = "chr"	
  
 	
  
           // Features	
  
           val chromatine =	
  
                    new Chromatine(	
  
                      name = "chromatine",	
  
                      ownerType = Chromosome,	
  
                      mapping = Map.empty[String, String]) 	
  
 }	
  	
  
implicit def enrich[A <: DomainModel](model: A) = new {	
  
      def metamodel: Option[Type] = Ontology.typeOf(model)	
  
}	
  
 	
  
def xmlFilter[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(_: XmlElement) ⇒ body(XmlModel[A](model))	
  
        case _ ⇒ fail[XmlModel[A]]!
          ("No XmlElement meta-model definition could be found")	
  
}	
  
 	
  
def ingoingEdges[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(vertex: GraphVertex) ⇒ !
             Ontology.edges.filter(_.target == vertex)	
  
        case _ ⇒ List.empty[GraphEdge]	
  
}	
  
implicit def enrich[A <: DomainModel](model: A) = new {	
  
      def metamodel: Option[Type] = Ontology.typeOf(model)	
  
}	
  
 	
  
def xmlFilter[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(_: XmlElement) ⇒ body(XmlModel[A](model))	
  
        case _ ⇒ fail[XmlModel[A]]!
          ("No XmlElement meta-model definition could be found")	
  
}	
  
 	
  
def ingoingEdges[A <: DomainModel] =	
  
      (model: A) ⇒ model.metamodel match {	
  
        case Some(vertex: GraphVertex) ⇒ !
             Ontology.edges.filter(_.target == vertex)	
  
        case _ ⇒ List.empty[GraphEdge]	
  
}	
  
trait Type extends Resource 	
  
       trait SimpleType extends Type	
  
       trait Entity extends Type!
!
       trait Relation extends Type 	
  
	
  
       trait   Feature[+T <: Type] extends Resource 	
  
       trait   SimpleFeature[+T <: SimpleType] extends Feature[T] 	
  
       trait   PrimitiveFeature extends SimpleFeature[Primitive] 	
  
       trait   EnumerationFeature extends SimpleFeature[Enumeration] 	
  
       trait   CompositeFeature extends SimpleFeature[Composite]	
  
       	
  
       trait   Primitive extends SimpleType 	
  
       trait   Enumeration extends SimpleType 	
  
       trait   Composite extends SimpleType	
  
       	
  
       	
  
trait PrimitiveLogic {	
  
       	
  
                               val resource: Primitive 	
  
	
  	
  	
   def ===[A](value: Primitive[A]): Operator = . . .	
  
           	
  	
  	
  	
  	
  	
  def in[A](values: PrimitiveList[A]): Operator = . . .	
  
}	
  	
  
	
  
	
  
def find(operator: Operator): Option[T]	
  
def list(operator: Operator): List[T]!
	
  
 	
  
import PrimitiveLogic._	
  
       	
  
dao list (Locus.locusUUID in list)	
  
 	
  
dao find (Locus.locusUUID === uuid)	
  	
  
import Logic._	
  
val validation =	
  
  Sequence.nucleotide.accession.accessionNumber !== x	
  
	
  
import GraphOps._	
  
val path =	
  
  Sequence.nucleotide ⤞	
  
       Sequence.protein ⤞	
  
               Locus.typeOfGene where (_ !== y)	
  	
  
for {!
      !
      locus    Chromosome ⤞ Gene ⤞ Locus!
         if Locus    range!
!
     path    locus ⤞ Sequence ⤞ nucleotide!
        if nucleotide alignment (_ > 89)!
!
} yield path!
trait Qvt[PIM, Query, View, PSM] {	
  
 	
  
         def query(pim: PIM): List[Query]	
  
 	
  
         def view(query: Query): View	
  
 	
  
         def transform(view: View): PSM	
  
         	
  
 }	
  
class GraphSimpleQvt(	
  
     ontologyProfile: OntologyProfile, 	
  
     graphProfile: GraphProfile)	
  
   extends SimpleQvt[Model, Package, GraphOntology] {	
  
          	
  
                 def query(pim: Model) = {	
  
                       walk[Package](pim)(_.getNestedPackages).	
  
                         filter(graphProfile.graphPredicate)	
  
                 }	
  
   	
  
                 def transform(view: Package) = graph(view)	
  
   	
  
                 def graph(element: Package): GraphOntology = {	
  
                       ...	
  
                 }	
  
                 .	
  
                 .	
  
                 .	
  
}	
  
def walk[A]	
  
      (element: A)	
  
      (f: A => Iterable[A]): List[A] = {	
  
        val children = f(element).toList	
  
        children ++ !
          (children.flatMap(walk(_, f)))	
  
}	
  
def packageName(element: Package): String =	
  
     Stream!
      .iterate(element)(_.getNestingPackage)	
  
      .takeWhile(!_.isInstanceOf[Model])	
  
      .map(_.getName)	
  
      .reverse	
  
      .mkString(".") //.scala rocks !!	
  
Thank	
  You	
  

Contenu connexe

Tendances

Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...CloudxLab
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Sanjeev_Knoldus
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should careJean Carlo Emer
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210Mahmoud Samir Fayed
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteDirkjan Bussink
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...scalaconfjp
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180Mahmoud Samir Fayed
 
Java script objects 2
Java script objects 2Java script objects 2
Java script objects 2H K
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsIván López Martín
 
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kirill Rozov
 

Tendances (20)

Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
Apache Spark - Key Value RDD - Transformations | Big Data Hadoop Spark Tutori...
 
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
Scala traits training by Sanjeev Kumar @Kick Start Scala traits & Play, organ...
 
Types and Immutability: why you should care
Types and Immutability: why you should careTypes and Immutability: why you should care
Types and Immutability: why you should care
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
 
The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210The Ring programming language version 1.9 book - Part 53 of 210
The Ring programming language version 1.9 book - Part 53 of 210
 
Lecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of TwenteLecture on Rubinius for Compiler Construction at University of Twente
Lecture on Rubinius for Compiler Construction at University of Twente
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
 
The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196The Ring programming language version 1.7 book - Part 41 of 196
The Ring programming language version 1.7 book - Part 41 of 196
 
The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88The Ring programming language version 1.3 book - Part 34 of 88
The Ring programming language version 1.3 book - Part 34 of 88
 
The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212The Ring programming language version 1.10 book - Part 40 of 212
The Ring programming language version 1.10 book - Part 40 of 212
 
The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180The Ring programming language version 1.5.1 book - Part 43 of 180
The Ring programming language version 1.5.1 book - Part 43 of 180
 
Java script objects 2
Java script objects 2Java script objects 2
Java script objects 2
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84The Ring programming language version 1.2 book - Part 20 of 84
The Ring programming language version 1.2 book - Part 20 of 84
 
The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210The Ring programming language version 1.9 book - Part 41 of 210
The Ring programming language version 1.9 book - Part 41 of 210
 
The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189The Ring programming language version 1.6 book - Part 35 of 189
The Ring programming language version 1.6 book - Part 35 of 189
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 

Similaire à Scala Domain Modeling and Architecture

An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testingVincent Pradeilles
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class PatternsJohn De Goes
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...adrianoalmeida7
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Eelco Visser
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?Tomasz Wrobel
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in HaskellHiromi Ishii
 
Programming haskell chapter10
Programming haskell chapter10Programming haskell chapter10
Programming haskell chapter10Kousuke Ruichi
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software TestingJavran
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Baruch Sadogursky
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEBHoward Lewis Ship
 
Good functional programming is good programming
Good functional programming is good programmingGood functional programming is good programming
Good functional programming is good programmingkenbot
 
JavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher ChedeauJavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher ChedeauReact London 2017
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 

Similaire à Scala Domain Modeling and Architecture (20)

ddd+scala
ddd+scaladdd+scala
ddd+scala
 
An introduction to property-based testing
An introduction to property-based testingAn introduction to property-based testing
An introduction to property-based testing
 
Scala for Jedi
Scala for JediScala for Jedi
Scala for Jedi
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala taxonomy
Scala taxonomyScala taxonomy
Scala taxonomy
 
(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?(How) can we benefit from adopting scala?
(How) can we benefit from adopting scala?
 
Pattern Matching in Scala
Pattern Matching in ScalaPattern Matching in Scala
Pattern Matching in Scala
 
Metaprogramming in Haskell
Metaprogramming in HaskellMetaprogramming in Haskell
Metaprogramming in Haskell
 
Coding in Style
Coding in StyleCoding in Style
Coding in Style
 
Programming haskell chapter10
Programming haskell chapter10Programming haskell chapter10
Programming haskell chapter10
 
Spock and Geb
Spock and GebSpock and Geb
Spock and Geb
 
QuickCheck - Software Testing
QuickCheck - Software TestingQuickCheck - Software Testing
QuickCheck - Software Testing
 
Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014Groovy puzzlers по русски с Joker 2014
Groovy puzzlers по русски с Joker 2014
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 
Good functional programming is good programming
Good functional programming is good programmingGood functional programming is good programming
Good functional programming is good programming
 
JavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher ChedeauJavaScript Code Formatting With Prettier by Christopher Chedeau
JavaScript Code Formatting With Prettier by Christopher Chedeau
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 

Dernier

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

Scala Domain Modeling and Architecture

  • 1. Scala  Domain  Modeling   and  Architecture   Experience  Report   Hossam  Karim  
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. for {! ! locus Chromosome ⤞ Gene ⤞ Locus! if Locus range! ! path locus ⤞ Sequence ⤞ nucleotide! if nucleotide alignment (_ > 89)! ! } yield path!
  • 8.
  • 9.
  • 10.
  • 11.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 12.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 13.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 14.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 15.   inputMessage >>= fasta >>= {   case n: Nucleotide ⇒ ! ("media" → "nucleotide") ~> n.giNumber     case _: AminoAcid ⇒ ! fail[String](! "Expected a ‘nucleotide’ Sequence")   case _ ⇒ !     fail[String](! "Expected a ‘single’ Sequence representation”)     } >>= { for {       query ← meta.Sequence ⤞ meta.nucleotide   if meta.nucleotide.giNumber === _ } yield query } >>= xml  !
  • 16. trait Message[A, H] {   val body: Validation[H, Option[A]]   val headers: H   }         trait MessageBuilder {   def build[A, H: Monoid](   body: Validation[H, Option[A]],   headers: H): Message[A, H]   }  
  • 17. trait Message[A, H] {   val body: Validation[H, Option[A]]   val headers: H   }         trait MessageBuilder {   def build[A, H: Monoid](   body: Validation[H, Option[A]],   headers: H): Message[A, H]   }  
  • 18. implicit def m2m[H]! (implicit builder: MessageBuilder, ! monoid: Monoid[H]) =!   new Monad[({type λ[α] = Message[α, H]})#λ] {     def pure[A](a: => A): Message[A, H] = . . .!   def bind[A, B]! (a: Message[A, H], ! f: (A) => Message[B, H]): Message[B, H] = . . .   }  
  • 19. def pure[A](a: => A) = ! builder.build[A, H](Success(Option(a)), ∅[H])    
  • 20. def bind[A, B](!     m: Message[A, H], ! f: (A) => Message[B, H]): Message[B, H] = {!   val mb: Message[B, H] = m.body match { case Success(Some(value)) ⇒ f(value)   case Success(None) ⇒! builder.build[B, H](! Success(Option.empty[B]), ∅[H])   case Failure(a) ⇒! builder.build[B, H](! Failure(a), ∅[H] |+| a)     }!   builder.build[B, H](mb.body, m.headers |+| mb.headers) }
  • 21. implicit object BasicMessageBuilder extends MessageBuilder {   def build[A, H: Monoid](! body: Validation[H, Option[A]], headers: H) =   BasicMessage(body, headers)   }   ! implicit object DiagnosisMessageBuilder extends! MessageBuilder {   def build[A, H: Monoid](! body: Validation[H, Option[A]], headers: H) =   DiagnosisMessage(body, headers)   }       def body[A](value: A)(implicit builder: MessageBuilder) :! Message[A, HL] =   builder.build(Success(Some(value)), List.empty[Header])      
  • 22. import Basic._! //import Diagnosis._! //import Transactional._! !   gene map { for (! e ← meta.Chromosome ⤞ meta.Gene ! if meta.Gene.uuid === _.uuid! ) yield e   } >>= search  
  • 23. (genex <**> geney) (_ ++ _) >>=   header("media-type", "application/vnd.x.gene+json") >>=   json           for {   m ← body(<gene xmlns="urn:model:gene:1.0">...</gene>)   gene ← xml(m)   } yield gene           gene map {   for {   e ← meta.Gene ⤞ meta.Gene.uuid   if meta.Gene.uuid === _.uuid   } yield e   } >>= search    
  • 25.
  • 26.
  • 27.
  • 28. trait Resource {! val name: String! } !     trait Ontology extends Resource {! val nestingOntology: Option[Ontology]! val nestedOntology: List[Ontology]! val ownedType: List[Type]! val ownedRelation: List[Relation]! }!  
  • 29. trait GraphResource {   this: Resource =>   }     trait GraphVertex extends GraphResource {   this: Entity =>   val graphFeatures: List[PrimitiveFeature]   val master: Boolean   val rootToMasterEdge: GraphEdge with Relation   val masterToSelf: Option[GraphEdge with Relation] = None   }     trait GraphEdge extends GraphResource {   this: Relation =>   }    
  • 30. trait RelationalResource {   this: Resource =>   }     trait NamedRelationalResource extends RelationalResource {   this: Resource =>   val relationalName: String   }       trait RelationalEntity extends NamedRelationalResource {   this: Entity =>   }     trait RelationalCompositeFeature extends RelationalResource {   this: CompositeFeature =>   val mapping: Map[String, String]   }  
  • 31. object Chromosome extends   Entity   with RelationalEntity!    with GraphVertex   with XmlElement {   self =>     sealed trait ChromosomePart {   val ownerType = self   }     // Ontology Trait   val featuringType = self   val ownedFeature = chromatine :: Nil     // XML Trait   val namespace = "urn:domain:chromosome:1.0"   val prefix = "chr"     // Features   val chromatine =   new Chromatine(   name = "chromatine",   ownerType = Chromosome,   mapping = Map.empty[String, String])   }    
  • 32. implicit def enrich[A <: DomainModel](model: A) = new {   def metamodel: Option[Type] = Ontology.typeOf(model)   }     def xmlFilter[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(_: XmlElement) ⇒ body(XmlModel[A](model))   case _ ⇒ fail[XmlModel[A]]! ("No XmlElement meta-model definition could be found")   }     def ingoingEdges[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(vertex: GraphVertex) ⇒ ! Ontology.edges.filter(_.target == vertex)   case _ ⇒ List.empty[GraphEdge]   }  
  • 33. implicit def enrich[A <: DomainModel](model: A) = new {   def metamodel: Option[Type] = Ontology.typeOf(model)   }     def xmlFilter[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(_: XmlElement) ⇒ body(XmlModel[A](model))   case _ ⇒ fail[XmlModel[A]]! ("No XmlElement meta-model definition could be found")   }     def ingoingEdges[A <: DomainModel] =   (model: A) ⇒ model.metamodel match {   case Some(vertex: GraphVertex) ⇒ ! Ontology.edges.filter(_.target == vertex)   case _ ⇒ List.empty[GraphEdge]   }  
  • 34. trait Type extends Resource   trait SimpleType extends Type   trait Entity extends Type! ! trait Relation extends Type     trait Feature[+T <: Type] extends Resource   trait SimpleFeature[+T <: SimpleType] extends Feature[T]   trait PrimitiveFeature extends SimpleFeature[Primitive]   trait EnumerationFeature extends SimpleFeature[Enumeration]   trait CompositeFeature extends SimpleFeature[Composite]     trait Primitive extends SimpleType   trait Enumeration extends SimpleType   trait Composite extends SimpleType      
  • 35. trait PrimitiveLogic {     val resource: Primitive         def ===[A](value: Primitive[A]): Operator = . . .              def in[A](values: PrimitiveList[A]): Operator = . . .   }         def find(operator: Operator): Option[T]   def list(operator: Operator): List[T]!       import PrimitiveLogic._     dao list (Locus.locusUUID in list)       dao find (Locus.locusUUID === uuid)    
  • 36. import Logic._   val validation =   Sequence.nucleotide.accession.accessionNumber !== x     import GraphOps._   val path =   Sequence.nucleotide ⤞   Sequence.protein ⤞   Locus.typeOfGene where (_ !== y)    
  • 37. for {! ! locus Chromosome ⤞ Gene ⤞ Locus! if Locus range! ! path locus ⤞ Sequence ⤞ nucleotide! if nucleotide alignment (_ > 89)! ! } yield path!
  • 38.
  • 39. trait Qvt[PIM, Query, View, PSM] {     def query(pim: PIM): List[Query]     def view(query: Query): View     def transform(view: View): PSM     }  
  • 40. class GraphSimpleQvt(   ontologyProfile: OntologyProfile,   graphProfile: GraphProfile)   extends SimpleQvt[Model, Package, GraphOntology] {     def query(pim: Model) = {   walk[Package](pim)(_.getNestedPackages).   filter(graphProfile.graphPredicate)   }     def transform(view: Package) = graph(view)     def graph(element: Package): GraphOntology = {   ...   }   .   .   .   }  
  • 41. def walk[A]   (element: A)   (f: A => Iterable[A]): List[A] = {   val children = f(element).toList   children ++ ! (children.flatMap(walk(_, f)))   }  
  • 42. def packageName(element: Package): String =   Stream! .iterate(element)(_.getNestingPackage)   .takeWhile(!_.isInstanceOf[Model])   .map(_.getName)   .reverse   .mkString(".") //.scala rocks !!  
  • 43.