SlideShare a Scribd company logo
1 of 44
Download to read offline
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	
  

More Related Content

What's hot

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
 

What's hot (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 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.