Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic Shape coproduct types reversed in section 2.4 #58

Open
SamDM opened this issue Dec 11, 2017 · 2 comments
Open

Generic Shape coproduct types reversed in section 2.4 #58

SamDM opened this issue Dec 11, 2017 · 2 comments

Comments

@SamDM
Copy link

SamDM commented Dec 11, 2017

Near the end of section 2.4 there is the following example:

  sealed trait Shape
  final case class Rectangle(width: Double, height: Double) extends Shape
  final case class Circle(radius: Double) extends Shape

  val gen = Generic[Shape]

gen is supposed to be:

Generic[Shape]{type Repr = Rectangle :+: Circle :+: CNil} = ...

But when I try it, it is (note that Rectangle and Circle are in reversed order):

Generic[Shape]{type Repr = Circle :+: Rectangle :+: CNil} = ...

I am going through the book to learn about shapeless, I don't know if this is intended behavior of shapeless and a bug in the documentation or the other way around. Or does this only happen on my system? If this is a bug in shapeless I'll open an issue there (unless someone beats me to it).

I'm using scala 2.12.3 and shapeless 2.3.2, I'm compiling with sbt.

@SamDM
Copy link
Author

SamDM commented Dec 11, 2017

Some more experimenting showed that the types are sorted by alphabet instead of order of occurence

@davegurnell
Copy link
Collaborator

davegurnell commented Dec 12, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants