[Haskell-cafe] Re: dummy variables

Serge D. Mechveliani mechvel at botik.ru
Thu Dec 30 00:28:13 EST 2004


What I meant:
  is this reasonable for future Haskell to make
  a variable  _foo   equivalent to  `_' 
  ?
In this case, one can use  _foo  as a self-commenting dummy 
variable:
           let  (x, _newEqs, _newVars) = f a
                (y, _newEqs, newVars ) = f b
           in 
           x:y:newVars

These  _foo  help to recall the type of  f  (suppose f is in 
another file, so that one needs to search and recall). 
This makes it easier to read/understand the program. 

-----------------
Serge Mechveliani
mechvel at botik.ru



On Wed, Dec 29, 2004 at 06:17:30PM +0000, Keean Schupke wrote:

> 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 at botik.ru> "Serge D. Mechveliani"
> ><mechvel at botik.ru> 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 at haskell.org
> >http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
> >  
> >
> 
> 


More information about the Haskell-Cafe mailing list