Ticket #4273 (closed feature request: fixed)

Opened 3 years ago

Last modified 3 years ago

TextEncoding lacks Eq and Show instances

Reported by: bos Owned by: simonmar
Priority: normal Milestone: 7.0.1
Component: libraries/base Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

When trying to debug a Handle encoding problem today, I noticed that although I can use hGetEncoding to get the encoding, I cannot find out what that encoding actually is, as there is neither an Eq nor a Show instance for TextEncoding.

Change History

  Changed 3 years ago by simonmar

  • owner set to simonmar
  • component changed from Compiler to libraries/base
  • milestone set to 6.14.1

  Changed 3 years ago by simonmar

  • status changed from new to closed
  • resolution set to fixed

Fixed:

Mon Sep 13 16:44:59 BST 2010  Simon Marlow <marlowsd@gmail.com>
  * Add a suitable Show instance for TextEncoding (#4273)

I didn't add an Eq instance, but you can always get an approximate equality by comparing the results of show.

follow-up: ↓ 4   Changed 3 years ago by bos

Thanks. Any particular reason you didn't go for Eq too?

in reply to: ↑ 3   Changed 3 years ago by simonmar

Replying to bos:

Thanks. Any particular reason you didn't go for Eq too?

I wasn't completely sure what it should do. e.g. do you want an Iconv-backed UTF-8 codec to compare equal to the built-in UTF-8 codec? They are functionally identical, so perhaps they should. If so, then comparing the results of show would be sufficient. If not, then Eq is more tricky.

  Changed 3 years ago by bos

I'd imagine that if they do the same thing, then they should compare as equal.

  Changed 3 years ago by judahj

I'd prefer that we avoided an Eq instance. Eventually TextEncoding will be an exposed datatype which could be defined by other libraries than base. When that happens, there won't be any guarantee that two TextEncodings with the same name will actually do the same thing. So allowing comparisons with == will be misleading, I think.

Note: See TracTickets for help on using tickets.