Read package name, version from .cabal file

Hi, I am trying to read a .cabal find and print the package name and version. Here is the code snippet: === Code === getName :: FilePath -> IO () getName cabal = do gdesc <- readPackageDescription normal cabal let desc = flattenPackageDescription gdesc final = pkgName $ package desc putStrLn final === END === === Output === Couldn't match expected type `[Char]' with actual type `PackageName' === END === I see that the method 'package' from: http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution... allows me to return the PackageIdentifier. Using pkgName returns a PackageName. http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution... But, how can I obtain the string value from it? Appreciate any help in this regard. Thanks! SK -- Shakthi Kannan http://www.shakthimaan.com

On Tue, Dec 13, 2011 at 2:23 PM, Shakthi Kannan
Hi,
I am trying to read a .cabal find and print the package name and version. Here is the code snippet:
=== Code ===
getName :: FilePath -> IO () getName cabal = do gdesc <- readPackageDescription normal cabal let desc = flattenPackageDescription gdesc final = pkgName $ package desc putStrLn final
=== END ===
=== Output ===
Couldn't match expected type `[Char]' with actual type `PackageName'
=== END ===
I see that the method 'package' from:
http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution...
allows me to return the PackageIdentifier. Using pkgName returns a PackageName.
http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution...
But, how can I obtain the string value from it?
Appreciate any help in this regard.
Thanks!
SK
-- Shakthi Kannan http://www.shakthimaan.com
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
You need to use pattern patching, e.g.: let PackageName str = pkgName $ ... HTH, Michael

Hi Michael,
--- On Tue, Dec 13, 2011 at 5:57 PM, Michael Snoyman
participants (2)
-
Michael Snoyman
-
Shakthi Kannan