Re: [Haskell-cafe] interaction between OS processes
On Sat, Sep 01, 2007 at 09:12:30PM -0400, Albert Y. C. Lai wrote: > Andrea Rossato wrote: > > loop s = do > > putStrLn s > > Most likely, the content of s sits in a local buffer and never leaves this > process, following most OS conventions and as others point out. Another > process waiting for it will deadlock. > > Most similar process deadlock problems are not specific to Haskell or even > relevant to Haskell; they are misunderstandings of the underneath OS. I > recommend every Haskell programmer to take an in-depth Unix course. Yes, I knew it was something related to the underneath OS. I'll have to study Unix seriously Thanks you guys for your kind attention. Andrea ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Looking for suggestions to improve my algorithm
I played around with this for a while based on the same sort of algorithm and ended up with a similar solution too. It turns out the operations saved by keeping track of already visited nodes are more than outweighed by the cost of doing so. (As you can see, I still have the hook in my code where amCn returns the visited list that I'm just disregarding. Ii had initially kept a giant array of all values to calculate, but the cost of that was unmanageable. After that, my big roadblock was that I couldn't come up with a good sumDivisors function to save my life. I tried a number of "optimized" methods that combined trial division with reduction based on prime factorizations, but i had to either reduce the lists by checking divisibility again somewhere along the way, or calling nub, and strictness and memoization still didn't let me produce a factorization in reasonable time. In the end, I ended up lifting yours. The only problem is that I've been staring at it for a bit and am not really sure how it works. I'd love an explanation. In any case, the code of my solution follows: amCn maxval n = amCn' (propDSum n) [] where amCn' cur visitedlist = if cur > maxval || cur < n then (0,visitedlist) else if elem cur visitedlist then (0,visitedlist) else if (cur == n) then ((length visitedlist) + 1,visitedlist) else (amCn' $! (propDSum cur)) $! (cur:visitedlist) longestAmTo maxval = longestAm' 2 (0,0) where longestAm' n bestFit@(chainLen,minVal) = if n > maxval then bestFit else longestAm' (n+1) $! bestFit' where (count, visited) = amCn maxval n bestFit' = if chainLen > count then bestFit else (count,n) properDivisorsSum :: UArray Int Int properDivisorsSum = accumArray (+) 1 (0,100) $ (0,-1):[(k,factor)| factor<-[2..100 `div` 2] , k<-[2*factor,2*factor+factor..100] ] propDSum n = properDivisorsSum ! n --S On Aug 30, 2007, at 11:33 AM, Chaddaï Fouché wrote: 2007/8/30, Chaddaï Fouché <[EMAIL PROTECTED]>: I managed it in 7 seconds (on 1500 MHz) with an idea close to yours (but I used IntSet, not IntMap), Daniel Fisher gave you some good ideas to achieve it, the real snail in this problem is the sumDivisors function. I put my final solution on the wiki, it get it done in 6s now (on a Pentium M 1.73Mhz). -- Jedaï ___ 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] Re: HApps API Documentation?
Martin Lütke wrote: > James Britt neurogami.com> writes: > >> Are there alternative sites for HAppS API docs? >> >> There are two links on http://happs.org/#documentation but both give >> "File not found!" messages. >> >> Thanks, >> >> James >> > > Just compile your one version from the HAppS source. Use runghc Setup.hs > haddock. OK, I can give that a shot. I'm still curious about my original question, though. Are there alternative online API docs for Happs? > You do have have haddock installed, havent you? > I didn't. I'm grabbing Alex from darcs now. James ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Extending the idea of a general Num to other types?
I like the fact that Haskel treats numbers in a generic way, so you can lift them to any other datatype by instantiating Num. Can the same be done on other builtin constructs? For example, if I have [a], can this list be lifted to other types? I guess not, because no type class exists for the list type? Does this make sense? I'm still searching for correct terminology... Thanks, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learn Prolog...
Peter Verswyvelen wrote: Thanks, this is very useful information! Prolog is indeed on my list as languages I want to learn. I understand the basic principles, but haven't digged deep yet. But first I want to do Haskell, which I'm now totally addicted to! But after reading http://en.wikipedia.org/wiki/Fifth_generation_computer, it seemed to me that Prolog was a dead language, having only pure theoretical purposes. Is this true? Having a rich imperative background (I wrote some simple imperative compilers and a large semi-functional visual programming toolkit currently being used by a game development company), a book I found really useful to understand how the inners of FP and Prolog work is Modern Compiler Design. It provides C code for all the concepts, so an imperative programmer feels right at home. But to me it had the side effect that after reading the last chapters on functional and logical programming, I felt I had to get rid of these imperative languages as quickly as possible (I always felt I was hacking when doing C, C++, or C#... which maybe just meant I'm a bad programmer ;-) PS: A part of the "Prolog for AI" book can be read on Google Books (this Google Books thing looks *very* illegal to me, but since it's google and not some hackers website, I felt free to provide a link here...) Cheers, Peter Verswyvelen [EMAIL PROTECTED] wrote: Yes, I know, this is Haskell list. So, I apologize, but not too much... Johan Grönqvist cites me: Anyway, I believe strongly that ALL people who have problems... should be encouraged to learn Prolog. IN DEPTH, Do you have a recommendation on how to do this? (e.g., books, web-pages, (available) lecture notes, problem sets) First, install a decent Prolog on your machine. There are plenty: http://kti.mff.cuni.cz/~bartak/prolog/implementations.html http://www.cs.cmu.edu/Groups/AI/html/faqs/lang/prolog/prg/part2/faq-doc-2.ht ml You may wish to install the free version of Visual Prolog. My favourite is the SWI Prolog: http://www.swi-prolog.org/ (University of Amsterdam) The documentation is complete, and the reference manual contains references to such standard books as ClocksinMellish, or Sterling&Shapiro. The last one is very, very instructive. Also, Prolog Programming for Artificial Intelligence, written by Bratko, is very useful. There are on the web collection of examples from this book, don't remember where. Try here: http://promethee.philo.ulg.ac.be/engdep1/download/prolog/bratko/ On-line there are thousands of examples, tutorials, etc. J. Fisher: (There is an example of cut, especially for A. Coppin) http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/contents.html others: http://www.coli.uni-saarland.de/~kris/learn-prolog-now/lpnpage.php?pageid=on line http://computing.unn.ac.uk/staff/cgpb4/prologbook/book.html http://www.cs.nuim.ie/~jpower/Courses/PROLOG/ Etc., etc. Really! Examples. For example: http://www.csse.monash.edu.au/~lloyd/tildeLogic/Prolog.toy/Examples/ http://kti.mff.cuni.cz/~bartak/prolog/learning.html http://www.visual-prolog.com/vip/example/ and of course there are discussion lists, FAQs, etc. Ask Google... === Andrew Coppin writes: I did once try to learn Prolog. And failed. Miserably. I just couldn't bend my head around how the Prolog interpreter manages to > make seemingly "impossible" leaps of deduction. (It's a *machine*! How can > it deduce arbitrarily complex conclusions from any arbitrary set of axioms? That requires *intelligence*!) And yet, in other, seemingly identical cases, it utterly fails to deduce patently *obvious* results... really weird! One of standard exercices in Prolog is the construction of the meta-interpreter of Prolog in Prolog. While this is cheating, I recommend it to you. It opens eyes. Actually, there are three basic items to learn while trying to master Prolog after having dealt with the syntactic essentials term construction, and the like. 1. The unification, which shows the "ultimate" instance of pattern-matching and is useful for recognizing some techniques for the automatic inference of types in functional languages. 2. The usage of unbound "logical variable", which sometimes permits to to do things which require laziness in Haskell. 3. The control backtracking, which is at the heart of the logical non-de- terminism. Now, the non-deterministic algorithms in Haskell are usually implemented using the *data backtracking*, or the List Monad. The control backtrack, via, say success/failure continuations, is more difficult, they are rarely taught, and problematic because of strong typing. Prolog strategies are straightforward, and I simply cannot understand the comments of Andrew Coppin. Which arbitrary set of conclusions?? Which patently obvious results not derivable?? Be kind
Re: [Haskell-cafe] RE: Definition of the Haskell standard library
A really simple way to track the "quality" of a package is to display the number of downloads. A posteriorae, this works great in other download sites. We can easily hypothesize about why a download count gives a decent indication of some measure of quality: - more people downloading it means more people specifically wanted that package - more people downloading it means more people trying it, giving feedback, maybe giving patches - and, of course, it's an objective measure, easy to do ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Learn Prolog...
Cool I had prolog for my Spectrum, many years ago (83?), but I stopped using it when I realized it didnt have any input/output capabilities beyond print, and no way to "escape" from the prolog "bubble", eg FFI (not sure what FFI stands for, but I think it is a way for Haskell to "escape" into other libraries?). Thanks for the links, it sounds fun. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] let and fixed point operator
Mitar wrote: I did once try to learn Prolog. And failed. Miserably. You should backtrack at this point and try again differently. :-) There is likely a problem if he has inadvently walked past a cut. XD ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] interaction between OS processes
Andrea Rossato wrote: loop s = do putStrLn s Most likely, the content of s sits in a local buffer and never leaves this process, following most OS conventions and as others point out. Another process waiting for it will deadlock. Most similar process deadlock problems are not specific to Haskell or even relevant to Haskell; they are misunderstandings of the underneath OS. I recommend every Haskell programmer to take an in-depth Unix course. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Definition of the Haskell standard library
On Sat, 2007-09-01 at 18:47 +0200, Sven Panne wrote: > On Tuesday 31 July 2007 19:39, Duncan Coutts wrote: > > [...] > > The docs for those packages would be available for packages installed > > via cabal (assuming the user did the optional haddock step) and would > > link to each other. > > Well, on a normal Linux distro a user should *never* have to call cabal (or > any of its cousins) directly, the distro's package manager should be the used > instead. On an e.g. RPM system, the .spec file would use Cabal to e.g. > (un-)register a package, because RPM has to know what is installed, which > other packages are prerequisites, how to cleanly uninstall, etc. IMHO Cabal > should not try to mirror a full-fledged package system, simply because on > every (non-Windows ;-) platform there are tons of native tools for this > purpose, and Cabal is not "in the driver's seat" when it comes to SW > installation. I think it's inevitable that there will always be a mixture of packages that are managed by the system package manager and ones that are too insignificant to be packaged by the distro. So cabal-install should cooperate with the system package manager somehow. Another strategy would be to have tools that the users can use to generate system packages from cabal packages and then install those via the system package manager. We already have such tools for rpm and gentoo ebuilds. Again, these would be for the case of less significant package that the distro does not package itself. For example, gentoo has a tool that can be used to install perl CPAN packages via the system package manager, since there are many 1000's of CPAN packages and only a few hundred of those are included in the main portage collection. There are other cases not covered by system package managers, like unprivileged user installations under $HOME. > > The problem with generating one of those is what manages it? What > > package would it belong to etc. > > Of course we are not the first project to face this kind of problem: Texinfo > offers a central contents page as well. To maintain this page, it comes with [..] > A "install-haddock" tool would be the solution IMHO. That re-generates the index page, right. Perhaps haddock itself should be extended with this ability. All it should need to do is read all the .haddock files that ghc-pkg knows about and generate the index page from that. I assume the .haddock files contain enough information to do this, or it could be modified to include enough. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: wanted: HAppS example combining state and io
Thomas Hartman db.com> writes: > > > In the latest happs (darcs pulled, updated > head is 0.9.1 iirc), I am experimenting with the example file in src/HAppS/Examples/HTTP1.hs. > I would like to combine state with io. > Eventually io will mean stuff like reading from a database, but for now > I'm just reading a file. > The example file HTTP1.hs has an example > that demonstrates state with macid. > I added an example that allows you to > execute arbitrary io. > I tried, but was unable to, add a handler > that combines state and io. > >, h ["iohandler"]GET $ ioReadFileHandler > >, h ["statehandler"] GET $ stateHandler > >--, h ["ioandstatehandler"] GET $ ioAndStateHandler > . > -- displays contents of HAPPS.hs in > current directory > ioReadFileHandler = iohandler $ readFile > "./HAppS.hs" > -- displays incremented state counter > stateHandler = ok $ \() () -> > > modify (+(1::Int)) >> get >>= > respond . show > -- should combine effect of iohandler > with statehandler > -- specifically, should display contents > of HAppS.hs, and under that an incremented state handler > -- is this possible > ioAndStateHandler = undefined undefined > Is mixing state and io possible with > HAppS? If so, an example showing how to do it would be extremely helpful. > best, thomas. > ---This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. > > Attachment (https1-whatsnew): application/octet-stream, 1933 bytes > Attachment (HTTP1.hs): application/octet-stream, 4794 bytes > > ___ > Haskell-Cafe mailing list > Haskell-Cafe haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I had no trouble getting this handler to work: h ["iohandler"] GET $ \() () -> do modify (+1) x <- get respond $ do cnts <- readFile "./sometext.txt" sresult 200 (cnts ++ show x) I believe the trick is that you cant mix io INTO the HAppS ServerPart monad. But from the ServerPart monad you can RETURN an io action. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: HApps API Documentation?
James Britt neurogami.com> writes: > > Are there alternative sites for HAppS API docs? > > There are two links on http://happs.org/#documentation but both give > "File not found!" messages. > > Thanks, > > James > Just compile your one version from the HAppS source. Use runghc Setup.hs haddock. You do have have haddock installed, havent you? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] let and fixed point operator
Hi! > I did once try to learn Prolog. And failed. Miserably. You should backtrack at this point and try again differently. :-) Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: RE: Definition of the Haskell standard library
Sven Panne wrote: > On Tuesday 31 July 2007 19:39, Duncan Coutts wrote: >> [...] >> The docs for those packages would be available for packages installed >> via cabal (assuming the user did the optional haddock step) and would >> link to each other. > > Well, on a normal Linux distro a user should *never* have to call cabal (or > any of its cousins) directly, the distro's package manager should be the used > instead. This is very theoretical. I use debian (stable) and have to install non-deb Haskell libraries all the time. No way distro package maintainers can provide packages for each and every library out there, and even for 'standard' libs (whatever that may mean) sometimes you need a newer or an older version of a certain library (relative to what the distro offers). >> On some systems (windows, gnome) there are dedicated help viewers that >> can help with this contents/index issue. haddock supports both (mshelp, >> devhelp). I'm not sure everyone would find that a sufficient solution >> however. > > A "install-haddock" tool would be the solution IMHO. Yes. Cheers Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Learn Prolog...
Yes, I know, this is Haskell list. So, I apologize, but not too much... Johan Grönqvist cites me: Anyway, I believe strongly that ALL people who have problems... should be encouraged to learn Prolog. IN DEPTH, Do you have a recommendation on how to do this? (e.g., books, web-pages, (available) lecture notes, problem sets) First, install a decent Prolog on your machine. There are plenty: http://kti.mff.cuni.cz/~bartak/prolog/implementations.html http://www.cs.cmu.edu/Groups/AI/html/faqs/lang/prolog/prg/part2/faq-doc-2.ht ml You may wish to install the free version of Visual Prolog. My favourite is the SWI Prolog: http://www.swi-prolog.org/ (University of Amsterdam) The documentation is complete, and the reference manual contains references to such standard books as ClocksinMellish, or Sterling&Shapiro. The last one is very, very instructive. Also, Prolog Programming for Artificial Intelligence, written by Bratko, is very useful. There are on the web collection of examples from this book, don't remember where. Try here: http://promethee.philo.ulg.ac.be/engdep1/download/prolog/bratko/ On-line there are thousands of examples, tutorials, etc. J. Fisher: (There is an example of cut, especially for A. Coppin) http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/contents.html others: http://www.coli.uni-saarland.de/~kris/learn-prolog-now/lpnpage.php?pageid=on line http://computing.unn.ac.uk/staff/cgpb4/prologbook/book.html http://www.cs.nuim.ie/~jpower/Courses/PROLOG/ Etc., etc. Really! Examples. For example: http://www.csse.monash.edu.au/~lloyd/tildeLogic/Prolog.toy/Examples/ http://kti.mff.cuni.cz/~bartak/prolog/learning.html http://www.visual-prolog.com/vip/example/ and of course there are discussion lists, FAQs, etc. Ask Google... === Andrew Coppin writes: I did once try to learn Prolog. And failed. Miserably. I just couldn't bend my head around how the Prolog interpreter manages to > make seemingly "impossible" leaps of deduction. (It's a *machine*! How can > it deduce arbitrarily complex conclusions from any arbitrary set of axioms? That requires *intelligence*!) And yet, in other, seemingly identical cases, it utterly fails to deduce patently *obvious* results... really weird! One of standard exercices in Prolog is the construction of the meta-interpreter of Prolog in Prolog. While this is cheating, I recommend it to you. It opens eyes. Actually, there are three basic items to learn while trying to master Prolog after having dealt with the syntactic essentials term construction, and the like. 1. The unification, which shows the "ultimate" instance of pattern-matching and is useful for recognizing some techniques for the automatic inference of types in functional languages. 2. The usage of unbound "logical variable", which sometimes permits to to do things which require laziness in Haskell. 3. The control backtracking, which is at the heart of the logical non-de- terminism. Now, the non-deterministic algorithms in Haskell are usually implemented using the *data backtracking*, or the List Monad. The control backtrack, via, say success/failure continuations, is more difficult, they are rarely taught, and problematic because of strong typing. Prolog strategies are straightforward, and I simply cannot understand the comments of Andrew Coppin. Which arbitrary set of conclusions?? Which patently obvious results not derivable?? Be kind, give some examples, otherwise people may suspect that you are issuing vacuous statements... The best. Jerzy Karczmarczuk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HApps API Documentation?
On 9/1/07, James Britt <[EMAIL PROTECTED]> wrote: > Are there alternative sites for HAppS API docs? I'm currently using the one from the tarball (runghc Setup.hs haddock). -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HApps API Documentation?
Are there alternative sites for HAppS API docs? There are two links on http://happs.org/#documentation but both give "File not found!" messages. Thanks, James ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Definition of the Haskell standard library
As a enthusiast Perl user over the years, I note that the CPAN and the associated toolkit (the CPAN module, its shell, ExtUtils::MakeMaker and Module::Build) is pretty good at this. It has it's share of cruft (in fact a whole lot of it) but it's certainly better than most solutions in this field in my eye. Perl already has it's own centralised documentation on the CPAN and local copies are installed and accessible through the command line tool perldoc and miscellanous other modules that allows a more pleasant esthetic experience (Pod::POM::Web is pretty good at this, it even comes with it's own little http server and allow you to search your local doc in many way). It might be worth keeping an eye on the development of the CP6AN if it ever comes to life (I'm a firm Perl6 believer but some don't share this belief, with some justifications I fear)... Cabal is an interesting experiment but it just don't compare for now. -- Jedaï ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Definition of the Haskell standard library
On Tuesday 31 July 2007 19:39, Duncan Coutts wrote: > [...] > The docs for those packages would be available for packages installed > via cabal (assuming the user did the optional haddock step) and would > link to each other. Well, on a normal Linux distro a user should *never* have to call cabal (or any of its cousins) directly, the distro's package manager should be the used instead. On an e.g. RPM system, the .spec file would use Cabal to e.g. (un-)register a package, because RPM has to know what is installed, which other packages are prerequisites, how to cleanly uninstall, etc. IMHO Cabal should not try to mirror a full-fledged package system, simply because on every (non-Windows ;-) platform there are tons of native tools for this purpose, and Cabal is not "in the driver's seat" when it comes to SW installation. > What is missing from the local docs is a single integrated index page > that lists all the modules and then links off to the various packages's > docs like we have on the ghc website. > > The problem with generating one of those is what manages it? What > package would it belong to etc. Of course we are not the first project to face this kind of problem: Texinfo offers a central contents page as well. To maintain this page, it comes with a tool "install-info", which updates the index page after (de-)installation. On RPM systems, the .spec file calls install-info after (de-)installation of a package with info pages. http://www.gnu.org/software/texinfo/manual/texinfo/html_node/Installing-an-Info-File.html > On some systems (windows, gnome) there are dedicated help viewers that > can help with this contents/index issue. haddock supports both (mshelp, > devhelp). I'm not sure everyone would find that a sufficient solution > however. A "install-haddock" tool would be the solution IMHO. Cheers, S. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] defining mapPairs function
On 9/1/07, Alexteslin <[EMAIL PROTECTED]> wrote: > > > Hi, > > It is the former, but I sat an exam and trying to discuss my exam answers > which will make no difference to what so ever to an exam, as an exam > duration was 1.5 hours. Which means that no matter how much i would like > to > try to amend my answers, it is too late. I merely trying to figure out if > i > answered my questions right. OK, my apologies! From the way you phrased it, it sounded to me like it was some sort of take-home exam you were working on. In retrospect I guess that was sort of unlikely, but stranger things have happened. =) -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] defining mapPairs function
On Sat, Sep 01, 2007 at 04:59:50AM -0700, Alexteslin wrote: > It is the former, but I sat an exam and trying to discuss my exam answers > which will make no difference to what so ever to an exam, as an exam > duration was 1.5 hours. Which means that no matter how much i would like to > try to amend my answers, it is too late. I merely trying to figure out if i > answered my questions right. I can confirm that this is innocent checking after the fact. This is question 2(e) on my resit paper, but the first posting was half an hour after the end of the exam. The answer you posted is correct, though those suggested by Neil and Max would be neater. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] defining mapPairs function
Brent Yorgey wrote: > > On 8/29/07, Alexteslin <[EMAIL PROTECTED]> wrote: >> >> >> Hello, >> >> I just came across with this question on the exam and can not think of >> implementing it. > > > Wait, is this an exam for a class you're taking? Or just a problem from > an > exam that you're trying to solve for fun? If the former, it really isn't > appropriate to ask the list to solve the problem for you, or even for > hints. Your work on the exam should be your own. > > -Brent > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > Hi, It is the former, but I sat an exam and trying to discuss my exam answers which will make no difference to what so ever to an exam, as an exam duration was 1.5 hours. Which means that no matter how much i would like to try to amend my answers, it is too late. I merely trying to figure out if i answered my questions right. -- View this message in context: http://www.nabble.com/defining-mapPairs-function-tf4350356.html#a12439704 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Data.Unique not "safe" in concurrent environments (or brain burned)?
Let me answer this myself - brain burnt... Of course it is OK, that is precisely the semantics of MVars - the are empty or full, thus assuring the mutual exclusion between threads. Been a hard week. Neil ... so the deeper question - why don't you realise these mistakes till five minutes *after* you've pressed the send button Neil Davies wrote: > Hi, I was looking over the libraries for bits of GHC (no doubt a standard > form of > relaxation for readers of this list), and noticed the following statement > (in Data.Unique): > > -- | Creates a new object of type 'Unique'. The value returned will > -- not compare equal to any other value of type 'Unique' returned by > -- previous calls to 'newUnique'. > > This set me thinking - so I looked at the code > > newUnique :: IO Unique > newUnique = do >val <- takeMVar uniqSource >let next = val+1 >putMVar uniqSource next >return (Unique next) > > In the concurrent execution world in which we live - I don't think that the > implementation > supports the "uniqueness" statement above - or am I not understanding > something? > > Cheers > > Neil > > > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Data.Unique not "safe" in concurrent environments (or brain burned)?
Hi, I was looking over the libraries for bits of GHC (no doubt a standard form of relaxation for readers of this list), and noticed the following statement (in Data.Unique): -- | Creates a new object of type 'Unique'. The value returned will -- not compare equal to any other value of type 'Unique' returned by -- previous calls to 'newUnique'. This set me thinking - so I looked at the code newUnique :: IO Unique newUnique = do val <- takeMVar uniqSource let next = val+1 putMVar uniqSource next return (Unique next) In the concurrent execution world in which we live - I don't think that the implementation supports the "uniqueness" statement above - or am I not understanding something? Cheers Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe