[Haskell-beginners] Re: Showing control characters
russ.abbott at gmail.com
Tue Nov 9 14:44:42 EST 2010
I wasn't at a computer with Haskell when I wrote the earlier message.
Here's how it seems to work.
*data *MyType = MyType
*instance *Show MyType *where*
show MyType = "a\nb"
Load the above file. Then:
> MyType -- This does what I want it to do after all.
> show MyType
> putStrLn (show MyType)
> print MyType
*-- Russ Abbott
* Professor, Computer Science
California State University, Los Angeles
Google voice: 424-235-5752 (424-cell-rja)
On Tue, Nov 9, 2010 at 9:40 AM, Russ Abbott <russ.abbott at gmail.com> wrote:
> Is there some way to include control characters in a Show string so that
> they take effect when the element is Shown?
> For example, if I define a String "a\nb" and use putStrLn on it, the \n
> causes a return, but when I simply return the string from a function, the \n
> is shown as \n. Is there a way to get the \n to execute when it's embedded
> in a returned value?
> -- Russ Abbott
> * Professor, Computer Science
> California State University, Los Angeles
> Google voice: 424-235-5752 (424-cell-rja)
> blog: http://russabbott.blogspot.com/
> vita: http://sites.google.com/site/russabbott/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners