Laws for Show and Read?

David Feuer david.feuer at gmail.com
Wed Jun 5 15:02:03 UTC 2019


We already have the law

  read . show = id

which implies the injectivity and surjectivity conditions you specify.

On Wed, Jun 5, 2019, 3:45 AM Dannyu NDos <ndospark320 at gmail.com> 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.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20190605/9217a9fd/attachment.html>


More information about the Libraries mailing list