0
我有一個返回IO X(假設X是特定類型)的函數。其中一個參數是輸出目錄的路徑。如果這不存在,它必須被創建。使用IO()操作,但返回IO X
我想使用createDirectoryIfMissing返回IO(),但我不知道如何保持類型一致。我所做的(和失敗)是這樣的:
process :: (Mutation a, Show a, Arbitrary a)
=> ((a -> BSL.ByteString),(BS.ByteString -> a))
-> Bool -> FilePath -> String -> String ->
Int -> Int -> FilePath -> FilePath -> IO Result
process (mencode,mdecode) par filename cmd prop maxSuccess maxSize outdir seeds =
let (prog, args) = (Prelude.head spl, Prelude.tail spl)
in (case prop of
"exec" ->
quickCheckWithResult stdArgs { maxSuccess = maxSuccess , maxSize = maxSize, chatty = not par }
(noShrinking $ execprop filename prog args mencode outdir)
"honggfuzz" ->
--do
--createDirectoryIfMissing True outdir (This fails)
quickCheckWithResult stdArgs { maxSuccess = maxSuccess , maxSize = maxSize, chatty = not par }
(noShrinking $ honggprop filename prog args mencode outdir)
_ -> process_custom arbitrary (mencode,mdecode) par filename cmd prop maxSuccess maxSize outdir seeds
) where spl = splitOn " " cmd
quickCheckWithResult ::可測試道具=>參數數量 - >屬性 - > IO結果 process_custom是基本相同的過程,但與其他參數
編輯:現在實際的代碼,對不起
您沒有看到足夠的代碼來查看您做錯了什麼。 – dfeuer
請至少爲您使用的編譯成功的東西提供類型簽名,以及您堅持使用的完整代碼。 – dfeuer
你的問題不太清楚。你想創建一個目錄並在那之後返回一些特定的內容? – wowofbob