|
If you had the ability to export the contents of an evaluated worksheet, how would you like those to be formatted. For example, lets say we have the following: case class LongThing(a: String, b: String, c: String, d: String)
val longThing1 = LongThing("one", "two", "three", "four")
val longThing2 = LongThing("one", "two", "three", "four")
val longThing3 = LongThing("one", "two", "three", "four")
val longThing4 = LongThing("one", "two", "three", "four")
val longThing5 = LongThing("one", "two", "three", "four")
val myListOfThings =
List(longThing1, longThing2, longThing3, longThing4, longThing5)
myListOfThings.map(_.copy(c = "now I'm five")) |
Replies: 4 comments 6 replies
|
Option A aka more concise: case class LongThing(a: String, b: String, c: String, d: String)
val longThing1 = LongThing("one", "two", "three", "four") // : LongThing = LongThing("one", "two", "three", "four")
val longThing2 = LongThing("one", "two", "three", "four") // : LongThing = LongThing("one", "two", "three", "four")
val longThing3 = LongThing("one", "two", "three", "four") // : LongThing = LongThing("one", "two", "three", "four")
val longThing4 = LongThing("one", "two", "three", "four") // : LongThing = LongThing("one", "two", "three", "four")
val longThing5 = LongThing("one", "two", "three", "four") // : LongThing = LongThing("one", "two", "three", "four")
val myListOfThings =
List(longThing1, longThing2, longThing3, longThing4, longThing5)
// myListOfThings: List[LongThing] = List(
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four")
// )
myListOfThings.map(_.copy(c = "now I'm five"))
// res0: List[LongThing] = List(
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four")
// )The short evaluations that can fit on the same line are on the same line, and the long ones underneath. |
|
Option B aka more consistent: case class LongThing(a: String, b: String, c: String, d: String)
val longThing1 = LongThing("one", "two", "three", "four")
// longThing1: LongThing = LongThing("one", "two", "three", "four")
val longThing2 = LongThing("one", "two", "three", "four")
// longThing2: LongThing = LongThing("one", "two", "three", "four")
val longThing3 = LongThing("one", "two", "three", "four")
// longThing3: LongThing = LongThing("one", "two", "three", "four")
val longThing4 = LongThing("one", "two", "three", "four")
// longThing4: LongThing = LongThing("one", "two", "three", "four")
val longThing5 = LongThing("one", "two", "three", "four")
// longThing5: LongThing = LongThing("one", "two", "three", "four")
val myListOfThings =
List(longThing1, longThing2, longThing3, longThing4, longThing5)
// myListOfThings: List[LongThing] = List(
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four"),
// LongThing("one", "two", "three", "four")
// )
myListOfThings.map(_.copy(c = "now I'm five"))
// res0: List[LongThing] = List(
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four"),
// LongThing("one", "two", "now I'm five", "four")
// )All the evaluations are underneath the expression they belong to. |
|
I don't have a strong opinion, but would be leaning towards more consistent for exporting.. (need to think of reasons why though, so maybe +0.1 for option b :D) How would they be used? Blog posts? |
|
I have an alternative proposal: make mdoc a valid worksheet format! That is, evaluate the code snippets within I think this might be a better solution, since mdoc already is the definition of how to format output. Then to integrate, you could have a trivial |
Option B aka more consistent: