Skip to content

Instantly share code, notes, and snippets.

@caente
Last active November 2, 2018 13:59
Show Gist options
  • Save caente/169b2e551cf6c5b51abc7638098f9560 to your computer and use it in GitHub Desktop.
Save caente/169b2e551cf6c5b51abc7638098f9560 to your computer and use it in GitHub Desktop.
sealed abstract case class Profile(
personId:PersonId,
timezone:DateTimeZone,
profileStatus:PersonStatus, // CUSTOMER, DISABLED, etc
schedulingHours:List[Constraint]
...
)
sealed trait Coordination
case class AssistantTo(p:Profile) extends Coordination// assistants are independent of the Meeting
case class AssistantFrom(p:Profile) extends Coordination
case class CoordinatorTo(p:ProfileInMeeting) extends Coordination
case class CoordinatorFrom(p:ProfileInMeeting) extends Coordination
sealed abstract case class ProfileInMeeting(
profile:ProfileData,
coordination:Coordination,
role: Role,//Host, Guest
statusInMeeting:StatusIndicator,// Mandatory, Required, Optional, etc
schedulingHours:List[Constraints],
...
)
//Also our other data structures would have the whole profile, instead of a PersonId
case class TimeFromPerson(
...
speaker: ProfileInMeeting,
...
)
//example of a typeclass, we should have one for each field,
//so we can use them in method signatures
trait Timezone[A]{
def timezone:DateTimeZone
}
object Timezone{
implicit object timezoneProfile extends Timezone[Profile]{
def timezone(p:Profile) = p.timezone
}
implicit object timezoneProfileInMeeting extends Timezone[ProfileInMeeting]{
def timezone(p:Profile) = p.profile.timezone
}
}
...
//example of usage
def doSomethingWithPeople[P:Timezone: SchedulingHours: StatusInMeeting](people:List[P]) = {
people.map{
p =>
p.timezone
p.schedulingHours
p.statusInMeeting
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment