Show the components of the sum

David Roundy droundy@jdj5.mit.edu
Mon, 23 Sep 2002 10:06:14 -0400


On Sat, Sep 21, 2002 at 02:55:24PM +0200, Frank Atanassow wrote:
>
> Almost. But then showA and showB are partial. It's better to do this:
> 
>   showA s = "A " ++ s
> 
> and similarly for B, and then:
> 
>   data D = A String | B String
>   instance  Show D where
>     show (A s) = showA s
>     show (B s) = showB s
>   instance  Read D where
>     readsPrec _ = readsD
>   readD s = (readsA s) ++ (readsB s)

Thank you for this advice! This solved my quandry quite cleanly.
-- 
David Roundy
http://civet.berkeley.edu/droundy/