All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ru.primetalk.synapse.shapeless.package.scala Maven / Gradle / Ivy

Go to download

SynapseGrid is a framework for constructing reactive real-time immutable data flow systems. -core contains everything to run a single-threaded system, -akka contains everything to run systemsover Akka actors, -slf4j - enables logging, -examples - a few test systems.

There is a newer version: 1.3.1
Show newest version
///////////////////////////////////////////////////////////////
// © ООО «Праймтолк», 2011-2013                              //
// Все права принадлежат компании ООО «Праймтолк».           //
///////////////////////////////////////////////////////////////
/**
 * SynapseGrid
 * © Primetalk Ltd., 2013.
 * All rights reserved.
 * Authors: A.Zhizhelev, A.Nehaev, P. Popov
 *
 * Created: 26.08.13, zhizhelev
 */
package ru.primetalk.synapse

import ru.primetalk.synapse.core.{Contact, StateHandle, SystemBuilder}
import _root_.shapeless._

package object shapeless {

  //  implicit class ShapelessSystemBuilder(sb:SystemBuilder){
  implicit class HNilContact[T](c: Contact[T]) {
    def hNil(implicit sb: SystemBuilder): Contact[T :: HNil] = {
      import sb._
      c.map(value => value :: HNil)
    }
  }

  implicit class ShapelessContact[L <: HList](c: Contact[L]) {
    def using[S](stateHandle: StateHandle[S])(implicit sb: SystemBuilder): Contact[S :: L] = {
      import sb._
      c.withState(stateHandle).stateMap[S :: L](
        (stateValue, message: L) =>
          (stateValue, new ::(stateValue, message))
      )
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy