所以我的haskell程序看起来像这样:
main = do
secondData <- loadSecondBars "output.data"
putStrLn $ "Generated Second Data " ++ (show $ length secondData)
let tenMinBars = secondData `seq` generateBars (barSize featureSet) secondData
putStrLn $ "Generated Ten Minute Bars " ++ (show $ length tenMinBars)
let combinedData = seq tenMinBars sortBars (tenMinBars ++ secondData)
putStrLn $ "Generated Combined" ++ (show $ length combinedData)
let completedOrderManager = evalState (runBar combinedData) startState
putStrLn "Ran Algo"
这样做大约需要 8 秒来加载我的第二个数据,然后大约 3 秒来完成其余的功能。
但是,如果我删除显示长度数据,它会闪烁
"Generated Second Data"
"Generated Ten Minute Bars"
"Generated Combined"
"Ran Algo"
然后暂停一下,直到它运行完所有实际功能。
我的理解是通过在其中放置 seq 来阻止惰性评估。我用错了吗?