[Haskell-cafe] Can I destructive rebind a local variable in haskell?

Wang, Chunye (NSN - CN/Beijing) chunye.wang at nsn.com
Tue Jan 6 02:33:00 EST 2009


Dear haskeller,
 
    Can I destructive rebind a local variable like this
 
import System.Directory
test filename = do 
  is_dir <- doesDirectoryExist filename
  let filename = if not is_dir then filename else filename
  putStrLn $ " filename " ++ filename
main = test "."
 
 
  in GHCi 6.10.1 on WinXP, the ghci aborts silencely when I executes
"main"
  after compile it into a executable file. 
 
c:\USERS\home\learning_haskell\>testDirectory
testDirectory
C stack overflow in generated code

  I have some code in scheme which works very well 
 
(define (func x)
  (let ((x x))
    x))

    By rebinding a formal variable, we can save naming some varaibles. I
am not good at naming a variable.

    Thank you in advance

Best Regards 
Chunye Wang <chunye.wang at nsn.com> 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090106/6eb670eb/attachment.htm


More information about the Haskell-Cafe mailing list