Re: Haskell 2020: 'let' to be optional and with wider scope of visibility, like other Haskell functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Haskell 2020: 'let' to be optional and with wider scope of visibility, like other Haskell functions

Doug McIlroy
> It's just helping clean up a bit words that doesn't have much meaning.
> Currently GHCi in GHC 8 is supporting this, so you could write both:
>
> x = 10
> x <- return 10
>
> Which is great!

I trust that "x = 10" above does NOT t mean the same as "let x = 10".
If it did, then it wouldn't mean what it does in Haskell.
Then code tried successfully in GHCI could fail in GHC.

Compare this GHCI session
        > let x = 10
        > :t x
        x :: Num a => a
        > x + 0.0
        10.0
to this, in which x = 10 has its Haskell meaning
        > :! cat test.hs
        x = 10
        > :load test.hs
        > :t x
        x :: Integer
        > x + 0.0
        No instance for (Fractional Integer) arising from the literal ‘0.0’.

Doug
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Haskell 2020: 'let' to be optional and with wider scope of visibility, like other Haskell functions

Brandon Allbery
On Wed, Apr 19, 2017 at 4:25 PM, Doug McIlroy <[hidden email]> wrote:
I trust that "x = 10" above does NOT t mean the same as "let x = 10".
If it did, then it wouldn't mean what it does in Haskell.
Then code tried successfully in GHCI could fail in GHC.

Compare this GHCI session
        > let x = 10
        > :t x
        x :: Num a => a
        > x + 0.0
        10.0
to this, in which x = 10 has its Haskell meaning
        > :! cat test.hs
        x = 10
        > :load test.hs
        > :t x
        x :: Integer
        > x + 0.0
        No instance for (Fractional Integer) arising from the literal ‘0.0’.

That's got nothing to do with 'let', it's about ghci having the monomorphism restriction turned off by default. (try ":showi language")

--
brandon s allbery kf8nh                               sine nomine associates
[hidden email]                                  [hidden email]
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.