
People, I have a question about usage of `show' in the GHCi dialogue system. I introduce my user class DShow, trying to improve the class Show of Haskell-98. For example, I program --------------------------- class DShow a where dShow :: ShowOptions -> a -> String ... main = let listOfListPairs = [ ([1,2,3], [] ), ([4,5,6], [7] ), ([9,8,0], [0,0,0]) ] :: [ ([Int], [Int]) ] opts = ShowOptions {verbosity = 2, listSepator = ", \n\n", fieldSeparator = ", \n"} in putStr (dShow opts listOfListPairs) --------------------------- Then, the command ./Main outputs ----------------------- [([1, 2, 3], []), ([4, 5, 6], [7]), ([9, 8, 0], [0, 0, 0])] ----------------------- This way of the output format control by dShow and ShowOptions is my goal. But the command
main
in the ghci interpreter outputs something like this: "[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]" How can the user force ghci to output the same output format as in the case of ./Main (how to interprete '\n') ? 1. If we give to the interpreter the line
listOfListPairs
, then the ghci dialogue system does interprete the NewLine characters on output as needed -- only for the value of (show listOfListPairs). And I need it for the value of (dShow opts listOfListPairs). Is there any way to substitute a user function instead of `show' in the ghci output? (and dShow has additional argument ...). 2. Which function outputs a string in the ghci dialogue system? Can the user make this function to interprete the NewLine character in the argument string? Thank you in advance for your explanation. ----------------- Serge Mechveliani mechvel@botik.ru

Hi Serge,
I think what you are looking for is putStr:
ghci> putStr "Test\nhere"
Test
here
Thanks
Neil
On 1/12/08, Serge D. Mechveliani
People,
I have a question about usage of `show' in the GHCi dialogue system.
I introduce my user class DShow, trying to improve the class Show of Haskell-98. For example, I program
--------------------------- class DShow a where dShow :: ShowOptions -> a -> String ... main = let listOfListPairs = [ ([1,2,3], [] ), ([4,5,6], [7] ), ([9,8,0], [0,0,0]) ] :: [ ([Int], [Int]) ] opts = ShowOptions {verbosity = 2, listSepator = ", \n\n", fieldSeparator = ", \n"} in putStr (dShow opts listOfListPairs) ---------------------------
Then, the command ./Main outputs
----------------------- [([1, 2, 3], []),
([4, 5, 6], [7]),
([9, 8, 0], [0, 0, 0])] -----------------------
This way of the output format control by dShow and ShowOptions is my goal. But the command
main
in the ghci interpreter outputs something like this:
"[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]"
How can the user force ghci to output the same output format as in the case of ./Main (how to interprete '\n') ?
1. If we give to the interpreter the line
listOfListPairs
, then the ghci dialogue system does interprete the NewLine characters on output as needed -- only for the value of (show listOfListPairs). And I need it for the value of (dShow opts listOfListPairs). Is there any way to substitute a user function instead of `show' in the ghci output? (and dShow has additional argument ...).
2. Which function outputs a string in the ghci dialogue system? Can the user make this function to interprete the NewLine character in the argument string?
Thank you in advance for your explanation.
----------------- Serge Mechveliani mechvel@botik.ru
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

On Sat, Jan 12, 2008 at 01:11:00PM +0000, Neil Mitchell wrote:
Hi Serge,
I think what you are looking for is putStr:
ghci> putStr "Test\nhere" Test here
Thank you. And my `main' function below did apply putStr. I am sorry, I got confused: cannot recall in what situation its output was "[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]" How strange ...
On 1/12/08, Serge D. Mechveliani
wrote: [..] --------------------------- class DShow a where dShow :: ShowOptions -> a -> String ... main = let listOfListPairs = [ ([1,2,3], [] ), ([4,5,6], [7] ), ([9,8,0], [0,0,0]) ] :: [ ([Int], [Int]) ] opts = ShowOptions {verbosity = 2, listSepator = ", \n\n", fieldSeparator = ", \n"} in putStr (dShow opts listOfListPairs) ---------------------------
Then, the command ./Main outputs
----------------------- [([1, 2, 3], []),
([4, 5, 6], [7]),
([9, 8, 0], [0, 0, 0])] ----------------------- [..] But the command
main
in the ghci interpreter outputs something like this: "[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]"
[..]

Hi Serge, On Sat, Jan 12, 2008 at 03:58:14PM +0300, Serge D. Mechveliani wrote:
main
in the ghci interpreter outputs something like this:
"[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]"
It shouldn't do; can you give a complete example please?
1. If we give to the interpreter the line
listOfListPairs
, then the ghci dialogue system does interprete the NewLine characters on output as needed -- only for the value of (show listOfListPairs). And I need it for the value of (dShow opts listOfListPairs). Is there any way to substitute a user function instead of `show' in the ghci output? (and dShow has additional argument ...).
Not as far as I know. Thanks Ian

On Sat, Jan 12, 2008 at 01:23:19PM +0000, Ian Lynagh wrote:
Hi Serge,
On Sat, Jan 12, 2008 at 03:58:14PM +0300, Serge D. Mechveliani wrote:
main
in the ghci interpreter outputs something like this:
"[([1, 2, 3), []),\n\n([4, 5, 6), [7]),\n\n([9, 8, 0],\n\n[0, 0, 0])]"
It shouldn't do; can you give a complete example please?
I am sorry, I got confused. Cannot recall in what situation it printed this. How strange ...
participants (3)
-
Ian Lynagh
-
Neil Mitchell
-
Serge D. Mechveliani