Haskell 98 sections
Folks, You have all been eating too much Xmas pudding. Only one Haskell98 Report issue has arisen since my release of 21 Dec. The issue is this: Section 3.5 says that (a + b +) is a valid operator section (meaning \x -> a + b + x) because (+) is right associative. But this is contradicted by the actual syntax, which only has the productions: aexp ::= '(' exp(i+1) qop(a,i) ')' | '(' qop(a,i) exp(i+1) ')' (Here 'a' ranges over the possible operator associativities of left, right, non-assoc, while i ranges over precendence levels.) This is clearly an inconsistency. I propose to fix the syntax in the way proposed by Simon and Ian (in a thread on GHC-bugs), by adding the following productions for aexp. '(' lexp(i) qop(l,i) ')' '(' qop(r,i) rexp(i) ')' This actually follows the way that qfunlhs is defined. There is no ambiguity, because an exp(i+1) is not an lexp(i). This should bring the formal syntax into line with the words in Section 3.5. Can anyone think of a reason why this won't work? Simon
Simon Peyton-Jones wrote:
Folks,
You have all been eating too much Xmas pudding. Only one Haskell98 Report issue has arisen since my release of 21 Dec.
OK, here comes a rather trivial issue regarding the libraries: Section 7.6 of the Library Report gives the following example definition of nub: nub :: (Eq a) => [a] -> [a] nub [] = [] nub (x:xs) = x : nub (filter (\y -> x /= y) xs) But then, in Section 7.9, the following actual implementation is given: nub :: Eq a => [a] -> [a] nub = nubBy (==) nubBy :: (a -> a -> Bool) -> [a] -> [a] nubBy eq [] = [] nubBy eq (x:xs) = x : nubBy eq (filter (\y -> not (eq x y)) xs) The two definitions are only equivalent, if for all x and y holds that (x /= y) and (not (x == y)) are equivalent. While this is true for all basic types, and is also true for user defined instances of Eq, if the programmer specifies only one of the two functions (==) or (/=) and leaves the other one at the default method, nobody can prevent me from writing an instance declaration where I define (==) and (/=) without adhering to the duality. This might be stupid to do, but still it contradicts the report, right? Janis. -- Janis Voigtlaender http://wwwtcs.inf.tu-dresden.de/~voigt/ mailto:voigt@tcs.inf.tu-dresden.de
participants (2)
-
Janis Voigtlaender -
Simon Peyton-Jones