Limits of Nat type in Shapeless

I will attempt one myself. I will gladly accept a better answer from Travis Brown or Miles Sabin. Nat can currently not be used to represent large numbers In the current implementation of Nat, the value corresponds to the number of nested shapeless.Succ[] types: scala> Nat(3) res10: shapeless.Succ[shapeless.Succ[shapeless.Succ[shapeless._0]]] = Succ() So to represent the number … Read more

Are HLists nothing more than a convoluted way of writing tuples?

Addressing questions one to three: one of the main applications for HLists is abstracting over arity. Arity is typically statically known at any given use site of an abstraction, but varies from site to site. Take this, from shapeless’s examples, def flatten[T <: Product, L <: HList](t : T) (implicit hl : HListerAux[T, L], flatten … Read more

IntelliJ Scala Plugin’s case class indentation is absurd

Try File -> Settings… -> Code Style -> Scala There are lots of settings to customize your code formatting in there. In the “Wrapping and Braces” tab, under “Method declaration parameters”: check “use normal indent for parameters” uncheck “Align when multiline” This will change it to the example you provided. If you want it to … Read more

How to access test resources in Scala?

Resources are meant to be accessed using the special getResource style methods that Java provides. Given your example of data.xml being in $SBT_PROJECT_HOME/src/test/resources/, you can access it in a test like so: import scala.io.Source // The string argument given to getResource is a path relative to // the resources directory. val source = Source.fromURL(getClass.getResource(“/data.xml”)) Of … Read more

How to quit scala 2.11.0 REPL?

I ran into the same issue on upgrade, just use colon q. :q Additionally, exit was deprecated in 2.10.x with sys.exit suggested instead, so this works as well: sys.exit As a side note, I think they did this so you can distinguish between exiting the scala console in sbt and exiting sbt itself, though I … Read more

What’s the best way to inverse sort in scala?

There may be the obvious way of changing the sign, if you sort by some numeric value list.sortBy(- _.size) More generally, sorting may be done by method sorted with an implicit Ordering, which you may make explicit, and Ordering has a reverse (not the list reverse below) You can do list.sorted(theOrdering.reverse) If the ordering you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)