Permalink
Browse files

! routing: remove layer of `*Aux` classes by type aliases for simplicity

  • Loading branch information...
jrudolph committed Oct 14, 2013
1 parent 979fc31 commit d86cb8081a7d5e03d3fc63443132df58c48b7b43
@@ -73,22 +73,18 @@ trait AnyParamDefMagnet2[T] {
}
object AnyParamDefMagnet2 {
+ import FieldDefMagnet2.FieldDefMagnetAux
+ import ParamDefMagnet2.ParamDefMagnetAux
+
implicit def forTuple[T <: Product, L <: HList, Out](implicit hla: HListerAux[T, L],
- apdma: AnyParamDefMagnetAux[L]) =
+ apdma: AnyParamDefMagnet2[L]) =
new AnyParamDefMagnet2[T] {
def apply(value: T) = apdma(hla(value))
type Out = apdma.Out
}
-}
-
-trait AnyParamDefMagnetAux[L] {
- type Out
- def apply(value: L): Out
-}
-object AnyParamDefMagnetAux {
implicit def forHList[L <: HList](implicit f: LeftFolder[L, Directive0, MapReduce.type]) =
- new AnyParamDefMagnetAux[L] {
+ new AnyParamDefMagnet2[L] {
type Out = f.Out
def apply(value: L) = {
value.foldLeft(BasicDirectives.noop)(MapReduce)
@@ -53,22 +53,15 @@ trait FieldDefMagnet2[T] {
type Out
def apply(value: T): Out
}
-object FieldDefMagnet2 {
- implicit def apply[A, B](implicit fdma: FieldDefMagnetAux[A, B]) = new FieldDefMagnet2[A] {
- type Out = B
- def apply(value: A) = fdma(value)
- }
-}
-trait FieldDefMagnetAux[A, B] extends (A B)
+object FieldDefMagnet2 extends ToNameReceptaclePimps {
+ type FieldDefMagnetAux[A, B] = FieldDefMagnet2[A] { type Out = B }
+ def FieldDefMagnetAux[A, B](f: A B) = new FieldDefMagnet2[A] { type Out = B; def apply(value: A) = f(value) }
-object FieldDefMagnetAux extends ToNameReceptaclePimps {
import spray.httpx.unmarshalling.{ FromRequestUnmarshaller UM, FormFieldConverter FFC, FromBodyPartOptionUnmarshaller FBPOU, _ }
import BasicDirectives._
import RouteDirectives._
- def apply[A, B](f: A B) = new FieldDefMagnetAux[A, B] { def apply(value: A) = f(value) }
-
/************ "regular" field extraction ******************/
def extractField[A, B](f: A Directive1[B]) = FieldDefMagnetAux[A, Directive1[B]](f)
@@ -113,4 +106,4 @@ object FieldDefMagnetAux extends ToNameReceptaclePimps {
implicit def from[T, LA <: HList, LB <: HList, Out <: HList](implicit fdma: FieldDefMagnetAux[T, Directive[LB]], ev: PrependAux[LA, LB, Out]) =
at[Directive[LA], T] { (a, t) a & fdma(t) }
}
-}
+}
@@ -79,22 +79,15 @@ trait ParamDefMagnet2[T] {
type Out
def apply(value: T): Out
}
-object ParamDefMagnet2 {
- implicit def apply[A, B](implicit pdma: ParamDefMagnetAux[A, B]) = new ParamDefMagnet2[A] {
- type Out = B
- def apply(value: A) = pdma(value)
- }
-}
-trait ParamDefMagnetAux[A, B] extends (A B)
+object ParamDefMagnet2 {
+ type ParamDefMagnetAux[A, B] = ParamDefMagnet2[A] { type Out = B }
+ def ParamDefMagnetAux[A, B](f: A B) = new ParamDefMagnet2[A] { type Out = B; def apply(value: A) = f(value) }
-object ParamDefMagnetAux {
import spray.httpx.unmarshalling.{ FromStringOptionDeserializer FSOD, _ }
import BasicDirectives._
import RouteDirectives._
- def apply[A, B](f: A B) = new ParamDefMagnetAux[A, B] { def apply(value: A) = f(value) }
-
/************ "regular" parameter extraction ******************/
private def extractParameter[A, B](f: A Directive1[B]) = ParamDefMagnetAux[A, Directive1[B]](f)
@@ -152,4 +145,4 @@ object ParamDefMagnetAux {
implicit def from[T, LA <: HList, LB <: HList, Out <: HList](implicit pdma: ParamDefMagnetAux[T, Directive[LB]], ev: PrependAux[LA, LB, Out]) =
at[Directive[LA], T] { (a, t) a & pdma(t) }
}
-}
+}

0 comments on commit d86cb80

Please sign in to comment.