[Haskell-cafe] Simulation and GHC Thread Scheduling
All, I have a simple Haskell P2P library that I've been playing with in simulations of 20 to 600 nodes. To run the simulation there is a Haskell thread (forkIO) for every node in the system, one that starts up all the nodes and prints the info (so prints aren't mangled), and one that acts as the router. Before its mentioned - I understand the best way forward would be to refactor the code into IO-less 'algorithm' sections and other sections that perform the needed IO when I'm not simulating. I know this would allow me to declare what order each node runs in and would free me from the scheduler. I'd like to do that if its practical... but! None-the-less, here I am saying that there are many interesting little simulations that could be done without refactoring and the correctness isn't altered by the order of operations (not if the nodes behave properly, the slight variation is actually a good test). What I would like to know is are there any plans for GHC to incorporate user-definable scheduler? It would be useful in numerous instance beyond this poor example; I know user scheduling was briefly mentioned in Li's paper but haven't seen or heard of any interest from others since then. Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why is Bool no instance of Num and Bits?
[...] unsafe [PerformIO ...] looks safer to me. Hmmm Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Darcs as undo/redo system?
I have thought about applications of patch theory like this as well. I could imagine applying it to the undo stack in GIMP. Allowing you to undo things on different layers. I think one of the things you Don't know about the GIMP, but in Emacs, you can select a region of text and undo just the changes in that region. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Haskell with associated types (and kind annotations)
Hi Dan, I was wondering whether anyone had any suggestions on a good way to generate repetitive code with associated types and kind annotations. I'd like to use TH but as far as I understand, it doesn't support this yet (I think associated types are in HEAD but not kinds), I implemented type families (including associated types) and kinds for TH in the HEAD. If there is anything missing that prevents you from using it, please let me know and I'll have a look at it. Manuel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Darcs as undo/redo system?
Una Merge does real-time merging and has per user undo. And it can do lots of stuff that seems darcs-like, though I don't know enough about darcs to say for sure (e.g. moving a user's own edits after other edits). http://www.n-brain.net/una_merge.html Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net|877-376-2724 x 101 On May 8, 2009, at 1:35 PM, Jeremy Shaw wrote: At Fri, 8 May 2009 17:33:25 +0200, Peter Verswyvelen wrote: [1 multipart/alternative (7bit)] [1.1 text/plain; ISO-8859-1 (7bit)] If you work with a text editor like Microsoft Visual Studio (maybe also Eclipse, don't know), each text editor has its own undo/redo history. However, when you perform refactoring - like renaming a function - this becomes an undo/redo on multiple files together, so in a sense these changes are part of a global history. If you read this paper, you will find an undo system for a colloborative editor complete with a theory that looks like a primitive version of darcs patch theory (complete with the dreaded merge bug of darcs 1): Undoing actions in collaborative work: Framework and experience by Prakash and Knister http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.48.6443rep=rep1type=pdf You will probably find these papers informative as well: Recognizing creative needs in user interface design by Terry and Mynatt http://www.cc.gatech.edu/fce/ecl/projects/openEnded/pubs/creativeInterfaces-creativecog2002.pdf A Selective Undo Mechanism for Graphical User Interfaces Based On Command Objects (1994) by Thomas Berlage http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.31.755 Flexible Conflict Detection and Management In Collaborative Applications (1997) by Keith Edwards http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.5439 Undo Any Operation at Any Time in Group Editors (2000) by Chengzheng Sun http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.32.6266 And, of course, you can use citeseer to find more papers that reference those. - jeremy ___ 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] is value evaluated?
But testing for something being evaluated has to be in the IO monad, or else you're going to break the semantics. On Fri, May 8, 2009 at 4:14 PM, Don Stewart d...@galois.com wrote: Andy Gill has been advocating programmatic access to the 'is evaluated' status bit for years now. 'seq' becomes cheaper, and we can write operational properties/assertions about strictness. -- Don jochem: Nikhil Patil wrote: Hi, I am curious to know if there is a function in Haskell to find if a certain value has already been evaluated. The function I need would have the type: (?!) :: a - Bool I will call this function `evaluated', since it is not a binary operator. The existence of such a function would violate referential transparency. What would the value of ( evaluated (fibs !! 100), evaluated (fibs !! 100) ) be ? Suppose that I first print the `fst' of this tuple, then print the 101st Fibonacci nummber, and then print the `snd' of this tuple. By lazy evaluation, one would expect that this yields False the 101st Fibonacci number True but this violates referential transparency. Cheers, -- Jochem Berndsen | joc...@functor.nl GPG: 0xE6FABFAB ___ 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
Re: [Haskell-cafe] Why is Bool no instance of Num and Bits?
Neil Mitchell wrote: [...] Which is a shame, having Bits on Bool seems entirely logical, having Num a superclass of Bits seems a little less clear. There are two default implementations in Bits bit i = 1 `shiftL` i x `testBit` i = (x .. bit i) /= 0 which rely on Num (and on the fact that 0 ~= 0..0 and 1 ~= 0..01, which doesn't have to be the case in all Num instances?). But is that worth having Num as superclass? When declaring in instance for Bits you have to implement at least 8 functions anyway so these two IMHO don't really make a difference, do they? //Stephan -- Früher hieß es ja: Ich denke, also bin ich. Heute weiß man: Es geht auch so. - Dieter Nuhr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GC
On Fri, May 8, 2009 at 2:37 PM, Andrew Coppin andrewcop...@btinternet.comwrote: John Lask wrote: on the other hand a function to release pool memory to the OS down to the current active level should (I hope) be easily implementable, and quickly incorporated into application where required, whereas arriving at one or more automatic deallocation policies would most likely require some analysis/trial and error. I would suggest that trying to do this automatically in a way that is optimal for all applications requires some fairly serious heuristics. OTOH, for many Haskell programs it isn't a problem in the first place. (E.g., if you write something like Darcs which only ever runs for a few seconds, you barely need GC in the first place.) That's not entirely true. Darcs has a fair number of operations that stream data and hence work well because the RTS can recycle the memory and keep the usage at a constant. I think I see your point and agree in principle though. A similar argument can be applied to laziness. Often times you end up evaluating most or all of the thunks, so what difference did it make? But, I guess it's a bit of an oversimplification in both cases. I'm just thinking, the application writer probably knows more about their specific program than the compiler designers do, so it would be nice to be able to provide hints to the RTS. Definitely. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Haskell with associated types (and kind annotations)
Hi I guess I should write the skeleton of the code I want to generate, get HSE to parse it, and then replace the parts I want to change of the AST with what I need? Is there a nicer way (TH-like?) to get the modified AST into GHC than prettyprinting the AST again and asking GHC to compile the output file? This package seems to do some of the bits you want. I've added it to my list of packages to look at in the future: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/haskell-src-meta Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Can HLint help spot space leaks? (was: Re: [Haskell-cafe] Generating Haskell with associated types (and kind annotations))
Hi Jason, Hi Neil, A bit off-topic, but your post reminded me: Does HLint currently help the user find space leaks? For example, does it recommend strict folds instead of lazy folds? I looked at the FAQ but this was not listed. I don't really know how feasible this is. It spots when you use replicateM or mapM, but don't use the result, and should have actually used the _ versions. It doesn't spot foldl s that should be foldl' s - in general you only know that if you have the strictness information, which HLint doesn't. You could add the rule foldl == foldl', but it's not in general correct, so it won't be added to the default rule set. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Writing a compiler in Hakell
Hi Doaitse Doaitse Swierstra wrote: Dear Rouan, on http://www.cs.uu.nl/wiki/HUT/WebHome you will find a collection of tools which may help you to construct a compiler. As an example you will find a Tiger compiler constructed with the uulib tools and the uuagc attribute grammar system. Tiger is the language used in the book series by Andrew Apple. Not that Tiger is a great language, but the compiler contains an instance of all the things that have to be done when writing a compiler. Once you like these tools you may take a look at the UHC compiler, which actually is a series of compilers, starting from a small language, which is than gradually extended, both with new language concepts and with new aspects, such as code generation, new forms of types etc. Here you will also see that writing a compiler for a language like Haskell is not a small endeavour. I tried the uu-parsinglib and must admit, that I got a bit frustrated. In my rant below I may sound very negative, but that is not my intention. My intention is to give you my initial impression of the rough spots when trying uu-parsinglib, which you may (or may not) use if you want to make uu-parsinglib more newcomer friendly. First the 55 page document Combinator Parsing: A Short Tutorial has, in my mind, some shortcoming: * A 55 page document should have a table of contents. It helps people understand the structure, and makes the document easier to navigate. * It is not really a tutorial! Or at least, not a tutorial that gets you quickly writing parses using uu-parselib. It describes alternative implementation, why something is implemented in a particular way, how something is implemented, ... These are all good things, but not something that helps me get started. They belong in an advanced section. Or maybe it would be better with two documents, with different target audiences. Furthermore, the Tiger example is good. But please provide type signatures for all functions. The signatures may be obvious to you, but for the newcomer they may not be. When I look at the uu-parselib interface [1] it seems very sparse. Compared to Parsec, I miss a lot of the standard combinators [2]. It seems like you have to implement those combinators yourself. Finally, there is no Haddock documentation in uu-parselib. The lack of entry-level documentation and few predefined parsing combinators in uu-parselib do make for a steep learning curve. Kind regards, Mads Lindstrøm [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/uu-parsinglib [2] http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/Text-Parsec-Combinator.html signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simulation and GHC Thread Scheduling
Thomas You can build your own scheduler very easily using what is already there. As with any simulation the two things that you need to capture are dependency and resource contention. Haskell does both the dependency stuff beautifully and the resource contention. Using STM you can even get nice compositional properties. All you really have to take care of is how time progresses (if that is the sort of simulation you are in to). Yes, refactor the code, choose an appropriate (monadic) framework to run it in and build a consistent logging/monitoring/measuring model into it - then things work great. Cheers Neil On 9 May 2009, at 00:22, Thomas DuBuisson wrote: All, I have a simple Haskell P2P library that I've been playing with in simulations of 20 to 600 nodes. To run the simulation there is a Haskell thread (forkIO) for every node in the system, one that starts up all the nodes and prints the info (so prints aren't mangled), and one that acts as the router. Before its mentioned - I understand the best way forward would be to refactor the code into IO-less 'algorithm' sections and other sections that perform the needed IO when I'm not simulating. I know this would allow me to declare what order each node runs in and would free me from the scheduler. I'd like to do that if its practical... but! None-the-less, here I am saying that there are many interesting little simulations that could be done without refactoring and the correctness isn't altered by the order of operations (not if the nodes behave properly, the slight variation is actually a good test). What I would like to know is are there any plans for GHC to incorporate user-definable scheduler? It would be useful in numerous instance beyond this poor example; I know user scheduling was briefly mentioned in Li's paper but haven't seen or heard of any interest from others since then. Thomas ___ 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] haskell - main function
Could anyone look at this segment of code; it's not compiling wondering if anyone could correct me as to why. Thanks Code: -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film Casino Royale Martin Campbell 2006 [Garry, Dave, Zoe]) ] becomeFan :: Title - fanName - [Film] - [Film] becomeFan _ _ [] = [] becomeFan Title fanName ((Film Title Director Year fan):xs) | filmName == title = (Film Title Director Year fanName:fan) : xs | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs main :: [Film] - IO() main db = do putStr Hi there! what is your name: fanName = getLine do putStr 1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : input = getLine x = read input :: Int if x == 1 then do putStr Enter film title: filmTitle - getLine putStr Enter director name: filmDirector - getLine putStr Enter release year: filmYear - getLine main insertFilm [Title Director Year [Film]] else if x == 2 then do putStr Enter film title: filmTitle - getLine putStr Enter fan name: fanName - getLine main becomeFan [Title fanName] else if x == 3 then do putStr Enter film title: filmTitle - getLine main numberOfFans [Title] else if x == 4 then do putStr Enter film release year: filmYear - getLine main filmsInGivenYear [Year [Film]] else if x == 5 then do putStr Enter the fan name: fanName - getLine main givenUser [fanName [Film]] else if x = 6 then return () -- View this message in context: http://www.nabble.com/haskell---main-function-tp23459841p23459841.html 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
Re: [Haskell-cafe] Simulation and GHC Thread Scheduling
properly, the slight variation is actually a good test). What I would like to know is are there any plans for GHC to incorporate user-definable scheduler? What exactly is it that you want from a user-definable scheduler? Do you want co-operative scheduling in your program, or do you want to be able to control the thread-grouping and running order in the GHC runtime? More details of your requirements would help -- I can't quite make out what you need from your email. Thanks, Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell - main function
At Sat, 9 May 2009 04:54:13 -0700 (PDT), applebiz89 wrote: Could anyone look at this segment of code; it's not compiling wondering if anyone could correct me as to why. Thanks There is a ton of things wrong with that code. I have attached a version that at least compiles, but there are still a bunch of things that are wrong. -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film Casino Royale Martin Campbell 2006 [Garry,Dave, Zoe]) ] becomeFan :: Title - Fan - [Film] - [Film] becomeFan _ _ [] = [] becomeFan title' fanName (film@(Film title director year fans) : films) | title == title' = (Film title director year (fanName:fans)) : films | otherwise = film : becomeFan title' fanName films insertFilm = undefined numberOfFans = undefined filmsInGivenYear= undefined givenUser = undefined mainLoop :: [Film] - IO() mainLoop db = do putStr Hi there! what is your name: fanName - getLine putStr 1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : input - getLine let x = read input :: Int if x == 1 then do putStr Enter film title: filmTitle - getLine putStr Enter director name: filmDirector - getLine putStr Enter release year: filmYear - fmap read getLine mainLoop $ insertFilm (Film filmTitle filmDirector filmYear []) db else if x == 2 then do putStr Enter film title: filmTitle - getLine putStr Enter fan name: fanName - getLine mainLoop $ becomeFan filmTitle fanName db else if x == 3 then do putStr Enter film title: filmTitle - getLine mainLoop $ numberOfFans filmTitle db else if x == 4 then do putStr Enter film release year: filmYear - getLine mainLoop $ filmsInGivenYear filmYear db else if x == 5 then do putStr Enter the fan name: fanName - getLine mainLoop $ givenUser fanName db else if x == 6 then return () else return () main :: IO () main = mainLoop testDatabase___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] haskell - main function
Hi applebiz89 wrote: Could anyone look at this segment of code; it's not compiling wondering if anyone could correct me as to why. Thanks Code: -- Film as datatype type Title = String type Director = String type Year = Int type Fan = String data Film = Film Title Director Year [Fan] -- List of films testDatabase :: [Film] testDatabase = [(Film Casino Royale Martin Campbell 2006 [Garry, Dave, Zoe]) ] becomeFan :: Title - fanName - [Film] - [Film] becomeFan _ _ [] = [] becomeFan Title fanName ((Film Title Director Year fan):xs) | filmName == title = (Film Title Director Year fanName:fan) : xs | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs main :: [Film] - IO() main db = do putStr Hi there! what is your name: fanName = getLine do putStr 1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a film, 4 = Film released in a year, 5 = Given fan, 6 = Stop : input = getLine x = read input :: Int if x == 1 then do putStr Enter film title: filmTitle - getLine putStr Enter director name: filmDirector - getLine putStr Enter release year: filmYear - getLine main insertFilm [Title Director Year [Film]] else if x == 2 then do putStr Enter film title: filmTitle - getLine putStr Enter fan name: fanName - getLine main becomeFan [Title fanName] else if x == 3 then do putStr Enter film title: filmTitle - getLine main numberOfFans [Title] else if x == 4 then do putStr Enter film release year: filmYear - getLine main filmsInGivenYear [Year [Film]] else if x == 5 then do putStr Enter the fan name: fanName - getLine main givenUser [fanName [Film]] else if x = 6 then return () You have an if without an else. You cannot have that. What should the program do when x /= 6. And you write x = 6 in stead of x == 6. But generally speaking, you want to include compiler output in this is not compiling-messages to haskell-cafe. Regards, Mads Lindstrøm signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] is value evaluated?
On May 8, 2009, at 16:31 , Sittampalam, Ganesh wrote: Brandon S. Allbery KF8NH wrote: Unless it catches exceptions itself (which strikes me as a bad idea; it becomes a trivial way to ignore exceptions, leading to bad programming practices) either they're handled inside the _|_ (in which case it isn't _|_ from the standpoint of our test) or in an outer scope (in which case our test produces _|_ from the standpoint of the exception handler). Surely it just needs to inspect the thunk to decide whether it's _|_ or not, rather than entering it? The point is it can never be given a thunk that is _|_ because exception handling will have either converted it to a non-_|_ or shunted past the test. And while my earlier com ent suggested that the test could conceivably itself do exception handling, you're right that all it does is inspect to see if a given thunk has been entered, so in fact exception handling shouldn't apply. In the end, when handed _|_ it can only produce False because a _|_ that has been entered cannot reach the test. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question concerning Haskell Foundation
On Thu, 2009-05-07 at 18:13 -0500, Vasili I. Galchin wrote: sorry should read With Haskell Platform 1) Can we still publish/push up packages to Hackage? E.g. now I am trying to get Graham Lyle's Swish (semantic web package) cabalized. 2) Will Hackage go away? Hackage and the platform are complementary not in competition. In particular, Hackage is the main infrastructure for the Haskell Platform. We rely on platform packages being published on Hackage. The aim is that new quality measures that we want for platform packages to be automated in Hackage where all packages can benefit from the extra information. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal parse problems
On Wed, 2009-05-06 at 19:37 -0500, Vasili I. Galchin wrote: are them some CLI switches I can enable in order to better determine what parse error is?? The problem is that we're using a parser that has no support for producing parse errors (Text.ParserCombinators.ReadP). The only reason we're using this parser is because it's the only one in the core libraries. Packages like parsec cannot be used in Cabal because Cabal is a core library and parsec is not. For this reason we've been considering just copying another parser module into Cabal so that we can have saner (and quicker) parsing. Kind regards, Vasili On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin vigalc...@gmail.com wrote: sorrily nope, Brian ... For what it's worth, Brian was right, you cannot have a trailing comma in a list field. Perhaps there was an additional error in the file that we could not see in the bit you posted. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] runhaskell CLI parameters
On Tue, 2009-05-05 at 22:39 -0500, Vasili I. Galchin wrote: Hello, I have forgotten the runhaskell CLI parameters ... sigh. In particular I want to a local build of a set of of package: runhaskell Setup.hs configure --user??? I just did a runhaskell -? which didn't tell me a lot! You may prefer to upgrade to the 'cabal' command line program which replaces the runhaskell Setup.hs command line interface. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simulation and GHC Thread Scheduling
On Sat, May 9, 2009 at 6:28 AM, Neil Brown nc...@kent.ac.uk wrote: properly, the slight variation is actually a good test). What I would like to know is are there any plans for GHC to incorporate user-definable scheduler? What exactly is it that you want from a user-definable scheduler? Do you want co-operative scheduling in your program, or do you want to be able to control the thread-grouping and running order in the GHC runtime? More details of your requirements would help -- I can't quite make out what you need from your email. I would like to alter the running order. For example, the router thread should be ran in between every other thread - its the other threads goal in life to send messages so there's probably one ready. Additionally, the older threads should gradually become higher priority (so they run more frequently and/or for longer than new threads). As I acknowledged, this simulation is a poor example, but what this would give me is a bias toward the nodes in the DHT and away from the hundreds of nodes sending join messages that will have high contention and be dropped (there will always be progress, but as with STM there is lots of retrying involved). Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Just 3 = (1+)?
Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] is value evaluated?
Brandon S. Allbery KF8NH wrote: On May 8, 2009, at 16:31 , Sittampalam, Ganesh wrote: Brandon S. Allbery KF8NH wrote: Unless it catches exceptions itself (which strikes me as a bad idea; it becomes a trivial way to ignore exceptions, leading to bad programming practices) either they're handled inside the _|_ (in which case it isn't _|_ from the standpoint of our test) or in an outer scope (in which case our test produces _|_ from the standpoint of the exception handler). Surely it just needs to inspect the thunk to decide whether it's _|_ or not, rather than entering it? The point is it can never be given a thunk that is _|_ because exception handling will have either converted it to a non-_|_ or shunted past the test. You can set up a thunk in one place, enter it wrapped in a catch in another place, and then inspect it in a third place, e.g. (somewhat pseudo-code): do let x = if 1==1 then error foo else 3 y - catch (evaluate x) (\_ - 2) b - isEvaluated x Cheers, Ganesh === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html === ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
Because you're looking for: Just 3 = return . (+1) or more simply Just 3 = Just . (+1) or more generally: return 3 = return . (+1) The second argument of (=) is supposed to be of type (Monad m = a - m b) but (+1) ishe of type (Num a = a - a). Wre is the monad in that? Thomas On Sat, May 9, 2009 at 12:31 PM, michael rice nowg...@yahoo.com wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] haskell - main function
applebiz89 wrote: becomeFan :: Title - fanName - [Film] - [Film] becomeFan _ _ [] = [] becomeFan Title fanName ((Film Title Director Year fan):xs) | filmName == title = (Film Title Director Year fanName:fan) : xs | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs In the type signature, you have to use types. In other words, use Fan instead of fanName in the first line. Variables have to begin with a lowercase letter. In other words, use title, director, year instead of Title, Director, Year. Regarding the IO: I still propose to get your pure functions to work first, then worry about IO. You can test your code by loading it into ghci. ghci nameofmyfile.hs If everything works (i.e. no compile errors), you can call your functions at the prompt: becomeFan Casine Royale apple, testDatabase Now ghci should answer with something like the following: [(Film Casino Royale Martin Campbell 2006 [apple, Garry, Dave, Zoe])] This way, you can test your stuff while working on it. Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
I think you're looking for fmap/liftM here. The type of = is: (=) :: (Monad m) = m a - (a - m b) - m b so it's trying to make your function (1+) return m b, which in this case should be a Maybe. Clearly, (1+) doesn't return a Maybe, so it breaks. Another options is to do return . (1+) to lift the function into Maybe, but that might be a little much. On Sat, May 9, 2009 at 3:31 PM, michael rice nowg...@yahoo.com wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] Just 3 = (1+)?
On Sat, 9 May 2009, michael rice wrote: Prelude Just 3 = (1+) fmap (1+) (Just 3) or Just 3 = return . (1+) or, with consistent order of functions return . (1+) = Just 3 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
Hi, (1+) :: Num a = a - a For the bind operator, you need something of type a - Maybe b on the RHS, not simply a - a. You want one of these instead: fmap (1+) (Just 3) liftM (1+) (Just 3) Alternatively, you may find it useful to define something like: (*) = flip liftM so that you can write: Just 3 * (1+) which bears a closer resemblance to the bind notation. Thanks, Neil. michael rice wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] Just 3 = (1+)?
On May 9, 2009, at 15:31 , michael rice wrote: Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude (=) must be applied to a function that produces a result in the same monad: (=) :: Monad m = m a - (a - m b) - m b That (a - m b) in the middle is what's failing to typecheck. The error is a bit obtuse because ghci is trying hard to find a way to do what you want, so it assumes m is (- r) (the functor/monad representing functions, also known as the Reader monad) which means b must be Maybe x for some x, but there are no instances of Maybe that are also instances of Num. If ghci had started by fixing m as Maybe (via the Just 3) the types in the error message would have made more sensen; fixing m is more restrictive The function you're actually looking for is liftm or fmap: liftm :: Monad m = m a - (a - b) - m b fmap :: Functor f = f a - (a - b) - f b which lifts the (1+) up inside the monad/functor (which in this case is Maybe, as per the above). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
michael rice wrote: Prelude Just 3 = (1+) Let's check the types. Prelude :t (=) (=) :: (Monad m) = m a - (a - m b) - m b Prelude :t Just 3 Just 3 :: (Num t) = Maybe t Prelude :t (1 +) (1 +) :: (Num a) = a - a Renaming the variables in the type of (1 +) gives: (1 +) :: (Num c) = c - c Since (Just 3) is the first argument of (=), we have to unify the types (Maybe t) and (m a). This leads to: m = Maybe t = a Since (1 +) is the second argument of (=), we have to unify the types (c - c) and (a - m b). This leads to: c = a = m b Since we haven't found any inconsistencies, typechecking succeeded, and we instantiate the types of Just 3, (=) and (1 +) to the following types by applying the substituations we found. Just 3 :: Num (Maybe b) = Maybe (Maybe b) (1 +) :: Num (Maybe b) = Maybe b - Maybe b (=) :: Monad Maybe = Maybe (Maybe b) - (Maybe b - Maybe b) - Maybe b And the type of the whole expression is accordingly: Just 3 = (1 +) :: (Monad Maybe, Num (Maybe b)) = Maybe b Now ghc looks at the constraints, figures out that Monad Maybe is fine, and complains about Num (Maybe b). Try the fmap function instead, it has the following type: Prelude :t fmap fmap :: (Functor f) = (a - b) - f a - f b Since every self-respecting Monad is also a Functor, you can use fmap (1 +) (Just 3). Now (a - b) is unified with (Num a = a - a), so that the overall type of the function is (Num a = Maybe a) as you would expect. Tillmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
Hi, Haskell expects the function with type (a - m b) in the right side of (=), but you put there function with type (a - a): try: :t (Just 3 =) (Just 3 =) :: (Num a) = (a - Maybe b) - Maybe b and: :t (1+) (1+) :: (Num a) = a - a You should put (1+) into Maybe monad, just do return.(1+), so Just 3 = return . (1+) will return `Just 4` -- Best regards, Vasyl Pasternak 2009/5/9 michael rice nowg...@yahoo.com Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] Just 3 = (1+)?
On Sat, May 9, 2009 at 12:31 PM, michael rice nowg...@yahoo.com wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude The type of (=) is (=) :: m a - (a - m b) - m b For the Maybe monad, that specializes to (=) :: Maybe a - (a - Maybe b) - Maybe b But when you say Just 3 = (+1) this desugars to (=) (Just 3) (\x - x + 1) but the second argument to (=) that you have given has the type (\x - x + 1) :: Num a = a - a, whereas it needs to return a type of Maybe a to fit the type signature. What you probably want is Just 3 = (Just . (+1)) so the second function returns a Maybe value. A nicer way of writing this is fmap (+1) (Just 3), which uses the Functor class. Intuitively, the fmap function applies a function to the inside of a container. All monads can be defined as Functors as well; all Monads in the standard libraries have their functor instances defined. Hope that helps you. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
Hey Michael, If you would look at the type of =, it would give (=) :: (Monad m) = m a - (a - m b) - m b and specifically in your case: (=) :: Maybe a - (a - Maybe b) - Maybe b You are applying Just 3 as first argument, which is correct, but then supply a partially applied function (1+) which is of type Num a = a - a, while it should be a - Maybe b. What are you expecting as result? You cannot pull something out of a monad using a bind operator. Maybe you meant something like this? (Just 3) = \x - return (x + 1) Notice how Just 3 is just the Maybe a argument, and \x - return (x + 1) is the (a - Maybe b) argument, finally delivering a Just 4 (of type Maybe b). (This is the same as do x - Just 3 return (x + 1) ) Oh and btw, fail should take an argument (the error string). Good luck, Bas van Gijzel On Sat, May 9, 2009 at 9:31 PM, michael rice nowg...@yahoo.com wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] Just 3 = (1+)?
Types. (=) :: Monad m = m a - (a - m b) - m b (1+) :: Num a = a - a So, the typechecker deduces that 1) a is the same as m b, and 2) a (and m b, therefore) must be of class Num Now, Just 3 :: Num t = Maybe t and the typechecker learns from that that m a must be the same as Maybe t, with t being of class Num. This leads to two observations: 3) m is Maybe, and 4) a is of class Num - the same as (2) above Now, from (1) and (3) it follows that a is the same as Maybe b. (2) lead than to Maybe b being of class Num - but GHCi doesn't have this instance, and complains. What you've probably meant is something like Just 3 = \x - return (x + 1) or, equivalently, liftM (+1) $ Just 3 On 9 May 2009, at 23:31, michael rice wrote: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ 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] Just 3 = (1+)?
Excerpts from michael rice's message of Sat May 09 14:31:20 -0500 2009: Why doesn't this work? Michael data Maybe a = Nothing | Just a instance Monad Maybe where return = Just fail = Nothing Nothing = f = Nothing (Just x) = f = f x instance MonadPlus Maybe where mzero = Nothing Nothing `mplus` x = x x `mplus` _ = x [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude Look at the types: Prelude :t (=) (=) :: (Monad m) = m a - (a - m b) - m b Prelude :t (+1) (+1) :: (Num a) = a - a Prelude The return type of '(+1)' in this case should be 'm b' but it instead only returns 'b'. If we tag a return on there, it will work fine: Prelude Just 3 = return . (+1) Just 4 Prelude Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
Am Samstag 09 Mai 2009 21:31:20 schrieb michael rice: Why doesn't this work? Michael [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude The type of (=) is Monad m = m a - (a - m b) - m b, the type of (1 +) is Num n = n - n. Using (1 +) as the second argument of (=), you must unify Num n = n - n with Monad m = a - m b the types of the arguments and results must match, so a = n m b = n = a , giving the type (Monad m, Num (m b)) = m b - m b The first argument of (=) is Just 3 :: Num k = Maybe k. That must be unified with m a, giving m = Maybe and a = k. On the other hand we previously found a = m b, so in Just 3 = (1 +) the (1 +) has type Num (Maybe b) = Maybe b - Maybe b and Just 3 has type Num (Maybe b) = Maybe (Maybe b). But ghci can't find an instance Num (Maybe b). You probably wanted fmap (1 +) (Just 3) ~ Just 4 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
On 10 May 2009, at 00:30, Brandon S. Allbery KF8NH wrote: On May 9, 2009, at 15:31 , michael rice wrote: Prelude Just 3 = (1+) That (a - m b) in the middle is what's failing to typecheck. The error is a bit obtuse because ghci is trying hard to find a way to do what you want, so it assumes m is (- r) (the functor/monad representing functions, also known as the Reader monad) Ehm? What? I haven't seen the (- r) monad anywhere near this code. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
On May 9, 2009, at 18:03 , Miguel Mitrofanov wrote: On 10 May 2009, at 00:30, Brandon S. Allbery KF8NH wrote: On May 9, 2009, at 15:31 , michael rice wrote: Prelude Just 3 = (1+) That (a - m b) in the middle is what's failing to typecheck. The error is a bit obtuse because ghci is trying hard to find a way to do what you want, so it assumes m is (- r) (the functor/monad representing functions, also known as the Reader monad) Ehm? What? I haven't seen the (- r) monad anywhere near this code. That's the only way I can get the error he got; if it uses Maybe as the monad then why is the Maybe on the *inside* in the error message? Clearly it bound m to something else, and ((-) r) is the only other one I can think of applying there. (Hm, I suppose it could be IO forced by the ghci context, but I didn't think it worked that way.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
On May 9, 2009, at 18:16 , Brandon S. Allbery KF8NH wrote: That's the only way I can get the error he got; if it uses Maybe as the monad then why is the Maybe on the *inside* in the error message? Clearly it bound m to something else, and ((-) r) is the only other one I can think of applying there. (Hm, I suppose it could be IO forced by the ghci context, but I didn't think it worked that way.) Er, clarifying: it's looking for Num (Maybe a), but the context where Num applies is inside the scope where the Maybe applies (a - m b has been fixed at Num n = n - m n). But the error message says ghc is trying to make *n* an instance of Num. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] cabal parse problems
Thanks .. very interesting on the cabal parsers. I somehow got around my problem ... forgot how though. Vasili On Sat, May 9, 2009 at 10:48 AM, Duncan Coutts duncan.cou...@worc.ox.ac.ukwrote: On Wed, 2009-05-06 at 19:37 -0500, Vasili I. Galchin wrote: are them some CLI switches I can enable in order to better determine what parse error is?? The problem is that we're using a parser that has no support for producing parse errors (Text.ParserCombinators.ReadP). The only reason we're using this parser is because it's the only one in the core libraries. Packages like parsec cannot be used in Cabal because Cabal is a core library and parsec is not. For this reason we've been considering just copying another parser module into Cabal so that we can have saner (and quicker) parsing. Kind regards, Vasili On Wed, May 6, 2009 at 6:12 PM, Vasili I. Galchin vigalc...@gmail.com wrote: sorrily nope, Brian ... For what it's worth, Brian was right, you cannot have a trailing comma in a list field. Perhaps there was an additional error in the file that we could not see in the bit you posted. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Just 3 = (1+)?
... There have been 12 replies to this question, all of which say the same thing. I'm glad we're so happy to help, but does Just 3 = return . (+1) Need to be explained by 12 different people? fmap (trying to++) $ Just help -- :D Cory Why doesn't this work? Michael [mich...@localhost ~]$ ghci GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude Just 3 = (1+) interactive:1:0: No instance for (Num (Maybe b)) arising from a use of `it' at interactive:1:0-14 Possible fix: add an instance declaration for (Num (Maybe b)) In the first argument of `print', namely `it' In a stmt of a 'do' expression: print it Prelude ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe