Comments (13)
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.
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.
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.
👍 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.
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.
@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.
@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.
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.
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.
@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.
Better make that 0.3.2, given my release problems today :P
from ultra.
Works great for me, thanks for the fix. Now I can use Ultra at work again 👍
from ultra.
Marking as resolved unless @ztellman returns to say otherwise.
from ultra.
Related Issues (20)
- compatibility with leiningen 2.9.0 HOT 4
- Ultra assert-expr changes `:actual` value
- Please support Java 11 HOT 1
- Does not work for JDK 12 + Clojure 1.10.0
- Does not work for JDK 12 + Clojure 1.10.0 + lein 2.9.1 HOT 9
- Exception with Puget when running lein repl HOT 4
- Fix `source` to follow provided custom colorscheme
- Ultra causes CIDER to hang indefinitely when running tests with some values HOT 11
- Comparisons between PersistentArrayMap and PersistentHashMap should diff on keys, not types HOT 1
- Whitespace in string diffs is incorrectly eliminated in tests.
- Test reporting can cause test code to run twice HOT 14
- On the main page you suggest to use version 0.5.3 but it does not exist HOT 1
- Is clojure 1.9 supported yet? HOT 5
- Newer ClojureScript versions clashes with rrb-vector which prevents building HOT 4
- If ultra is "finished" can the version reflect it? HOT 1
- Colors not working on Windows HOT 2
- using circleci.test with ultra HOT 5
- Update org.clojure/tools.nrepl 0.2.12 to nrepl 0.5.3? HOT 6
- Declare middleware HOT 5
- Broken on JDK11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultra.