Questions tagged [shapeless]

shapeless is (an exploration of) a type class and dependent type based generic (aka polytypic/polymorphic) programming library for Scala.

shapeless is (an exploration of) a type class and dependent type based generic (aka polytypic/polymorphic) programming library for Scala derived from the various talks Miles Sabin has given over the course of 2011 on implementing scrap your boilerplate and higher rank polymorphism in Scala.

shapeless is an Open Source project under the Apache License v2.

1030 questions
0
votes
1 answer

JsValue serialization fail

In my app I'm using https://github.com/fommil/spray-json-shapeless library for serializaion, but I have problem with this class: case class FooResult(var id: Option[String], jobId: String, completedAt: DateTime, result: JsValue) extends…
mgosk
  • 1,874
  • 14
  • 23
0
votes
0 answers

Scala Spray Templated Custom Routing Directive

Okay so.... I have this: def convertPost = extract { _.request.entity.asString.parseJson.convertTo[CustomClass] } private def myRoute: Route = (post & terminalPath("routeness")) { convertPost { req => detach() { …
gloomy.penguin
  • 5,833
  • 6
  • 33
  • 59
0
votes
1 answer

Generic way of reading CSV of class hierarchy in scala

I know there are various libraries around to read CSV in scala. I have tried the shapeless way , but I am having trouble reading csv in generic way for a hierarchy . For e.g. I need something like this : abstract class A case class…
Harsh Gupta
  • 339
  • 4
  • 20
0
votes
0 answers

Map a list of types with shapeless

case class Foo1(s: String) // Matching names case class Foo2(s: String) case class Bar(f: Foo2) val foo = Foo1("foo") :: HNil val fooGen1 = LabelledGeneric[Foo1] val fooGen2 = LabelledGeneric[Foo2] val barGen = Generic[Bar] object mapping { …
Reactormonk
  • 21,472
  • 14
  • 74
  • 123
0
votes
0 answers

Shapeless zipWith HList compiler problems

i try to merge to HLists with Ints. The resulte should be a list with the sums of the ints. I have a problem moving the code to a separate object (in this case "Adder"). If i do everything inline it works as expected. But this does not compile and…
Bomgar
  • 553
  • 1
  • 3
  • 13
0
votes
1 answer

Type based Id generator with Shapeless

I want to implement a type based id generator that I can call like this: val nextPersonId = idGen.id[Person] I'd like IdGen to be a trait (if possible): trait IdGen[L <: HList] { def id[T] = { if (T is an element in the L type) return 0L +…
eirirlar
  • 814
  • 6
  • 24
0
votes
0 answers

Building a typesafe generic client and server from some schema

Say I have the following schema defined: object CalculatorSchema { case class AddRequest(x: Int, y: Int) case class AddReply(sum: Int) case class SubtractRequest(x: Int, y: Int)   case class SubtractReply(diff: Int)   // Some code to pair…
jvliwanag
  • 1,508
  • 1
  • 13
  • 29
0
votes
1 answer

Ambiguous Implicit Values when using HMap

HMap seems to be the perfect data structure for my use case, however, I can't get it working: case class Node[N](node: N) class ImplVal[K, V] implicit val iv1 = new ImplVal[Int, Node[Int]] implicit val iv2 = new ImplVal[Int, Node[String]] implicit…
user3127060
  • 1,493
  • 2
  • 10
  • 10
0
votes
3 answers

Enrich case class via implicit extension

there is Person model case class which is exposed to the client via REST endpoint. scala> case class Person(firstname: String, lastname: String) defined class Person Now one of the internal service wants to "enrich" this Person case class and add…
user2066049
  • 1,371
  • 1
  • 12
  • 26
0
votes
1 answer

How to check SQL, Language syntax in String at compile time (Scala)

I am writing a translator which converts DSL to multiple programming language (It seems like Apache Thrift). For example, // an example DSL LOG_TYPE: COMMERCE COMMON_FIELD : session_id KEY: buy FIELD: item_id, transaction_id KEY:…
1ambda
  • 1,145
  • 8
  • 19
0
votes
1 answer

Implicit method for typeclass not found

This is continuation of Diverging implicit expansion for type class. I've came up with another version that still doesn't compile, but now for another reason, hence a different question. Here's what I did: I've basically added a new typeclass…
Haspemulator
  • 11,050
  • 9
  • 49
  • 76
0
votes
0 answers

Shapeless Lens Not Working Properly

I am trying to use a small snippet of Shapeless example code: import shapeless._ case class Person(name : String, age : Int) val ageLens = lens[Person].age val person = Person("Joe Grey", 37) val person2 = ageLens.set(person)(38) //…
BAR
  • 15,909
  • 27
  • 97
  • 185
0
votes
1 answer

Avoid structural type with shapeless alternative

I want to find out if a particular class member is present in a given case class or not. Following does give me that answer, failing at compile time which is right. (credit to Travis Brown) scala> def getIntId[A, R <: HList](a: A)(implicit | …
Vikas Pandya
  • 1,998
  • 1
  • 15
  • 32
0
votes
1 answer

Type level definition of pipeline dependency

I want to build a pipeline dependency where 2nd level depends on 1st one, 3rd depends on 2nd AND 1st and so on … I have defined such structures trait Level[A <: Level[A]] { type DependsOn <: Level[DependsOn] val previousDependencies:…
goral
  • 1,275
  • 11
  • 17
0
votes
1 answer

scala spray class file name too long

I am trying to build a jar of my spray project with sbt assembly. However, I find that some of the class files generated have very long names/paths. Following is one such long path…
adefor
  • 299
  • 2
  • 9
1 2 3
68
69