Skip to content

Instantly share code, notes, and snippets.

@sameei
Created March 31, 2018 09:05
Show Gist options
  • Select an option

  • Save sameei/8d1a341a911b2ff58df25628e2a53d2b to your computer and use it in GitHub Desktop.

Select an option

Save sameei/8d1a341a911b2ff58df25628e2a53d2b to your computer and use it in GitHub Desktop.
SARF Abstraction
object SARFAbstraction { self ⇒
trait Frame {
type Tracked
type Untracked
type TrackingCode
def apply(untracked: Untracked, trackingCode: TrackingCode): Tracked
def apply(tracked: Tracked): (Untracked, TrackingCode)
}
sealed trait Channel {
type Frame <: self.Frame
}
trait Source extends Channel
trait Sink extends Channel
trait TypeInfo[T] {
def string(t: T): String
def name: String
}
trait TypeTool[T, F <: Frame] {
def frame(t: T): F#Untracked
def unframe(f: F#Untracked): T
}
trait FunctionDef[In, Out] {
type InFrame <: Frame
type OutFrame <: Frame
type Src <: Source # { type Frame <: InFrame }
type Snk <: Sink # { type Frame <: OutFrame }
def typeInfoOfIn: TypeInfo[In]
def typeToolOfIn: TypeTool[In, InFrame]
def typeInfoOfOut: TypeInfo[Out]
def typeToolOfOut: TypeTool[Out, OutFrame]
def apply(in: In): Out
}
trait Service
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment