These are chat archives for ensime/ensime-atom

30th
Jun 2016
Viktor Hedefalk
@hedefalk
Jun 30 2016 08:59
@d6y Is it possible for me to ask you a slick question? I feel it might be to stupid for SO… :)
Matthew de Detrich
@mdedetrich
Jun 30 2016 11:41
@hedefalk I use slick, so you can ask me
Also, another thing that I am sorely missing from Intellij, ability to create a “scala class”. Its the same as making a blank file, except that it puts the package name automatically at the top (and in Intellij it names the file the same as the class)
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:42
@mdedetrich I think it was a bit too stupid… But here it goes anyways:
Yeah, that we should probably make on the client. However, since using ensime, I actually started moving away from folders reflecting package names.
So, a global action like "create Scala class/trait/object" would probably need to ask for package name anyways and then there's not much gain…
Matthew de Detrich
@mdedetrich
Jun 30 2016 11:44
Well I personally do it all the time, but yeah its just a lot of time being wasted having to type package names at the top all of the time
And in our case, 90% of the time it does reflect the folder structure
(it actually comes up as an incorrect inspection in Intellij if it doesn’t follow the file structure)
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:45

I'm using Slick to make queries against an old legacy db and I'm typically way beyond 22 columns. So I'm into HList land. I feel this is cumbersome.

I want to be able to put my schema definitions in a separate artifact without compile time dependencies to my domain model. However, slick seems to need me to have some default projection of my Tables - they need to be typed to something. I don't entirely understand this.

So I do realize I could still probably get away with putting my table definitions in abstract classes that doesn't define the model type:

abstract class Activity[T](_tableTag: Tag) extends Table[T](_tableTag, "activity") {…}

Matthew de Detrich
@mdedetrich
Jun 30 2016 11:46
You can make your projections against a tuple instead of a case class
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:46
But I haven't seen much of that in any examples, so I'm feeling I'm doing something wrong… But I do feel I have a need to delay the translation into value classes/case classes/hlists or whatever and don't tie it to the schema definition.
Matthew de Detrich
@mdedetrich
Jun 30 2016 11:46
But you are going to have issues if you have more than 22 columns
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:47
Yeah, doesn't really help, still 22 limit and I also have to list the type.
I would like to just define my schema without any "output-type" so to speak. I guess I can by keeping the Table class abstract over type but then again…
Matthew de Detrich
@mdedetrich
Jun 30 2016 11:49
There is now a shapeless slick plugin which you can use
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:49
What do I gain? Better HList than slicks?
Matthew de Detrich
@mdedetrich
Jun 30 2016 11:53
Shapeless HList is a lot nicer to use, there is basically no boilerplate
Let me find the plugin
The shapeless HList actually allows you to automatically convert to case classes without any boilerplate, as long as they have the same structure
There are also various tutorials around
Viktor Hedefalk
@hedefalk
Jun 30 2016 11:59

HLists are killing my presentation compiler. This project is tiny, but my laptop is warm as hell. I actually would rather work with nested case classes, but then again, I don't feel they belong in the schema definition.

But thanks for the pointer, I'll try that one I think…

Matthew de Detrich
@mdedetrich
Jun 30 2016 12:00
Yeah I think that HLists are pretty taxing, but you can ask @fommil since Shapeless is used everywhere in ensime-server (iirc)
I think that nested case classes would give you a lot more problems, but I can’t comment entirely on your use case
(it seems like you wanted to avoid case classes)
Viktor Hedefalk
@hedefalk
Jun 30 2016 12:02
I wanted to avoid everything :)
Matthew de Detrich
@mdedetrich
Jun 30 2016 12:03
Honestly I think HList is a solution to the problem you are specifically asking for, but I am not sure about the issue regarding perfromance for presentation compiler. Shapeless does do a lot of fancy stuff, but then again, this generic stuff always pushes the compiler to its limits
Viktor Hedefalk
@hedefalk
Jun 30 2016 12:04
In my naivety, I thought I could somehow just define my schema somewhere with minimal boilerplate, and then make queries using this and directly map it into "anything". But I do now realize that Slick at some point needs to instantiate something that it itself understands from the db cursor, which is just tuples, case classes and hlists. So I gotta go via that before I do my in-app logic.
And since I'm well beyond 22 columns, I need HLists. But I don't like them :)
Matthew de Detrich
@mdedetrich
Jun 30 2016 12:07

In my naivety, I thought I could somehow just define my schema somewhere with minimal boilerplate, and then make queries using this and directly map it into "anything”.

This is what Slickless does. If tuples didn’t have 22 arity limit, then it would work just with tuples. Slick does provide its own HList implementation, but its inferior to shapeless (like if you want to map the HList to anything without boilerplate, you need shapeless for that)

Viktor Hedefalk
@hedefalk
Jun 30 2016 12:09
Gonna try it… Big problem is I will still have a (sure nicely typed, but still…) long lists of unnamed Longs, Strings, Dates and Crap to hold in my head.