[Haskell-cafe] symbol $

Maverick duongthaiha at gmail.com
Mon May 7 14:19:15 EDT 2007


Thanks a lot for your help

I got the idea of this symbol now.
It will be great if you can help me this time as well, this time is the
symbol @

Here is the code that i got

> evalExpr                          :: Expr -> Mem -> (Bool,Expr)
> evalExpr (Val x) _                =  (True,Val x)
> evalExpr (Var n) env              =  if isNothing (lookup n env) then
> (False,Var n) else (True,Val (envLookup n env))
> evalExpr c@(App op e1 e2) e       =  let (b1,v1) = (evalExpr e1 e)
>                           (b2,v2) =    (evalExpr e2 e)    >                           
> in if b1 && b2 then (True,Val (eval c e)) else (False,App op v1 v2)  
> Thanks once more

Best regard
Maverick 



Stefan Holdermans wrote:
> 
> Maverick,
> 
>> Do you mind tell what is mean by the symbol $ in this piece of  
>> code? Thanks
>> a lot.
> 
> It denotes function application:
> 
>    infixr 1 $
> 
>    ($)   :: (a -> b) -> a -> b
>    f $ x =  f x
> 
> Note how its precedence and associativity is the opposite of that of  
> 'regular' function application. The ($) is typically used to limit  
> the number of parentheses needed in a piece of code:
> 
>    f (g (h x)) vs. f $ g $ h $ x
> 
> There are other options though:
> 
>    (f . g . h) x
>    f . g . h $ x
> 
> HTH,
> 
>    Stefan
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

-- 
View this message in context: http://www.nabble.com/symbol-%24-tf3701618.html#a10362633
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list