
Dear Haskellers, dear GHC team, Is a variable `_x' equivalent to `_' ? I discover that ghc-6.2.2 assigns a value to _rem in the program f :: Int f = let (q, _rem ) = quotRem 5 2 (q', _rem') = quotRem 7 4 in _rem + _rem' I got used to write the programs like let (x, _remainder ) = ... (y, _remainder') = ... in x + y using _remainder as a self-commenting dummy variable. Because it is a better commentary than `_'. And now, it occurs that these are the variables taking values! And removing the quote suffix from _remainder' even leads to the report of "conflicting definitions". Does really Haskell mean this? It this reasonable? How to set self-commenting dummy variables? Or, maybe, it is a GHC bug? Thank you in advance for the explanation. ----------------- Serge Mechveliani mechvel@botik.ru

In message <20041229115341.A431@botik.ru> "Serge D. Mechveliani"
Dear Haskellers, dear GHC team,
Is a variable `_x' equivalent to `_'
No, '_x' is a perfectly ordinary variable. The only special "dummy variable" (a pattern that matches anything but does not bind a varialbe) is '_'.
Does really Haskell mean this? It this reasonable? How to set self-commenting dummy variables?
You can use them as dummy variables by never using them in an expression context, only in pattern/binding context. As you noted they should be unique withing each scope. Duncan

Except for GHC, where a variable staring with an '_' will not report a warning if it is unused in the body of a funtion: let _ = x in y -- no warning let result = x in y -- waring about result being unused let _result = x in y -- no warning, but variable can still be used. Keean. Duncan Coutts wrote:
In message <20041229115341.A431@botik.ru> "Serge D. Mechveliani"
writes: Dear Haskellers, dear GHC team,
Is a variable `_x' equivalent to `_'
No, '_x' is a perfectly ordinary variable. The only special "dummy variable" (a pattern that matches anything but does not bind a varialbe) is '_'.
Does really Haskell mean this? It this reasonable? How to set self-commenting dummy variables?
You can use them as dummy variables by never using them in an expression context, only in pattern/binding context. As you noted they should be unique withing each scope.
Duncan _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (3)
-
Duncan Coutts
-
Keean Schupke
-
Serge D. Mechveliani