문제

I'm new to Haskell. How come when I try to use Days from Data.Time I get this error:

Could not find module `Data.Time':
      It is a member of the hidden package `time-1.1.4'.
      Perhaps you need to add `time' to the build-depends in your .cabal file.

I am importing Data.List and Control.Monad, and neither gives me this error message, but the code import Data.Time does.

What am I missing?

Thanks for the help!

EDIT: I'm getting a similar error message when I use: import Directory

Thanks guys, your answers got me on track!

도움이 되었습니까?

해결책

Fire up Leksah with this project, open the package menu and select "edit package" from it. Now, choose "dependencies" and add the dependency you need (in your case time). You may also choose a version.

PS: Don't forget to hit the "save" button afterwards. (I think this is a design failure...).

다른 팁

Just edit the projects .cabal file, usually in the top directory named ProjectName.cabal and find the line(s) with "build-depends:" and add "time" to this list. No need for Leksah, unless you already use it.

EDIT: To answer your question of "why now and not with module X"

Data.Time is in the time package, which evidently isn't included in your build dependencies. Similar story for the Directory module. You don't get these errors with Data.List or Control.Monad because they are part of the base package which I'll bet is in your build-deps.

On a side note, it is worth taking time to learn what modules are in base and what functionality those modules provide. Base is rather large and very useful.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top