[Haskell-cafe] Can't use libraries in haskell

Jason Dagit dagitj at gmail.com
Sun Jun 26 16:48:42 CEST 2011


2011/6/26 Александр <kommunist1917 at mail.ru>:
> Thank you, for reply.
>
> Yes i use ghc.
>
>>First thing is to do 'ghc-pkg list'. If your package doesn't show up
>>then it's not installed, according to the package registry. 'cabal
>>install' should have registered it. If it is in the list, then it
>>depends how you're building. If you use ghc manually, then you have
>>to give '-package xyz'. If you use 'ghc --make', ghc will
>>automatically add the -package for you. If you use cabal, you put the
>>package in the dependencies, and 'cabal build' will add -package for
>>you.
>
> If i want to use ghci to test any function from my project. How can i import lib then?

I find this is easiest with cabal-dev.  Here is a guide to using cabal-dev:
http://www.reddit.com/r/haskell/comments/f3ykj/psa_use_cabaldev_to_solve_dependency_problems/

When I want to test out a library in ghci I do the following:
mkdir -p ~/tmp/test-foo
cd ~/tmp/test-foo
cabal-dev install foo
cabal-dev ghci

That puts me in ghci with the newly installed foo available so then
you just type, :m + Data.Foo, or in recent ghci you can even type
import Data.Foo.

I hope that helps,
Jason



More information about the Haskell-Cafe mailing list