[Haskell-cafe] Do you want to maintain bindings-DSL?
Hi, bindings-DSL[1] is a stable and reliable macro package for FFI. It just got a new tutorial and its repository is now in git. If no one else wants to maintain it, I'll still be looking at issue reports and fixing possible problems, but I've not been actively using Haskell for some time, and won't add anything new or make plans for future changes. The original idea behind bindings-DSL was to build a wide set of community maintained raw bindings to interesting C libraries, on which Haskell programmers could safely depend when creating their own higher level packages. Although that idea never really took off, bindings-DSL itself got some popularity, probably because it makes instancing Storable easy. If you want to take maintenance, you have some options. You could just kill the bindings-* idea and add some flexibility to new macros, which I always avoided to enforce consistency. Or you could keep the original goal, and maybe add a mailing list and a web page where users could request new libraries and discuss solutions to trick issues. A possible plan for version 2 is to be independent of hsc2hs, and use a new syntax instead of C macros. Thanks. Best, Maurício [1]: http://bitbucket.org/mauricio/bindings-dsl ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] video for linux two (v4l2) bindings
Hi, all, I've added that 'extra-libraries' to .cabal, and also modules for fcntl.h and sys/mman.h (mmap). Would you please test it and check if it solves the problem before I upload it to hackage? https://bitbucket.org/mauricio/bindings-dsl/downloads/bindings-posix-1.2.3.tar.gz Just download from that link, unpack and do 'cabal install' inside the new directory. Best, Maurício 2011/7/8, Claude Heiland-Allen : > Hi, > > On 05/07/11 10:19, Christopher Done wrote: > [snip] >> /usr/bin/ld: >> /home/chris/.cabal/lib/bindings-posix-1.2.2/ghc-6.12.3/libHSbindings-posix-1.2.2.a(Signal.o):(.text+0x5dfb): >> error: undefined reference to 'pthread_kill' > [snip] >> I guess on Claude's system it's linked to by default. So for guys >> trying the examples with that error I'd recommend the following >> commandline: >> >>cabal install v4l2-examples --ghc-option=-lpthread > > I think this could be a bug in bindings-posix (maintainer CC'd), I guess > it could do with this in its .cabal file: > > Extra-libraries: pthread > >> Can't really play about with the webcam right now but I'd had a small >> but cool project I've had in mind for a while that v4l is perfectly >> suited for, so I'll get back to you with my experiences. Thanks for >> releasing it, Claude. :-) > > Cool, look forward to seeing it! Hopefully I'll soon find time to > upload to Hackage a preliminary (feature-incomplete) release of the > higher-level interface that I'm working on; until then: > https://gitorious.org/hsv4l2/v4l2 > > > Claude > -- > http://claudiusmaximus.goto10.org > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Off-topic]Functional parsing theory
After reading your message I found "Why Attribute Grammars Matter" and a few other introductions, and it seems attribute grammars are exactly what I'm trying to do. Do you know of some place (mailing list etc.) where I can discuss attribute grammars or ask for suggestions on design? Thanks, Maurício 2010/10/7, bieniusa : > It's not entirely clear what you mean: > > Do you want to describe grammars or parsers functionally: > > In the first case, parser combinators are what you want (or some > encoding of them). There are many variations on these: LL(k), > context-free, dependent. Cyclicity (of what kind?) or empty productions > are not necessarily a problem. > > If you already parsed the input to an abstract syntax tree, and want to > act on this input in terms of your grammar, then attribute grammars are > what you are looking for. > > - Arie > > Am 06.10.2010 17:43, schrieb Maurício CA: >> Hi, all, >> >> I've been working in a tool that reads a grammar with associated >> actions and act on input based on that grammar. I would like to >> rewrite it in a functional style, but I've not been able to find a >> theory that would handle any possible grammar with cyclicity and >> empty productions, and flexibility is more important for this tool >> than performance. >> >> Do you have a suggestion on that? What I'm using now is this >> (non-functional) article on Earley method: >> >> http://www.springerlink.com/content/602270808666074p >> >> Thanks, >> >> Maurício >> >> ___ >> 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] Who takes care of Haskell mailing lists?
Hi, I would like to create a mailing list for Portuguese speaking Haskell programmers. I tried checking haskell.org mailing lists page, but the only contact e-mail I see is 'mail...@haskell.org', and a message sent to that address is replied with an automatic message saying I'm not authorized to use it. Is there someone I could contact about that? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell programmers in São Carlos - SP - Brazil?
> I would as well, but what would we gain with it? Wouldn't it rot > because every message one of us wanted to post was general enough > to just post on haskell-cafe? Would it be able to attract > Portuguese-speaking people that aren't fluent English speakers? > > I'm not being pessimistic, just a thought. :) Of course, this was in my mind too. But I think we could have more general discussion groups in Portuguese, now that there's a standard ortography :) I think it's worth a shot. At least there are many students who do not speak good english, and even for those who use english all time most of us will always be able to write deeper thoughts in Portuguese than in English. I'll check with the guys at: http://haskell.org/mailman/listinfo If it doesn't suceed, we'll just erase it. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell programmer s in São Carlos - SP - Brazil?
Is there already any mailing list or group in Portuguese? I would like that if it were a list for Portuguese speakers, no matter they are from Portugal or Moçambique. Maurício > Hey, we have enough people for a São Paulo Haskell User Group. > Anyone else interested? > > Best regards, > Daniel Yokomizo > > 2009/5/21 Fernando Henrique Sanches : >> São Caetano, SP, Brazil - right next to São Paulo. UFABC Student. >> >> Fernando Henrique Sanches >> >> >> 2009/5/19 Maurício >>> Anybody else around here? >>> >>> Best, >>> Maurício >>> >>> ___ >>> 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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: haddock could be a pretty-printer?
>> The new version of haddock makes use of GHC parser. How much >> of effort would take to make haddock generate pretty-print >> of the source code itself, (...) > (...) Is this what you want or is there some reason why you > want the code to be pretty-printed? I usually have to resort to braces or bad indenting to get code to parse, but I like to give it good presentation before publishing. I used to pretty-print my code using haskell-src-exts with great result, but that kills documentation. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haddock could be a pretty-printer?
Hi, The new version of haddock makes use of GHC parser. How much of effort would take to make haddock generate pretty-print of the source code itself, including haddock documentation (although probably loosing other comments)? Maybe even an html version that documentation could point to? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Problem with haddock importing definition
>>> When you say documentation disappears, do you mean that R is still >>> listed, but its comments are not shown, or is R completely absent from >>> the documentation? >> See http://trac.haskell.org/haddock/ticket/107 >> He just needs to include B in the other-modules list, so that cabal will >> pass it to haddock (and setup sdist). > I would still like to know the answer to my question though, since I > think we can improve Haddock here. R is completely absent from documentation. I did include a working example with .cabal file in that ticket, maybe that can help. (Just to note, my problem was solved by 'other-modules'.) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problem with haddock importing definition
Hi, I have a situation like this: module A imports R (a newtype declaration) from module B, and lists it in its (module A) export list. Documentation for R is included by haddock in documentation for module A, as I want. However, if my package exposes only module A, documentation for R desapears. So: if my .cabal file lists A and B in 'exposed-modules', documentation for R is included in A documentation. If I remove B from 'exposed-modules', R documentation in A desapears. Do you know what should I do? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: List of exports of a module - are there alternatives?
I would like a keyword we could add to a single declaration, like: hidden a :: Int -> Int a = (...) The 200 names is not the best example. It's more a question of proportion: if you export 5 declarations in a module with 20, it's OK, but if you export 19 declarations in a module of 20 maintenance can be painfull to your eyes, going up and down into your file to check if the list is correct. Maurício > I would like to see this too. Maybe just a private keyword that would > make everything after it invisible to the outside (or until a public > keyword appeared)? > >> Are there propositions to alternatives to that (I could not >> find one)? Like, say, add a "do export" or "do not export" >> tag to declarations we want to (not) export? >> >> (I think something like that could be nice when we have modules >> with 200 declarations and just a few are (not) going to be >> exported.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] List of exports of a module - are there alternatives?
Hi, When we want to list which declarations are exported by a module we do: module Mod ( list of exports ) where ... Are there propositions to alternatives to that (I could not find one)? Like, say, add a "do export" or "do not export" tag to declarations we want to (not) export? (I think something like that could be nice when we have modules with 200 declarations and just a few are (not) going to be exported.) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: When is it OK to create a new mailing list?
>> Would this not fit well in the wxHaskell mailing list? That list is not very >> high traffic and there is an obvious overlap in the target audience. > This was my thought as well. Adding another list is considerable > overhead, and keeping it on the wxHaskell list has the benefits of > no-administration and possibly drawing in interested wxHaskellers (and > I imagine many issues will turn out to be wxHaskell issues, so keeping > them in the loop from the start is a good idea anyway). > Or: while your package has not get a user base big enough to make a mailing list work well, maybe what you need is just a bug-tracking system. The community server provides that (as Duncan pointed earlier). Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Help from C libraries experts
>> My goal is to have a place where one can find reliable and >> comprehensive low-level bindings to foreign libraries, so that >> writing higher level bindings becomes an easier task. > (...) In your guidelines, you say: >> Code should be portable and easy to build. > Does your understanding of "portable" include Windows? My thought on that was: anyone trying to wrap a library will have to solve this kind of problem. So, if it is possible to write such wrap, at least one solution exist, and 'bindings' set will try to select the best one for general use. Sometimes, this may be adding the C code itself, as is my current attempt on sqlite3. Sometimes the task can be delegated to pkg-config. Actually, that is the reason why my first post was a call for help from libraries experts. This has to be solved on a per library base. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Help from C libraries experts
>>>>> Do you understand very well a C library and would like >>>>> Haskell to have a binding for it? (...) > Could you perhaps then summarise what design rules you're using? Yes. They are summarised at the main module documentation: http://hackage.haskell.org/packages/archive/bindings/0.1/doc/html/Bindings.html > For example, why did you pick the new 'Bindings' namespace? The most important guideline is: users guide guidelines. If you have a better sugestion for a base module name, please open a ticket at development website, under 'Issues/Create new issue' (you can do it as anonymous): http://bitbucket.org/mauricio/bindings > What are you doing that's different to having standalone > small packages? I'm trying to write "canonical" bindings libraries. > One risk I see is that 'bindings' will depend on a large number of C > libraries (...) Sure. I would like to have: bindings-common bindings-testsAndExamples bindings-sqlite3 bindings-openusb bindings-agar etc. But I thought I should not polute hackage before this package get at least a few people understanding and agreeing with the concept. > Maybe this is a better discussion for librar...@? OK. I'll repost there, with text updated after your thoughts. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why do I need a 'do'?
>> import System.Random >> >> rollDice :: IO Int >> rollDice = getStdRandom (randomR (1,6)) >> >> rollNDice :: Int -> [IO Int] >> rollNDice 0 = [] >> rollNDice n = rollDice : rollNDice (n-1) > > > replicateM n rollDice > > http://www.haskell.org/haskellwiki/Avoiding_IO#State_monad Or, if you want the original idea: sequence (rollNDice 10) Check the type of sequence at Control.Monad. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Help from C libraries experts
>>> Do you understand very well a C library and would like >>> Haskell to have a binding for it? (...) If you are >>> willing to help me with questions about your favorite C >>> library, like compile options I should be carefull about >>> or differences I may find between systems, I'll be glad to >>> write a low level binding to it. >> I think "bindings" is an unfortunate choice of name for >> this package, as it doesn't tell us anything about what >> it contains. (...) It's not important what it contains, but how. Well, it does contain bindings, as many as possible. The important thing is that any new binding can be added following strictly the same guidelines used for others. 'Bindings.Sqlite3' is just an example on how this will be done. Suppose that 5 people want to write 5 different USB high-level modules. The beneficts are: - they all can use the low-level binding in this package for OpenUSB (which is not available now, until some expert on that library helps me do it). No need for testing, debugging, checking for portability or proper initialization, as all that has been taken into account. - no need to read documentation. Guidelines in 'bindings' ensures that the documentation for the original package (in this case, the C documentation for OpenUSB) is valid for Haskell binding. If you know OpenUSB in C, you can use Bindings.OpenUSB almost without even looking at the documentation for that module. - if a bug is discovered in Bindings.OpenUSB, it's solved there. Those 5 high-level modules won't need to check for the same error. - those writing the high-level modules have no need to learn about 'foreign import'. - if high-level coders fell unsafe about the behavior of the API, they can write an HUnit test that will be added to the test code in 'bindings'. (This is stated in the documentation. If you write a test and it does apply, it will be added to the test code.) All five high level modules benefict from that. > For example, the StandardC module would seem to duplicate the > 'cmath' > package: (...) While the Sqlite3 module duplicates: > (...)sqlite This package came from my need to use sqlite3. If 'sqlite' existed before, it probably would not exist. But this is not important. What is important is: if 'sqlite', and all other many sqlite3 packages, removed their low-level ("foreign import .*" etc.) and instead added 'bindings' as a dependency, they could all count on "Many eyes make all bugs shallow" to the low level code. And everybody could expend more time with the high level stuff, which I'm sure everybody likes the most. I would like this package to be a repository where we could find any good portable C (and other languages, when FFI support that) package. If that happens (and the maintainer will probably have to be someone better than me) I think a new module space is worthwhile. Maybe 'Foreign.Bindings.*' instead of 'Bindings.*'. Sorry for the long post, but it took me a lot of time to get the proper design for this package, specially for the guidelines. If it doesn't work (i.e., nobody gets interested), it's dead for good. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Help from C libraries experts
Hi, Do you understand very well a C library and would like Haskell to have a binding for it? I've been working on this package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bindings My goal is to have a place where one can find reliable and comprehensive low-level bindings to foreign libraries, so that writing higher level bindings becomes an easier task. If you are willing to help me with questions about your favorite C library, like compile options I should be carefull about or differences I may find between systems, I'll be glad to write a low level binding to it. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What happened to Haskell original goals?
I remember reading "avoid success at all costs" somewhere. I miss the old days when I could read all messages in this list. Today, I can hardly keep up with a few of the most interesting threads. Good programming for all you guys in 2007. Thanks for your support and comments, and for helping me learning this really cool language. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell genetic algorithm
Hi, Does anyone knows of nice genetic algorithms implementations in Haskell? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Genetic programming Haskell
Hi, Does anyone know of a package for genetic programming for Haskell? I tried some links from Haskell wiki and some I found on google, and found many interesting papers, but none of them pointed to downloadable code. Does anyone know where can I find a good implementation (even an experimental one)? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Nice cygwin application to be used with ghci
Hi, I've just uploaded a package ('rlwrap') to cygwin that I like to use with ghci. You can use it like this: rlwrap ghcii.sh and then you will use ghci as if it were readline aware (i.e., you can press up arrow to get last typed lines etc.). 'rlwrap' is very stable and I never had unexpected results while using it. Since the issue of ghci integration with terminals has been raised here sometimes, I thought some guys here would be interested (actually, I found rlwrap looking for a better way to use ghci). Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Opening a file that another process is writing
Hi, I want to open for reading a log file that another process is locking for write. I know it's possible, since 'cat' and 'vim' can read that file (but not edit it, of course). How can I do that in Haskell? 'openFile' says "permission denied". Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Small syntax question
That's very good for us begginers. It would be great if this could be in the main Haskell site. Doaitse Swierstra wrote: Jeroen Fokker has made Haskell syntax diagrams, which are part of lecture notes for first-year students. Maybe they are helpful to others too, Doaitse http://abaris.zoo.cs.uu.nl:8080/wiki/pub/FP/CourseLiterature/haskellsyntax-main.pdf On Jul 11, 2006, at 4:30 PM, Thiago Arrais wrote: By the way, you can find the syntax specification here http://haskell.org/onlinereport/syntax-iso.html Regards, Thiago Arrais --Mergulhando no Caos - http://thiagoarrais.blogspot.com Pensamentos, idéias e devaneios sobre desenvolvimento de software e tecnologia em geral ___ 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] Small syntax question
Hi, I can do this: (let a=3 in a) + (let b=4 in b) but not this: (a where a=3) + (b where b=3) Why? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Efficient way to edit a file
David Roundy wrote: On Fri, Jun 02, 2006 at 12:34:51PM +1000, Donald Bruce Stewart wrote: dons: briqueabraque: Hi, I need to edit big text files (5 to 500 Mb). But I just need to change one or two small lines, and save it. What is the best way to do that in Haskell, without creating copies of the whole files? Thinking further, since you want to avoid copying on the disk, you need to be able to keep the edited version in memory. So the strict bytestring would be best, for example: dons is right here, but I'd add that it's hard to safely edit a big file without creating a copy, if you want your program to leave the file in a consistent state even if it crashes (power failure, kill, file server failure). dons' suggestion could leave you with a deleted file (if power goes down at the beginning of a write). If you aren't changing the size of the file, opening it ReadWrite will allow you to modify it reasonably safeily. If you *are* changing its size, then doing something explicit would probably be the way to go (and I'd probably actually use mmap and memmove to make the change, if you do need to modify the file size). But then, I'm thinking posix (as I generally do), which may not be the case for you. And perhaps you don't need to be careful. I've found that if bad things can happen, they do. But that's largely because darcs has lots of users... I like very much the idea of memory mapping the file. In some situations, random access to the file would help a lot. Can I do that on Windows? Also: safety is not a concern. I can delete those big files as much as I need, they are only temporary data. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Efficient way to edit a file
Hi, I need to edit big text files (5 to 500 Mb). But I just need to change one or two small lines, and save it. What is the best way to do that in Haskell, without creating copies of the whole files? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Unexpected results with simple IO
I'm also using GHC 6.4.1 and rxvt v2.7.10. The problem does occur in compiled code, but everything is OK in ghci! hFlush stdout did solve the problem, as expected. I've just started using rxvt. If you have tips on how to make ghci work well with rxvt, please share them with me (for instance, how to set the top arrow to repeat the last line, instead of moving the cursor one live above. I don't understand very well how those applications handle keyboard). Best, Maurício Emil Axelsson wrote: What version of GHC are you using? Your code works for me in rxvt in Cygwin, with GHC 6.4.1. But I remember having that same problem earlier (in some earlier GHC version, so it may be fixed by now). The solution was to run hFlush after each putStr, like so: import System.IO (hFlush, stdout) do putStr "..." hHlush stdout ... If I remember correctly, the problem only occurred in GHCi and Hugs -- not when compiling the code. / Emil Maurício skrev: You're right... I was running the example in rxvt, in cygwin. Now I tried in Windows command shell and it works. Thanks, Maurício Cale Gibbard wrote: That doesn't happen for me at all, it works just fine. Maybe it's something wrong with your terminal? You could possibly try playing with the buffering settings on stdout, using hSetBuffering in System.IO. - Cale On 17/02/06, Maurício <[EMAIL PROTECTED]> wrote: Dear Haskell users, I have a problem using IO. The small test program below asks the user to guess from a list of random numbers between 1 and 10. Everything works well excepts for one problem: all the messages ("Guess a number...", "Right..." and "Wrong...") are printed after the program finishes, i.e., I have to use it blind. I'm afraid I misunderstand something important about lazyness or monads... What am I doing wrong? Thanks, Maurício module Main where import Random main = do r_gen <- getStdGen --random generator let r_list = (randomRs (1,10) r_gen) --random list guess_loop (r_list) guess_loop (r:r_others) = do putStrLn "Guess a number between 1 and 10:" n <- readLn if n==r then do putStrLn "Right! :)" return () else do putStrLn "Wrong... :(" guess_loop r_others ___ 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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Unexpected results with simple IO
You're right... I was running the example in rxvt, in cygwin. Now I tried in Windows command shell and it works. Thanks, Maurício Cale Gibbard wrote: That doesn't happen for me at all, it works just fine. Maybe it's something wrong with your terminal? You could possibly try playing with the buffering settings on stdout, using hSetBuffering in System.IO. - Cale On 17/02/06, Maurício <[EMAIL PROTECTED]> wrote: Dear Haskell users, I have a problem using IO. The small test program below asks the user to guess from a list of random numbers between 1 and 10. Everything works well excepts for one problem: all the messages ("Guess a number...", "Right..." and "Wrong...") are printed after the program finishes, i.e., I have to use it blind. I'm afraid I misunderstand something important about lazyness or monads... What am I doing wrong? Thanks, Maurício module Main where import Random main = do r_gen <- getStdGen --random generator let r_list = (randomRs (1,10) r_gen) --random list guess_loop (r_list) guess_loop (r:r_others) = do putStrLn "Guess a number between 1 and 10:" n <- readLn if n==r then do putStrLn "Right! :)" return () else do putStrLn "Wrong... :(" guess_loop r_others ___ 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] Unexpected results with simple IO
Dear Haskell users, I have a problem using IO. The small test program below asks the user to guess from a list of random numbers between 1 and 10. Everything works well excepts for one problem: all the messages ("Guess a number...", "Right..." and "Wrong...") are printed after the program finishes, i.e., I have to use it blind. I'm afraid I misunderstand something important about lazyness or monads... What am I doing wrong? Thanks, Maurício module Main where import Random main = do r_gen <- getStdGen --random generator let r_list = (randomRs (1,10) r_gen) --random list guess_loop (r_list) guess_loop (r:r_others) = do putStrLn "Guess a number between 1 and 10:" n <- readLn if n==r then do putStrLn "Right! :)" return () else do putStrLn "Wrong... :(" guess_loop r_others ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Layout processing
Hi, Is it possible to ask GHC or other Haskell compiler to generate a Haskell source file just after the processing of layout? I.e., I would like to see this: main = do a <- some_function Transformed into this: main = do {a <- some_function; I thought that would be usefull to understand better how layout works. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Small syntax question
Hi, This is valid code: module Main where main = do let a = 3 return () Why isn't this one? module Main where main = do { let a = 3; return (); }; Thanks for your help, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell code for this example of flow control
Kurt Hutchinson wrote: On 2/2/06, Maurício <[EMAIL PROTECTED]> wrote: I understand those examples, but I really would like to know how to do that with monads. I would like to ask the same question, but now with this code: double a = 1000; double b = 0; while (a != b) { a /= 2; cout << a; // Prints a cin << b; // User gives a number, stored in b }; An idiomatic approach: example :: Double -> Double -> IO () example a b | a == b= return () | otherwise = do let a' = a / 2 print a' b' <- readLn example a' b' main = example 1000 0 Thanks! Robert's, Chris' and yours examples solved many of my questions. I understand I can insert modifications in IORefs (as used by Robert and Chris) inside the loop above: | otherwise = do let a' = a / 2 ... modifyIORef some_ioref some_function ... example a' b' I wonder if I could write a generic while based on your example: while :: (a -> IO a) -> (a -> Bool) -> IO () I'll probably learn something trying that. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell code for this example of flow control
Donald Bruce Stewart wrote: briqueabraque: Hi, I would like to know what options I have in Haskell to do something similar to this C++ code: double a = 1000; while (a>1) a/=2; I'm able to do that with lists, but I would like to know how to do that with monads and variables with state. You'll get good code using a normal recusive loop: main = print (loop 1000) where loop a | a <= 1= a | otherwise = loop (a/2) All such control structures may be implemented using recursion. -- Don I understand those examples, but I really would like to know how to do that with monads. I would like to ask the same question, but now with this code: double a = 1000; double b = 0; while (a != b) { a /= 2; cout << a; // Prints a cin << b; // User gives a number, stored in b }; Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell code for this example of flow control
Hi, I would like to know what options I have in Haskell to do something similar to this C++ code: double a = 1000; while (a>1) a/=2; I'm able to do that with lists, but I would like to know how to do that with monads and variables with state. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Can I use Haskell for web programming
I think it would be interesting to ask some professional site to install hsp, before I go to the cgi solution. If I want to do that, what should I ask them to install to get a full working environment, with access to SQL and other stuff? Maurício Niklas Broberg wrote: hsp can be run in two different modes. Running the full-blown version with runtime system will probably be hard on a professional site, you would have to convince them to install hsp. But if you can do without the fancier bits, in particular application-scoped data, you can run hsp pages as ordinary cgi scripts. Look in the HSPR.CGI.RunCGI module. /Niklas On 1/21/06, Maurício <[EMAIL PROTECTED]> wrote: They both look cool. Do you think I'll be able to find someone to host professional sites using those libraries? [], Maurício Sebastian Sylvan wrote: On 1/21/06, Maurício <[EMAIL PROTECTED]> wrote: Hi, Can I use Haskell to do what people do with, say, PHP? More and more I have the need for that, and I've been looking into Ruby on Rails. Do you thing Haskell could be a choice? Of course, I don't need something exactly like PHP (for instance, I don't care if I can't insert code in the middle of xhtml pages. If I have to generate everything from Haskell code, I would probably like it. Also, CGI can be a choice). But I need reasonable efficiency and to be able to find someone to host my site. What solutions do you suggest me? Take a look at WASH and HSP... http://www.informatik.uni-freiburg.de/~thiemann/WASH/ http://www.cs.chalmers.se/~d00nibro/hsp/ -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ 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] Re: Can I use Haskell for web programming
Interesting. It's hosted on Haskell site. Do you think I would be able to do what you have done in a professional hosting service computer? Best, Maurício Neil Mitchell wrote: Hi, Can I use Haskell to do what people do with, say, PHP? I wrote Hoogle (http://haskell.org/hoogle) using Haskell, without using any libraries - just directly as a console program. It's open source so you can download it and see how its done, if you want. Of course the web handling bit is more low level than WASH and HSP. Thanks Neil On 21/01/06, Maurício <[EMAIL PROTECTED]> wrote: Hi, and more I have the need for that, and I've been looking into Ruby on Rails. Do you thing Haskell could be a choice? Of course, I don't need something exactly like PHP (for instance, I don't care if I can't insert code in the middle of xhtml pages. If I have to generate everything from Haskell code, I would probably like it. Also, CGI can be a choice). But I need reasonable efficiency and to be able to find someone to host my site. What solutions do you suggest me? Thanks, Maurício ___ 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] Re: Can I use Haskell for web programming
They both look cool. Do you think I'll be able to find someone to host professional sites using those libraries? [], Maurício Sebastian Sylvan wrote: On 1/21/06, Maurício <[EMAIL PROTECTED]> wrote: Hi, Can I use Haskell to do what people do with, say, PHP? More and more I have the need for that, and I've been looking into Ruby on Rails. Do you thing Haskell could be a choice? Of course, I don't need something exactly like PHP (for instance, I don't care if I can't insert code in the middle of xhtml pages. If I have to generate everything from Haskell code, I would probably like it. Also, CGI can be a choice). But I need reasonable efficiency and to be able to find someone to host my site. What solutions do you suggest me? Take a look at WASH and HSP... http://www.informatik.uni-freiburg.de/~thiemann/WASH/ http://www.cs.chalmers.se/~d00nibro/hsp/ -- Sebastian Sylvan +46(0)736-818655 UIN: 44640862 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Can I use Haskell for web programming
Hi, Can I use Haskell to do what people do with, say, PHP? More and more I have the need for that, and I've been looking into Ruby on Rails. Do you thing Haskell could be a choice? Of course, I don't need something exactly like PHP (for instance, I don't care if I can't insert code in the middle of xhtml pages. If I have to generate everything from Haskell code, I would probably like it. Also, CGI can be a choice). But I need reasonable efficiency and to be able to find someone to host my site. What solutions do you suggest me? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Begginer question
Jules Bean wrote: (...) Why Haskell converts "4" to Complex but not a Float? The answer lies available to you in ghci: Prelude> :t 4 4 :: forall t. (Num t) => t The type of for is 'any type in the Num class'. So '4' stands for the Integer four as well as the Float four and the Double four and indeed the Complex 4. No conversion is actually happening. Interesting. The tutorial I'm following didn't say anything about classes yet. I'll read about it and then go back to my problem. Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe