
Thanks for the tip, David, I didn't know about that flag! Looks
really handy for playing with EDSLs, which is usually better off
displayed through Doc, but the default Show instance is indispensable
when I find a bug in the conversion to the Doc.
Unfortunately, though, I'd be reluctant to make data-pprint the
universal default as it is now. I forgot to mention this in my
previous post, but data-pprint doesn't let you customize the output
per-datatype. It just works generically over Data.Data instances and
the format is fixed to be the same as default Show instances (except
for lists, which are special-cased internally). So as annoying as the
explicit pprint is, I see it as a necessary evil. Perhaps I can
generalize its interface and send a patch. I have some ideas but
never got around to trying them.
On Wed, Jul 24, 2013 at 10:16 PM, David McBride
You might like to know about this option for ghci -interactive-print
I tested it with data-pprint though and it didn't work because it returns an IO Doc instead of IO () (I assume). But if you wrote a function that used that, returned the right type, cabal installed it and put it in your .ghci, you would have your pprinting by default whenever you use ghci.
On Wed, Jul 24, 2013 at 7:33 AM, Jun Inoue
wrote: The data-pprint package's pprint function might give you a quick fix. For example:
Prelude> :m Data.PPrint Prelude Data.PPrint> pprint [1..] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, …, ……] Prelude Data.PPrint> let long_computation = long_computation Prelude Data.PPrint> pprint [1, long_computation, 3] [1, ⊥₁, 3] ⊥₁: timeout at 0%
It's a bit of a hassle to have to type "pprint" all the time though, and it doesn't give you a way to show the data without printing to the terminal in the IO monad.
On Wed, Jul 24, 2013 at 4:30 AM, yi lu
wrote: I am wondering how can I ask ghci to show an infinite list wisely. When I type
fst ([1..],[1..10])
The result is what as you may guess
1,2,3,4,...(continues to show, cut now)
How could I may ghci show
[1..]
this wise way not the long long long list itself?
Yi
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Jun Inoue
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Jun Inoue