Importing Haskell modules
Asked Answered
S

2

5

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!

Schilit answered 13/11, 2010 at 1:29 Comment(2)
From the error message, I assume you're using cabal to build your project. In that case, you need to list the packages your project depends on in its cabal file. I think the syntax is something like "build-depends: time, directory"; I'm sure someone here will know the exact syntax if that's not it.Heartsick
I've been using Leksah. Maybe its using Cabal behind the scenes and I need to manually configure the build???Schilit
C
10

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...).

Chung answered 13/11, 2010 at 7:7 Comment(0)
A
4

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.

Archdeaconry answered 13/11, 2010 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.