[Haskell-beginners] ghci loading of hs files...

Antoine Latter aslatter at gmail.com
Thu Feb 3 22:36:07 CET 2011


On Thu, Feb 3, 2011 at 3:09 PM, Patrick Lynch <kmandpjlynch at verizon.net> wrote:
> ...I'm using the book "Real World Haskell"...
> ...In Chapter 22, it uses two files, namely: ...\ch22\PodDB.hs and
> ...\ch22\PodTypes.hs.
>
> ...This is the calling code in PodDB.hs:
>    {-- snippet all --}
>    module PodDB where
>    import Database.HDBC
>    import Database.HDBC.Sqlite3
>    import PodTypes
>
> ...I was instructed to start ghci and invoke the command: ...> :load
> C:\Users\User\Downloads\rwh-examples2\examples\ch22\poddb.hs
> ...this gives the following error message:
>      C:\Users\User\Downloads\rwh-examples2\examples\ch22\poddb.hs:6:7:
>      Could not find module `PodTypes':
>         Use -v to see a list of the files searched for.
>      Failed, modules loaded: none.
>
> ...I then tried the command: :l
> C:\Users\User\Downloads\rwh-examples2\examples\ch22\poddb.hs
> C:\Users\User\Downloads\rwh-examples2\examples\ch22\podtypes.hs
> ...it loaded both files...
>
> ...is there someway to modify the code in PodDB.hs that would allow me to
> simply invoke the command, as mentioned by the author, :load PodDB.hs?
>
> Thank you
>

Does "cd C:\Users\User\Downloads\rwh-examples2\examples\ch22" before
launching GHCi work?

You could also use the -i parameter for GHCi - it tells GHCi to look
in the specified directory for source files.

You won't be able to modify the code to do this - the notion that a
Haskell module corresponds to a file on disk (and that there is a
naming convention for this correspondence) isn't addressed in the
language definition.

This is why Haskell libraries on Hackage ship with meta-data
describing the layout of the source files for the library.

Antoine

>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>



More information about the Beginners mailing list