Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 它是“time-1.5'”包中的一个隐藏模块;“运行时”:加载数据.Time.Clock.UTC“;_Haskell - Fatal编程技术网

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
模块,您必须执行以下操作:

  • 导入数据.Time.Clock
  • 将谓词的定义更改为使用UTCTime而不是时钟时间
  • 从控件导入SomeException.Exception
  • 定义一个
    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 (\_ -> ...