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

Shapeless: Why align does not work with singleton types?

I expected this code to compile import shapeless._ import record._ import ops.record._ import ops.hlist.Align import syntax.singleton._ case class From(i: Int, s: String, a: Int, b: Int, c: Int) case class To(j: Int, s1: String, s2: String, a: Int,…
visa
  • 300
  • 2
  • 10
0
votes
0 answers

Converting HList to HMap[Int, TypeTag[_]] in shapeless

Lets assume the below code, import scala.reflect.runtime.universe._ import shapeless._ trait Base case class A() extends Base case class B() extends Base case class C() extends Base val tt = List(typeTag[A], typeTag[B], typeTag[C]) val tts =…
druuu
  • 1,676
  • 6
  • 19
  • 36
0
votes
1 answer

Macros/Shapeless to control string value in method

I'm creating a DSL where users have a given when then, where they pass a string with the action they want. All those actions are controlled using some regular expressions. Now using shapeless or macros I would like to control what users compones…
paul
  • 12,873
  • 23
  • 91
  • 153
0
votes
0 answers

Return result without losing type

I am trying to create partial function at the end of the step. Here is my adt to represent result of the process. sealed trait Result object Result { case class Success[T](result: T) extends Result case class Fail(cause: String) extends…
Br Meka
  • 11
  • 1
0
votes
1 answer

how to filter and extract case class objects from big flat csv files using shapeless?

I have a big flat denormalized csv file containing multiples objects on single row like this: a1, a2, a3, b1, b2, b3 ... ... and I have objects: case class A(a1: Int, a2: String, a3: Float) case class B... ... and the legacy is writing complicated…
zinking
  • 5,561
  • 5
  • 49
  • 81
0
votes
1 answer

Scala implicit specialization

I'm working on a generic conversion library and I'd like to add automatic typeclass derivation using shapeless. It works in the general case but I'd like to introduce Haskellesque newtypes with automatic unwrapping and so I'd like to specialize the…
erdeszt
  • 799
  • 5
  • 12
0
votes
1 answer

Extract type of labelled generic column

I have the following case class case class Test(field1: Int, field2: String) I want to be able to have a method that for a column name it can map that value to other, I want it to be typesafe meaning that the funtion f should accept the same type…
Mikel San Vicente
  • 3,831
  • 2
  • 21
  • 39
0
votes
1 answer

Get a SelectAll from Union in Shapeless / scala

I have a Union created from two HList, let say E and F. From this Union, I would like to get back a new HList with type E. It will not necessarily have the same value than the original list, but I don't care, I only want a HList with the correct…
Molochdaa
  • 2,158
  • 1
  • 17
  • 23
0
votes
1 answer

Shapeless HList Containing a Sequence

I have a String representation as below that I would like to represent as a HList. Here is it: 123456,/02/2017,0,0,0,0,0,0,170.153 So the type that I'm interested in is: Int :: DateTime :: Seq[Double] I was able to manage one-to-one mapping done,…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
0 answers

Error while using EntityAutoInc as a Dao generic in playframework

trait EntityAutoInc[PK, E <: EntityAutoInc[PK, E]] extends Entity[PK] { self: E => import shapeless._ import tag.@@ import tag.$at$at def copyWithNewId(id : PK)(implicit mkLens: MkFieldLens.Aux[E, Symbol @@ Witness.`"id"`.T, PK]) : E = …
user100557
  • 1
  • 2
  • 1
0
votes
1 answer

Scala shapeless: how to convert a hlist.Mapper to a case class?

I'm brand new to shapeless and I would like to transform a Mapper[mix.type, HNil]#Out to a case class How can I do this? (Let me know if you need more infos...)
Simon
  • 6,025
  • 7
  • 46
  • 98
0
votes
1 answer

Capturing an hlist's ToList evidence as an implicit class parameter

I'm trying to use shapeless's hlist to construct introspectable URL templates, but I'm having trouble with traversing my HList. The following doesn't compile: import shapeless.{::, HList, HNil} import shapeless.LUBConstraint._ import…
Chad
  • 2,064
  • 1
  • 22
  • 29
0
votes
1 answer

Add multiple elements to shapeless HList

How to add multiple items to HList? My naive version doesn't compile: (1 to 100).foldLeft(HNil)((l,i) => i :: l) For ordinary Lists this approach would work well. For HList, however, I assume, it's required to provide a Poly2 that takes a single…
0
votes
1 answer

Compile time structural typing of close method

I've got the following helper method in my project: def close(c: Closeable) { Option(c).foreach(s => Try(s.close)) } I've got some classes that have a close method but do not implement Closeable. If I change the helper method to use structural…
eirirlar
  • 814
  • 6
  • 24
0
votes
0 answers

Create encoder for parametrized case class using Shapeless HList

I want to implement ItemEncoder type class for Element class and encode elements collection trait Tag case class Element[A](attrName: String, value: A) extends Tag val elements = Element("name", "foo") :: Element("age", 37) :: Element("married",…
iuriisusuk
  • 424
  • 5
  • 15