Re: [Haskell-cafe] Re: How to generalize executing a series of commands, based on a list?
Thanks very much for the url; helpful site. I got mapM to do what I wanted (first time I've used it); cool function; now I understand it. At your note for mapM I noticed (mapM print); I've been using (show [list]) so much, (mapM print) will be nice for formatting while debugging, etc. Thanks again! -- Peter On Thu, Nov 18, 2010 at 3:44 PM, Henk-Jan van Tuyl wrote: > On Thu, 18 Nov 2010 21:20:10 +0100, Peter Schmitz > wrote: > > Thank you very much for the help. Good tips for improving my code design. >> I'm new to sequence, mapM, and mapM_; I've seen mapM a lot while reading >> code and wanted to learn it; now I have a reason! Thanks. >> -- Peter >> >> > You can find explanations, with usage examples, of these functions at > http://members.chello.nl/hjgtuyl/tourdemonad.html > > Regards, > Henk-Jan van Tuyl > > > -- > http://Van.Tuyl.eu/ <http://van.tuyl.eu/> > http://members.chello.nl/hjgtuyl/tourdemonad.html > -- > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to generalize executing a series of commands, based on a list?
Thank you very much for the help. Good tips for improving my code design. I'm new to sequence, mapM, and mapM_; I've seen mapM a lot while reading code and wanted to learn it; now I have a reason! Thanks. -- Peter On Thu, Nov 18, 2010 at 5:40 AM, steffen wrote: > 1. Write one routine, which does all the work for just one command. > 2. use sequence or mapM, mapM_ from Control.Monad (depending on your > needs), > to apply your function to a list of commands > > accumulating results you may want to process the output of "sequence" > or use the WriterT Monad Transformer. > > If you want to stop processing the rest of the list on error, either > write a recursive function yourself or use foldM or use ErrorT Monad > Transformer. > > On Nov 18, 3:03 am, Peter Schmitz wrote: > > I am able to use System.Cmd (system) to invoke a shell command > > and interpret the results. > > > > Please see the code below that works okay for one such command. > > (I invoke a program, passing two args.) > > > > I am wondering how to generalize this to do likewise for a > > series of commands, where the varying args (filenames, in this > > case) are in a list ('inOutLeafs'). > > > > I will also want to accumulate some results; probably just a > > failure count at this time. > > > > Any advice or pointers to examples would be much appreciated. > > > > Thanks in advance, > > -- Peter > > > > > > > > > > > > > > > > > > > > > run :: ... -> IO (Int)-- will return a fail count > > > run > > >-- some args to this function here... > > >= do > > > -- ... set up: inputLeafs, outputLeafs, etc. > > > > > -- zip two lists of filenames: > > > let inOutLeafs = zip inputLeafs outputLeafs > > > > > -- the first pair for the first command: > > > let (inFile1,outFile1) = head inOutLeafs > > > > > -- build 1st command using 1st pair of filenames: > > > let cmd1 = ... > > > > > exitCode <- system cmd1 > > > case (exitCode) of > > > ExitSuccess -> do > > > putStrLn $ "-- OK." > > > return 0 > > > ExitFailure failCnt -> do > > > putStrLn $ "-- Failed: " ++ show failCnt > > > return 1 > > > > ___ > > Haskell-Cafe mailing list > > haskell-c...@haskell.orghttp:// > www.haskell.org/mailman/listinfo/haskell-cafe > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to generalize executing a series of commands, based on a list?
Thank you very much for the help. -- Peter On Thu, Nov 18, 2010 at 4:48 AM, Scott Turner <1hask...@pkturner.org> wrote: > On 2010-11-17 21:03, Peter Schmitz wrote: > > I am wondering how to generalize this to do likewise for a > > series of commands, where the varying args (filenames, in this > > case) are in a list ('inOutLeafs'). > > The 'sequence' function is handy for combining a series of actions, such > as [system cmd1, system cmd2, ...]. > > > I will also want to accumulate some results; probably just a > > failure count at this time. > > 'sequence' hangs on to the results. That may be what you need. For > control over accumulating results the good stuff is in Data.Foldable. > > > Any advice or pointers to examples would be much appreciated. > > > > Thanks in advance, > > -- Peter > > > > > >> run :: ... -> IO (Int)-- will return a fail count > >> run > >>-- some args to this function here... > >>= do > >> -- ... set up: inputLeafs, outputLeafs, etc. > >> > >> -- zip two lists of filenames: > >> let inOutLeafs = zip inputLeafs outputLeafs > >> > >> -- the first pair for the first command: > >> let (inFile1,outFile1) = head inOutLeafs > >> > >> -- build 1st command using 1st pair of filenames: > >> let cmd1 = ... > >> > >> exitCode <- system cmd1 > >> case (exitCode) of > >> ExitSuccess -> do > >> putStrLn $ "-- OK." > >> return 0 > >> ExitFailure failCnt -> do > >> putStrLn $ "-- Failed: " ++ show failCnt > >> return 1 > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to generalize executing a series of commands, based on a list?
I am able to use System.Cmd (system) to invoke a shell command and interpret the results. Please see the code below that works okay for one such command. (I invoke a program, passing two args.) I am wondering how to generalize this to do likewise for a series of commands, where the varying args (filenames, in this case) are in a list ('inOutLeafs'). I will also want to accumulate some results; probably just a failure count at this time. Any advice or pointers to examples would be much appreciated. Thanks in advance, -- Peter > run :: ... -> IO (Int)-- will return a fail count > run >-- some args to this function here... >= do > -- ... set up: inputLeafs, outputLeafs, etc. > > -- zip two lists of filenames: > let inOutLeafs = zip inputLeafs outputLeafs > > -- the first pair for the first command: > let (inFile1,outFile1) = head inOutLeafs > > -- build 1st command using 1st pair of filenames: > let cmd1 = ... > > exitCode <- system cmd1 > case (exitCode) of > ExitSuccess -> do > putStrLn $ "-- OK." > return 0 > ExitFailure failCnt -> do > putStrLn $ "-- Failed: " ++ show failCnt > return 1 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unexpected results from ExitCode
Dean, Thanks very much, that indeed worked. -- Peter On Wed, Nov 3, 2010 at 9:16 PM, Dean Herington wrote: > At 8:45 PM -0700 11/3/10, Peter Schmitz wrote: >> >> I have a program (test.hs): >> >>> module Main (main) where >>> import System.Exit >>> main :: IO ExitCode >>> main = do >>> return (ExitFailure 1) >> >> >> In another program, I invoke it via 'system': >> >>> exitCode <- system ".\\test.exe" >>> case (exitCode) of >>> ExitFailure failCnt -> do >>> putStrLn $ "-- Fail count is: " ++ show failCnt >>> exitFailure >>> ExitSuccess -> do >>> putStrLn $ "-- OK." >>> exitSuccess >> >> >> but it always gets ExitSuccess (not ExitFailure failCnt as I expected). >> (I am running under Windows.) >> >> My other use of system (such as with ghc commands) works okay, >> sometimes getting success, sometimes failure, as expected. >> >> Any suggestions much appreciated. >> Thanks, >> -- Peter > > The value returned by `main` is always discarded. You need to use > `exitWith`: > > main = exitWith (ExitFailure 1) > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Unexpected results from ExitCode
I have a program (test.hs): > module Main (main) where > import System.Exit > main :: IO ExitCode > main = do >return (ExitFailure 1) In another program, I invoke it via 'system': >exitCode <- system ".\\test.exe" >case (exitCode) of > ExitFailure failCnt -> do > putStrLn $ "-- Fail count is: " ++ show failCnt > exitFailure > ExitSuccess -> do > putStrLn $ "-- OK." > exitSuccess but it always gets ExitSuccess (not ExitFailure failCnt as I expected). (I am running under Windows.) My other use of system (such as with ghc commands) works okay, sometimes getting success, sometimes failure, as expected. Any suggestions much appreciated. Thanks, -- Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Regression test utility suggestions?
I am seeking suggestions for a regression test utility or framework to use while developing in Haskell (in a MS Windows environment). I am developing a Haskell application that parses an input text file, and outputs some information about what was parsed. The application is currently in a GUI, but the parsing/analysis code does not require any user interaction, so it would be simple to implement a command-line based version (that could be invoked by a regression test utility -- http://en.wikipedia.org/wiki/Regression_testing), that takes as args: the input and output file pathnames. As I develop, I have a growing set of input files that are used to test various aspects of the grammar. I am seeking a regression test utility that I could point at a dir of test input files, and it would process each input file using my app, creating a corresponding output file. The utility would then compare each output file with a known good output file, and let me somehow review the results (i.e., the differences), and for each test file (or all of them) allow me to decide one of: -- there were no diffs; all is well -- the diff shows the output changed as I expected, due to coding enhancements or fixes; take the new output file and use it as the new good output file -- oops, unexpected diffs; I need to fix my code and then re-run the utility afterwards I have reviewed http://www.haskell.org/haskellwiki/Introduction_to_QuickCheck and http://hackage.haskell.org/packages/archive/pkg-list.html#cat:testing but I did not see anything that seems to fit. I'm not sure whether (or how) QuickCheck would lend itself to this type of testing. I don't want to generate any test cases; I have a manually created collection of test cases that I want to use (which is all I am interested in, at this point). In the past I have coded something like this using shell or Perl scripts, etc. I am wondering if there is a commonly used utility available for this purpose that you like. (I use a MS Windows environment, but I have a Bash and various gnu shell utils installed.) (It does not matter to me whether it is written in Haskell, although I suppose that would make it more enjoyable to hack on. :) Thanks in advance very much for any suggestions. -- Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Parsec question (new user): unexpected end of input
Antoine and Christian: Many thanks for your help on this thread. (I am still digesting it; much appreciated; will post when I get it working.) -- Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsec question (new user): unexpected end of input
I am a new Parsec user, and having some trouble with a relatively simple parser. The grammar I want to parse contains tags (not html) marked by angle brackets (e.g., ""), with arbitrary text (no angle brackets allowed) optionally in between tags. Tags may not nest, but the input must begin and end with a tag. Whitespace may occur anywhere (beginning/end of input, inside/between tags, etc.), and is optional. I think my problem may be a lack of using "try", but I'm not sure where. At runtime I get: Error parsing file: "...\sampleTaggedContent.txt" (line 4, column 1): unexpected end of input expecting "<" The input was: stuff more stuff < tag 3 > even more The code is below. (I'm using Parsec-2.1.0.1.) I don't really want to return anything meaningful yet; just parse okay. Any advice about the error (or how to simplify or improve the code) would be appreciated. Thanks much, -- Peter > -- Parsers: > taggedContent = do >optionalWhiteSpace >aTag >many tagOrContent >aTag >eof >return "Parse complete." > > tagOrContent = aTag <|> someContent "tagOrContent" > > aTag = do >tagBegin >xs <- many (noneOf [tagEndChar]) >tagEnd >optionalWhiteSpace >return () > > someContent = do >manyTill anyChar tagBegin >return () > > optionalWhiteSpace = spaces -- i.e., any of " \v\f\t\r\n" > tagBegin = char tagBeginChar > tagEnd = char tagEndChar > > -- Etc: > tagBeginChar = '<' > tagEndChar = '>' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] parsec manyTill documentation question
Stephen, Thanks much for the pointer to the examples in the sources; found them. (Its nice to learn from the coding style used by the authors.) -- Peter On Sat, Sep 25, 2010 at 12:34 AM, Stephen Tetley wrote: > On 25 September 2010 05:30, Evan Laforge wrote: > >> I thought the parsec source included some example parsers for simple >> languages? In any case, there is lots of material floating around, >> [Snip] > > > The best documentation is Daan Leijen's original manual, plus the > original source distribution which has example parsers for Henk, Tiger > and Mondrain. > > Both are available from here - the original poster was working with > the HTML version of the manual - there is also a PDF version: > > http://legacy.cs.uu.nl/daan/parsec.html > > It would be nice if the Hackage package added the examples back into > the distribution. > > The parser in the Scheme in 48 hours tutorial isn't a great example of > Parsec as it doesn't use the Token module. Not using the Token module > means the Scheme parser does hacky things such as parseNumber which > uses /read/ - this is double work, Parsec already handles numbers, it > doesn't need to call out to another parser (Haskell's builtin read). > > > http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours/Parsing > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] parsec manyTill documentation question
On Fri, Sep 24, 2010 at 9:28 PM, Evan Laforge wrote: >>> simpleComment = do{ string "")) >>> } >>> >>> Note the overlapping parsers anyChar and string "", ... > > Yes, I think the doc just made a mistake there. In fact, it looks > like the same mistake is in the current doc at > http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Combinator.html Evan, Thanks very much for the typo confirmation, the explanation about backtracking below, and the tip about the source distribution for the examples. I need to remember that multiple char strings imply backtracking, and that backtracking is not the default, hence "try". Thanks. -- Peter > >> Second, manyTill, by definition, keeps applying p (anyChar) until >> end (string "-->") is satisfied, so I would expect one could just >> write: >> >> manyTill anyChar (string "-->") > > The problem is that "-->" has multiple characters. So if you have > "-not end comment", it will match the '-' against the (string "-->"). > Since it doesn't backtrack by default, it's committed now and will > fail when it hits the 'n'. The 'try' will make it backtrack to > 'anyChar' when the second '-' fails to match. > >> (If anyone knows of a collection of parsec demos or good examples, I >> would appreciate a link; thanks) > > I thought the parsec source included some example parsers for simple > languages? In any case, there is lots of material floating around, > though I found parsec so intuitive and the docs so good that I just > started hacking. I think the 'build scheme in haskell' tutorial uses > parsec for the parsing. > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] parsec manyTill documentation question
I am new to parsec and having difficulty understanding the explanation of manyTill in http://legacy.cs.uu.nl/daan/download/parsec/parsec.html. (I really appreciate having this doc by the way; great reference.) I.e.: > manyTill :: GenParser tok st a -> GenParser tok st end -> GenParser tok st [a] > > (manyTill p end) applies parser p zero or more times until parser > end succeeds. Returns the list of values returned by p . This parser > can be used to scan comments: > > simpleComment = do{ string "")) > } > > Note the overlapping parsers anyChar and string "", ... since anyChar begins reading input beginning with the char *after* string ""). Second, manyTill, by definition, keeps applying p (anyChar) until end (string "-->") is satisfied, so I would expect one could just write: manyTill anyChar (string "-->") Assuming the documentation is correct on both counts, I would really appreciate any explanation someone could offer. Thanks very much, (really like Haskell & parsec) -- Peter (If anyone knows of a collection of parsec demos or good examples, I would appreciate a link; thanks) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious why "cabal upgrade parsec" not installing latest version
Ivan, Duncan, Thank you both very much for your kind help and comments. I'm really impressed with the quality of help at Haskell Cafe, and Cabal really has worked great for me; I'll just avoid "upgrade" in the future. Anyone: So, to get a clean start with my library situation I will delete my "...\Application Data\ghc" dir which includes dir "...\Application Data\ghc\i386-mingw32-6.12.1\package.conf.d\" which contains a lot of .conf files. I am also wondering about whether I should delete any dirs in my cabal tree. I would keep my cabal config file, and "...\cabal\bin\" of course, but should I delete the various package dirs there also? And should I delete the "...\cabal\packages\hackage.haskell.org\" tree? Those seem to be tarballs. Thanks again, -- Peter On Thu, Sep 16, 2010 at 8:54 PM, Ivan Lazar Miljenovic wrote: > On 17 September 2010 13:52, Ivan Lazar Miljenovic > wrote: >> Run "ghc-pkg check", and do a "cabal install --reinstall" for all >> packages that it says need to be rebuilt at the bottom. > > Actually, I just re-read your post and you seem to have bigger problems... > > The cause of the problem: you used "cabal upgrade". This appears to > have resulted in cabal-install "upgrading" boot libraries, which is a > big no-no. > > Probably the easiest way to fix this is to delete your ~/.ghc/ > directory (and thus wipe out the libraries you installed with > cabal-install) and re-install the libraries you want. > ... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious why "cabal upgrade parsec" not installing latest version
This gets a little hilarious (but better to laugh than cry). Well, I decided to try Parsec version 3 (i.e., 3.1.0) after all, and edited my cabal config to include: preference: parsec >= 3 I did not include "base >= 4"; hope that is not a problem. I did "cabal upgrade parsec", which went great. It added the new dirs: ...\cabal\parsec-3.1.0 ...\cabal\mtl-1.1.1.0 ...\cabal\bytestring-0.9.1.7 I recompiled my little parsec demo.hs using various appropriate Text.Parsec modules (instead of Text.ParserCombinators.Parsec), and it worked great. Wonderful! So, I tried to recompile another program I have that uses: > module Main where > import Control.Monad.Trans ( liftIO ) > import Data.IORef > import Graphics.UI.Gtk > import Graphics.UI.Gtk.Gdk.GC > import Graphics.UI.Gtk.Gdk.EventM > import Graphics.UI.Gtk.Glade > import List ( delete, nub ) For this code (which previously compiled okay): >on canvas exposeEvent $ do > -- drawWindow <- eventWindow > -- region <- eventRegion > liftIO $ do-- <<< this is line 135 > updateCanvas canvas currentPattern pattern2CanvasOffset zoomFactor id > (w,h) <- widgetGetSize canvas -- get (width,height) of DrawingArea > putStrLn $ "DrawingArea redrawn; (width, height) = " ++ show (w,h) > return True I get: > life.hs:135:6: > No instance for (Control.Monad.Trans.MonadIO >(mtl-1.1.0.2:Control.Monad.Reader.ReaderT > (GHC.Ptr.Ptr EExpose) IO)) > arising from a use of `liftIO' at life.hs:135:6-11 > Possible fix: > add an instance declaration for > (Control.Monad.Trans.MonadIO > (mtl-1.1.0.2:Control.Monad.Reader.ReaderT > (GHC.Ptr.Ptr EExpose) IO)) > In the first argument of `($)', namely `liftIO' > In the expression: > liftIO > $ do { updateCanvas > canvas currentPattern pattern2CanvasOffset zoomFactor id; >(w, h) <- widgetGetSize canvas; > putStrLn >$ "DrawingArea redrawn; (width, height) = " ++ show (w, h); >return True } > In the second argument of `($)', namely > `do { liftIO > $ do { updateCanvas > canvas currentPattern pattern2CanvasOffset zoomFactor id; >(w, h) <- widgetGetSize canvas; > } }' When I did: "ghc --make life.hs -v", I saw among the output: "hiding package mtl-1.1.0.2 to avoid conflict with later version mtl-1.1.1.0" I guess that the parsec upgrade installed the newer mtl, and I'm wondering if that is what is making life.hs fail to compile. (?) Silly me, I noticed my gtk package was not up to date: > * gtk > Synopsis: Binding to the Gtk+ graphical user interface library. > Latest version available: 0.11.2 > Latest version installed: 0.11.0<<< > Homepage: http://www.haskell.org/gtk2hs/ > License: LGPL-2.1 So!, thinking it might help, I did: "cabal upgrade gtk" too. (In the past I have successfully done "cabal install gtk", so I thought this would be okay. :-) I got: > H:\proc\dev\cmd>cabal upgrade gtk > Resolving dependencies... > Configuring old-time-1.0.0.5... > cabal: The package has a './configure' script. This requires a Unix > compatibility toolchain such as MinGW+MSYS or Cygwin. > Configuring random-1.0.0.2... > Preprocessing library random-1.0.0.2... > Building random-1.0.0.2... > [1 of 1] Compiling System.Random( System\Random.hs, > dist\build\System\Random.o ) > Registering random-1.0.0.2... > Installing library in H:\proc\tools\cabal\random-1.0.0.2\ghc-6.12.1 > Registering random-1.0.0.2... > cabal: Error: some packages failed to install: > cairo-0.11.1 depends on old-time-1.0.0.5 which failed to install. > directory-1.0.1.2 depends on old-time-1.0.0.5 which failed to install. > gio-0.11.1 depends on old-time-1.0.0.5 which failed to install. > glib-0.11.2 depends on old-time-1.0.0.5 which failed to install. > gtk-0.11.2 depends on old-time-1.0.0.5 which failed to install. > haskell98-1.0.1.1 depends on old-time-1.0.0.5 which failed to install. > old-time-1.0.0.5 failed during the configure step. The exception was: > ExitFailure 1 > pango-0.11.2 depends on old-time-1.0.0.5 which failed to install. > process-1.0.1.3 depends on old-time-1.0.0.5 which failed to install. (This is where I began laughing instead of crying :-) I don't recall ever having problems with old-time in the past. If anyone has any suggestions, I would appreciate it. I am willing to either keep parsec 3 and resolve the life.hs compile errors, or to revert to parsec 2 and somehow undo my package installation problems. (E.g., is there a "cabal uninstall " command?) Thanks again very much. -- Peter p.s., trying to compile the parsec 3 demo yields (sorry about the formatting): H:\proc\dev\AAA\LC>ghc --make demo.hs -v Glasgow Haskell Compiler, Version 6.12.1, for Haskell 98, sta
Re: [Haskell-cafe] Curious why "cabal upgrade parsec" not installing latest version
Jason, Thank you for the insights into Cabal. I am new to Parsec, and relatively new to Cabal, and was not aware of the info that you (and Thomas and Ivan) posted. Great help; thanks again. I will probably stick with Cabal's default for the time being because I don't have a compelling reason not to, but it's good to know how Cabal works. I am finding developing in Haskell + Gtk2Hs + Glade + Parsec a lot of fun. Parser combinators are so cool. -- Peter On Wed, Sep 15, 2010 at 8:15 PM, Jason Dagit wrote: > On Wed, Sep 15, 2010 at 7:47 PM, Peter Schmitz wrote: >> Not that I'm having any problem with parsec 2.1.0.1, but I guess I >> would like to install the latest (3.1.0), unless there is a reason >> not to. >> >> I can't seem to get Cabal to do so; thanks in advance for any help. >> >> I don't understand part of the output from "cabal install --dry-run >> --reinstall -v parsec" at the end below, which includes: >> "selecting parsec-2.1.0.1 (hackage) and discarding parsec-2.0, >> 2.1.0.0, 3.0.0, 3.0.1 and 3.1.0". >> >> (http://hackage.haskell.org/package/parsec seems to point to 3.1.0.) > > I consider this a misfeature of cabal-install. Cabal-install will check here: > http://hackage.haskell.org/packages/archive/preferred-versions > > Before deciding out how to handle an 'install' request. You'll notice > that it says: > parsec < 3 > > Sadly cabal-install doesn't warn you or ask what version you want. > There is an unwritten policy that cabal knows better than you do about > what packages you want. And then it silently enforces it's point of > view on you unless you specify a conflicting constraint. And unless > the package is base, in which case it only listens if you either a) > give an upper bound on base, or b) provide a preference (instead of a > constaint). > > You can work around these (broken) global policies by editing your > local cabal config. Should be in $HOME/.cabal/config (or the similar > place on windows). You can add a line like: > preference: base >= 4, parsec >= 3 > > That should help to nullify the global policy. > > Cabal bugs not withstanding, this comes about because cabal is not a > package manager. Unlike distributions like Debian there is no way to > subscribe to 'stable', 'experimental', or 'developer only' package > classifications. Unfortunately, the current 'solution' has been to > enforce a 'one size fits all' policy on users with an essentially > undocumented way to override it (which has to be applied for each > cabal-install installation). I assume this strategy was picked > because it was easy to implement and developer time can be scarce. > > Jason > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious why "cabal upgrade parsec" not installing latest version
Thomas, Ivan, Thanks much for the info. -- Peter On Wed, Sep 15, 2010 at 8:00 PM, Ivan Lazar Miljenovic wrote: > On 16 September 2010 12:47, Peter Schmitz wrote: >> Not that I'm having any problem with parsec 2.1.0.1, but I guess I >> would like to install the latest (3.1.0), unless there is a reason >> not to. > > Because Parsec-3 apparently still has some speed regressions compared > to Parsec-2 (I'm not qualified to note whether its design is slow or > if you have to use it differently to get good performance out of it), > so many developers prefer to stick to Parsec-2 for this reason. > > As such, and because a lot of Cabal files just state "parsec" without > a dependency, by default cabal-install will assume that an unversioned > dependency (which includes installing/upgrading it via the command > line) refers to Parsec-2 and not Parsec-3. > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Curious why "cabal upgrade parsec" not installing latest version
Not that I'm having any problem with parsec 2.1.0.1, but I guess I would like to install the latest (3.1.0), unless there is a reason not to. I can't seem to get Cabal to do so; thanks in advance for any help. I don't understand part of the output from "cabal install --dry-run --reinstall -v parsec" at the end below, which includes: "selecting parsec-2.1.0.1 (hackage) and discarding parsec-2.0, 2.1.0.0, 3.0.0, 3.0.1 and 3.1.0". (http://hackage.haskell.org/package/parsec seems to point to 3.1.0.) Under Windows XP: > H:\proc\dev\cmd>cabal update > Downloading the latest package list from hackage.haskell.org > > H:\proc\dev\cmd>cabal info parsec > * parsec (library) > Synopsis: Monadic parser combinators > Latest version available: 3.1.0 > Latest version installed: 2.1.0.1 > Homepage: http://www.cs.uu.nl/~daan/parsec.html > Bug reports: [ Not specified ] > Description: Parsec is designed from scratch as an industrial-strength >parser library. It is simple, safe, well documented (on the >package homepage), has extensive libraries and good error >messages, and is also fast. It is defined as a monad >transformer that can be stacked on arbitrary monads, and it >is also parametric in the input stream type. > Category: Parsing > License: BSD3 > Author:Daan Leijen , Paolo Martini > > Maintainer:Derek Elkins > Source repo: [ Not specified ] > Flags: base4 > Dependencies: mtl -any, bytestring -any, base >=4 && <5, syb -any, >base >=3.0.3 && <4 > Documentation: [ Not installed ] > Cached:No > Modules: > Text.ParserCombinators.Parsec > Text.ParserCombinators.Parsec.Char > Text.ParserCombinators.Parsec.Combinator > Text.ParserCombinators.Parsec.Error > Text.ParserCombinators.Parsec.Expr > Text.ParserCombinators.Parsec.Language > Text.ParserCombinators.Parsec.Perm > Text.ParserCombinators.Parsec.Pos > Text.ParserCombinators.Parsec.Prim > Text.ParserCombinators.Parsec.Token > > > H:\proc\dev\cmd>cabal upgrade parsec > Resolving dependencies... > No packages to be installed. All the requested packages are already installed. > If you want to reinstall anyway then use the --reinstall flag. > > > H:\proc\dev\cmd>cabal install --dry-run --reinstall parsec > Resolving dependencies... > In order, the following would be installed (use -v for more details): > parsec-2.1.0.1 > > > H:\proc\dev\cmd>cabal install --dry-run --reinstall -v parsec > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc.exe --numeric-version > looking for package tool: ghc-pkg near compiler in > H:\proc\tools\Haskell Platform\2010.1.0.0\bin > found package tool in > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc-pkg.exe > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc-pkg.exe --version > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc.exe --supported-languages > Reading installed packages... > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc-pkg.exe dump --global > H:\proc\tools\Haskell Platform\2010.1.0.0\bin\ghc-pkg.exe dump --user > Reading available packages... > Resolving dependencies... > selecting parsec-2.1.0.1 (hackage) and discarding parsec-2.0, > 2.1.0.0, 3.0.0, 3.0.1 and 3.1.0 > selecting base-3.0.3.2 (installed) and 4.2.0.0 (installed) and discarding > syb-0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.2 and 0.2.1 > selecting ffi-1.0 (installed) > selecting ghc-prim-0.2.0.0 (installed) > selecting integer-gmp-0.2.0.0 (installed) > selecting rts-1.0 (installed) > selecting syb-0.1.0.2 (installed) > In order, the following would be installed: > parsec-2.1.0.1 (reinstall) changes: base-4.2.0.0 -> 3.0.3.2 > > H:\proc\dev\cmd> -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple Parsec example, question
Daniel, Thanks much; the more I learn Haskell and Parsec, the more I like them. -- Peter On Wed, Sep 15, 2010 at 4:02 PM, Daniel Fischer wrote: > On Wednesday 15 September 2010 23:01:34, Peter Schmitz wrote: >> > textLine :: Parser String >> > textLine = do >> > x <- many (noneOf "\n") >> > char '\n' >> > return x >> > >> > textLines :: Parser [String] >> > textLines = many textLine >> >> And it can probably be coded more succinctly that that (suggestions >> welcome). > > textLine = manyTill anyChar (char '\n') > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple Parsec example, question
Antoine, Thank you very much for your reply. Adding type sigs did help me think about it. I got it to work. I replaced: > eol = char '\n' > textLines = endBy eol with: > textLine :: Parser String > textLine = do >x <- many (noneOf "\n") >char '\n' >return x > > textLines :: Parser [String] > textLines = many textLine And it can probably be coded more succinctly that that (suggestions welcome). I wanted to use Parsec because I want to learn it, and just wanted to start with something very simple. Thanks again! -- Peter On Tue, Sep 14, 2010 at 7:48 PM, Antoine Latter wrote: > Hi Peter, > ... > What do you expect the type of 'textLines' to be? Does the error > change if you add a type annotation to 'textLines'? > > Adding more type signatures is my usual first step in understanding > bewildering error messages. > > In this case, I think the issue is that the 'emdBy' function from > Parsec expect two arguments[1], and you have only give it one. You've > written the 'separator' parser, but you also need to specify what to > parse between the separators. > > If this is as complex as the task is, you may be better off with the > function Prelude.lines[2] :-) > > Take care, > Antoine > > [1] > http://hackage.haskell.org/packages/archive/parsec/3.1.0/doc/html/Text-Parsec-Combinator.html#v:endBy > > [2] > http://haskell.org/ghc/docs/6.12.1/html/libraries/base-4.2.0.0/Prelude.html#v:lines ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Simple Parsec example, question
Simple Parsec example, question I am learning Parsec and have been studying some great reference and tutorial sites I have found (much thanks to the authors), including: http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#UserGuide http://legacy.cs.uu.nl/daan/download/parsec/parsec.html#ReferenceGuide http://book.realworldhaskell.org/read/using-parsec.html http://lstephen.wordpress.com/2007/06/19/first-go-with-parsec/ http://jonathan.tang.name/files/scheme_in_48/tutorial/overview.html http://www.defmacro.org/ramblings/lisp-in-haskell.html I'm having trouble coding a simple parser to count the number of lines in a text file. "lineCount" fails to compile; the compiler error text is below it. Any advice, code, etc. would be appreciated. For those using Gtk2Hs + Glade, I have included the glade file after the Haskell code, in case you want to try it. (You will need to remove the leading "> " and fix some lines that the email wrapped.) If you do wish to offer code, feel free to remove or rewrite: eol, textLines and lineCount entirely. I'm looking for the simplest way to code this. Thanks very much, -- Peter > -- A parsing demo, using: > -- Haskell + Gtk2Hs + Glade (GtkBuilder) + Parsec > module Main where > > -- import Data.IORef > import Graphics.UI.Gtk > import Graphics.UI.Gtk.Builder > import Graphics.UI.Gtk.Selectors.FileChooser > -- import System.Cmd -- e.g., for invoking a shell cmd > import System.Glib.GError > import Text.ParserCombinators.Parsec > > main :: IO () > main = do >initGUI > >-- create builder; load UI file >builder <- builderNew >handleGError (\(GError dom code msg) -> fail msg) $ > builderAddFromFile builder "demo.glade" > -- Error message would look something like: > -- app.exe: user error (Failed to open file 'app.glade': > --No such file or directory) > >-- get widget handles (reduce boilerplate?) >mainWindow <- builderGetObject builder castToWindow "mainWindow" >pickFileButton <- > builderGetObject builder castToFileChooserButton "pickFileButton" >parseButton<- builderGetObject builder castToButton "parseButton" >exitButton <- builderGetObject builder castToButton "exitButton" > >-- signal handlers -- > >-- parse selected file >onClicked parseButton $ do > file <- fileChooserGetFilename pickFileButton > > case file of > Nothing -> do > putStrLn "\nPlease first select a file." > return () > Just file -> do > putStrLn $ "\nParsing file: " ++ show file > result <- parseFromFile lineCount file > case (result) of >Left err -> print err >Right x -> putStrLn $ "Line count = " ++ show x > return () > >-- exit >onDestroy mainWindow mainQuit >onClicked exitButton mainQuit > >-- go >widgetShowAll mainWindow >mainGUI > > - > eol = char '\n' > > -- from RWH; perhaps use in future: > -- eol = try (string "\n\r") > -- <|> try (string "\r\n") > -- <|> string "\n" > -- <|> string "\r" > -- "end of line" > > textLines = endBy eol > > lineCount :: Parser Int > lineCount = do >xs <- textLines >return (length xs) > > > -- demo.hs:72:3: > -- Couldn't match expected type `GenParser Char () Int' > --against inferred type `GenParser Char st sep -> b' > -- In a stmt of a 'do' expression: xs <- textLines > -- In the expression: > -- do { xs <- textLines; > -- return (length xs) } > -- In the definition of `lineCount': > -- lineCount = do { xs <- textLines; > -- return (length xs) } -- demo.glade follows -- > > > > > > True > demo v.8 > > > True > 6 > vertical > 10 > > > True > You can hover > over the buttons below for some information about them. > > You can also resize this window, to make the buttons bigger. > > Demo: Haskell + Gtk2Hs > + Glade (GtkBuilder) + Parsec > > > > 0 > > > > > True > 5 > > > True > Use this > File Chooser widget to select the file to parse. > > 0 > none > > > True > 12 > >id="pickFileButton"> > True > Select > file > > > > > > > True > Select > file to parse: > True > > >
[Haskell-cafe] Re: Trying to compile Glade Gtk2Hs demo / cabal install glade problem
Thanks so very much Axel and Ivan. You were both absolutely correct and I can compile Glade apps now fine. Great help! The tricky part (for me) would have been looking at the error from cabal install glade: "setup.exe: The pkg-config package libglade-2.0 version >=2.0.0 is required but it could not be found." and determining that the problem was that libglade-2.0.pc needed the edit you described, but I made the edit and it all works now. -- Peter And I guess I don't need these edits to cabal/config after all: -- -- extra-include-dirs: -- extra-lib-dirs: extra-include-dirs: H:\proc\tools\Gtk+\include extra-lib-dirs: H:\proc\tools\Gtk+\lib -- New "cabal install glade" after libglade-2.0.pc edit: H:\proc\dev\cmd>pkg-config --modversion libglade-2.0 2.6.4 H:\proc\dev\cmd>cabal install glade Resolving dependencies... C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\Gtk2HsSetup.hs:25: warning: #warning Setup.hs is guessing the version of Cabal. If compilation of Setup.hs fails use -DCABAL_VERSION_MINOR=x for Cabal version 1.x.0 when building (prefixed by --ghc-option= when using the 'cabal' command) [1 of 2] Compiling Gtk2HsSetup ( C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\Gtk2HsSetup.hs, C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\dist\setup\Gtk2HsSetup.o ) [2 of 2] Compiling Main ( C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\Setup.hs, C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\dist\setup\Main.o ) Linking C:\DOCUME~1\pschmitz\LOCALS~1\Temp\glade-0.11.12236\glade-0.11.1\dist\setup\setup.exe ... Configuring glade-0.11.1... Preprocessing library glade-0.11.1... Building glade-0.11.1... [1 of 2] Compiling Graphics.UI.Gtk.Glade.Types ( dist\build\Graphics\UI\Gtk\Glade\Types.hs, dist\build\Graphics\UI\Gtk\Glade\Types.o ) [2 of 2] Compiling Graphics.UI.Gtk.Glade ( dist\build\Graphics\UI\Gtk\Glade.hs, dist\build\Graphics\UI\Gtk\Glade.o ) Registering glade-0.11.1... Installing library in H:\proc\tools\cabal\glade-0.11.1\ghc-6.12.1 Registering glade-0.11.1... H:\proc\dev\cmd> ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trying to compile Glade Gtk2Hs demo / cabal install glade problem
(I am posting this to Cafe and Gtk2Hs Users; if you subscribe to both, please reply to Cafe; but I will see your replies either place; thanks much.) I am trying to compile the Gtk2Hs demo program GladeTest.hs (located in the ...\demo\glade dir), under MS Windows XP. The error I get is: H:\proc\tools\Gtk2Hs\demo\glade>ghc --make GladeTest.hs GladeTest.hs:4:7: Could not find module `Graphics.UI.Gtk.Glade': (--Note:-- I am using H: instead of C: for reasons described later.) I did these okay: cabal install cabal-install cabal update cabal install gtk2hs-buildtools cabal install gtk and I can compile and run some other Gtk2Hs demos (that do not use Glade) okay. In general, I am assuming that I need to "cabal install foo" when Haskell module foo cannot be found during compile. (Please correct me if I am wrong.) I get an error during the glade install: H:\proc\dev\cmd>cabal install glade ... Configuring glade-0.11.1... setup.exe: The pkg-config package libglade-2.0 version >=2.0.0 is required but it could not be found. ... (the full output is listed below) I think I have package libglade-2.0 installed, because I installed the GTK+ and Glade bundle from: http://ftp.gnome.org/pub/GNOME/binaries/win32/glade3/3.6/glade3-3.6.7-with-GTK+.exe at: http://ftp.gnome.org/pub/GNOME/binaries/win32/glade3/3.6/ at: http://glade.gnome.org/ That install created tree: H:\proc\tools\Gtk+\ which includes these: H:\proc\tools\Gtk+\include\libglade-2.0\ and H:\proc\tools\Gtk+\glade-3.exe H:\proc\tools\Gtk+\bin\libglade-2.0-0.dll H:\proc\tools\Gtk+\lib\libglade-2.0.a H:\proc\tools\Gtk+\lib\pkgconfig\libglade-2.0.pc So, I'm thinking maybe my install of Gtk+ (just running glade3-3.6.7-with-GTK+.exe) was lacking somehow, or cabal somehow doesn't see my Gtk+ dir (during "cabal install glade") ? So, I tried editing my cabal config so it would see my Gtk+ tree. I uncommented and edited these lines in the main, un-indented section: extra-include-dirs: H:\proc\tools\Gtk+\include extra-lib-dirs: H:\proc\tools\Gtk+\lib but it doesn't seem to help. (my full cabal config listing is below) Regarding my use of H: instead of C:, I have a non-standard configuration of the Haskell Platform and cabal. I need to develop (Haskell code that uses Gtk2Hs, Glade, etc.) in a MS Windows network, from any of several PCs (one at a time), each of which uses a common tools tree. So, instead of installing the Haskell Platform, cabal, Gtk+, etc. to C:, I have installed them to a network drive (H:). So, I have: H:\proc\tools\Haskell Platform H:\proc\tools\Gtk+ H:\proc\tools\cabal etc. Any help or pointers would be appreciated. Thanks very much, -- Peter --- Following is various config and output info --- My PATH is: ++ SET P_TOOLS=H:\proc\tools SET HASK_PLAT=%P_TOOLS%\Haskell Platform\2010.1.0.0 PATH %HASK_PLAT%\bin; %P_TOOLS%\cabal\bin; %P_TOOLS%\gtk\bin; %HASK_PLAT%\lib\extralibs\bin; %HASK_PLAT%\mingw\bin ++ Some of my environment vars are: == REM This is so Cabal will get its config from the Haskell Platform, REM rather than C:\Documents and Settings\pschmitz\Application Data\cabal SET CABAL_CONFIG=%P_TOOLS%\cabal\config CABAL_CONFIG=H:\proc\tools\cabal\config PKG_CONFIG_PATH=H:\proc\tools\Gtk+\lib\pkgconfig GTK_HOME=\\fbpxfile01\users$\pschmitz\proc\tools\Gtk+ HASK_PLAT=H:\proc\tools\Haskell Platform\2010.1.0.0 INCLUDE=\\fbpxfile01\users$\pschmitz\proc\tools\Gtk+\include LIB=\\fbpxfile01\users$\pschmitz\proc\tools\Gtk+\lib Path=H:\proc\tools\Haskell Platform\2010.1.0.0\bin;H:\proc\tools\cabal\bin;H:\proc\tools\Gtk+\bin; H:\proc\tools\Haskell Platform\2010.1.0.0\lib\extralibs\bin;H:\proc\tools\Haskell Platform\2010.1. 0.0\mingw\bin; == The full output from "cabal install glade" is: - H:\proc\dev\cmd>cabal --version cabal-install version 0.8.2 using version 1.8.0.2 of the Cabal library H:\proc\dev\cmd>cabal list glade * glade Synopsis: Binding to the glade library. Latest version available: 0.11.1 Latest version installed: [ Not installed ] Homepage: http://www.haskell.org/gtk2hs/ License: LGPL-2.1 ... H:\proc\dev\cmd>cabal info glade * glade(library) Synopsis: Binding to the glade library. Latest version available: 0.11.1 Latest version installed: [ Not installed ] Homepage: http://www.haskell.org/gtk2hs/ Bug reports: http://hackage.haskell.org/trac/gtk2hs/ Description: This library allows to load externally stored user interfaces into programs. This allows alteration of the interface without recompilation of the program. Category: Graphics License: LGPL-2.1 Author:Manuel M T Chakravarty Maintainer:gtk2hs-us...@sourceforge.net Source repo: http://code.haskell.org/glade/ Dependencies: base >=4 && <5, array -any, containers -any, haskell98 -any, mtl -any, glib >=0.11 && <
[Haskell-cafe] Trying to statically link Gtk2Hs application (Windows XP, network drive)
In [Haskell-beginners], please see: http://www.haskell.org/pipermail/beginners/2010-August/004949.html Please reply to [Haskell-beginners]; thanks much. -- Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
On Thu, Jul 29, 2010 at 8:47 PM, Ivan Miljenovic wrote: > On 30 July 2010 13:32, Peter Schmitz wrote: > > I have a question about finding the Gtk2Hs demos (the demos written in > > Haskell). > > They're not there: > http://osdir.com/ml/haskell-cafe@haskell.org/2010-07/msg00724.html > Ivan: Because I am a new Cabal user, I thought I was misusing it somehow, so that's why I included all the info. I found the demos and they compile and run fine. Thanks very much. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
I have a question about finding the Gtk2Hs demos (the demos written in Haskell). To summarize what I have done so far: I'm a new Cabal user; need to use Cabal in a Windows XP environment, where it and the Haskell Platform are located on a network drive (H:) instead of C:. (Need to be able to do development on any of several PCs, using a single tools dir.) I want to write Haskell code that uses Gtk2Hs (and Glade). I have edited Cabal's config and placed it on H:, and so I have set up: H:\proc\tools\Haskell Platform H:\proc\tools\gtk H:\proc\tools\cabal etc. My edited Cabal config is listed at the end below. I modified my PATH, etc. as follows: SET P_TOOLS=H:\proc\tools SET HASK_PLAT=%P_TOOLS%\Haskell Platform\2010.1.0.0 PATH %HASK_PLAT%\bin;%P_TOOLS%\cabal\bin;%P_TOOLS%\gtk\bin;%HASK_PLAT%\lib\extralibs\bin;%HASK_PLAT%\mingw\bin REM This is so Cabal will get its config from the Haskell Platform, REM rather than C:\Documents and Settings\pschmitz\Application Data\cabal SET CABAL_CONFIG=%P_TOOLS%\cabal\config I had to add the mingw\bin dir to PATH to get cpp (needed during "cabal install gtk"), and the extralibs dir to get alex (for "cabal install gtk2hs-buildtools"). I download the GTK+ "All-in-one bundle" 2.20.0 (current maintained branch), and ran gtk-demo; it works. The following commands then completed okay, with various warnings, but no fatal errors: cabal install cabal-install cabal update cabal install gtk2hs-buildtools cabal install gtk (There seems to be no "cabal install gtk2hs".) *** At this point I am trying to find the Gtk2Hs demos, so I can compile and run them. I cannot find them anywhere in my "H:\proc\tools\" tree. If anyone can help me see what I am missing, I would appreciate it. http://code.haskell.org/gtk2hs/INSTALL says: "To get started, you can compile and run one of the programs that reside in the demo/ directory in the respective packages. For example: ~/gtk2hs/gtk/demo/hello:$ make". But I don't see a "gtk2hs/" dir anywhere. I tried looking for the sources directly (google "gtk2hs demos", etc.) but didn't have any luck. Thanks very much, -- Peter - My Cabal config follows. The email may remove indentation, but I was careful to maintain the original indentation when editing. It seems to work fine. -- This is the configuration file for the 'cabal' command line tool. -- The available configuration options are listed below. -- Some of them have default values listed. -- Lines (like this one) beginning with '--' are comments. -- Be careful with spaces and indentation because they are -- used to indicate layout for nested sections. remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive remote-repo-cache: H:\proc\tools\cabal\packages -- local-repo: -- verbose: 1 -- compiler: ghc -- with-compiler: -- with-hc-pkg: -- scratchdir: -- program-prefix: -- program-suffix: -- library-vanilla: True -- library-profiling: False -- shared: False -- executable-profiling: False -- optimization: True -- library-for-ghci: True -- split-objs: False -- executable-stripping: True -- user-install: True -- package-db: -- flags: -- extra-include-dirs: -- extra-lib-dirs: -- constraint: -- cabal-lib-version: -- preference: -- documentation: False -- doc-index-file: $datadir\doc\index.html -- root-cmd: -- symlink-bindir: build-summary: H:\proc\tools\cabal\logs\build.log -- build-log: remote-build-reporting: anonymous -- username: -- password: install-dirs user prefix: "H:\\proc\\tools\\cabal" -- bindir: $prefix\bin -- libdir: $prefix -- libsubdir: $pkgid\$compiler -- libexecdir: $prefix\$pkgid datadir: "H:\\proc\\tools\\Haskell Platform\\2010.1.0.0" -- datasubdir: $pkgid -- docdir: $prefix\doc\$pkgid -- htmldir: $docdir\html -- haddockdir: $htmldir install-dirs global prefix: "H:\\proc\\tools\\Haskell Platform\\2010.1.0.0" -- bindir: $prefix\bin -- libdir: $prefix -- libsubdir: $pkgid\$compiler -- libexecdir: $prefix\$pkgid datadir: "H:\\proc\\tools\\Haskell Platform\\2010.1.0.0" -- datasubdir: $pkgid -- docdir: $prefix\doc\$pkgid -- htmldir: $docdir\html -- haddockdir: $htmldir ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
> > Rogan is right. You just need to edit the cabal config file to point > to locations on your other drive. > > I would suggest not relocating the config file itself. If you really > must do so then you can use the --config-file flag or the environment > variable CABAL_CONFIG. > > Duncan > I will try that. Thanks very much guys. Great help. -- Peter (and sorry about getting the reply address wrong the first time Duncan) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
Rogan: Again, thanks very much for your reply. My situation is that I need to be able to use Cabal (and the Haskell Platform, Gtk2Hs, etc.) at any of several PCs in a (Windows XP) LAN, each of which has access to the network drive H:. So, I am using: H:\proc\tools\Haskell Platform H:\proc\tools\gtk H:\proc\tools\cabal(hopefully) etc. So I need to not use C: for anything related to Haskell tools (although temp files would be okay I guess), and have everything in the H: tools tree, so that new versions of Cabal, Haskell libraries, etc. get installed to the appropriate dir on H:. I will try experimenting with editing the config file and using that hidden option you mentioned. ** Cabal experts: If anyone knows how to do this sort of thing in a better way, I would appreciate a word. Thanks much, -- Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
Rogan: Thanks very much. I began by downloading the latest gtk+ bundle from http://www.gtk.org/download-windows.html The instructions there said to just copy the files to any dir and add its ...\gtk\bin dir to my PATH, which I did, so that worked okay without admin privs. Given that I need to use these tools on a network drive (H:), and not C:, I have installed the Platform and gtk to: H:\proc\tools\Haskell Platform and H:\proc\tools\gtk (My H: is a hdd, not usb; and I am trying to do all this without admin privs, which is working fine so far.) The gtk tests: pkg-config --cflags gtk+-2.0 and gtk-demo run fine. Great! Anyone: So, I am trying to use cabal (for the first time), on a Windows XP system/network. I need to keep everything on H:, and not use C:. The only copy of cabal I have is what came with the Platform: "H:\proc\tools\Haskell Platform\2010.1.0.0\lib\extralibs\bin\cabal.exe". I placed that bin dir in my PATH and tried a "cabal update". (Does is matter what my current dir is, when I use cabal?) It said: H:\proc\dev\cmd>cabal update Config file path source is default config file. Config file C:\Documents and Settings\pschmitz\Application Data\cabal\config not found. Writing default configuration to C:\Documents and Settings\pschmitz\Application Data\cabal\config Downloading the latest package list from hackage.haskell.org Note: there is a new version of cabal-install available. To upgrade, run: cabal install cabal-install So, by default, cabal wants to put its config and updates on C:. I looked at C:\Documents and Settings\pschmitz\Application Data\cabal\config It has various references to C:, some commented out. E.g.: remote-repo-cache: C:\Documents and Settings\pschmitz\Application Data\cabal\packages build-summary: C:\Documents and Settings\pschmitz\Application Data\cabal\logs\build.log install-dirs user -- prefix: "C:\\Documents and Settings\\pschmitz\\Application Data\\cabal" etc. I also reviewed the Cabal User's Guide, including section 4.1.2.2 Paths in the simple build system which has a table with command line switches and pathname defaults for Windows including: --prefix (global installs with the --global flag) C:\ProgramFiles\Haskell and --prefix (per-user installs with the --user flag) C:\DocumentsAndSettings\user\ApplicationData\cabal Given that I want to keep everything on H:, and assuming that I don't want to place the Cabal configs and updates in the Platform tree (H:\proc\tools\Haskell Platform), I would _like_ to create a dir such as H:\proc\tools\cabal to hold everything that Cabal would normally put on C:. *** I'm afraid I'm having trouble figuring out how to accomplish this. Is there (hopefully) a combination of cabal command line switches that will create a new config file over on H: for me, or must I edit the config file directly and move it to H:? And then, how do I invoke cabal each time, to get it to use its tree on H: (and ignore C:) ? Thanks (very much) in advance. -- Peter Schmitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] new Cabal user question -- installing to Haskell Platform on Windows network drive?
I have recently installed the Haskell Platform (for the first time) to a MS Windows network drive; e.g.: H:\aaa\bbb\Haskell Platform\2010.1.0.0\ I did so without admin privs. It has ghc-6.12.1 I need to not install to C:. I would like to install and use Gtk2Hs and Glade on the Platform also. I have used Gtk2Hs and Glade in Haskell (with just ghc, not the Platform), but I have never used Cabal or the Haskell Platform. I see at http://www.haskell.org/gtk2hs/ that Gtk2Hs now comes in a Cabal package ("Gtk2Hs 0.11.0 released"). The info there says you can just install "the Gtk+ libraries", and then do: cabal install gtk2hs-buildtools cabal install gtk I interpret "the Gtk+ libraries" to mean "gtk: the base GUI library" package listed at http://www.haskell.org/gtk2hs/download/ (is that correct?). That is a link to http://hackage.haskell.org/package/gtk which has "gtk-0.11.0.tar.gz (Cabal source package)", which I downloaded and unpacked to a temp directory which now contains "gtk-0.11.0". I've reviewed the Cabal documentation (that came with the Platform) and I'm having a little trouble determining exactly what to do next -- the exact commands to use for my non-C: / network drive installation. (I have not used Cabal before.) I would prefer to do this without admin privs, if possible. ** If anyone could help me out here with a step-by-step, I would appreciate it. Hopefully the procedure for glade will then be similar. Thanks (very much) in advance. -- Peter Schmitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trying to build a stand-alone executable GLUT app with ghc, Windows XP
Problem summary Trying to build a stand-alone executable GLUT app with ghc, Windows XP Problem description I compile and link (without errors) a simple GLUT application under Windows XP. When I run it, XP pops an error window saying the app cannot start due to a missing "glut32.dll". I want to do a static build to create a stand-alone executable GLUT app under Windows XP, without using DLL files, or placing any files in the Windows system dir. This is my first GUI code in Haskell, and I chose GLUT because it is a standard library. Following are some details. Thanks much for any advice. Source code -- Simple GLUT app to create a window module Main(main) where import Graphics.Rendering.OpenGL import Graphics.UI.GLUT main = do (progname, _) <- getArgsAndInitialize createWindow "Hello World" mainLoop Compile/run Environment ghc-6.8.2 on a USB flashdrive under a non-admin Windows XP account ghc dir is not on C: E:\apps\ghc\ghc-6.8.2 XP shell used: cmd.exe shell path E:\ghcTest>path PATH=C:\WINDOWS\system32;C:\WINDOWS;E:\apps\ghc\ghc-6.8.2\bin;.\ ghc library path E:\ghcTest>ghc --print-libdir E:/apps/ghc/ghc-6.8.2 compile/link output E:\ghcTest>ghc --make x -package GLUT [1 of 1] Compiling Main ( x.hs, x.o ) Linking x.exe ... E:\ghcTest> files (sizes in bytes) 186 x.hs 387 x.hi 3,184 x.o 498 x.exe.manifest 609,222 x.exe When application is run Error dialog window pops up window title a.exe - Unable To Locate Component window text The application has failed to start because glut32.dll was not found. Re-installing the application may fix this problem. No output in shell; no glut window is created. Other builds tried; same runtime error ghc --make x -package GLUT -static ghc -package GLUT x.hs -o x ghc --make x -package GLUT -LE:\apps\ghc\ghc-6.8.2\lib\GLUT-2.1.1.1 ghc --make x -LE:\apps\ghc\ghc-6.8.2\lib\GLUT-2.1.1.1 -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Unbuffered character IO under Windows XP?
module Main(main) where import System.IO main = do b1 <- hGetBuffering stdin print b1 b2 <- hGetBuffering stdout print b2 -- not sure if these help, or are needed hSetBuffering stdin NoBuffering hSetBuffering stdout NoBuffering b1 <- hGetBuffering stdin print b1 b2 <- hGetBuffering stdout print b2 putStr "0" c <- getChar -- echoes during input by default putStr "1" -- want this output w/o hitting Enter hFlush stdout -- adding this does not help putStrLn [c] {--- Output: E:\ghcTest>ghc --version The Glorious Glasgow Haskell Compilation System, version 6.8.1 E:\ghcTest>ghc --make main [1 of 1] Compiling Main ( main.hs, main.o ) Linking main.exe ... E:\ghcTest>main LineBuffering LineBuffering NoBuffering NoBuffering 0a 1a E:\ghcTest> - Question: Is it possible to have unbuffered character IO under Windows XP? I would like to be able to type a single character and have the processing and IO continue without having to hit Enter. I.e., rather than this (had to hit Enter after typing the 'a' in '0a'): 0a 1a I would like to have this (without having to hit Enter after typing the char): 0a1a I have tried a few combinations of hSetBuffering and put/get Str/Char functions, without success. NOTE: I need to run under Windows XP, non-administrator account. This test was run using the normal XP shell cmd.exe. Thanks much in advance. -- Peter } ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe