我有以下代码,已被剥离,我认为尽可能小,有一些非常奇怪的行为.
代码由两个源文件组成:一个用于定义一些数据:
module MyFunction where
data MyFunction =
MyFunction {
functionNumber :: Int,
functionResult :: IO String
}
makeMyFunction :: Show a => Int -> IO a -> MyFunction
makeMyFunction number result = MyFunction {
functionNumber = number,
functionResult = result >>= return . show }
Run Code Online (Sandbox Code Playgroud)
另一个是Main:
module Main (main) where
import System.CPUTime (getCPUTime)
import Data.List (foldl')
import Data.Foldable (foldlM)
import Control.Monad (foldM)
import MyFunction
exampleFunction = do
--let x = foldl' (\a b -> a `seq` (a + b)) …Run Code Online (Sandbox Code Playgroud) haskell ×1