[Haskell-beginners] Why are the types of the result different?

Russ Abbott russ.abbott at gmail.com
Wed Sep 29 21:19:33 EDT 2010


testWhere1 = a
             where b = 1
                      a = b+1

> testWhere1
 2

testWhere2 = a
             where b = 1
                      c = 1/(b - b)
                      a = b+1

> testWhere2
 2.0

The same thing happens with let.

testLet1 = let a = b+1
                         b = 1
               in a

> testLet1
2

testLet2 = let a = b+1
                   c = 1/(b - b)
                   b = 1
               in a

> testLet2
2.0



-- Russ Abbott
______________________________________
  Professor, Computer Science
  California State University, Los Angeles

  Google voice: 424-242-USA0 (last character is zero)
  blog: http://russabbott.blogspot.com/
  vita:  http://sites.google.com/site/russabbott/
______________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100929/b82ab3dc/attachment.html


More information about the Beginners mailing list