migmit: (Default)
[personal profile] migmit
utop[0]> open Core.Std;;
utop[1]> let a = lazy (printf "A\n"; 0);;
val a : int lazy_t = <lazy>
utop[2]> let b (a : int) = lazy (printf "B\n"; 0);;
val b : int -> int lazy_t = <fun>
utop[3]> Lazy.force Lazy.(a >>= b);;
A
B
- : int = 0

Ну ё-моё...

Date: 2013-08-13 01:54 pm (UTC)
From: [identity profile] d-ao.livejournal.com
Ленивость в хаскеле:

a = do
print "A"
return 0

b x = do
print "B"
return 0

main = a >>= b

$ ./Proba01
"A"
"B"

Date: 2013-08-13 03:49 pm (UTC)
From: [identity profile] migmit.livejournal.com
a = trace "A" 0 и далее аналогично.