Joy of joys, I found it completely by accident while looking for something 
completely different in this excellent online ClojureScript book:

https://funcool.github.io/clojurescript-unraveled/#printing

For reference (and in case the above link doesn't work for any reason), you 
need to implement IPrintWithWriter, like thus:

IPrintWithWriter
  (-pr-writer [p writer _]
    (-write writer (str "#<MyType " ,,, ">")))


on your type.

Simply brilliant!

On Saturday, April 25, 2020 at 9:11:25 AM UTC+5:30, Outrovurt # wrote:
>
> If I create a type like this
>
> (deftype MyType [x] ...)
>
> is there any way I can control what is displayed at the REPL when I create 
> a new instance of MyType?
>
> At present all I see is:
>
> cljs.user=> (MyType. 1)
> #object[cljs.user.MyType]
>
> It's this "#object[cljs.user.MyType]" which I'd like to customise. I've 
> checked so much of the documentation and can't find anything which might 
> let me display something else.
>
> Thanks.
>
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojurescript/147e222c-150b-434d-b183-05d1b96e17bf%40googlegroups.com.

Reply via email to