22 Apr
2003
22 Apr
'03
3:35 p.m.
Bernd Holzmüller <holzmueller@ics-ag.de> writes:
I'd like to have a better way for "showing" a list of things, e.g.
show (f1 t) ++ show (f2 t) ++ show (f3 t) ++ ....
I would love to just write: (f1 # f2 # f3) t but I do not see how to define an operator like # in Haskell without applying show over again on the first arguments (i.e. f1 and f2). Because polymorphic lists are not possible, I can not define # as to write [f1,f2,f3] # t either.
How about the following? infixr # (#) :: (Show b) => (a->b) -> (a->String) -> (a->String) f # g = \t-> show (f t) ++ g t newline, empty :: a -> String newline _ = "\n" empty _ = "" which you could use like (f1 # f2 # f3 # newline) t Regards, Malcolm