[Haskell-cafe] trace output statements
erik
eraker at gmail.com
Sun Dec 23 20:19:04 UTC 2018
Tom,
Why does "b" evaluate before "a" in your example? I would have thought
left-hand and then right-hand if needed. I'm on my phone but I'd like to
try the same example with booleans and `&&` instead of `+`.
Erik
On Sat, Dec 22, 2018, 11:40 PM Tom Ellis <
tom-lists-haskell-cafe-2017 at jaguarpaw.co.uk wrote:
> On Sat, Dec 22, 2018 at 09:52:18AM +0100, Damien Mattei wrote:
> > i have inserted trace statement that output variable
> > ... i have strange behavior of output:
>
> Let's take a simpler example. Do you understand why the trace statments
> from this small program appear in the order that they do? (And for what
> it's worth I really think you'll be better off writing programs using do
> notation).
>
>
> % cat test.hs
> import Debug.Trace
>
> result =
> let a = trace "evaluating a" 2
> b = trace "evaluating b" 10
> c = trace "evaluating c" (a + b)
> in c
> ~% ghci -e result test.hs
> evaluating c
> evaluating b
> evaluating a
> 12
> _______________________________________________
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20181223/cba4eaa0/attachment.html>
More information about the Haskell-Cafe
mailing list