Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Haskell-beginners] Printf and bool

25 views
Skip to first unread message

Aditya Mahajan

unread,
Jan 19, 2009, 11:20:13 AM1/19/09
to begi...@haskell.org
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

_______________________________________________
Beginners mailing list
Begi...@haskell.org
http://www.haskell.org/mailman/listinfo/beginners

Brent Yorgey

unread,
Jan 19, 2009, 1:22:07 PM1/19/09
to begi...@haskell.org
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

Aditya Mahajan

unread,
Jan 19, 2009, 2:43:25 PM1/19/09
to begi...@haskell.org
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

0 new messages