Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Li Haoyi
    @lihaoyi
    sure why not
    or Arrow
    just need to write a upickle visitor
    Srepfler Srdan
    @schrepfler
    that would be interesting, use big data tools to analyse logs directly
    and it would cost you less if you ship them around both in disk and network
    though I suppose everybody gzips the text anyhow
    Frank P. Tominc
    @franktominc
    I'm having a problem somewhere in the toolchain, not sure where. If I add only the pprint dependency I got some NoClassDef exceptions saying it couldn't find scala-reflect. Not really hard to fix, but it's annoying. Is there a way to make it a transitive dependency, so I don't need to add it manually on the build.sbt?
    Mark Moore
    @MarkRBM
    would we expect pprint to cut off output and add an ellipsis when being used with ammonite in a .sc file ?
    I don’t think its my shell truncating the output, if its pprint, is there a way for me to turn off truncation?
    sorry I see in the docs now that truncation is talked about a good bit, trying to find how to turn it off
    Li Haoyi
    @lihaoyi
    height = 99999
    Dermot Haughey
    @hderms
    curious if it would make sense to be able to turn that off wholesale or if there is some technical reason it's difficult
    I was just about to come in here to ask the same question as @MarkRBM
    Li Haoyi
    @lihaoyi
    no reason
    feel free to send a PR to make -1 disable truncation
    Dermot Haughey
    @hderms
    cool i'll look into doing it
    Anton Sviridov
    @keynmol

    Boy this room doesn't get much action :D

    I'm doing something for mdoc and playing with width and height values gives me surprising results:

    @ import $ivy.`com.lihaoyi::pprint:0.5.4`
    import $ivy.$
    
    @ val x = List.fill(15)("helloasdasdasdasdasdasdasdasd!")
    x: List[String] = List(
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
    ...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=5, width=10, initialOffset=0).foreach(print)
    List(
      "helloasdasdasdasdasdasdasda...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=2, width=10, initialOffset=0).foreach(print)
    List(
    ...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=8, width=10, initialOffset=0).foreach(print)
    List(
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasd...

    Are those values expressed in characters or tokens? and if it's tokens - how is height interpreted?

    Li Haoyi
    @lihaoyi
    width and height are meant to be in characters; can you try using 0.6.0? i fixed some bugs in the latest version
    initialOffset is meant to be any characters to the left of the first line of the thing you're printing, so it can wrap to the next line early if necessary
    Anton Sviridov
    @keynmol
    let me try 0.6.0
    I'm getting the same result:
    ➜  pprint git:(master) amm
    Loading...
    Welcome to the Ammonite Repl 2.2.0-4-4bd225e (Scala 2.13.3 Java 1.8.0_252)
    @ import $ivy.`com.lihaoyi::pprint:0.6.0`
    import $ivy.$
    
    @ val x = List.fill(15)("helloasdasdasdasdasdasdasdasd!")
    x: List[String] = List(
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasdasdasdasdasd!",
    ...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=5, width=10, initialOffset=0).foreach(print)
    List(
      "helloasdasdasdasdasdasdasda...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=2, width=10, initialOffset=0).foreach(print)
    List(
    ...
    
    @ pprint.PPrinter.BlackWhite.tokenize(x, height=8, width=10, initialOffset=0).foreach(print)
    List(
      "helloasdasdasdasdasdasdasdasd!",
      "helloasdasdasdasd...

    I'm also looking at one of the tests (I might be reading it wrong, I've only now imported pprint)

            test{
              val Check = new Check(width = 60, height = 5)
              Check(
                "a" * 1000,
                "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "..."
              )
            }

    It seems like it expects the width to be 60, but it checks that the string is truncated to roughly ~480 characters?

    Li Haoyi
    @lihaoyi
    the height takes into account terminal wrapping, in addition to any newlines that may be present in the output

    so if you lay out the string

    "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"+
                 "..."

    And wrap it every 60 characters, it gets truncated with ... when consuming a total of 5 vertical lines of space

    Li Haoyi
    @lihaoyi
    pprint doesn't actually do the wrapping of long strings, but assumes the terminal will wrap them at the specified width and truncates them accordingly to fit within the specified height
    Anton Sviridov
    @keynmol

    I see, and from the examples above does the height truncation look right to you?

    And with regards to width - if pprint is being run outside of a terminal (i.e. in mdoc it's used for markdown generation), it would default to the values it has, right? I guess pprint actually doesn't interact with terminal directly

    Anton Sviridov
    @keynmol
    Definitely some interesting interplay between width and height:
    ➜  pprint git:(master) ✗ cat test.sc
    import $ivy.`com.lihaoyi::pprint:0.6.0`
    
    val x = List.fill(sys.env("LIST_LENGTH").toInt)("a")
    
    pprint.PPrinter.BlackWhite
            .tokenize(x,
                      height=sys.env("HEIGHT").toInt,
                      width=sys.env("WIDTH").toInt,
                      initialOffset=0)
            .foreach(print)
    ➜  pprint git:(master) ✗ LIST_LENGTH=30 HEIGHT=15 WIDTH=2 amm test.sc
    List(
      "a",
      "a",
      "a",
      "a"...#
    ➜  pprint git:(master) ✗ LIST_LENGTH=30 HEIGHT=15 WIDTH=10 amm test.sc
    List(
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
      "a",
    .
    Li Haoyi
    @lihaoyi
    yeah the examples all look right
    if you manually line wrap them at width, it should be height lines tall (including the ...)
    if you’re not in a terminal, you may have to postprocess the output to wrap things yourself
    vito-c
    @vito-c
    Anyone know how to define a pprint.Config object so that you can change the width for your project ?
    Yuriy Badalyantc
    @LMnet

    Hi! Looks like link to the documentation in the readme is outdated: https://www.lihaoyi.com/PPrint/

    What's the correct url?

    Albert Bikeev
    @kell18
    Hi! Cmon, can somebody share the docs link please?
    Li Haoyi
    @lihaoyi
    looks like I forgot to update the link in the org move
    Albert Bikeev
    @kell18
    Cool, thanks!
    Albert Bikeev
    @kell18
    By the way, is there a way to print case class field names?
    I used this solution before https://stackoverflow.com/a/57080463/2453144
    but maybe it was merged and renamed somehow?
    Christopher McClellan
    @rubberduck203
    Does anyone know if there's a way to completely disable truncation?
    Christopher McClellan
    @rubberduck203
    Also, if the author is in here, I want to thank you from the bottom of my heart.
    I'm working on an interpreter and this is absolutely perfect for printing the AST out for debugging.
    Li Haoyi
    @lihaoyi
    I've been doing height = Int.MaxValue
    Christopher McClellan
    @rubberduck203
    That's not a terrible idea.
    Thanks!
    Matthew de Detrich
    @mdedetrich
    I just created com-lihaoyi/PPrint#64, let me know if anyone has any design issues/concerns
    I still need to write tests for it
    Matthew de Detrich
    @mdedetrich
    Also is there any actual CI?
    It seems like support for Travis is removed (no .travis.yml file) yet the status check on the PR is frozen
    Matthew de Detrich
    @mdedetrich
    Ah the feature already got added in, closing PR
    vito-c
    @vito-c
    https://www.lihaoyi.com/PPrint/ this doesn't resolve for me
    Vladimir Polushin
    @vovapolu
    Hi! Any plans to merge com-lihaoyi/PPrint#55 ? I need to print russian text :D