Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Holiday Expansion #11

Merged
merged 6 commits into from
Jan 2, 2017
Merged

Holiday Expansion #11

merged 6 commits into from
Jan 2, 2017

Conversation

andyscott
Copy link
Collaborator

@andyscott andyscott commented Dec 28, 2016

  • Clean up type classes. Decoder is now more powerful and Read is only used for generic derivation.
  • Split modules more cleanly, limiting dependencies in the process.
  • Simplify tests
  • Cross build for ScalaJS
  • Support shocon or similar JVM/JS lib so there's a backend for ScalaJS

@andyscott
Copy link
Collaborator Author

andyscott commented Dec 31, 2016

@raulraja I wouldn't mind feedback from you or anyone else over the next few days as I make improvements

Copy link

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments with some ideas. LGTM! Looking fwd to the first release to integrate in Freestyle! Cheers!

}

sealed trait DecodeErrorInstances {
import wheel._

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😼

case (h, t) ⇒ field[K](h) :: t
})

implicit def mkDecoderGeneric[A, B, L <: HList](

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

}

/*
sealed abstract class UnconfiguredMkDecoder[A, B] extends Serializable {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a dirty WIP for supporting default values pulled from the case class constructors.

import org.scalacheck.Prop._

import org.scalacheck.derive._
import org.scalacheck.{ Shapeless ⇒ blackMagic }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

@@ -0,0 +1,69 @@
/* -

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all examples should go in tut files as parts of the docs or they'll be invisible for most casual users

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

import classy.typesafe._
import TypesafeDecoders.std._

val decodeA = string("a")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a decode[String]('path) over specific per datatype methods that are harder to remember.

val decodeBars = configList("bars") andThen decodeBar.sequence

implicit val decodeFoo = (decodeA and decodeB and decodeC and decodeBars).map {
case (((a, b), c), bar) ⇒ Foo(a, b, c, bar)
Copy link

@raulraja raulraja Dec 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pattern matching this way can be cumbersome. We should provide alternatives through the applicative cartesian builder in the exampels and for the main module an Unapply extractor to hide the nested tuples in the internals and not expose them to the end user so that we end up with something cleaner like:

(decodeA and decodeB and decodeC and decodeBars).map {
        case Decoded(a, b, c, bar)  Foo(a, b, c, bar)
}


libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 11)) => Seq(
compilerPlugin("com.milessabin" % "si2712fix-plugin" % "1.2.0" cross CrossVersion.full))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If using the typelevel compiler, do you need this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get 2.11 working w/ the typelevel compiler-- so I just did this instead. 2.11.9 should come out soon and then I can just use LB Scala.

@@ -1,5 +1,7 @@
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.5.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.3")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.8")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove most of these plugins when using sbt-microsites

@andyscott andyscott force-pushed the holiday-expansion branch 2 times, most recently from 77a50f4 to b733cce Compare January 2, 2017 19:36
@andyscott andyscott changed the title WIP holiday expansion Holiday Expansion Jan 2, 2017
@andyscott andyscott force-pushed the holiday-expansion branch 2 times, most recently from 44e6a0e to 41d9c4b Compare January 2, 2017 20:11
@andyscott andyscott merged commit a5edf6f into master Jan 2, 2017
@andyscott andyscott deleted the holiday-expansion branch January 2, 2017 20:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants