SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
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	
  

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
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
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
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
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 

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.