<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><div style="direction: inherit;">Report says explicitly "ignoring associativity". Yet, I have written manual Show/Read to make Show of list-like data prettier: I don't know any problem with that. Would be good to know, why report is written as it is.</div><div style="direction: inherit;"><br></div><div style="direction: inherit;">- Oleg</div><div style="direction: inherit;"><br></div><div style="direction: inherit;"><span style="background-color: rgba(255, 255, 255, 0);">The result of <tt>show</tt> is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. Parentheses are only added where needed, <i>ignoring associativity</i>. No line breaks are added. The result of <tt>show</tt>is readable by <tt>read</tt> if all component types are readable. (This is true for all instances defined in the Prelude but may not be true for user-defined instances.)</span></div><br>Sent from my iPhone</div><div><br>On 6 Jan 2019, at 3.53, Dannyu NDos <<a href="mailto:ndospark320@gmail.com">ndospark320@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Sorry for the mix-up. I mean associativity, not fixity!<br></div><br><div class="gmail_quote"><div dir="ltr">2019년 1월 6일 (일) 오전 9:06, Dannyu NDos <<a href="mailto:ndospark320@gmail.com">ndospark320@gmail.com</a>>님이 작성:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace">For the following code as an example:</span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><div style="font-weight:normal;line-height:22px;white-space:pre-wrap"><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"> {-# LANGUAGE TypeOperators #-}</span></span></span></font></div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"> infixr 5 :.</span></span></span></font></div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"> data List a = Null | a :. List a deriving (Eq, Ord, Show, Read)</span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace">The Show instance and the Read instance are inaware of the fixity of (:.):</span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"> *Main> 2 :. 3 :. Null<br> 2 :. (3 :. Null)<br> *Main> read "2 :. 3 :. Null" :: List Int<br> *** Exception: Prelude.read: no parse<br> *Main> read "2 :. (3 :. Null)" :: List Int</span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"> 2 :. (3 :. Null)<br></span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace">The derived instances should be:</span></span></span></font></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div><div><div style="font-weight:normal;line-height:22px;white-space:pre-wrap"><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> instance Show a => Show (List a) where</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> showsPrec p Null = showParen (11 <= p) (showString "Null")</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> showsPrec p (x :. xs) = showParen (5 <= p) (go p (x :. xs)) where</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> go _ Null = showString "Null"</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> go p (x :. xs) = showsPrec p x . showString " :. " . go p xs</span></font></span></span></div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"><br></span></font></span></span><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span>instance Read a => Read (List a) where</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> readPrec = parens $ do</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> Ident "Null" <- lexP</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> return Null</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> +++ (do</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> x <- readPrec</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> Symbol ":." <- lexP</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> xs <- readPrec</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> return (x :. xs)</span></font></span></span></div><div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> <span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"> </span></font></span></span> )</span></font></span></span></div></div><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><font size="2"><span style="font-family:monospace,monospace"></span></font></span></span></div><div><font size="2"><span style="color:rgb(0,0,0)"><span style="background-color:rgb(255,255,255)"><span style="font-family:monospace,monospace"><br></span></span></span></font></div></div></div></div></div></div>
</blockquote></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Libraries mailing list</span><br><span><a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a></span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a></span><br></div></blockquote></body></html>