Time cost of Haskell `seq` operator

前端 未结 5 1160
逝去的感伤
逝去的感伤 2021-02-13 22:32

This FAQ says that

The seq operator is

seq :: a -> b -> b

x seq y will evaluate x, enough to chec

5条回答
  •  生来不讨喜
    2021-02-13 23:12

    You can always check with unsafePerformIO or trace

    import System.IO.Unsafe (unsafePerformIO)
    
    main = print (x `seq` f (x + x))
      where
        f = (+4)
        x = unsafePerformIO $ print "Batman!" >> return 3
    

提交回复
热议问题