Given:

data X = (:*){ x :: Int, y :: Int }  deriving(Show)

which is syntactically correct:

> constr -> con { fielddecl[1] , ... , fielddecl[n] } (n>=0)
> con -> ( consym )

and the following from 10.4:

     * If the constructor is defined to be an infix operator, then the
       derived Read instance will parse only infix applications of the
       constructor (not the prefix form). 

     * If the constructor is defined using record syntax, the derived
       Read will parse only the record-syntax form, and furthermore,
       the fields must be given in the same order as the original
       declaration. 

the behavor of the Show instance seems to be contradicted, since :+ is
an infix operator and is defined using record syntax. 

Suggested resolution:

     * If the constructor is defined using infix syntax, then the
       derived Read instance will parse only infix applications of the
       constructor (not the prefix form). 

Thus, 'data X = Int :+ Int' would show infix but 'data X = (:+) Int
Int' would not. 

Alternatively, change the con in the above production for constr to
conid, thus banning infix record constructors. 

Status:

[EMAIL PROTECTED]:/tmp$ cat Main.hs
data X = (:*) { x :: Int, y :: Int } deriving(Show)

main = print ((:*) 2 2)
[EMAIL PROTECTED]:/tmp$ runghc Main.hs
(:*) {x = 2, y = 2}
[EMAIL PROTECTED]:/tmp$ runhugs Main.hs
:* {x = 2, y = 2}
[EMAIL PROTECTED]:/tmp$ yhc Main.hs
Compiling Main             ( Main.hs )
[EMAIL PROTECTED]:/tmp$ yhi Main.hbc
2 :* 2
[EMAIL PROTECTED]:/tmp$

Note that the hugs output for this corner case is unparseable and thus
buggy!

Stefan
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to