Chris Kuklewicz wrote:
> > *MyShow> main
> > Hello" ""World #"[17,18,19]"!"
> > I also think [4,5,6]" and "7" are ""cool""."
> 
> The extra double quotes being what I am trying to avoid with MyShow

This is your only special case, a single list of a sigle type that is
different from other lists?  To avoid undecidable, incoherent and other
nasty instances, just do what the Prelude does:

class MyShow t where
    swim     :: t -> String
    swimList :: [t] -> String
    swimList [] = "[]"
    swimList xs = '[' : foldr1 (\x -> (swim x ++) . (',' :)) "]" xs

instance MyShow Char where
    swim     = (:[])
    swimList = id


Untested, but you get the idea.  It's pure Haskell 98.  Heck, it's
almost Prelude.Show.  It won't scale to more type constructors easily,
but you didn't ask for that ability, either ;-)


Udo.
-- 
"As far as Clinton supposedly cheating on his wife, what do people think
he's going to do?  Be president of another country while he's president
of ours?"
        -- Tom R., age 12

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to