Skip to content

PatternSynonyms vs Show/Read #463

@kazu-yamamoto

Description

@kazu-yamamoto

PatternSynonyms solves the problem of closed sum types. However, it introduced a possible backward compatibility issue relating to Show and Read:

> import Network.Socket
> ReuseAddr 
SockOpt {sockOptLevel = 65535, sockOptName = 4}
> show ReuseAddr 
"SockOpt {sockOptLevel = 65535, sockOptName = 4}"
> read "ReuseAddr" :: SocketOption 
<interactive>:4:1: error:
    • No instance for (Read SocketOption) arising from a use of ‘read’
    • In the expression: read "ReuseAddr" :: SocketOption
      In an equation for ‘it’: it = read "ReuseAddr" :: SocketOption

It's easy to fix this issue by adding Read and Show instance by hand. I would like to discuss it's worth doing.

Relating to #459.

Cc: @vdukhovni, @eborden

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions