Derived instance of Read/Show causes runtime exception for infix Unicode value constructors
When I run the following program test-show.hs
on ghc 7.10.3:
data Y = Д星 String String deriving (Eq, Ord, Show, Read)
data X = String :☆ String deriving (Eq, Ord, Show, Read)
main :: IO ()
main = do
let y = Д星 "" ""
d = 0
print $ map fromEnum $ show y
print $ (y, "") `elem` (readsPrec d (showsPrec d y ""))
print $ (read $ show y :: Y)
let x = "" :☆ ""
d = 0
print $ map fromEnum $ show x
print $ (x, "") `elem` (readsPrec d (showsPrec d x ""))
print $ (read $ show x :: X)
I got the following results:
$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 7.10.3
$ stack runhaskell test-show.hs
[1044,26143,32,34,34,32,34,34]
True
Д星 "" ""
[34,34,32,58,9734,32,34,34]
False
test-show.hs: Prelude.read: no parse
This behavior does not conform to Section 11.4 of Haskell 2010 Language Specification: https://www.haskell.org/onlinereport/haskell2010/haskellch11.html#x18-18600011.4 :
It should be the case that (x,"") is an element of (readsPrec d (showsPrec d x ""))
Trac metadata
Trac field | Value |
---|---|
Version | 7.10.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |