Skip to content

Simplify REPL #3560

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

Merged
merged 1 commit into from
Nov 27, 2017
Merged

Simplify REPL #3560

merged 1 commit into from
Nov 27, 2017

Conversation

allanrenucci
Copy link
Contributor

  • Remove monadic API when not needed: methods returning Result[T] now return T if failure is not possible
  • Other minor polishing

- Remove monadic API when not needed: methods returning `Result[T]`
now return `T` if failure is not possible
- Other minor polishing
Copy link
Contributor

@felixmulder felixmulder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Not sure I get why you're changing the print of Nil though.

val B: List[Int] = Nil
val C: List[Int] = Nil
val B: List[Int] = List()
val C: List[Int] = List()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@@ -72,12 +73,12 @@ object Show {

implicit def showList[T](implicit st: Show[T]): Show[List[T]] = new Show[List[T]] {
def show(xs: List[T]) =
if (xs.isEmpty) "Nil"
if (xs.isEmpty) "List()"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

else "List(" + xs.map(_.show).mkString(", ") + ")"
}

implicit val showNil: Show[Nil.type] = new Show[Nil.type] {
def show(xs: Nil.type) = "Nil"
def show(xs: Nil.type) = "List()"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is what scalac does:

scala> List()
res0: List[Nothing] = List()

scala> List(1, 2)
res1: List[Int] = List(1, 2)

I think it is more consistent

Copy link
Contributor

@felixmulder felixmulder Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\__(ツ)_/¯

Sounds like a debate for the ages. I'm definitely fine with the change, just wanted to know if there was some other motive beside the superficial one :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purely superficial =)

@allanrenucci allanrenucci merged commit 463b996 into scala:master Nov 27, 2017
@allanrenucci allanrenucci deleted the topic/repl branch November 27, 2017 15:47
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

Successfully merging this pull request may close these issues.

2 participants