hobwekiva / newtypes

MIT License
115 stars 4 forks source link

Can't put opaque newtypes in Arrays #6

Closed joroKr21 closed 4 years ago

joroKr21 commented 6 years ago

But you can put translucent newtypes:

@translucent type Foo = Int
@opaque type Bar = Int
Array(Foo.Impl(42)) // ok
Array(Bar.Impl(42)) // no ClassTag

I couldn't come up with a modification of the encoding that would solve this. Maybe at least add a row in the comparison table for Arrays

hobwekiva commented 6 years ago

Just add an implicit classTag: ClassTag[Bar] in the companion object.

joroKr21 commented 6 years ago

A ClassTag that points to java.lang.Integer or Int? Maybe this should be added by the macro annotation.

joroKr21 commented 4 years ago

In general this doesn't work, e.g.

  type HK[G[_], A] = G[A]
  @opaque type OpaqueHK[G[_], A] = HK[G, A]