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

Generate only friendly names for public exposed types generated by macro. #381

Open
raulraja opened this issue Jul 10, 2017 · 2 comments
Open
Projects

Comments

@raulraja
Copy link
Contributor

Since IDEA let's you expand and keep the expanded scalameta code we should only generate friendly names in types and type args expanded by our macros.

@raulraja raulraja added this to the Release 0.4.0 milestone Jul 10, 2017
@raulraja raulraja added this to Open in freestyle Jul 10, 2017
@anamariamv anamariamv moved this from Open to Backlog in freestyle Jul 12, 2017
@anamariamv anamariamv modified the milestones: Sprint 5, Release 0.4.0 Aug 23, 2017
@peterneyens
Copy link
Member

An example of the code generated by a @free algebra that is used in the tests :

{
  trait Y[FF$145[_]] extends _root_.freestyle.internal.EffectLike[FF$145] { def bar(x: Int): FS[Int] }
  @_root_.java.lang.SuppressWarnings(_root_.scala.Array("org.wartremover.warts.Any", "org.wartremover.warts.AsInstanceOf", "org.wartremover.warts.Throw")) object Y {
    sealed trait Op[_] extends _root_.scala.Product with _root_.java.io.Serializable { val FSAlgebraIndex144: _root_.scala.Int }
    final case class BarOp(x: Int) extends _root_.scala.AnyRef with Op[Int] { override val FSAlgebraIndex144: _root_.scala.Int = 0 }
    type OpTypes = _root_.iota.KCons[Op, _root_.iota.KNil]
    trait Handler[MM$151[_]] extends _root_.freestyle.FSHandler[Op, MM$151] {
      protected[this] def bar(x: Int): MM$151[Int]
      override def apply[AA$152](fa$153: Op[AA$152]): MM$151[AA$152] = ((fa$153.FSAlgebraIndex144: @_root_.scala.annotation.switch) match {
        case 0 =>
          val fresh154: BarOp = fa$153.asInstanceOf[BarOp]
          bar(fresh154.x)
        case i =>
          throw new _root_.java.lang.Exception("freestyle internal error: index " + i.toString() + " out of bounds for " + this.toString())
      }).asInstanceOf[MM$151[AA$152]]
    }
    class To[LL$147[_]](implicit ii$148: _root_.freestyle.InjK[Op, LL$147]) extends Y[LL$147] {
      private[this] val toInj149 = _root_.freestyle.FreeS.inject[Op, LL$147](ii$148)
      override def bar(x: Int): FS[Int] = toInj149(BarOp(x))
    }
    implicit def to[LL$147[_]](implicit ii$148: _root_.freestyle.InjK[Op, LL$147]): To[LL$147] = new To[LL$147]
    def apply[LL$147[_]](implicit ev$150: Y[LL$147]): Y[LL$147] = ev$150
  }
}

I don't now if IntellJ does any simplification while expanding?

I am not sure what we want to simplify? The things which make it harder to read are the fact that the types are fully qualified and that we use fresh types, but that is not really something we can change?

@raulraja
Copy link
Contributor Author

We should be able to change the usage of freshtypes because non of the types we use are external to the expansion. For example if FF$145[_] is defined as just F[_] would there be any issues beside potentially shadowing?

@anamariamv anamariamv modified the milestones: Sprint 5, Sprint 8 Oct 3, 2017
@anamariamv anamariamv removed this from the Sprint 8 milestone Oct 20, 2017
@anamariamv anamariamv removed the ready label Oct 20, 2017
@peterneyens peterneyens removed their assignment Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
freestyle
Backlog
Development

No branches or pull requests

3 participants