
On Sun, Oct 19, 2014 at 9:18 AM, Herbert Valerio Riedel
On 2014-10-19 at 12:20:23 +0200, Herbert Valerio Riedel wrote:
[...]
instance Show (a -> b) where showsPrec _ _ = showString "<function>"
PS: An effect of having this instance made default in Prelude is that GHCi would show a somewhat different result in some cases (not sure though if this a good or bad thing):
GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. λ:2> id
<interactive>:2:1: No instance for (Show (a0 -> a0)) arising from a use of ‘print’ In a stmt of an interactive GHCi command: print it λ:3> import Text.Show.Functions λ:4> id <function> it :: a -> a
You seem to have ":set +t" on (show types), which isn't the default unless
it changed in HEAD very recently.
I'm -1 for reasons including
* Worse usability in ghci by default. If I see "No instance for (Show
(IOMode -> IO Handle))", I can figure out that I omitted an argument of
type IOMode, but if I see "<function>" I only know that I omitted some
argument, and I have to redo the command with :t to learn more.
* Precludes other instances Show (a -> b), some of which already exist in
the wild, e.g. lambdabot's that uses Typeable to produce a string like
"