Marcin 'Qrczak' Kowalczyk wrote:
> Show instance for functions should not be needed. It is only for lazy
> programmers who want to make a quick dirty instance, for debugging
> perhaps.
And why not? There is no problem with Showing functions with finite domains.
For example, try:
module ShowFun where
instance (Show a) => Show (Bool -> a) where
show f = show ((f True),(f False))
instance (Show (a -> b -> c)) => Show ((a,b) -> c) where
show f = show (\ a b -> f (a,b))
If you load this into Hugs (with -98) then you will be able to show
functions like && and not,and much more complicated ones like
(\ (a,(b,c)) (d,e) -> length (filter id [a,b,c,d,e]))
Indeed since show returns a string which can be infinite I suppose you
can just as well define
instance (Show a) => (Show (Int -> a))
But you will need to be clever about interleaving if you want to be able
to show functions of type Int -> Int -> a in such a way that all strings
are distinguishable.
(I realise this message has no serious purpose whatsoever and apologise
to people whose time it has wasted. But it's the weekend after all.)