11

I'm creating a simple website using yesod.

It was working until I added a field of type UTCTime to my database model.

I initially got an error suggesting I add "time-1.2.0.3" to my cabal file, so I did and now I get much the same error without the suggestion:

Model.hs:6:8:
    Could not find module `Data.Time.Clock.UTC':
      it is a hidden module in the package `time-1.2.0.3'
      Use -v to see a list of the files searched for.

The ghc command-line generated by cabal is:

"C:\Program Files (x86)\Haskell Platform\2011.2.0.1\bin\ghc.exe" --make -o dist\build\lpi\lpi.exe -hide-all-packages -fbuilding-cabal-package -package-conf dist\package.conf.inplace -i -idist\build\lpi\lpi-tmp -i. -idist\build\autogen -Idist\build\autogen -Idist\build\lpi\lpi-tmp -optP-DPRODUCTION -optP-include -optPdist\build\autogen\cabal_macros.h -odir dist\build\lpi\lpi-tmp -hidir dist\build\lpi\lpi-tmp -stubdir dist\build\lpi\lpi-tmp -package-id base-4.3.1.0-f520cd232cc386346843c4a12b63f44b -package-id bytestring-0.9.1.10-cd85f14e02463c02ba4c77d7adcdb54f -package-id clientsession-0.7.3.6-70ebb09e2b4c14267f1463cef3c932ea -package-id hamlet-0.10.5-1bacb5fe791e5cc9e28c8cf9f07c06e2 -package-id hjsmin-0.0.14-a1d374204877c150b681896452f205f4 -package-id mime-mail-0.4.1.0-05d76f10c6f18f7178113a6d760f371a -package-id monad-control-0.3.1-092d8fe82727181557b850f795f847bc -package-id persistent-0.6.4.3-6e59b956a206ce4f4a9296367507c2b8 -package-id persistent-sqlite-0.6.2.1-d32462e51baa09b53b6fd83dae922fc7 -package-id shakespeare-css-0.10.4-f8e17e4528d3a37edee74b13441720de -package-id shakespeare-js-0.10.3-dfec6b68f60671528332da06c9799659 -package-id shakespeare-text-0.10.3-a0ae9b85c3588ff2572080a6d1cdd4c3 -package-id template-haskell-2.5.0.0-7d9b1443ac5ab69e5ed705a487990deb -package-id text-0.11.1.9-a75bb47eca7b1c98d59b7697de77ca4d -package-id time-1.2.0.3-74ef6ac31cee9aec02b036978af002d2 -package-id yesod-0.9.3.4-6339564f13b46afd787d750cf9daa3bf -package-id yesod-auth-0.7.8-94a2849a33bb6f6d4c0e15615ef22bea -package-id yesod-core-0.9.3.6-a70073f17a6f050226a91a97c305403d -package-id yesod-default-0.4.1-1f30d8d893952d0661328b681d9ce291 -package-id yesod-form-0.3.4-a84ba844c230f9847bca7c0056375179 -package-id yesod-static-0.3.2-c82f332e85e2c9ba709375b8a14040a1 -O -Wall -threaded -O2 -XHaskell98 -XTemplateHaskell -XQuasiQuotes -XOverloadedStrings -XNoImplicitPrelude -XCPP -XMultiParamTypeClasses -XTypeFamilies -XGADTs -XGeneralizedNewtypeDeriving -XFlexibleContexts .\main.hs

so time-1.0.2.3 is definitely being referenced.

All the packages were downloaded in the last 24 hours so they should be pretty much up-to-date.

How can I unhide Data.Time.Clock.UTC?

arx
  • 16,686
  • 2
  • 44
  • 61
  • Can you show your `.cabal` file to demonstrate exactly how you added the dependency? – dflemstr Dec 21 '11 at 05:14
  • `Data.Time.Clock.UTC` is not exposed by the `time` package, so you can't access it from outside. You can't expose hidden modules from a package, so the only, but not recommended¹ way would be to reinstall `time` with a changed `.cabal` file exposing the module. ¹If you do that, your code won't work for anybody else, because for them it's still hidden. – Daniel Fischer Dec 21 '11 at 05:30
  • 1
    The `Data.Time.Clock` re-exports `Data.Time.Clock.UTC` (which is hidden). What import statement are you using in Model.hs - does `import Data.Time.Clock` not work? – stephen tetley Dec 21 '11 at 09:09

2 Answers2

5

I got the same error recently amd the answer was to

import Data.Time

instead of

import Data.Time.Clock.UTC

since the first module re-exports the hidden module.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
  • Exactly right. I starting using UTCTime and Haskell complained that it wasn't defined. So I poked around until I found the definition and imported "Data.Time.Clock.UTC", which doesn't work. Changed to "Data.Time" and now it does. Thank you. – arx Dec 21 '11 at 13:41
3

Sounds to me like a variant of cabal dependency hell. If you run ghc-pkg list time, I'm guessing you'll see multiple versions of time installed. Your app is probably using a newer version than the underlying libraries.

In your cabal file, try relying on precisely the same version of time as is being mentioned in the error message and see if that solves it.

Michael Snoyman
  • 31,100
  • 3
  • 48
  • 77
  • Not the problem (see the other answer), but thanks for Yesod. I'm a week and a half into Haskell and three days into Yesod and liking them both. – arx Dec 21 '11 at 13:48