Giter Site home page Giter Site logo

Comments (13)

venantius avatar venantius commented on June 27, 2024

While I'm completely unfamiliar with Manifold, my guess is that this is an underlying issue with Whidbey, which injects some nREPL middleware in that is likely overriding something. Might take me a while to ferret this down.

from ultra.

greglook avatar greglook commented on June 27, 2024

This is because whidbey (which uses puget under the hood) has no integration with the built in print-method or print-dup multimethods. You can think of the built-ins as converting values into printed strings - Puget can't really know a-priori how to colorize those strings without doing parsing and syntax highlighting, which is way out of scope.

Puget's format-doc multimethod instead turns values into print documents, which are then serialized into text by fipp. If you want to add custom printing for values, you should define a new method for puget.printer/format-doc which outputs the appropriate data structure.

from ultra.

venantius avatar venantius commented on June 27, 2024

I think it's probably undesirable to force anybody who uses Ultra to write custom print-methods for their respective data structures. I'll try to think of some way of intelligently checking to see if Puget knows how to represent the data in question, and if not to defer to the data structure's native print methods.

from ultra.

DizzeePascall avatar DizzeePascall commented on June 27, 2024

👍 I ran into this issue today

@venantius I don't think the behaviour you've outlined above is the desired behaviour (at least in my case). For example, my company has a print-method for URIs so that they print as e.g. #org-name/uri "www.google.com" but Puget overrides this as #uri "www.google.com". Even with your suggested changes this would produce different serialisation on machines with Ultra to machines without it.

I'd prefer custom print-method methods to take preference over Puget

from ultra.

greglook avatar greglook commented on June 27, 2024

One option would be to add an option to Puget like :print-fallback which could select whether to use its built-in unknown formatter or Clojure's print-method.

from ultra.

venantius avatar venantius commented on June 27, 2024

@greglook Is print-method defined for all known classes such that checking to see if they have an implementation is a waste of time? I'm wondering if it might make sense (and/or be possible) to simply do an equality check on a given class' :print-method against some default or set of default :print-methods and if that fails to use the custom :print-method.

In the short term something like what you're describing makes sense as an escape hatch for 90% of Ultra's use cases, I'm just trying to think about what the sensible longer term solution might look like.

from ultra.

DizzeePascall avatar DizzeePascall commented on June 27, 2024

@venantius print-method has a default implementation. Is it possible to check whether there's a custom print-method before using Puget's alternative printing implementations?

TBH, I'd prefer the option @greglook suggests of having the option to disable Puget's formatter. It'd be simple and is the behaviour that I'd expect when using a general purpose dev environment like Ultra

from ultra.

greglook avatar greglook commented on June 27, 2024

If you look at the relevant code in Puget, you can see that the default dispatch for format-doc calls the single-argument arity of unknown-document. This uses str to render the value inside the <class@id repr> format.

A really simple change would be to use pr-str instead, so we would get any custom print-method output included in the document at least. I think the best alternate option is to add the :print-fallback config as above, which would change the default dispatch to just use pr-str and omit the other markup around the value.

from ultra.

venantius avatar venantius commented on June 27, 2024

After starting work on a Puget PR, I've come to realize that Manifold is something of a special case - it satisfies clojure.lang.IPending, which has a special format-doc method.

Since the Manifold deferred isn't realized, this ends up calling color-doc and going a rather different execution path, which ends up using the 3-arity version of unknown-doc.

Personally, my preference would be to default to just using the pr-str of unrealized clojure.lang.IPending values rather than explicitly evaluating their class names and printing those, but I'm open to more elegant solutions that I haven't considered.

from ultra.

venantius avatar venantius commented on June 27, 2024

@ztellman I believe this issue should be resolved with Ultra 0.3.0. If you're feeling so inclined, I'd recommend updating and giving it a try.

from ultra.

venantius avatar venantius commented on June 27, 2024

Better make that 0.3.2, given my release problems today :P

from ultra.

DizzeePascall avatar DizzeePascall commented on June 27, 2024

Works great for me, thanks for the fix. Now I can use Ultra at work again 👍

from ultra.

venantius avatar venantius commented on June 27, 2024

Marking as resolved unless @ztellman returns to say otherwise.

from ultra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.