how do you use a package (.cabal)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how do you use a package (.cabal)?

7stud-2
In chapter 5 in RWH, they show you how to create, configure,
and install a package.  This is the final step:

...mypretty$ runghc Setup install
Installing: /usr/local/lib/mypretty-0.1/ghc-6.8.2
Setup: /usr/local/lib/mypretty-0.1: createDirectory: permission
 denied (Permission denied)

.../mypretty$ sudo runghc Setup install
Password:
Installing: /usr/local/lib/mypretty-0.1/ghc-6.8.2
Registering mypretty-0.1...
Reading package info from "dist/installed-pkg-config" ... done.
Saving old package config file... done.
Writing new package config file... done.

$ ghc-pkg list
/usr/local/lib/ghc-6.8.2/package.conf:
    Cabal-1.2.3.0, GLUT-2.1.1.1, HUnit-1.2.0.0, OpenAL-1.3.1.1,
    OpenGL-2.2.1.1, QuickCheck-1.1.0.0, array-0.1.0.0, base-3.0.1.0,
    bytestring-0.9.0.1, cgi-3001.1.5.1, containers-0.1.0.1,
    directory-1.0.0.0, fgl-5.4.1.1, filepath-1.1.0.0, (ghc-6.8.2),
    haskell-src-1.0.1.1, haskell98-1.0.1.0, hpc-0.5.0.0, html-1.0.1.1,
    mtl-1.1.0.0, mypretty-0.1, network-2.1.0.0, old-locale-1.0.0.0,
    old-time-1.0.0.0, packedstring-0.1.0.0, parallel-1.0.0.0,
    parsec-2.1.0.0, pretty-1.0.0.0, process-1.0.0.0, random-1.0.0.0,
    readline-1.0.1.0, regex-base-0.72.0.1, regex-compat-0.71.0.1,
    regex-posix-0.72.0.2, rts-1.0, stm-2.1.1.0,
    template-haskell-2.2.0.0, time-1.1.2.0, unix-2.3.0.0,
    xhtml-3000.0.2.1

The mypretty package is in that list.  But what does that do for
me? How do I access that package? The .cabal file has this
text in it:

library
   Exposed-Modules: SimpleJSON
                    PrettyJSON
                    Prettify
   Build-Depends: base >= 2.0

                             
But I created a Main.hs file that imported the
"exposed modules":


module Main () where

import Prettify
import PrettyJSON
import SimpleJSON


main = let s = JString "hello world"
           aDoc = renderJValue s
       in printPrettified aDoc

--JString is a JValue value constructor and JValue is defined in
SimpleJSON.hs

--renderJVAlue is a function defined in PrettyJSON.hs, and it returns
a data type that is defined in Prettify.js

--printPrettified is a function defined in PrettyJSON.hs


This is what happens:

$ ghc -c Main.hs
~/2testing/dir3$ ghc -o test Main.hs
compilation IS NOT required
/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning -F: directory name
(/Users/me/Library/Frameworks) does not exist

/usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:
___stginit_myprettyzm0zi1_Prettify_
___stginit_myprettyzm0zi1_PrettyJSON_
___stginit_myprettyzm0zi1_SimpleJSON_
_myprettyzm0zi1_PrettyJSON_printPrettified_closure
_myprettyzm0zi1_PrettyJSON_renderJValue_closure
_myprettyzm0zi1_SimpleJSON_JString_static_info
collect2: ld returned 1 exit status

I googled cabal tutorials, but I can't find anything that
tells me how to access an installed package.




Reply | Threaded
Open this post in threaded view
|

how do you use a package (.cabal)?

Brandon S Allbery KF8NH
On 2009 Mar 28, at 2:35, 7stud wrote:
> $ ghc -c Main.hs
> ~/2testing/dir3$ ghc -o test Main.hs


If you're not using the cabal framework to build your program, you  
want to use "ghc --make" so it will chase down the package  
dependencies.  Otherwise you would need to say "ghc -package mypretty".

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [hidden email]
system administrator [openafs,heimdal,too many hats] [hidden email]
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090328/ca64aaf2/PGP.bin
Reply | Threaded
Open this post in threaded view
|

Re: how do you use a package (.cabal)?

7stud-2
Brandon S. Allbery KF8NH <allbery <at> ece.cmu.edu> writes:

>
> On 2009 Mar 28, at 2:35, 7stud wrote:
> > $ ghc -c Main.hs
> > ~/2testing/dir3$ ghc -o test Main.hs
>
> If you're not using the cabal framework to build your program,

I thought I was.

> you  
> want to use "ghc --make" so it will chase down the package  
> dependencies.  Otherwise you would need to say "ghc -package mypretty".
>

Based on what I did to install the package, how am I supposed to use
the package in a program?  The book doesn't give any clue.








Reply | Threaded
Open this post in threaded view
|

Re: how do you use a package (.cabal)?

Brandon S Allbery KF8NH
On 2009 Mar 28, at 3:40, 7stud wrote:
> Brandon S. Allbery KF8NH <allbery <at> ece.cmu.edu> writes:
>> On 2009 Mar 28, at 2:35, 7stud wrote:
>>> $ ghc -c Main.hs
>>> ~/2testing/dir3$ ghc -o test Main.hs
>>
>> If you're not using the cabal framework to build your program,
>
> I thought I was.

You used it to build your package.  You're using ghc directly to build  
your program, not doing "runhaskell Setup.hs build" or "cabal install".

>> you
>> want to use "ghc --make" so it will chase down the package
>> dependencies.  Otherwise you would need to say "ghc -package  
>> mypretty".
>
> Based on what I did to install the package, how am I supposed to use
> the package in a program?  The book doesn't give any clue.

That is exactly what you just quoted.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [hidden email]
system administrator [openafs,heimdal,too many hats] [hidden email]
electrical and computer engineering, carnegie mellon university    KF8NH


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/beginners/attachments/20090328/ad675927/PGP.bin