Printf and bool

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Printf and bool

Aditya Mahajan
Hi,

I like the printf function from Text.Printf to display results on the
terminal. I noticed that there is no format specifier for Bool. Can
someone suggest how to create an instance of PrintfArg for Bool?

Aditya

Reply | Threaded
Open this post in threaded view
|

Printf and bool

Brent Yorgey-2
On Mon, Jan 19, 2009 at 10:04:21AM -0500, Aditya Mahajan wrote:
> Hi,
>
> I like the printf function from Text.Printf to display results on the
> terminal. I noticed that there is no format specifier for Bool. Can someone
> suggest how to create an instance of PrintfArg for Bool?

Why not just use something like

  printf "%s" (show b)

where b :: Bool ?

-Brent
Reply | Threaded
Open this post in threaded view
|

Re: Printf and bool

Aditya Mahajan
On Mon, 19 Jan 2009, Brent Yorgey wrote:

> On Mon, Jan 19, 2009 at 10:04:21AM -0500, Aditya Mahajan wrote:
>> Hi,
>>
>> I like the printf function from Text.Printf to display results on the
>> terminal. I noticed that there is no format specifier for Bool. Can someone
>> suggest how to create an instance of PrintfArg for Bool?
>
> Why not just use something like
>
>  printf "%s" (show b)
>
> where b :: Bool ?

Because it breaks type safety.

Aditya