{"action":"created","issue":{"url":"https://api.github.com/repos/frees-io/iota/issues/187","repository_url":"https://api.github.com/repos/frees-io/iota","labels_url":"https://api.github.com/repos/frees-io/iota/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/frees-io/iota/issues/187/comments","events_url":"https://api.github.com/repos/frees-io/iota/issues/187/events","html_url":"https://github.com/frees-io/iota/issues/187","id":301155539,"number":187,"title":"Error when projecting a scalacheck Arbitrary Coproduct","user":{"login":"juanjovazquez","id":240119,"avatar_url":"https://avatars2.githubusercontent.com/u/240119?v=4","gravatar_id":"","url":"https://api.github.com/users/juanjovazquez","html_url":"https://github.com/juanjovazquez","followers_url":"https://api.github.com/users/juanjovazquez/followers","following_url":"https://api.github.com/users/juanjovazquez/following{/other_user}","gists_url":"https://api.github.com/users/juanjovazquez/gists{/gist_id}","starred_url":"https://api.github.com/users/juanjovazquez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juanjovazquez/subscriptions","organizations_url":"https://api.github.com/users/juanjovazquez/orgs","repos_url":"https://api.github.com/users/juanjovazquez/repos","events_url":"https://api.github.com/users/juanjovazquez/events{/privacy}","received_events_url":"https://api.github.com/users/juanjovazquez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-28T19:39:34Z","updated_at":"2018-02-28T20:28:40Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"A `java.lang.ClassCastException` is raised when projecting a sample `Coproduct` obtained through a scalacheck `Arbitrary`. Example:\r\n\r\n```scala\r\nimport iota.{ Cop, TNil }\r\nimport iota.TList.::\r\nimport iota.scalacheck._\r\nimport org.scalacheck.{ Arbitrary, Gen }\r\n\r\nobject IotaScalacheck {\r\n\r\n  object Monday\r\n  object Tuesday\r\n  object Wednesday\r\n  object Thursday\r\n  object Friday\r\n\r\n  type Weekday = Cop[\r\n    Monday.type ::\r\n    Tuesday.type ::\r\n    Wednesday.type ::\r\n    Thursday.type ::\r\n    Friday.type ::\r\n    TNil\r\n  ]\r\n\r\n  implicit val arbMonday    = Arbitrary(Gen.const(Monday))\r\n  implicit val arbTuesday   = Arbitrary(Gen.const(Tuesday))\r\n  implicit val arbWednesday = Arbitrary(Gen.const(Wednesday))\r\n  implicit val arbThursday  = Arbitrary(Gen.const(Thursday))\r\n  implicit val arbFriday    = Arbitrary(Gen.const(Friday))\r\n\r\n  def main(args: Array[String]): Unit = {\r\n    val weekday: Weekday = implicitly[Arbitrary[Weekday]].arbitrary.sample.get\r\n\r\n    val MondayInject    = Cop.Inject[Monday.type, Weekday]\r\n    val TuesdayInject   = Cop.Inject[Tuesday.type, Weekday]\r\n    val WednesdayInject = Cop.Inject[Wednesday.type, Weekday]\r\n    val ThursdayInject  = Cop.Inject[Thursday.type, Weekday]\r\n    val FridayInject    = Cop.Inject[Friday.type, Weekday]\r\n\r\n    weekday match { // runtime error! java.lang.ClassCastException: org.scalacheck.ArbitraryLowPriority$$anon$1 cannot be cast to IotaScalacheck$Thursday$\r\n      case MondayInject(day)    => println(day)\r\n      case TuesdayInject(day)   => println(day)\r\n      case WednesdayInject(day) => println(day)\r\n      case ThursdayInject(day)  => println(day)\r\n      case MondayInject(day)    => println(day)\r\n      case FridayInject(day)    => println(day)\r\n    }\r\n  }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/frees-io/iota/issues/comments/369372037","html_url":"https://github.com/frees-io/iota/issues/187#issuecomment-369372037","issue_url":"https://api.github.com/repos/frees-io/iota/issues/187","id":369372037,"user":{"login":"andyscott","id":310363,"avatar_url":"https://avatars3.githubusercontent.com/u/310363?v=4","gravatar_id":"","url":"https://api.github.com/users/andyscott","html_url":"https://github.com/andyscott","followers_url":"https://api.github.com/users/andyscott/followers","following_url":"https://api.github.com/users/andyscott/following{/other_user}","gists_url":"https://api.github.com/users/andyscott/gists{/gist_id}","starred_url":"https://api.github.com/users/andyscott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyscott/subscriptions","organizations_url":"https://api.github.com/users/andyscott/orgs","repos_url":"https://api.github.com/users/andyscott/repos","events_url":"https://api.github.com/users/andyscott/events{/privacy}","received_events_url":"https://api.github.com/users/andyscott/received_events","type":"User","site_admin":false},"created_at":"2018-02-28T20:28:40Z","updated_at":"2018-02-28T20:28:40Z","author_association":"MEMBER","body":"I think this is a mistake on my part:\r\nhttps://github.com/frees-io/iota/blob/84a417bab5585b1ac45a84f2c40bcfab4ba43f66/modules/scalacheck/src/main/scala/iota/scalacheck/package.scala#L18\r\n\r\n`gens` should be renamed to `arbitraries` then unsafe untyped line needs to be adjusted to get the `Gen` by calling `.arbitrary` on the arbitrary instance. Ideally we can add some tests to ensure this works correctly.\r\n\r\nI can take a stab at this later this week."}}
{"actor":{"display_login":"andyscott"}}