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

Tuples are not pretty printed in REPL #3025

Closed
newca12 opened this Issue Aug 26, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@newca12
Contributor

newca12 commented Aug 26, 2017

scala> def foo[T](f: T => T, b: T) = f(b)
def foo[T](f: Function1[T, T], b: T): T
scala> def pairself[T](a:T) = (a,a)
def pairself[T](a: T): Tuple2[T, T]
scala> pairself(("ouch",2.0))
val res0: Tuple2[Tuple2[String, Double], Tuple2[String, Double]] = ((ouch,2.0),(ouch,2.0))

@felixmulder felixmulder changed the title from Types are not pretty printed in brand new REPL to Tuples are not pretty printed in REPL Aug 26, 2017

@felixmulder

This comment has been minimized.

Show comment
Hide comment
@felixmulder

felixmulder Aug 26, 2017

Contributor

Thanks for reporting, we haven't implemented these desugarings in UserFacingPrinter, should be trivial 👍

Contributor

felixmulder commented Aug 26, 2017

Thanks for reporting, we haven't implemented these desugarings in UserFacingPrinter, should be trivial 👍

@smarter

This comment has been minimized.

Show comment
Hide comment
@smarter

smarter Aug 26, 2017

Member

RefinedPrinter already has code to deal with this:

def toTextTuple(args: List[Type]): Text =
"(" ~ Text(args.map(argText), ", ") ~ ")"
def toTextFunction(args: List[Type], isImplicit: Boolean): Text =
changePrec(GlobalPrec) {
val argStr: Text =
if (args.length == 2 && !defn.isTupleType(args.head))
atPrec(InfixPrec) { argText(args.head) }
else
toTextTuple(args.init)
("implicit " provided isImplicit) ~ argStr ~ " => " ~ argText(args.last)
}

Member

smarter commented Aug 26, 2017

RefinedPrinter already has code to deal with this:

def toTextTuple(args: List[Type]): Text =
"(" ~ Text(args.map(argText), ", ") ~ ")"
def toTextFunction(args: List[Type], isImplicit: Boolean): Text =
changePrec(GlobalPrec) {
val argStr: Text =
if (args.length == 2 && !defn.isTupleType(args.head))
atPrec(InfixPrec) { argText(args.head) }
else
toTextTuple(args.init)
("implicit " provided isImplicit) ~ argStr ~ " => " ~ argText(args.last)
}

felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 29, 2017

felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 29, 2017

felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 29, 2017

felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 29, 2017

OlivierBlanvillain added a commit to dotty-staging/dotty that referenced this issue Aug 31, 2017

allanrenucci added a commit to allanrenucci/dotty that referenced this issue Sep 1, 2017

liufengyun added a commit to dotty-staging/dotty that referenced this issue Sep 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment