[Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

Daniel Fischer daniel.is.fischer at web.de
Sun Aug 27 08:18:17 EDT 2006

Am Sonntag, 27. August 2006 01:02 schrieb Daniel Fischer:
> Extremely odd,
> today ghc 6.4.2 (also on linux) works for me, too:
> Prelude InfixR> show (A `And` A)
> "A `And` A"
> Prelude InfixR> show (And A A)
> "A `And` A"
> Prelude InfixR> read (show (And A A)) :: T
> A `And` A
> Prelude InfixR> read "And A A" :: T
> *** Exception: Prelude.read: no parse
> Prelude InfixR> read "A `And` A" :: T
> A `And` A
> (and it can't read "And A A", which is what ghc 6.2.2 could read),
> yesterday it couldn't read either form.
> What sort of hiccough could produce such behaviour?????????
> Bewildered,
> Daniel

Probably my sleep deprived memory erred and what couldn't read either form
was ghc 6.4.1. Bash history confirms that this is definitely a possibility.
And since it's far easier to believe that I erred in this respect than that 
the derived Read instance of one day could read what that from another day 
couldn't, I'm pretty sure that's what happened.

Another thing:
Would it be a good idea to create derived Read instances that could parse 
both, "A `And` A" and "And A A" ?
Since 6.4.2 parses the former and 6.2.2 parses the latter that should be 
possible, I believe (and both forms are accepted at the ghci prompt).



"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
	-- Blair P. Houghton

More information about the Haskell-Cafe mailing list