RE: eval_thunk_selector: strange selectee 29
I can confirm that this happens on my solaris machine as well. Moreover it crashes my computer! I have seen the same crash when working with the ffi on solaris but haven't been able to reproduce it. What happens is this: In the window I'm running ghci/my ffi application gets filled with prompts. I'm guessing something has started forking like crazy. Anyway this eats up all the computer resources and all I can do is restart the computer. It would be Very Nice if you could fix the crashing bug as this sometimes crashes programs running for example wxHaskell. I get very uneasy as soon as I start to program with the ffi. We've fixed the strange selectee 29 bug, but I doubt that could be the cause of your infinite forking behaviour. If you manage to get a repeatable example, we can look into it. To prevent it crashing your machine, you should set a limit on the number of processes creatable by each user. To do it locally for yourself, use the 'ulimit' shell command. Most OSs have a way to set this globally or on a user-by-user basis too (can't remember exactly how Solaris does it, sorry). Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: type class problem / GHC bug
A bug thank you; now fixed. Please send bug reports about GHC to [EMAIL PROTECTED], not to the Haskell mailing list. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brandon | Michael Moore | Sent: 08 November 2003 13:20 | To: [EMAIL PROTECTED] | Subject: type class problem / GHC bug | | Hi everyone | | I've built GHC from CVS and I'm getting some odd errors about overlapping | instances. This is different from 6.0.1, but it's not obvious it is wrong, | so I'm probably missing something here. | | The example is | | class A x | class (A x) = B x | instance A x | instance B x | | The new GHC complains that the second instance overlapps with the first. | Maybe because of the context on B x the instance for B x is interpreted as | a claim we have A x too, but shouldn't it be the other way, that you need | an instance A x from somewhere along with an instance for B x? | | Thanks | | Brandon | | ___ | Haskell mailing list | [EMAIL PROTECTED] | http://www.haskell.org/mailman/listinfo/haskell ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Incompatibilities between RPM .tar.gz versions of ghc-6.0.1
It seems as if the RPM and .tar.gz versions of ghc-6.0.1 are binary incompatible. That is, a library built for one will not necessarily work on the other. For example, libHSbase.a defines the symbol GHCziRead_lvl18_closure in the .tar.gz version, which can be externally called; however in the RPM version it is not defined. Many thanks for Walter Guttmann for discovering this. I hope he won't mind if I quote from his original message: No, I have another version of that file, also from a binary release, which explains the problem. The download homepage of ghc 6.0.1 http://www.haskell.org/ghc/download_ghc_601.html offers several binaries, even for x86/Linux. I found out that your libHSbase.a comes from Binary tar for Linux/x86 with glibc 2.2 and mine comes from base RPM (even though I do not use RedHat Linux). Note that the RPM's name is ghc-6.0.1-1.i386.rpm where the -1 might indicate something. The creation date of your libHSbase.a is 2003-07-29 and that of mine is 2003-07-30. I don't know if there have been some changes between the two builds, if they just forgot to update the other build or if the differences necessarily arise for the two builds (which would be very sad). Anyway, I installed the other build and was able to compile, link and run MainhsMines.hs. So I'm happy now, but you might want to contact the ghc-builders and ask them about the difference. ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: Incompatibilities between RPM .tar.gz versions of ghc-6.0.1
It seems as if the RPM and .tar.gz versions of ghc-6.0.1 are binary incompatible. That is, a library built for one will not necessarily work on the other. For example, libHSbase.a defines the symbol GHCziRead_lvl18_closure in the .tar.gz version, which can be externally called; however in the RPM version it is not defined. Yes, this is entirely possible. I'm not sure of the exactly list of things which must be identical in order to get two binary-compatible builds, but I suspect that having exactly the same OS / platform is a good start (the RPM and binary tars were built on different versions of RedHat Linux). Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
RE: Strange panic when examining interface files
The answer, once it stuck me, seemed quite obvious: use --show-iface and the compiler will either show me the interface (I used the compiler with right version) or will complain and say that it expected number this and that but found the number I was looking for. Sadly, when doing this with both ghc v6.0 and v6.0.1 I got the following: ghc-6.0: panic! (the `impossible' happened, GHC version 6.0): Ix{Int}.index: Index (16777216) out of range ((0,36)) Thanks, this will be fixed in 6.2. Cheers, Simon ___ Glasgow-haskell-bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
Re: DiffArray Performance
Glynn Clements [EMAIL PROTECTED] writes: Stefan Reich wrote: I'd like to ask a general question about unsafePerformIO: What exactly does unsafe mean? Just impure or rather may lead to all kinds of problems, you better don't use this? Essentially both. Haskell assumes purity (referential transparency), so impurity is likely to result in all kinds of problems. Here's a thing that can easily happen: my_trace = unsafePerformIO . putStrLn f x = trace f called `seq` Now, when f is evaluated, it will print the message. However, when f is re-evaluated (normally with a different x), no message is printed! Why? Because the system will optimize by realizing that 'trace' is called with the same argument, and it will just keep the old value (). This behaviour depends on the level of optimization in your compiler/interpreter, feel free to experiment! The fix is of course to do my_trace (f called with arg ++show x) `seq` ... which will usually do what you expect. Moral: unsafe means you can use it, but it doesn't give you any complaining rights when it doesn't do what you think it should do. (Sometimes in my darker moments, I feel we might bite the bullet, and call the whole thing unsafeHaskell, and be done with it :-) -kzm PS: trace is defined in the libraries, not sure if it behaves more reasonable in this respect. -- If I haven't seen further, it is by standing in the footprints of giants ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[ ghc-Feature Requests-837563 ] GHCi (Mac OS X) file names
Feature Requests item #837563, was opened at 2003-11-06 16:47 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=358032aid=837563group_id=8032 Category: None Group: None Status: Open Priority: 5 Submitted By: Hamilton Richards (hamrichards) Assigned to: Nobody/Anonymous (nobody) Summary: GHCi (Mac OS X) file names Initial Comment: It would be nice if, in file names, \ were handled as . This would make the GHCi interface consistent with those of Terminal and Hugs. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detailatid=358032aid=837563group_id=8032 ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
RE: command line option --show-iface
Good idea -- done. Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:glasgow-haskell-users- | [EMAIL PROTECTED] On Behalf Of Steffen Mazanek | Sent: 27 October 2003 21:27 | To: [EMAIL PROTECTED] | Subject: command line option --show-iface | | Hello, | | the following error is slightly confusing: | | ghc --show-iface | ghc-6.0.1: unrecognised flag: --show-iface | Usage: For basic information, try the `--help' option. | | ghc --show-iface Unify.hi | __interface Main Unify 1 where | __export Unify Unifiable{mgu} match mguType varBind; | ... | | A hint in the right direction would be more | convenient :-) | | Maybe in /ghc/compiler/main/DriverUtil.hs a function | | unknownFlagErrUsage :: String-String - a | unknownFlagErrUsage f specusage = throwDyn | (UsageError (unrecognised flag: ++ f ++ \n ++ |hint: ++ specusage)) | | and changing processOneArg from DriverFlags.hs | |HasArg fio - | if rest /= | then fio rest return args | else case args of | [] - unknownFlagErrUsage dash_arg argument for flag expected | (arg1:args1) - fio arg1 return args1 | | Would this be ok? | | Regards, | Steffen | ___ | Glasgow-haskell-users mailing list | [EMAIL PROTECTED] | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: time since the epoch
On Fri, 7 Nov 2003 19:55:47 +0100 Stefan Karrmann [EMAIL PROTECTED] wrote: I've inserted 'convert = (uncurry cFromTai) . cToTai'. Great, thanks. A fixed and checked version is appended and carbon copied to [EMAIL PROTECTED]. What's haskell-libs-developers? I thought libraries' development was carried over on [EMAIL PROTECTED] (And shouldn't we be discussing Tai.lhs there, BTW :) I'm attaching a patch (diff -u2) with a few small changes: - 1%seconds_per_day - 1 % seconds_per_day (otherwise GHC complains in -fglasgow-exts mode because it misinterprets it as an implicit parameter). - I've put a few _ here and there to silence warnings for unused arguments. - I've renamed a few variables because of shadows an existing binding warnings. - I've deleted a few internal definitions apparently not used (according to -Wall), like cumulated_month_length_after_february. - I've corrected a few typos. More coments: - I'm sending you the patch throw the Haskell list because previous attempts of sending to your e-mail address failed. - Are you very fond of the literate style? I ask because unlit'ing it would allow adding Haddock coments, which would be nice. - I'm not sure I like depending on a leapseconds table hardcoded in the source, even if it changes slowly. Wouldn't it be better to have the data in a file and load it through unsafePerformIO? (And isn't loading configuration data one of the few good examples of use of unsafePerformIO, after all? :) - I get a warning with -Wall: Warning: Defined but not used: TimeDiff, days_from_MJD2unixEpoch, days_from_unixEpoch2MJD', hours_per_day, isodelta, isomoveDHM, isomoveS, isomoveYM, libtaiEpoch, month_per_year, test, test2 Several of these are neither used nor exported. ??? Thanks, Juanma Tai.lhs.diff.bz2 Description: Binary data ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Preliminary CFP: GPCE'04 -- Generative Programming and Component Engineering
PRELIMINARY CALL FOR PAPERS -- Third International Conference on Generative Programming and Component Engineering (GPCE'04) Vancouver, October 24-28, 2004 co-located with OOPSLA 2004 http://gpce04.gpce.org -- Scope Generative and component approaches have the potential to revolutionize software development in a similar way as automation and components revolutionized manufacturing. Generative Programming (developing programs that synthesize other programs), Component Engineering (raising the level of modularization and analysis in application design), and Domain-Specific Languages (elevating program specifications to compact domain-specific notations that are easier to write and maintain) are key technologies for automating program development. GPCE arose as a joint conference, merging the prior conference on Generative and Component-Based Software Engineering (GCSE) and the Workshop on Semantics, Applications, and Implementation of Program Generation (SAIG). The goal of GPCE is to provide a meeting place for researchers and practitioners interested in cutting edge approaches to software development. We aim to foster further cross-fertilization between the software engineering research community on the one hand, and the programming languages community on the other, in addition to supporting the original research goals of both the GCSE and the SAIG communities. We seek papers both in software engineering and in programming languages, and especially those that bridge the gap and are accessible to both communities at the same time. Topics of Interest The conference solicits submissions related (but not limited) to: * Generative programming o Reuse, meta-programming, partial evaluation, multi-stage and multi-level languages, step-wise refinement o Semantics, type systems, symbolic computation, linking and explicit substitution, in-lining and macros, templates, program transformation o Runtime code generation, compilation, active libraries, synthesis from specifications, development methods, generation of non-code artifacts, formal methods, reflection * Generative techniques for o Product lines and architectures o Embedded systems o Model-driven architecture * Component-based software engineering o Reuse, distributed platforms, distributed systems, evolution, analysis and design patterns, development methods, formal methods * Integration of generative and component-based approaches * Domain engineering and domain analysis o Domain-specific languages (DSLs) including visual and UML-based DSLs * Separation of concerns o Aspect-oriented programming, feature-oriented programming, o Intentional programming, and multi-dimensional separation of concerns * Industrial applications Reports on applications of these techniques to real-world problems are especially encouraged, as are submissions that relate ideas and concepts from several of these topics, or bridge the gap between theory and practice. The program committee is happy to advise on the appropriateness of a particular subject. Important Dates * Pre-submission: March 12, 2004 (title + abstract) * Submission: March 19, 2004 * Conference: 24-28 October 2004 Organization General chair * Tim Sheard (OGI School of Science Engineering at OHSU) Program committee chairs * Gabor Karsai (Vanderbilt University) * Eelco Visser (Utrecht University) Program committee * Uwe Assmann (Linkopings Universitet) * Don Batory (University of Texas) * Jan Bosch (Universiteit Groningen) * Jean Bezivin (Université de Nantes) * Jim Cordy (Queen's University) * Krzysztof Czarnecki (University of Waterloo) * Mathew Flatt (University of Utah) * Robert Glueck (University of Copenhagen) * George Heineman (Worcester Polytechnic Institute) * Michael Leuschel (University of Southampton) * Karl Lieberherr (Northeastern University) * Simon Peyton Jones (Microsoft Research) * Douglas R. Smith (Kestrel Institute) * Gabriele Taentzer (Technical University of Berlin) * Todd Veldhuizen (Indiana University) * Kris de Volder (University of Britisch Columbia) * Dave Wile (Teknowledge Corp.) * Alexander Wolf (University of Colorado at Boulder) Contact * [EMAIL PROTECTED]
Inspecting reduced/optimized code
Is it possible/easy in any of the compilers/interpreters to see what the results of rewriting/optimisations are? (I'm sure it is *possible*, I'm really asking if any produce simple output in a well documented format that I'm likely to understand). The reason I ask is because I'm curious whether the well known fold (foldr) (I don't have it to hand, but it's something like fold (\x g - \n - g x n) id) that is equivalent to foldl generates the same code as foldl itself (ie defined recursively). I know I can do timing, or look at the C code from GHC, which would tell me whether they are identical, I guess, but I was hoping for something higher level (I suupose transformed Haskell code is too much to ask for?). Should I be looking at some kind of debugging tool (never used a debugger in Haskell)? Thanks, Andrew PS Despite its sweet naivete, this post comes from a balding middle aged programmer looking for something to relieve the tedium of working shifts away from home, and not some grasping, lazy, evil student that wants to save time on homework to indulge in yet more wild, drunken orgies [sighs wistfully, looks at clock, gets back to work...]. -- http://www.acooke.org/andrew ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: Inspecting reduced/optimized code
Is it possible/easy in any of the compilers/interpreters to see what the results of rewriting/optimisations are? (I'm sure it is *possible*, I'm really asking if any produce simple output in a well documented format that I'm likely to understand). Very easy in GHC. GHC does its optimisations on code in a functional language called Core, which is a cut-down version of Haskell with explicit typing. It's quite readable (apart from the weird automatically-chosen variable names), and you can get it to dump it at various stages. Take a look at http://www.haskell.org/ghc/docs/latest/html/users_guide/options-debugging.html for info. You might find the following link useful for understanding what the various passes are: http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/ HTH. --KW 8-) ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
CfP: ESSLLI'04 Student Session
CALL FOR PAPERS ESSLLI-2004 STUDENT SESSION 9-20 August, 2004 in Nancy, France Deadline: February 22, 2004 http://esslli2004.loria.fr/ We are pleased to announce the Student Session of the 16th EuropeanSummer School in Logic, Language and Information (ESSLLI-2004),which will be held in Nancy from August 9-20, 2004. We invite submission of papers for presentation at the ESSLLI-2004 Student Session and for appearance in the proceedings. PURPOSE: This ninth ESSLLI Student Session will provide, like the previouseditions, an opportunity for ESSLLI participants who are students topresent their own work in progress and get feedback from seniorresearchers and fellow-students. The ESSLLI Student Sessionencourages submissions from students at any level, undergraduates(before completion of the Master Thesis) as well as postgraduates(before completion of the PhD degree). Papers co-authored bynon-students will not be accepted. Papers may be accepted for fullpresentation (30 minutes including 5 to 10 minutes of discussion) or for a poster presentation. All the accepted papers will be published in the ESSLLI-2004 Student Session proceedings, which will be made available during the summer school. REQUIREMENTS: The Student Session papers should describe original, unpublished work, completed or in progress, that demonstrates insight, creativity, and promise. No previously published papers should be submitted. We welcome submissions with topics within the areas of Logic, Language and Computation. SUBMISSION DETAILS: Student authors are invited to submit a full paper, not to exceed 7 pages of length exclusive of references. Note that the length of the final version of the accepted papers will not be allowed to exceed 10 pages. The submissions will be reviewed by the student session programme committeeand additional reviewers. A plain ASCII text version of the identification pageshould be sent separately, using the following format: Title: title of the submission First author: firstname lastname Address: address of the first author .. Last author: firstname lastname Address: address of the last author Short summary: abstract (5 lines) Subject area (one or two of): Logic | Language | Computation In case the paper is being submitted to another conference or workshop, this must be clearly indicated on the identification page. The preferred formats of submissions are PostScript, PDF, or plain text,although other formats will also be accepted. In case of acceptance, the final version of the paperwill have to be submitted in LaTeX format. The papers must use single column A4 size pages,11pt or 12pt fonts, and standard margins. Submissions not in accordance with the specified formattingand length requirements may be subject to rejection without review. The paper and separate identification page must be sent electronically to: [EMAIL PROTECTED] by FEBRUARY 22, 2004. PROGRAMME COMMITTEE: Laura Alonso i Alemany (Universitat de Barcelona, Barcelona)Carlos Areces (LORIA, Nancy)Jaume Baixeries (Universitat Politècnica de Catalunya, Barcelona)Willem Comradie (Rand Afrikaans University, South Africa)Benoit Crabbé (LORIA, Nancy)Paul Egré (IHPST, Université Paris 1, IJN)Judit Gervain (SISSA, Trieste)Bart Geurts (University of Nijmegen, Nijmegen)Ivana Kruijff-Korbayova (Universität des Saarlandes, Saarbrücken)Marco Kuhlmann (Universität des Saarlandes, Saarbrücken)Mª Magdalena Ortiz de la Fuente (Universidad de las Americas, Puebla)Benjamin Spector (Laboratoire de Linguistique Formelle, Université Paris 7, ENS) IMPORTANT DATES: Deadline for submission of papers: February 22, 2004.Authors notifications : April 19, 2004.ESSLLI early registration: May 1, 2004.Final papers for proceedings: May 15, 2004.ESSLLI-2004 Student Session: August 9-20, 2004. ESSLLI-2004 INFORMATION: In order to present a paper at ESSLLI-2004 Student Session, at least one student author of each accepted paper has to register as a participant at ESSLLI-2004. The authors of accepted papers will be eligible for reduced registration fees even after the deadline forearly registration. For all information concerning ESSLLI-2004, please consult the ESSLLI-2004 main website at http://esslli2004.loria.fr/ For more information about the ESSLLI'04 student session, consultthe ESSLLI'04 student session website at:http://lingua.fil.ub.es/~lalonso/stusESSLLI04/. If you have any further question about the student session, do not hesitate to contact us: Laura Alonso i Alemany Paul Egré[EMAIL PROTECTED] [EMAIL PROTECTED]Departament de Lingüística GeneralIHPST / Université Paris 1 / Institut Jean-Nicod Gran Via de les Corts Catalanes, 585Institut d'Histoire et de Philosophie des Sciences et Techniques Universitat de Barcelona 13, rue du FourBarcelona, SPAIN 75006 Paris, FRANCE telephone number: +34 93 403 56 93 telephone number: + (33) (0)1 43
Re: haskell httpd
Thank you for the discussion, but let me ask some more questions: Simple questions: 1. Is there ssl support for the haskell httpd somewhere? 2. Does this httpd actually build w/ modern GHC? 3. Why doesn't haskell.org run this httpd? More complex question: Assumptions: * This httpd can do 1000 req./sec. on modern CPUs (enough for me) * I write-ahead log all PUT/POST/DELETE requests before executing * I can reproduce server state at a given time by replaying the log * I checkpoint periodically so I don't have to replay the whole log * I treat each HTTP PUT/POST/DELETE as a discrete state transition Question: Can I make sure that I have concurrency only w/r/t client communication? I don't want the thread of control to change during state transitions. What happens if state is too big to fit in memory? * Does forkIO switch control if a thread writes to the disk but write-caching is enabled or if the thread access some part of memory that is swapped to disk? Optimization question: If I am using RAID, can I allow control to switch if I am handling multiple GET requests but lock for PUT/POST/DELETE requests? Notes: * Write-caching means the app is not slowed by disk writes * Write-ahead logs mean not worrying about crashes during writes * If necessary, I can scale up GET performance using caching and multiple CPUs each doing log recovery. -Alex- ___ S. Alexander Jacobson Check out my new blog!!! 1-212-787-1914 voice http://alexjacobson.com ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
neat trick: parallel show
while working on a random project, I had opprotunity to write a 'parallel show' which concurrently evaluates everything needed to show a structure and lets you print succesivly refined versions as vaules are calculated and filled in. it is nice because a value that takes a long time (or perhaps forever) to evaluate at the front of your structure doesn't keep you from seeing what else is in it. I must say it has been a very useful little bit of code so thought I might share the concept and was curious if anyone else does things like this.. it works something like foo = [Right foo, Left undefined, undefined, Right here] parShow (parPretty foo) = putStrLn = (Right foo) (Left _|_) _|_ (Right here) and succesive calls to parShow will fill in the _|_ values as they get evaluated. my attached implementation is rather weak (my real one is tied into a project and does wierd things with ANSI escape codes to redraw the screen as things get evaluated and handles exceptions differently) but the gist is the same. would people be interesting in me( or someone else :) ) turning this into a full fledged library? does one alreoady exist which does this? I was thinking integrating it into a real pretty printing system would be handy but might be too much work, if there were a way to reuse an existing pretty printing library without change and somehow add this capability then that would be cool. I couldn't think of a way to do it since the final 'render' routine obviously needs to be in the IO monad so the MVars can be checked again when rerendering.. John -- --- John Meacham - California Institute of Technology, Alum. - [EMAIL PROTECTED] --- module Main(main) where import Control.Concurrent import Maybe import Monad import System.IO.Unsafe import Control.Exception infixr 5 / infixr 6 ,+ data Doc = DocStr !String | DocPost !Doc !(MVar Doc) | DocCat !Doc !Doc text s = DocStr s a b = DocCat a b a + b = a textb a / b = a text \n b post els d = DocPost els $! unsafePerformIO $ do mv - newEmptyMVar forkIO $ do handle (\_ - return ()) $ evaluate d = putMVar mv return mv postb d = post (text _|_) d parShow :: Doc - IO String parShow (DocStr s) = return s parShow (DocCat a b) = do na - parShow a nb - parShow b return (na ++ nb) parShow (DocPost els mv) = do md - tryTakeMVar mv parShow (fromMaybe els md) parShowAll :: Doc - String parShowAll (DocStr s) = s parShowAll (DocCat a b) = parShowAll a ++ parShowAll b parShowAll (DocPost _ mv) = parShowAll (unsafePerformIO $ readMVar mv ) foo = [Right foo, Left undefined, undefined, Right here] foo2 = undefined parPretty xs = postb (foldl (+) (text ) $ map (postb . parPrettyE) xs) parPrettyE (Left l) = text (Left + postb (text l) text ) parPrettyE (Right r) = text (Right + postb (text r) text ) main = do let foo_p = parPretty foo let foo2_p = parPretty foo2 putStrLn parShow foo_p parShow foo_p = putStrLn putStrLn parShow foo2_p parShow foo2_p = putStrLn putStrLn parShow foo_p parShow foo_p = putStrLn --putStrLn parShowAll foo --putStrLn $ parShowAll foo_p ___ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell
Re: determining if a int is a power
[EMAIL PROTECTED] writes: I'm new to haskell and have to do some excersises. Okay. Thank you for being up-front about it. You got some advice, so I'll just add that So i have been trying using any with a helper function Yep, this is a good way to do it. You may want to consider filter or map as well, depending on what you want for result. -kzm -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Beta Reduction, undefined vs Type Classes
class Thing t where thing :: t [..] Can someone please explain why fst (1,thing) ...gets an 'ambiguous type variable' error, but fst (1,undefined) ...doesn't? And is there anything I can change to make the former work as well? Even modifying fst doesn't work: This kind of thing is a bit of a trap for young players. You'll get errors when entering things into the interactive toplevel (hugs/ghci), but if you put it in a program you will almost certainly not get the errors, because more information will be available to the compiler from a full program than from a toy example. The problem is that the member function thing doesn't take anything of type t by which the compiler might infer which instance it is. You can see this even more easily by typing [] into ghci. To fix it, give it a type annotation: fst (1,thing::Thing Int) ([]::[Double]) for example. The reason you don't get the error for fst (1,undefined) is because undefined has the perfectly good type (forall a. a), and so (1,undefined) has type (forall a. (Integer,a)) and fst (1,undefined) has type Integer. Polymorphism (like the type of undefined) is much better behaved than overloading (like the types of thing). It's actually more complicated than this, though - 1 actually has type Num a = a, but Haskell has a built-in defaulting rule which says that anything of this type should default to Integer or Double, in that order. So you don't get ambiguity errors for simple numbers. This makes life simpler when using Haskell as a calculator. HTH. --KW 8-) -- Keith Wansbrough [EMAIL PROTECTED] http://www.cl.cam.ac.uk/users/kw217/ University of Cambridge Computer Laboratory. ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Beta Reduction, undefined vs Type Classes
Jared Warren wrote: Consider: class Thing t where thing :: t instance Thing Int where thing = 0 instance Thing Char where thing = 'a' Can someone please explain why fst (1,thing) ...gets an 'ambiguous type variable' error, but fst (1,undefined) ...doesn't? Perhaps because thing has an ambiguous type (it's either Int of Char), but undefined doesn't, (it's for all a.a). Remember that type inference in the Haskell type system does not assume knowledge of the semantics of functions. In order to deduce the type of an application of fst, you need to determine the type of its argument - you can't discard one of ithe tuple components just because you know you will lose it when you apply a projection function. Type checking is done before any evaulation, compile-time or run-time. You might argue that it would be a good idea to apply some program transformations early to avoid this kind of unnecessary ambiguity, but I have doubts about its general usefullness. And is there anything I can change to make the former work as well? Even modifying fst doesn't work: fst' :: Thing b = (a,b) - a fst' (~a,~b) = a You should not expect it to work. The problem is with the type ambiguity, not with the semantics of fst. --brian -- Brian Boutel Wellington New Zealand Note the NOSPAM ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Treating POSIX signals as exceptions?
I was wondering why System.Posix.Signals is as it is, and whether it could be rewritten to use exceptions, which seems like the obvious way to handle signals. Of course, that requires asynchronous exceptions, but that doesn't seem like a severe problem. What I currently do is to use the following function withSig :: Signal - IO a - IO a - IO a withSig s handler job = do id - myThreadId installHandler s (Catch $ throwDynTo id s) Nothing job `catchDyn` catcher where catcher s' | s' == s = handler catcher s' = throwDyn s' which just catches a given signal and throws an exception, and then catches that exception with a given default handler. This has the nice effect that my 'job' can't be rudely interrupted by the user hitting ^C at just the wrong time (since I use this to catch sigINT). Thus, this makes bracket work in the presence of signals, allows me to use block to avoid being interrupted by a ^C when this could cause data corruption, etc. (Yes, I know that the above isn't very clean, since any other process that uses {catch,throw}Dyn on a CInt will mess things up, but creating a new Typeable instance seemed like too much trouble.) Is there any reason all of System.Posix.Signals couldn't be done in this manner? Have the RTS always add a handler for each signal, which just throws an exception. Off the top of my head, all we'd need is one function acceptSignals :: IO () -- tells RTS to send signal exceptions to this -- thread. We'd also need some sort of SignalException type (and of course, to define all the signals), and the rest would be done using the existing Control.Exception code. And, of course, default signal handlers would need to be converted to default exception handlers. Is there a problem with this idea? -- David Roundy http://www.abridgegame.org/darcs ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Value space transformations
I just found myself writing some code like this: processFoo processBar = toFoo . processBar . fromFoo where fromFoo foo = ... toFoo bar = ... and noticed some similarity in style to certain kinds of transformation used in linear algebra, such as for diagonalization: D = T M inv(T) This got me to wondering if this is a common pattern in functional programming. There seems to be some similarity, for example, with the way that Monads are sometimes used, where operations are lifted into (?) a Monad. So my questions are: (a) is there a common functional programming pattern that corresponds to vector space transformations so that a function defined over one space can be used in another, and (b) if so, are there any not-too-heavy papers or articles discussing this pattern? #g Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Is there an easier way to use guards in an expression...
aside This is almost a reprise of a question that came up back in July [1]. At the time, Mark Jones posted a reference [2], but I'm not seeing how it is relevant to this issue of case expressions. [1] http://haskell.org/pipermail/haskell-cafe/2003-July/004708.html [2] ftp://ftp.research.bell-labs.com/dist/smlnj/papers/92-tr-aitken.ps /aside The following code works, but it seems a bit clumsy: [[ mapXsdBoolean = DatatypeMap { -- mapL2V :: String - Maybe Bool mapL2V = \s - case s of s | matchT s - Just True | matchF s - Just False | otherwise - Nothing -- mapV2L :: Bool - Maybe String , mapV2L = Just . (\b - if b then true else false) } ]] The case expression seems rather an unwieldy way of getting guards into an expression. If this was an ordinary variable declaration rather than a field definition, I'd use a function definition with guards, but I can't see how to make that work with a lambda expression. Is there a neater way? And a supplementary question... do the prelude or standard libraries define any function like this: cond :: Bool - a - a - a cond True a _ = a cond False _ b = b #g Graham Klyne For email: http://www.ninebynine.org/#Contact ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Value space transformations
So my questions are: (a) is there a common functional programming pattern that corresponds to vector space transformations so that a function defined over one space can be used in another, and (b) if so, are there any not-too-heavy papers or articles discussing this pattern? Many times when you have a pair of functions: f : S - T g : T - S you find that they form a projection-embedding pair: f . g = id g . f = id where the = ordering typically indicates loss of information. For example, read and show are related this way with the read function losing information about whitespace, comments, etc. Various kinds of lookup tables and set representations (linear lists, arrays, binary trees, etc.) are also related in this way. A useful generalization is an adjunction or galois connection. Section 3 of this paper has a concise definition and, more usefully, helps give you some intuition about them. A reflection on call-by-value, Amr Sabry and Philip Wadler. http://www.research.avayalabs.com/user/ wadler/topics/call-by-need.html#reflection Other people can probably suggest better papers. Hope this helps, -- Alastair Reidwww.haskell-consulting.com ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe