This commit is contained in:
xuwei-k 2018-06-27 10:55:02 +09:00
parent c54ff75965
commit 02174dbe56
3 changed files with 5 additions and 5 deletions

View File

@ -203,7 +203,7 @@ class TypeClassMacros(val c: Context) {
val skipMethod = !simpleArgs.foldLeft(true)(_ && _._2.isDefined)
if(skipMethod) List.empty else {
//rewrites all occurences of any of the args which are defined on the method to the lifted arg
//rewrites all occurrences of any of the args which are defined on the method to the lifted arg
val rewriteSimpleArgs = new FoldTransformer(simpleArgs.foldLeft(List.empty[Transformer]) {
case (ts, (_, Some(simpleArg), liftedTypeArg, _)) => new RewriteTypeName(from = simpleArg.toTypeName, to = liftedTypeArg.name) :: ts
})

View File

@ -10,12 +10,12 @@ import scala.collection.immutable.List
class JvmTypeClassTest extends WordSpec with Matchers {
"the @typeclass annotation" should {
"generate serializable traits by default" in {
seralizeDeserialize(Semigroup[Int]).append(1, 2) shouldBe 3
seralizeDeserialize(Functor[List]).map(List(1, 2, 3))(_+1) shouldBe List(2, 3, 4)
serializeDeserialize(Semigroup[Int]).append(1, 2) shouldBe 3
serializeDeserialize(Functor[List]).map(List(1, 2, 3))(_+1) shouldBe List(2, 3, 4)
}
}
def seralizeDeserialize[A](value: A): A = {
def serializeDeserialize[A](value: A): A = {
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream }
val bytesOut = new ByteArrayOutputStream()
val os = new ObjectOutputStream(bytesOut)

View File

@ -206,7 +206,7 @@ class Examples extends WordSpec with Matchers {
(1 |+| 2) =#= (2 |+| 1)
}
// Alernatively, multiple type class ops can be combined in to a syntax object, which provides
// Alternatively, multiple type class ops can be combined in to a syntax object, which provides
// a single import for all implicit conversions
{
object all extends Equal.ToEqualOps with Semigroup.ToSemigroupOps with Monoid.ToMonoidOps