tut icon indicating copy to clipboard operation
tut copied to clipboard

Type rewriting?

Open tpolecat opened this issue 9 years ago • 4 comments

@milessabin asked if types could be rewritten ... perhaps by removing prefixes like shapeless. or scalaz. and then rewriting selected type constructors like (:: and \/) in infix form. Would be nice if this could be done without rewriting the output stream, but so far IMain has been immune to hacking attempts. Worth another look.

tpolecat avatar Mar 26 '15 17:03 tpolecat

It also occurs to me that this might be a better contribution to Scala itself since most of us would like to have this behavior for real in the REPL.

tpolecat avatar Mar 26 '15 17:03 tpolecat

Might be possible via some kind of integration with Ammonite?

tpolecat avatar Jun 23 '15 05:06 tpolecat

Ammonite already does this... feel free to use it, or just grab the code to vendor in your own projects. It's like one file:

https://github.com/lihaoyi/Ammonite/blob/master/repl/src/main/scala-2.11/ammonite/repl/frontend/TPrintImpl.scala#L1

  • some autogenerated thing to TPrint functions and some interfaces so 2.10.x can fall back to .toString

lihaoyi avatar Jan 31 '16 01:01 lihaoyi

really interested in this feature, going to do some digging around ammonite with an eye toward whether a tut integration is possible

any more recent context on the state/plausibility of this is welcome!

my immediate use-case is overhauling the docs on hammerlab/iterators, where a lot of examples' return-values' toString is non-empty iterator 😆

vaguely related is also a ToLines type-class I wrote/use, and customizable auto-derivations for it

ryan-williams avatar Mar 15 '18 00:03 ryan-williams