Skip to content

Instantly share code, notes, and snippets.

@AndreasKostler
Created June 22, 2015 07:41
Show Gist options
  • Save AndreasKostler/654a33f329bf66455a38 to your computer and use it in GitHub Desktop.
Save AndreasKostler/654a33f329bf66455a38 to your computer and use it in GitHub Desktop.
// These are my two event classes...
case class Event1(id: Int, eventStartTime: DateTime, entityRoles: EntityRoles)
object Event1 {
override def toString = "ev1"
implicit val isTimeStamped: Timestamped[Event1] =
Timestamped.from(_.eventStartTime)
implicit val isEntityRoleAware: EntityRoleAware[Event1] =
EntityRoleAware.from(_.entityRoles.roles)
implicit val hasOrdering: Ordering[Event1] =
Ordering.by(e => (e.eventStartTime, e.entityRoles))
}
case class Event2(id: Int, eventStartTime: DateTime, entityRoles: EntityRoles)
object Event2 {
override def toString = "ev2"
implicit val isTimeStamped: Timestamped[Event2] =
Timestamped.from(_.eventStartTime)
implicit val isEntityRoleAware: EntityRoleAware[Event2] =
EntityRoleAware.from(_.entityRoles.roles)
implicit val hasOrdering: Ordering[Event2] =
Ordering.by(e => (e.eventStartTime, e.entityRoles))
object entityRoles extends Poly1 {
implicit def event1Case = at[Event1](e => e.entityRoles)
implicit def event2Case = at[Event2](e => e.entityRoles)
}
}
// These are my events...
type EventCoproduct = Event1 :+: Event2 :+: CNil
val events: List[EventCoproduct] = Random.shuffle(testEvents1 :+: testEvents2 :+: nil)
// When I do this:
ThermometerSource(events)
.selectPattern[Event1, Event2]((x: EventCoproduct) => (x map entityRoles).select[EntityRoles].get,true)
// I get a type error
[error] found : au.com.cba.omnia.eventually.core.EntityRoles
[error] required: K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment