Showing a Haskell list of tuples with custom syntax
问题 I have a list of tuples [(1,'a','%',"yes"),(2,'b','[',"no"),(3,'c',']',"ok")] . How can I show this list as output in the form of [(1,a,%,yes),(2,b,[,no),(3,c,],ok)] ? 回答1: Looks like the transformation you wish to make is to strip out quote characters? If so, filtering the results of calling show on your data will be enough: > let x = [(1,'a','%',"yes"),(2,'b','[',"no"),(3,'c',']',"ok")] Then apply a filter, > putStrLn . filter (`notElem` "'\"") . show $ x [(1,a,%,yes),(2,b,[,no),(3,c,],ok)]