Haskell 它是“time-1.5'”包中的一个隐藏模块;“运行时”:加载数据.Time.Clock.UTC“;
我正在尝试Haskell 它是“time-1.5'”包中的一个隐藏模块;“运行时”:加载数据.Time.Clock.UTC“;,haskell,Haskell,我正在尝试BetterPredicate.hs的,关于ClockTime的代码片段在我的ghc 7.6.3下抛出错误: Couldn't match expected type `ClockTime' with actual type `time-1.4.0.1:Data.Time.Clock.UTC.UTCTime' 根据Hyogel Lee对该书在线版本的评论,“getModificationTime在ghc 7.6.3中不返回时钟时间类型,但您可以使用UT
BetterPredicate.hs
的,关于ClockTime
的代码片段在我的ghc 7.6.3
下抛出错误:
Couldn't match expected type `ClockTime'
with actual type `time-1.4.0.1:Data.Time.Clock.UTC.UTCTime'
根据Hyogel Lee对该书在线版本的评论,“getModificationTime在ghc 7.6.3中不返回时钟时间类型,但您可以使用UTCTime来代替。”
,在prelude提示符下,我尝试了:+m Data.Time.Clock.UTC
,我得到了以下错误:
<no location info>:
Could not find module `Data.Time.Clock.UTC'
It is a member of the hidden package `time-1.4.0.1'.
it is a hidden module in the package `time-1.5'
it is a hidden module in the package `time-1.4.0.1'
但我还是不知道该怎么办
编辑:根据用户2407038,我使用ghc pkg unregister time-1.5
删除time-1.5,之后,我得到了类似的错误:
:m +Data.Time.Clock.UTC
Could not find module `Data.Time.Clock.UTC'
It is a member of the hidden package `time-1.4.0.1'.
it is a hidden module in the package `time-1.4.0.1'
及
要修复RWH第9章中的
BetterPredicate.hs
模块,您必须执行以下操作:
handleAny
函数saferFileSize
和getFileSize
函数中,使用handleAny
而不是handle
这里有固定代码:您有多个版本的时间,您几乎肯定会遇到问题,因此您应该注销一个版本。Data.Time.Clock.UTC似乎不存在于任何版本的时间中
getModificationTime
只返回Data.Time.Clock
中的UTCTime
。ClockTime
抛出错误的代码片段到底是什么?我问这个问题是因为我在BetterPredict.hs
用户5402中的任何地方都看不到Data.Time.Clock
,对不起!我犯了一个愚蠢的错误,我忘记使用源代码来重现这个问题的错误。它应该是源代码段中的System.Time
,这将导致错误与ghc 7.6.3下的预期类型
ClockTime'`不匹配。您需要发布您的BetterPredicate.hs
版本,并准确显示错误所在的行。抱歉,我不知道如何“加载UTCTime类型/构造函数”我可以运行:m+Data.Time.Clock
,但是我发现UTCTime
不是Clock
的直接子类型,当运行:t getModificationTime
时,我得到了`getModificationTime`:文件路径->IO Time-1.4.0.1:Data.Time.Clock.UTC.UTCTime
用户5402,谢谢您的时间!似乎。。。隐藏包时间-1.4.0.1
是我真正的问题。我已经尝试将所有的ClockTime
替换为UTCTime
。是的-尝试“ghc pkg hide time-1.5”看看是否能解决问题。对不起,我上面的评论不是很清楚。我已经更新了我的问题,并添加了两个注释,其中我解释了。。。隐藏包时间-1.4.0.1
是我真正的问题。所以,我不能接受你的回答。
:m +Data.Time.Clock.UTC
Could not find module `Data.Time.Clock.UTC'
It is a member of the hidden package `time-1.4.0.1'.
it is a hidden module in the package `time-1.4.0.1'
Prelude> :m +Data.Time.Clock
<no location info>:
Could not find module `Data.Time.Clock'
It is a member of the hidden package `time-1.4.0.1'.
UTCTime
:: time-1.4.0.1:Data.Time.Calendar.Days.Day -> DiffTime -> UTCTime
import Data.Time.Clock (UTCTime)
import Control.Exception (bracket, handle, SomeException)
...
type Predicate = FilePath -- path to directory entry
-> Permissions -- permissions
-> Maybe Integer -- file size (Nothing if not file)
-> UTCTime -- last modified
-> Bool
...
handleAny :: (SomeException -> IO a) -> IO a -> IO a
handleAny = handle
...
saferFileSize path = handleAny (\_ -> ...
...
getFileSize path = handleAny (\_ -> ...