[Haskell-cafe] question about show

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Thu Mar 6 04:21:22 UTC 2014


On 06/03/14 03:53, David Fox wrote:
> Show is supposed to convert its argument into a haskell expression which,
> when evaluated, returns the same value that was initially passed to show.
>  So by this definition, "\252" is just as correct  as "ü".
> 
> There are some Show instances out in the world that do not follow this
> rule, but they are bad.  I'm looking at you, Network.URI!
> 
> 

What about instances where we can't have a reasonable Show that fulfills
your requirement? Say, any structure which encapsulates a function.

While I agree that ideally Show (or some other typeclass) would be used
so that ‘read’ also works, it's not always possible. If people are
expected to follow the implicit Show rules then perhaps base functions
such as ‘print :: Show a => a -> IO ()’ shouldn't be using Show to begin
with! It's inconvenient to not make Show instances/make the instances be
readable if all the functions that actually let us have a look at the
structures use ‘Show’. ‘print’ is great and no one is going to abandon
in because one of the 30 fields in their structure happens to be a function.


-- 
Mateusz K.


More information about the Haskell-Cafe mailing list