Laws for Show and Read?

Li-yao Xia lysxia at gmail.com
Wed Jun 5 14:32:52 UTC 2019


Hi Dannyu,

On 6/5/19 3:45 AM, Dannyu NDos wrote:
> Shouldn't it be laws that "show" must be injective and "read" must be
> surjective? Without such laws, one could define:
> 
> data Foo = Foo
> instance Show Foo where
>      show _ _ = id
> instance Read Foo where
>      readPrec = pfail
> 
> which should be prevented.


This doesn't look like something anyone would ever want to do, even out 
of ignorance. So that example is not really compelling.

What is your general motivation to add "laws" to Show and Read?

Li-yao


More information about the Libraries mailing list