
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
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