Re: Re[Haskell-cafe] mote invocations in Haskell?
* Yves Parès limestr...@gmail.com [2010-03-23 13:46:25-0700] Is there a way to perform some kind of remote method invocation in haskell? (Or, remote object, but I prefer not to use this term, as there are no objects strictly speaking in Haskell) I would like to use a higher level API than sockets for network programing. There is for example XML-RPC library for Haskell. http://hackage.haskell.org/package/haxr -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Getting a string from url-converted UTF8 input
* Eugene Dzhurinsky b...@redwerk.com [2010-05-16 18:42:08+0300] Hello all! Can somebody please explain wha am I doing in wrong way? [snip] I am getting the output: === 1) 345 =K=G5 4= 1...@0bl :=86:8 2 2845 FB2? 2) :0:9 5ABL ADB =0 65;57:C B8?0 B5;5D= A Symbian === which is wrong. So what do I miss in encoding the data in UTF? I assume you are using GHC 6.12. The trouble is in conversion done by putStrLn. Use one from System.IO.UTF8. Or try to upgrade to GHC 6.12 which respects the locale settings. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Process priority
* Andrew Coppin andrewcop...@btinternet.com [2010-06-03 08:27:21+0100] I've had a hunt around in System.Process, but I can't discover any way to adjust the priority of the process you just spawned. Am I missing something, or has this just not been implemented yet? (I must confess, I don't know whether Windows and Unix both have the same ideas about priority numbers...) For POSIX systems you have 'nice' and 'setProcessPriority' in System.Posix.Process. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with connectTo function in network package
* aditya siram aditya.si...@gmail.com [2010-06-03 22:30:33-0500] Hi all, I had an issue where using the connectTo [1] function would fail to connect to localhost if my wireless card was turned off. The moment I turned on my wireless connection it worked. But if I use connectTo with 127.0.0.1 [2] with my network off it works. I confirmed that localhost' resolves to 127.0.0.1 by pinging localhost from command line with the Internet off. Is this a bug in connectTo? -deech [1] connectTo localhost (PortNumber some_number) [2] connectTo 127.0.0.1 (PortNumber some_number) How exactly did it fail? Did it throw an exception? If so, what was the exception? Which operating system did you observe that under? If that was Linux, can you show the contents of the following files on that system: /etc/nsswitch.conf /etc/hosts -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with connectTo function in network package
Another way round -- it (the server) was only listening on IPv4 and the (Haskell) client only tried to connect via IPv6. The bug is described here (with a patch): http://trac.haskell.org/network/ticket/30 * Jeremy Shaw jer...@n-heptane.com [2010-06-04 16:57:38-0500] Perhaps it was only listening on IPv6 ? ::1 ? - jeremy On Thu, Jun 3, 2010 at 10:30 PM, aditya siram aditya.si...@gmail.comwrote: Hi all, I had an issue where using the connectTo [1] function would fail to connect to localhost if my wireless card was turned off. The moment I turned on my wireless connection it worked. But if I use connectTo with 127.0.0.1 [2] with my network off it works. I confirmed that localhost' resolves to 127.0.0.1 by pinging localhost from command line with the Internet off. Is this a bug in connectTo? -deech [1] connectTo localhost (PortNumber some_number) [2] connectTo 127.0.0.1 (PortNumber some_number) ___ 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 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell logo
* Andrew Coppin andrewcop...@btinternet.com [2010-06-10 18:47:23+0100] I just visited haskell.org and noticed that the old logo is back. Anybody know when/why this happened? Result of restoring from backups? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] threadDelay correctness
* David Powell da...@drp.id.au [2010-06-11 16:09:55+1000] This is a slightly different issue, but isn't there a potential problem with threadDelay? I noticed that internally threadDelay uses gettimeofday() as the absolute time source (on linux at least). Isn't there potential problem with this since wall-clock time isn't guaranteed to be monotonic increasing? On linux, I'd have thought the right thing to do would be to use clock_gettime(CLOCK_MONOTONIC) although that is probably not very portable. Good point -- I remember xmobar hanging after adjusting clock. Seems like this is the cause. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using the ContT monads for early exits of IO ?
* Günther Schmidt gue.schm...@web.de [2010-06-11 01:22:27+0200] there is nothing wrong with ifs as such except the won't actually exit a long piece of code, the computation will continue, just in a useless way. Can you clarify? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Graph type
* C K Kashyap ckkash...@gmail.com [2010-06-13 22:45:44+0530] Hi, I am trying to write a routine that would generate a graph - where each vertex would be a string. type Graph v = [(v,[v])] -- list of tuples of vertices and adjacent vertices list addEdgeToGraph :: Graph - String - String - Graph I am having trouble coming up with the body of this function - that takes the original graph, and an edge (string - string) and the produces the new graph. If you know that the vertices already exist and you need only to add an edge, then you just go through all the vertices, compare current vertex to given ones and if they match add a vertex. \begin{code} addEdgeToGraph :: Graph String - String - String - Graph String addEdgeToGraph gr v1 v2 = map modify gr where modify (v,vs) | v == v1 = (v,v2:vs) modify (v,vs) | v == v2 = (v,v1:vs) modify x = x \end{code} Otherwise it is possible that one (or both) vertex doesn't exist yet, so you first need to try the first version, and if at least one of the vertex is not found, add it to the list. You can use fold for this. \begin{code} addEdgeToGraph' :: Graph String - String - String - Graph String addEdgeToGraph' gr v1 v2 = let (newgr, (foundV1, foundV2)) = foldr modify ([],(False,False)) gr in (if foundV1 then [] else [(v1,[v2])]) ++ (if foundV2 then [] else [(v2,[v1])]) ++ newgr where modify (v,vs) (lst,(_,foundV2)) | v == v1 = ((v,v2:vs):lst, (True,foundV2)) modify (v,vs) (lst,(foundV1,_)) | v == v2 = ((v,v1:vs):lst, (foundV1,True)) modify v (lst,f) = (v:lst,f) \end{code} -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] parsec: how to get end location
Suppose I have some parser 'p'. I want to parse it as well as get its span in the text. So I could write \begin{code] pWithLocation = do loc_start - getPosition pval - p loc_end - getPosition return (pval,loc_start,loc_end) \end{code} except that loc_end gives me the location _after_ 'p'. In case when 'p' has consumed trailing newline I see no way to recover the end location of 'p' (it is the last column of the previous line). So, can I do anything with this without patching parsec? I use parsec3 if it matters. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] parsec: how to get end location
* Antoine Latter aslat...@gmail.com [2010-06-13 16:47:28-0500] On Sun, Jun 13, 2010 at 4:17 PM, Roman Cheplyaka r...@ro-che.info wrote: Suppose I have some parser 'p'. I want to parse it as well as get its span in the text. So I could write \begin{code] pWithLocation = do loc_start - getPosition pval - p loc_end - getPosition return (pval,loc_start,loc_end) \end{code} except that loc_end gives me the location _after_ 'p'. In case when 'p' has consumed trailing newline I see no way to recover the end location of 'p' (it is the last column of the previous line). So, can I do anything with this without patching parsec? I use parsec3 if it matters. Can you use a parser which doesn't consume leading/trailing whitespace? Or somehow layer the parsers so that the whitepsace munching happens outside of parseWithLocation. Of course most parsers don't consume trailing newlines. But I was writing general function to use in many places in the code which would recover the end location. In most cases it just subtracts 1 from the column number, but what if it just happened so that column number is 1? So I got an impression that this way of obtaining the end location is at least ugly. It would be better if there was a function parseWithLocation :: Parser a - Parser (a, SourcePos, SourcePos) which, I guess, is easy to implement within Parsec without any such hacks. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Terminology
* Emmanuel Castro emmanuel.cas...@laposte.net [2010-06-15 00:10:09+0200] I am looking for the name of the property linking two functions f and g when : [f(a),f(b),f(c)] = g([a,b,c]) Is there a standard name? In practice, g is an optimised version of f when working on large amount of elements. Sometimes (particularly in Data Parallel Haskell, but also in other languages) 'g' is called vectorized version of 'f'. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What is Haskell unsuitable for?
* aditya siram aditya.si...@gmail.com [2010-06-15 19:47:37-0400] Hi all, Haskell is a great language and in a lot of ways it still hasn't found a niche, but that's part of what is great about it. But I wanted to ask people are more experienced with Haskell - what kinds of problems is it unsuited for? Have you ever regretted using it for something? Meaning if you could write the program over you would do it in another language. This topic was already discussed on this list, you might want to search the archives. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Understanding GHC allocations
I'm trying to optimize the following program: http://github.com/feuerbach/particles/blob/303c8a17c9b732e22457b5409bdce4b7520be94a/run.hs Of course general suggestions are welcome (BTW I'm going to give a try to vector), but currently I'm concerned with two questions: 1. Heavy allocations in 'distance' function. Here is (part of) the profile: COST CENTRE MODULE%time %alloc ticks bytes d2Main9.0 22.0290 6 d Main8.6 65.9278 18 d1Main7.5 11.0242 29970 From reading core I got the impression that everything is strict unboxed. Perhaps this is related to creating some closures? How to get rid of those allocations? 2. Again from reading the core I learned that although 'l' and other constants are inlined, their type is boxed Double. This makes sense since CAFs are evaluated on demand, but obviously in this particular case it does not make sense, so can I somehow make them unboxed? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Understanding GHC allocations
* Roman Cheplyaka r...@ro-che.info [2010-06-17 12:40:59+0300] I'm trying to optimize the following program: http://github.com/feuerbach/particles/blob/303c8a17c9b732e22457b5409bdce4b7520be94a/run.hs Of course general suggestions are welcome (BTW I'm going to give a try to vector), but currently I'm concerned with two questions: 1. Heavy allocations in 'distance' function. Here is (part of) the profile: COST CENTRE MODULE%time %alloc ticks bytes d2Main9.0 22.0290 6 d Main8.6 65.9278 18 d1Main7.5 11.0242 29970 From reading core I got the impression that everything is strict unboxed. Perhaps this is related to creating some closures? How to get rid of those allocations? 2. Again from reading the core I learned that although 'l' and other constants are inlined, their type is boxed Double. This makes sense since CAFs are evaluated on demand, but obviously in this particular case it does not make sense, so can I somehow make them unboxed? Forgot to mention, I'm using ghc 6.12.1, compiling with -O2. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Understanding GHC allocations
* Daniel Fischer daniel.is.fisc...@web.de [2010-06-17 16:27:01+0200] On Thursday 17 June 2010 11:43:09, Roman Cheplyaka wrote: * Roman Cheplyaka r...@ro-che.info [2010-06-17 12:40:59+0300] I'm trying to optimize the following program: http://github.com/feuerbach/particles/blob/303c8a17c9b732e22457b5409bd ce4b7520be94a/run.hs Of course general suggestions are welcome (BTW I'm going to give a try to vector), but currently I'm concerned with two questions: 1. Heavy allocations in 'distance' function. Here is (part of) the profile: COST CENTRE MODULE%time %alloc ticks bytes d2Main9.0 22.0290 6 d Main8.6 65.9278 18 d1Main7.5 11.0242 29970 I suspect the distance function is not what you intended, distance 0.2 24.8 = 24.6, while the wrapping suggests that it should be 0.4, so in d2, it should be d1 instead of d. Good catch! :) Either way, both d and d1 are = 25, so the 'abs' in d2 is superfluous, Correct removing that alone reduces the allocations drastically and the running time by ~40% That's exactly what I'm asking about. 'abs' in C does not require any allocations, does it? So why does it require any allocations in Haskell, assuming we've got no lazyness, typeclass indirection (I assume 'abs' was specialized and inlined) or other high-level features in resulted low-level code? Further, if you export only main from the module, you allow GHC to be more aggressive with optimising. On my box, that leads to more allocation again because there aren't enough registers, but things become a little faster. Good idea indeed. Perhaps this is related to creating some closures? How to get rid of those allocations? Do you need to? Sometimes an allocating loop is faster than a non- allocating one (of course, if you have enough registers for the allocating loop to run entirely in registers, it'll be much faster still). IMO, the important criteria are time and resident memory, not allocation. Maybe, but what bothers me is that I can't answer myself where are those allocation from. What problem do they solve? 2. Again from reading the core I learned that although 'l' and other constants are inlined, their type is boxed Double. This makes sense since CAFs are evaluated on demand, but obviously in this particular case it does not make sense, so can I somehow make them unboxed? Putting bangs in the loops where they are used likely uses the unboxed values; not exporting them too. I'll play with this, thanks. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Core packages and locale support
While ghc 6.12 finally has proper locale support, core packages (such as unix) still use withCString and therefore work incorrectly when argument (e.g. file path) is not ASCII. Is someone already working on this? If it's just a matter of time and manpower I can help but I need some guidance from authority. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Core packages and locale support
* Jason Dagit da...@codersbase.com [2010-06-24 20:52:03-0700] On Sat, Jun 19, 2010 at 1:06 AM, Roman Cheplyaka r...@ro-che.info wrote: While ghc 6.12 finally has proper locale support, core packages (such as unix) still use withCString and therefore work incorrectly when argument (e.g. file path) is not ASCII. Pardon me if I'm misunderstanding withCString, but my understanding of unix paths is that they are to be treated as strings of bytes. That is, unlike windows, they do not have an encoding predefined. Furthermore, you could have two filepaths in the same directory with different encodings due to this. In this case, what would be the correct way of handling the paths? Converting to a Haskell String would require knowing the encoding, right? My reasoning is that Haskell Char type is meant to correspond to code points so putting them into a string means you have to know their code point which is different from their (multi-)byte value right? Perhaps I have some details wrong? If so, please clarify. Jason, you got everything right here. So, as you said, there is a mismatch between representation in Haskell (list of code points) and representation in the operating system (list of bytes), so we need to know the encoding. Encoding is supplied by the user via locale (https://secure.wikimedia.org/wikipedia/en/wiki/Locale), particularly LC_CTYPE variable. The problem with encodings is not new -- it was already solved e.g. for input/output. As I said, I'm willing to prepare the patches, but I really need a mentor for this. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Core packages and locale support
* Jason Dagit da...@codersbase.com [2010-06-25 10:09:21-0700] On Thu, Jun 24, 2010 at 11:42 PM, Roman Cheplyaka r...@ro-che.info wrote: * Jason Dagit da...@codersbase.com [2010-06-24 20:52:03-0700] On Sat, Jun 19, 2010 at 1:06 AM, Roman Cheplyaka r...@ro-che.info wrote: While ghc 6.12 finally has proper locale support, core packages (such as unix) still use withCString and therefore work incorrectly when argument (e.g. file path) is not ASCII. Pardon me if I'm misunderstanding withCString, but my understanding of unix paths is that they are to be treated as strings of bytes. That is, unlike windows, they do not have an encoding predefined. Furthermore, you could have two filepaths in the same directory with different encodings due to this. In this case, what would be the correct way of handling the paths? Converting to a Haskell String would require knowing the encoding, right? My reasoning is that Haskell Char type is meant to correspond to code points so putting them into a string means you have to know their code point which is different from their (multi-)byte value right? Perhaps I have some details wrong? If so, please clarify. Jason, you got everything right here. So, as you said, there is a mismatch between representation in Haskell (list of code points) and representation in the operating system (list of bytes), so we need to know the encoding. Encoding is supplied by the user via locale (https://secure.wikimedia.org/wikipedia/en/wiki/Locale), particularly LC_CTYPE variable. The problem with encodings is not new -- it was already solved e.g. for input/output. This is the part where I don't understand the problem well. I thought that with IO the program assumes the locale of the environment but that with filepaths you don't know what locale (more specifically which encoding) they were created with. So if you try to treat them as having the locale of the current environment you run the risk of misunderstanding their encoding. Sure you do. But there is no other source of encoding information apart from the current locale. So UNIX (currently) puts the responsibility on the user. It's hard to give convincing examples demonstrating this semantics because UNIX userspace is mostly written in C and there char is just a byte, so most of them don't bother with encoding and decoding. Difference between IO and filenames is vague -- what if you pipe ls(1) to some program? Since ls does no recoding, encoding filenames differently from locale is a bad idea. By the way, GTK (which internally uses UTF-8 for strings) treats this problem differently -- it has special variable G_FILENAME_ENCODING and also G_BROKEN_FILENAMES (which means that filenames are encoded as locale says). I have no clue how their G_* variables are better than our conventional LC_* variables though. http://www.gtk.org/api/2.6/glib/glib-Character-Set-Conversion.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Core packages and locale support
* Brandon S Allbery KF8NH allb...@ece.cmu.edu [2010-06-25 05:00:08-0400] On 6/25/10 02:42 , Roman Cheplyaka wrote: * Jason Dagit da...@codersbase.com [2010-06-24 20:52:03-0700] On Sat, Jun 19, 2010 at 1:06 AM, Roman Cheplyaka r...@ro-che.info wrote: While ghc 6.12 finally has proper locale support, core packages (such as unix) still use withCString and therefore work incorrectly when argument (e.g. file path) is not ASCII. Pardon me if I'm misunderstanding withCString, but my understanding of unix paths is that they are to be treated as strings of bytes. That is, unlike windows, they do not have an encoding predefined. Furthermore, you could have two filepaths in the same directory with different encodings due to this. you got everything right here. So, as you said, there is a mismatch between representation in Haskell (list of code points) and representation in the operating system (list of bytes), so we need to know the encoding. Encoding is supplied by the user via locale (https://secure.wikimedia.org/wikipedia/en/wiki/Locale), particularly LC_CTYPE variable. You might want to look at how Python is dealing with this (including the pain involved; best to learn from example). Do you mean the pain when filenames can not be decoded using current locale settings and thus the files are not accessible? (The same about environment variables.) Agreed, it's unpleasant. The other way would be changing [Char] to [Word8] or ByteString. But this would a) break all existing programs and b) be an OS-specific hack. Crap. Brandon, do you have any ideas on how we should proceed with this? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Error monads (was: Call for comments: neither package)
* Stephen Tetley stephen.tet...@gmail.com [2010-06-29 12:02:45+0100] The Applicative Programming with Effects Paper has the monodial accumulating applicative instance on a sum type Conor McBride and Ross Paterson call Except: data Except err a = OK a | Failed err The names are nice and to the point, but they would equally describes the other exception model (monadic - exit on first fail) and having both might be particularly confusing to newcomers: two error types - one with an obvious name, one with an unfamiliar one, the unfamiliar one might be the one they need most often... On a slightly related note, in my projects I tend to define my own Error-like types with descriptive names, often more than one failure mode and apropriate instances. For an example of this approach, see http://github.com/feuerbach/loker/blob/master/testingtool.hs#L33 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error monads (was: Call for comments: neither package)
* Vo Minh Thu not...@gmail.com [2010-06-29 16:26:06+0200] 2010/6/29 Roman Cheplyaka r...@ro-che.info: * Stephen Tetley stephen.tet...@gmail.com [2010-06-29 12:02:45+0100] The Applicative Programming with Effects Paper has the monodial accumulating applicative instance on a sum type Conor McBride and Ross Paterson call Except: data Except err a = OK a | Failed err The names are nice and to the point, but they would equally describes the other exception model (monadic - exit on first fail) and having both might be particularly confusing to newcomers: two error types - one with an obvious name, one with an unfamiliar one, the unfamiliar one might be the one they need most often... On a slightly related note, in my projects I tend to define my own Error-like types with descriptive names, often more than one failure mode and apropriate instances. For an example of this approach, see http://github.com/feuerbach/loker/blob/master/testingtool.hs#L33 From a quick glance at it, I believe it would be easier to use Either MyError MyResult and then have data MyError = All | The | Possible | Descriptive | Errors I would have to have separate constructor for satisfying Error class constraint, which I don't want to deal with later. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] a very pedestrian question about maillists
* Vasili I. Galchin vigalc...@gmail.com [2010-07-02 23:51:09-0500] Hello, Suppose I have the following fragment of a posting: Message: 3 Date: Fri, 2 Jul 2010 12:32:43 -0500 From: aditya siram aditya.si...@gmail.com Subject: Re: [Haskell-cafe] How easy is it to hire Haskell programmers To: Andrew Coppin andrewcop...@btinternet.com Cc: haskell-cafe@haskell.org Message-ID: aanlktil-p8qmnkpdqewdsciqw2rjaszbrl2-spyf0...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 On another posting I tried counter-posting using the Message-ID but the counter-post bounced back to me as non-deliverable. How do I post on a thread like How easy is it to hire Haskell programmers? Message-ID is not an email address, it's just an ID looking like an email address. To reply to that thread, you need to copy that id to the References or In-Reply-To header of your message. See e.g. http://cr.yp.to/immhf/thread.html However, it's better to put this kind of work on your mail client if possible. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Monad transformers (was: Is my code too complicated?)
* Andrew Coppin andrewcop...@btinternet.com [2010-07-03 14:20:14+0100] In my experience, using more than one monad transformer at once makes code utterly incomprehensible. See X monad (xmonad) for an counterexample. -- | The X monad, 'ReaderT' and 'StateT' transformers over 'IO' -- encapsulating the window manager configuration and state, -- respectively. -- -- Dynamic components may be retrieved with 'get', static components -- with 'ask'. With newtype deriving we get readers and state monads -- instantiated on 'XConf' and 'XState' automatically. -- newtype X a = X (ReaderT XConf (StateT XState IO) a) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad transformers
* Andrew Coppin andrewcop...@btinternet.com [2010-07-03 15:07:17+0100] Roman Cheplyaka wrote: * Andrew Coppin andrewcop...@btinternet.com [2010-07-03 14:20:14+0100] In my experience, using more than one monad transformer at once makes code utterly incomprehensible. See X monad (xmonad) for an counterexample. -- | The X monad, 'ReaderT' and 'StateT' transformers over 'IO' -- encapsulating the window manager configuration and state, -- respectively. -- -- Dynamic components may be retrieved with 'get', static components -- with 'ask'. With newtype deriving we get readers and state monads -- instantiated on 'XConf' and 'XState' automatically. -- newtype X a = X (ReaderT XConf (StateT XState IO) a) In my experience, defining a type representing several stacked monad transformers is the easy part. Of course it is. It wasn't my intention just to show you how easy it is to define a newtype in Haskell :) I just showed you a monad stack which is successfully used in xmonad -- and you really need to read the code a bit to get the taste of it. The hard part is figuring out how in the name of God to run the resulting computation It is run just in the one place, so you don't need to think about it each time you do some changes. or how to access functions burried at various levels of the stack. See above: -- Dynamic components may be retrieved with 'get', static components -- with 'ask'. So you use ask to get some configuration variable (reader monad is used for configuration in xmonad) and get/put/modify to deal with dynamic state of application. You use liftIO (abbreviated to 'io') to run IO computations. From what I've seen, it usually ends up being faster and easier to just define a custom monad that does exactly what you want, and then use that. In which way is it faster and easier? Can you show faster and easier implementation of the X monad shown above? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANNOUNCE: Haskell 2010 Report (final)
* Simon Marlow marlo...@gmail.com [2010-07-06 13:00:36+0100] The Haskell 2010 report is done! I've uploaded it to www.haskell.org, and linked it from the main Haskell wiki: http://www.haskell.org/haskellwiki/Language_and_library_specification online HTML version: http://www.haskell.org/onlinereport/haskell2010 PDF: http://www.haskell.org/definition/haskell2010.pdf Greetings! Now, can different compiler/interpreter authors make statements about support of this standard in their compilers please? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] libmpd-haskell RFC
* Ben Sinclair [EMAIL PROTECTED] [2008-01-16 22:02:40+1100] If anybody has already used libmpd-haskell (the darcs repo version) or would like to look over it I would appreciate their comments. Thanks, Ben http://turing.une.edu.au/~bsinclai/code/libmpd-haskell/ I'd like to use it in xmonad extension to control MPD, but since all extensions live in one package (XMonadContrib), adding new dependencies is discouraged, so I chose ad-hoc solution using netcat. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] libmpd-haskell RFC
* Don Stewart [EMAIL PROTECTED] [2008-01-17 08:56:14-0800] roma: * Ben Sinclair [EMAIL PROTECTED] [2008-01-16 22:02:40+1100] If anybody has already used libmpd-haskell (the darcs repo version) or would like to look over it I would appreciate their comments. Thanks, Ben http://turing.une.edu.au/~bsinclai/code/libmpd-haskell/ I'd like to use it in xmonad extension to control MPD, but since all extensions live in one package (XMonadContrib), adding new dependencies is discouraged, so I chose ad-hoc solution using netcat. We could have multiple extension packages (i.e. xmonadcontrib-network) for things that touch the network. It doesn't really matter -- I hardly imagine amarok user who would agree to fetchbuild libmpd-haskell in order to use some other network-related extension. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] placeholders in hsql
Is there an ability to use placeholders in SQL statement using hsql? (Actually I'm interested in SQLite.) E.g. INSERT INTO sales (product_code, qty, price) VALUES (?, ?, ?) and then supply values that will be escaped and inserted in place of each '?'. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] coerce (safe!)
* Krzysztof Skrzętnicki [EMAIL PROTECTED] [2008-03-02 01:21:42+0100] Well, it is simply coerce :: a - b coerce _ = undefined so coerce is simply empty function. But still, it is possible to write a function of type (a-b). Well, possibly I didn't write anything particularly new, but please excuse me for I'm still in sort of a shock after I've discovered it. Also there's nice possibility of defining Maybe a without ADT. type Maybe a = (a, Bool) just x = (x, True) nothing = (undefined, False) -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [GSoC] A data parallel physics engine
I'm looking for interesting project to work on during Google Summer of Code. So I found [1]A data parallel physics engine ticket and got excited about it. I'd like to know interested mentors and community opinion about the complexity of such project. I have not very deep knowledge about both NDP and physics engines. Is it feasible to learn all the necessary stuff during these 2 month before SoC starts? 1. http://hackage.haskell.org/trac/summer-of-code/ticket/1535 -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [GSoC] A data parallel physics engine
* Manuel M T Chakravarty [EMAIL PROTECTED] [2008-03-13 12:30:40+1100] Indeed, a matrix library would be really nice. Before getting serious about this, please take a very close look at how PETSc (http://www-unix.mcs.anl.gov/petsc/) handles matrices. The abstraction is very important because most large matrices of interest are sparse or have some symmetry that makes them asymptotically cheaper to apply (like with an FFT, FMM, or tensor product). In my experience, it is a lot harder to get somebody who is motivated to write a general-purpose library than getting somebody who is motivated to write an application, which you can run and show to people at the end. You're absolutely right from my (i.e. student's) point of view :) -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error handling in calculations
* [EMAIL PROTECTED] [EMAIL PROTECTED] [2008-03-19 21:47:52+0100] L.S., When playing with exceptions, I noticed the following strangeness: *Main 1 / 0 Infinity *Main 1 `div` 0 *** Exception: divide by zero This is in GHCi 6.8.2; WinHugs Sep 2006 gives: Main 1 / 0 1.#INF Main 1 `div` 0 Program error: divide by zero Is this difference between fractional and integral calculation intentional? It makes error handling more difficult. I think it's because in the first case you have floating-point overflow (which can happen not just in case of division by 0 and means some very-large number -- remember, you cannot distinguish 0 and 0.00..001) and in the second case it's just division by zero -- meaningless operation. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] doctest for haskell -- a good project?
* Shaun Cutts [EMAIL PROTECTED] [2008-03-22 02:20:38-0400] Hello, I am an experienced programmer, currently learning Haskell. Currently I write many things in python. I use both the doctest and unittest modules extensively. As I write code, I simultaneously write doctest code in the doc strings to explain/set out the typical narrative of how the code is used. Then finishing off a module I write unittests for boundary conditions, more complex test cases, and generally code that would be annoying to write read in doctests. I note that there is a unit testing framework for Haskell, but I don't see any doctest module. Might this be a good project? If so, suggestions as to resources would be greatly appreciated. I believe I can't just introspect Haskell modules to get at documentation/comments, like I can in python? (Why not? :)) I notice that there are a few documentation generators. Should I try to write an extension of one of these? Haddock, for instance? Are there any Haddock developers hanging out on this list, to encourage or dissuade me? :) (And where is the Haddock doc for Haddock?) In any case, thanks in advance for any comments advice. - Shaun Cutts Did you try haddock? -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unboxed arrays
* Andrew Coppin [EMAIL PROTECTED] [2008-03-26 12:37:53+] Somebody asked me, so now I'm asking you... In Haskell, you can make unboxed arrays of certain value types. These are typically more efficient in space, and probably time too, and also make the array strict in its values. However, you can only do this magic trick for certain types - not for *all* types. Why is that? Is it because nobody has done anything about it yet? Is it because it's thought to be not necessary in some way? Is there some theoretical problem? Has somebody got a better idea? I did think it was along the lines of oh, well, if you want to unbox a type of your own, you just need to write your own instance. The thing that makes me suspicious of this logic is the absense of an instance for tuples. Surely this would be trivial to write, and yet it's not present. If we had instances for a couple of sizes of tuples, it would surely be quite easy to write your own custom instances that just sit on top of this and tuple/untuple your custom values... Any insights here? Could Data Parallel Haskell[1] be useful for you? It was designed for parallel computation, but it includes unboxed arrays, nice list-like syntax and array comprehensions. 1. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unboxed arrays
* Henning Thielemann [EMAIL PROTECTED] [2008-03-26 14:22:20+0100] On Wed, 26 Mar 2008, Roman Cheplyaka wrote: * Andrew Coppin [EMAIL PROTECTED] [2008-03-26 12:37:53+] Somebody asked me, so now I'm asking you... In Haskell, you can make unboxed arrays of certain value types. These are typically more efficient in space, and probably time too, and also make the array strict in its values. However, you can only do this magic trick for certain types - not for *all* types. Why is that? Is it because nobody has done anything about it yet? Is it because it's thought to be not necessary in some way? Is there some theoretical problem? Has somebody got a better idea? I did think it was along the lines of oh, well, if you want to unbox a type of your own, you just need to write your own instance. The thing that makes me suspicious of this logic is the absense of an instance for tuples. Surely this would be trivial to write, and yet it's not present. If we had instances for a couple of sizes of tuples, it would surely be quite easy to write your own custom instances that just sit on top of this and tuple/untuple your custom values... Any insights here? Could Data Parallel Haskell[1] be useful for you? It was designed for parallel computation, but it includes unboxed arrays, nice list-like syntax and array comprehensions. 1. http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell A light-weight unboxed array variant is: http://code.haskell.org/~sjanssen/storablevector/ I thought it might be more efficient sometimes to split, say Word8 and Double data into two arrays, instead of padding data in order to align a (Word8,Double) record, but this wouldn't fit into the array data structure. As far as I know, ndp (which I linked above) takes exactly this approach. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [GSoC] X Haskell bindings
Hi! I've written a draft proposal for GSoC on XCB Haskell Bindings[1]. I'd appreciate any feedback. Especially I need help with Milestones section. I'm not quite sure how it should look like for such project. 1. http://ro-che.info/docs/xhsb.txt -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [GSoC] X Haskell bindings
* Adam Langley [EMAIL PROTECTED] [2008-03-31 11:29:57-0700] 2008/3/31 Roman Cheplyaka [EMAIL PROTECTED]: Especially I need help with Milestones section. I'm not quite sure how it should look like for such project. This would seem to be a commendable SoC project. I'm not sure that the milestones are all that important - no plan ever survives contact with reality. However, I'd suggest that these would be important aspects: * A working parser for the XCB (this involves choosing an XML parser and getting useful data structures from it) * A working Haskell code generator which outputs bindings for a minimal subset of the functions (the last two need not be in Haskell, although I suspect that it would be a good idea for them to be so) * The first, minimal, Haskell X client using XCB * Having sensible bindings for 25%/50%/75% and 100% of the XCB interface. Thanks, Adam! Your suggestions will help me a lot. -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] QuickCheck: outdated manual
Online QC manual[1] says[2] that 'vector' takes number of elements and generator, while in QuickCheck-1.1.0.0 it takes only number and generates vector of arbitrary's. Please fix that. By the way, I find the old version as useful as the new one. Although both are trivially implemented, I don't see any reason of why one is included and the other is not. Does anyone? 1. http://www.cs.chalmers.se/~rjmh/QuickCheck/manual.html 2. http://www.cs.chalmers.se/~rjmh/QuickCheck/manual_body.html#17 -- Roman I. Cheplyaka :: http://ro-che.info/ ...being in love is totally punk rock... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monotype error
* Martijn van Steenbergen mart...@van.steenbergen.nl [2009-10-14 20:35:06+0200] Dear café, {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ImpredicativeTypes #-} type Void = forall a. a newtype Mono a = Mono { runMono :: [Void] } beep :: Mono a - Mono a beep (Mono vs) = Mono (map undefined vs) Compiling this with GHC results in: Monotype.hs:9:28: Cannot match a monotype with `Void' Expected type: Void Inferred type: a What does this error mean and why does the code not compile? It works if you annotate the type of undefined: beep (Mono vs) = Mono (map (undefined :: Void - Void) vs) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announcing the GHC Bug Sweep
Cool, I'm in! (Also inspired by [1]this post by Erik de Castro Lopo) It would be nice to keep track of participants somewhere, so that each of us knows he's not alone :) 1. http://www.mega-nerd.com/erikd/Blog/CodeHacking/DDC/hacking_ddc.html * Simon Marlow marlo...@gmail.com [2009-11-16 16:29:46+] Help us weed the GHC ticket database, and get a warm fuzzy feeling from contributing to Haskell core technology! There are currently ~750 tickets against GHC. Many of them have not been looked at in months or years. Often when I go through old tickets I find easy targets: bugs that have already been fixed, duplicates, bugs that are not reproducible and the submitter has gone away. So the idea we have is this: do an incremental sweep of the whole database, starting from the oldest tickets. Check each one, and try to make some progress on it. If we get enough momentum going we can make sure every ticket gets looked at every few months at the least. This is a game for the whole family! We don't care how much progress you make on each ticket, just as long as someone has taken a look and moved the ticket forward in some way. For example, you might check for duplicates, update the metadata, ask for more information from the submitter, try to reproduce the bug against the latest version of GHC. To claim a ticket all you have to do is remove it from the list on the wiki. Full instructions are here http://hackage.haskell.org/trac/ghc/wiki/BugSweep including a list of suggestions for ways to make progress on a ticket. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Great Programs to Read?
* Don Stewart d...@galois.com [2009-11-30 13:01:11-0800] mlesniak: Hello, In terms of to become a great programmer, you need to read great programs[1] what are great programs written in Haskell (for your personal definition of great), which source code is freely available on hackage or somewhere else on the net? I'm personally also interested in your definitions of great; for me, a great programs is defined by one of * good and well-written documentation (literate Haskell helps a lot) * novel ideas to use functional programming * elegance * showing how functional programming can ease tasks that are difficult to achieve in an imperative style Maybe we should create a Page on haskell.org (which I would do if I had write-access) mirroring the pages [2,3]? It's been reported that xmonad is a good read. Notably, it uses a nested zipper to statically avoid out-of-index errors in the core data structures. Parts of the core have been modelled in Coq too, which is unusual. IMO, xmonad is also an example of a great extension API (just look at the number of third-party contribs) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Memory-aware Haskell?
Imagine some system with hard memory bound (e.g. 64M of physical memory, no swap). I don't want some accidental laziness (maybe even not in my code, but in some used package) to crash my program. So, let's think what we can do at runtime. Suppose RTS takes the parameter -- upper limit of consumed memory. When it sees that memory consumption is close to upper bound, it can: 1. force garbage collection 2. apply some heuristics to find and reduce some chunks which will benefit from reduction in terms of size 3. if nothing helps, throw an exeption. It can be caught in IO and memory-aware program can make apropriate decision -- e.g. abort opening a large file and gracefully warn the user. (And there still is a problem of foreign code whose memory consumption we know nothing about...) What do you think? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
* Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] On Sun, Feb 21, 2010 at 1:58 PM, Artyom Kazak artyom.ka...@gmail.com wrote: So, if I type ./prog +RTS --RTS +RTS, the output will be +RTS. But I want the output to be equal to the input IN ALL CASES, without any quotes, additional options, etc. I want all the command line to go to my program. How can I do it? (The only way I know now - hacking the GHC. If there are no other ways, I'll do it.) How about a wrapper script? Something like, #! /usr/bin/env bash ./prog --RTS $* Just use that as the front-end to your Haskell program. If you want Haskell program to get exactly the same arguments that were passed to the wrapper, use ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
* Brandon S. Allbery KF8NH allb...@ece.cmu.edu [2010-02-24 00:02:12-0500] On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+$@} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. Are you referring to some Solaris shell bug? Under POSIX these constructs seem to be equivalent. If there are no positional parameters, the expansion of '@' shall generate zero fields, even when '@' is double-quoted. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC RTS question
* Artyom Kazak artyom.ka...@gmail.com [2010-02-24 10:23:07+0200] 2010/2/24 Brandon S. Allbery KF8NH allb...@ece.cmu.edu: On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+$@} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. And with Windows, of course :) Haskell is cross-platform, isn't it? Haskell is a language, it does not have any notion of platform. It has several implementations, which may or may not be cross-platform. (OP asked specifically about ghc, which supports a number of platforms, including Windows.) Here we talk not about ghc itself, but about POSIX shell interpreter, which is available on every POSIX-compliant operating system. Windows (out of the box) lacks implementation of POSIX shell. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [offtopic] UNIX Shell (was: GHC RTS question)
* Magnus Therning mag...@therning.org [2010-02-24 09:11:54+] On Wed, Feb 24, 2010 at 07:18, Roman Cheplyaka r...@ro-che.info wrote: * Brandon S. Allbery KF8NH allb...@ece.cmu.edu [2010-02-24 00:02:12-0500] On Feb 22, 2010, at 03:36 , Roman Cheplyaka wrote: * Anthony Cowley acow...@seas.upenn.edu [2010-02-21 14:15:00-0500] #! /usr/bin/env bash ./prog --RTS $* ./prog --RTS $@ Otherwise it will work wrong if arguments contain quoted field separators (e.g. spaces). #! /bin/sh ./prog --RTS ${1+$@} The longer specification above should work with whatever /bin/sh is around, whether it's Solaris /sbin/sh, FreeBSD's sh, general Linux bash, Debian/Ubuntu dash, etc. Are you referring to some Solaris shell bug? Under POSIX these constructs seem to be equivalent. If there are no positional parameters, the expansion of '@' shall generate zero fields, even when '@' is double-quoted. I believe he's referring to the following bit (taken from bash's man page): @ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, $@ is equivalent to $1 $2 ... If the double-quoted expansion occurs within a word, the expansion of the first parameter is joined with the beginning part of the original word, and the expansion of the last parameter is joined with the last part of the original word. When there are no positional parameters, $@ and $@ expand to nothing (i.e., they are removed). Well, this agrees with POSIX. So still I don't see the difference between $@ and ${1+$@}. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ParsecT bug [was: ANNOUNCE: Parsec 3.1.0]
By coincidence, today I found a bug in the parsec 3.0.[01]. Probably due to changes introduced the bug is absent in parsec 3.1.0. I think it is worth to release 3.0.2 with this bug fixed. The bug itself is demonstrated in the following code. It gives Right (False,True) with parsec-3.0.x while should be giving Right (False,False). And, by the way, does parsec have any code repository and/or bug tracker? import Text.Parsec hiding (parse) import Control.Monad.Reader type Parser = ParsecT String () (Reader Bool) change :: Parser a - Parser a change p = local (const False) p p = change $ do was - ask anyChar now - ask return (was,now) parse :: Parser a - SourceName - String - Either ParseError a parse p name s = runReader (runPT p () name s) True main = print $ parse p a * Derek Elkins derek.a.elk...@gmail.com [2010-03-03 22:45:12-0600] Changes: - the changes to the core of Parsec lead to some changes to when things get executed when it is used as a monad transformer In the new version bind, return and mplus no longer run in the inner monad, so if the inner monad was side-effecting for these actions the behavior of existing code will change. - notFollowedBy p now behaves like notFollowedBy (try p) which changes the behavior slightly when p consumes input, though the behavior should be more natural now. - the set of names exported from Text.Parsec.Prim has changed somewhat -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unified Haskell login
* Michael Snoyman mich...@snoyman.com [2010-09-17 08:47:02+0200] * OpenID. Fixes the extra password problem, but doesn't give us any extra information about the user (email address, etc). This is a popular misconception. As was noted on this thread, many OpenID provideers may provide you an email or other information if you asked for it and user had supplied it. But even if not, nothing actually prevents you from *just asking the user* for the email if you need it. See stackoverflow for an example when you authenticate yourself and then can supply more information about yourself. These things are simply unrelated. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskellers.com recent changes (and I need some volunteers)
On Mon, 11 Oct 2010 11:54:12 +0100, Magnus Therning mag...@therning.org wrote: On Mon, Oct 11, 2010 at 08:37, Michael Snoyman mich...@snoyman.com wrote: [...] Also, now 10 random profiles will be displayed on the homepage. Only verified users will be displayed here. I'm also considering adding a new status as well: real picture, so that only people with real images (not cartoons, not identicons) can show up on the homepage. I think this might give a more professional feel. Thoughts? I'd be weary of making that a requirement, there are good reasons for not putting your picture on the web, just like there are good reasons to not use your real name :-) ... just like there are good reasons not to publish yourself in a public catalogue (such as haskellers.com) at all. I have nothing against anonymity. I voted against requirement of real names on hackage. But in this particular case, the whole point to be in the listing is to present yourself. So I find the above proposal very reasonable. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskellers.com recent changes (and I need some volunteers)
On Mon, 11 Oct 2010 13:09:00 +0200, Vo Minh Thu not...@gmail.com wrote: 2010/10/11 Roman Cheplyaka r...@ro-che.info: On Mon, 11 Oct 2010 11:54:12 +0100, Magnus Therning mag...@therning.org wrote: On Mon, Oct 11, 2010 at 08:37, Michael Snoyman mich...@snoyman.com wrote: [...] Also, now 10 random profiles will be displayed on the homepage. Only verified users will be displayed here. I'm also considering adding a new status as well: real picture, so that only people with real images (not cartoons, not identicons) can show up on the homepage. I think this might give a more professional feel. Thoughts? I'd be weary of making that a requirement, there are good reasons for not putting your picture on the web, just like there are good reasons to not use your real name :-) ... just like there are good reasons not to publish yourself in a public catalogue (such as haskellers.com) at all. I have nothing against anonymity. I voted against requirement of real names on hackage. But in this particular case, the whole point to be in the listing is to present yourself. So I find the above proposal very reasonable. Hi, In the belgian law, an employer can (of course) request a faithful resume, but cannot request the resume to contain a picture of you. This is a clear example where you wish to advertise yourself, but not necessarily with a picture. Anyway, I don't think it is difficult to imagine situations where one doesn't wish to show a picture of his/her face. Agree. But then there should be no picture at all for a given person. As Michael said -- no cartoons, no identicons. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskellers.com recent changes (and I need some volunteers)
On Mon, 11 Oct 2010 13:14:21 +0100, John Lato jwl...@gmail.com wrote: From: Michael Snoyman mich...@snoyman.com Also, now 10 random profiles will be displayed on the homepage. Only verified users will be displayed here. I'm also considering adding a new status as well: real picture, so that only people with real images (not cartoons, not identicons) can show up on the homepage. I think this might give a more professional feel. Thoughts? I agree that it would be nice to use only real pictures, however I wouldn't want to leave out those who choose not to use any image at all. What about a site policy that user images must be real pictures (if they exist), and violations can be flagged/blocked? Although, I don't know how this would interact with using OpenID, which appears to be most of the users currently displaying an identicon. This is Gravatar's issue, which has little to do with OpenID, as far as I understand. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsec in Haskell platform
Since Parsec 2 and Parsec 3 are usually considered to be different packages, it's ambiguous to say that 'parsec' is included in Haskell Platform [1]. Could someone please: 1. Clarify which version(s) are included? 2. Fix the page [1] It would be convenient to have a page which would list all the HP packages with their versions. The release page [2] only has a list of packages whose versions has changed since the last release, as I understood. [1] http://hackage.haskell.org/platform/contents.html [2] http://hackage.haskell.org/platform/changelog.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monads and Functions sequence and sequence_
* Mark Spezzano mark.spezz...@chariot.net.au [2010-10-30 15:37:30+1030] Can somebody please explain exactly how the monad functions sequence and sequence_ are meant to work? The others in this thread have already explained how these functions work, so I'll just give an example how they are used. Consider the following task: to read 30 lines from standard input. For one line you would use an action getLine :: IO String How to execute this 30 times? Haskell has a function replicate :: Int - a - [a] which takes a number and produces a list with that number of identical elements. So this is close to what we need: replicate 30 getLine :: [IO String] This is a list containing 30 'getLine' actions. But the list of actions _is not_ an action itself. This is what sequence does -- it transforms a list of actions into a single action which gathers the results into one list. As its name suggests, it does sequencing of actions. sequence $ replicate 30 getLine :: IO [String] Exactly what we need, an action producing a list of lines read. Now, let's consider this code: sequence [ putStrLn $ show i ++ green bottles standing on the wall | i - reverse [1..10] ] :: IO [()] This action prints 10 lines and also returns us gathered results, i.e. 10 '()', one from each putStrLn (recall that putStrLn has type String - IO (). Most probably we don't care about those '()', but they still occupy memory and introduce a space leak as explained here[1]. That's why a version of sequence is introduced which ignores the results of actions and simply returns (). It is called sequence_. sequence_ :: (Monad m) = [m a] - m () As a side note, we can rewrite our last example without using list comprehension in the following way: let p i = putStrLn $ show i ++ green bottles standing on the wall in sequence_ $ map p $ reverse [1..10] The combinations of sequence and sequence_ with map are so common that they have special names: mapM = \f - sequence . map f :: (Monad m) = (a - m b) - [a] - m [b] mapM_ = \f - sequence_ . map f :: (Monad m) = (a - m b) - [a] - m () [1] http://neilmitchell.blogspot.com/2008/12/mapm-mapm-and-monadic-statements.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Who's in charge of the new Haskell.org server?
* Thomas Schilling nomin...@googlemail.com [2010-12-01 20:29:48+] On 1 December 2010 18:55, Christopher Done chrisd...@googlemail.com wrote: I think adding new extensions would be possible if they are considered useful enough. I find it useful, especially for (potential) newcomers who don't yet have enough motivation to install ghc. It would be convenient for others too. And it would impress! Running Haskell code has some security implications, so that'll require a good argument for why it's safe. I think Christopher proposed using tryhaskell.org as a service providing evaluation (I make this conclusion from If tryhaskell.org ever goes down the script can just fall back to displaying code.) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] $ do?
* Jonathan Geddes geddes.jonat...@gmail.com [2010-12-14 19:59:14-0700] Quick question: Why do I need the $ in the following bits of code? main = withSocketsDo $ do --do something with sockets foo = fromMaybe 0 $ do --do something in the maybe monad I don't see (after admittedly only a minute or so thinking about it) where any grammar ambiguities would be if 'do' had an implicit $ in front of it: foo = fromMaybe 0 do --do something in maybe Though now that I've written it down, that is hard for me to visually parse at a glance. I'm still curious though. Hi Jonathan, it's not clear whether you ask how this implies from the standard or what the rationale of such syntax is. Regarding the former, there are two distinct syntactic categories in Haskell: lexp and aexp. aexp produces all the constructs that can be used as function arguments and does not include do expressions. lexp is more broad and produces do expressions as well. Next look at these productions to see the difference between function application and operator application (sections 3.3 and 3.4 of 2010 report): fexp→ [fexp] aexp infixexp → lexp qop infixexp Regarding the rationale, I'm not so sure and I'd like to hear an explanation from someone competent. But I assume it has something to do with the fact that if you supply a 'do' argument, you cannot supply any more arguments (because 'do' extends to the right as far as possible). Not that I'm convinced that it is a valid reason to prohibit such construct. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] DFAs and self-referential data
* Maxime Henrion mhenr...@gmail.com [2010-12-26 12:01:31+0100] Anyone knows what I'm doing wrong here? I suspect my attempt at having self-referential data is somehow buggy; do I need to treat transitions to the same state differently? The problem is that when you call 'self', you record *that* state of your DFA in the map. When DFA gets updated further, the recorded self-reference is not updated appropriately. In your case a workaround is to call 'self' after all the other updates, i.e. test :: String - Bool test = accept s1 where s1 = self '1' . path '0' s2 $ empty True s2 = self '1' . path '0' s1 $ empty False But I don't see why you need 'self' at all -- you can just use path as with any other type of transition: test :: String - Bool test = accept s1 where s1 = path '0' s2 . path '1' s1 $ empty True s2 = path '0' s1 . path '1' s2 $ empty False -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc -O2 and HUnit weirdness
* Jürgen Doser jurgen.do...@gmail.com [2011-01-07 00:18:09+0100] El jue, 06-01-2011 a las 16:41 -0400, Joey Hess escribió: So, the problem seems to be that ghc -O2 somehow optimises the static assertBool _ True away, in what seems to be a bad way. Remove the -O2 and the test fails as expected. Presumably, although I have not verified, less static boolean values would not trigger the optimisation. Is this a ghc or HUnit bug? (Versions: 6.12.1, 1.2.2.1) Looks like a GHC bug. Works with -fno-state-hack. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc -O2 and HUnit weirdness
* Roman Cheplyaka r...@ro-che.info [2011-01-07 01:42:24+0200] * Jürgen Doser jurgen.do...@gmail.com [2011-01-07 00:18:09+0100] El jue, 06-01-2011 a las 16:41 -0400, Joey Hess escribió: So, the problem seems to be that ghc -O2 somehow optimises the static assertBool _ True away, in what seems to be a bad way. Remove the -O2 and the test fails as expected. Presumably, although I have not verified, less static boolean values would not trigger the optimisation. Is this a ghc or HUnit bug? (Versions: 6.12.1, 1.2.2.1) Looks like a GHC bug. Works with -fno-state-hack. Here's a particular quote from the GHC source [1] Technically, this isn't quite right, because (f True) `seq` 1 should diverge, but it'll converge if we eta-expand f. Nevertheless, we do so; it improves some programs significantly, and increasing convergence isn't a bad thing. As it turns out in the case of HUnit, it may be a bad thing. [1]: http://www.haskell.org/ghc/docs/6.12.3/html/libraries/ghc-6.12.3/src/CoreArity.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generalizing catMaybes
* Tony Morris tonymor...@gmail.com [2011-01-08 12:56:28+1000] I am wondering if it possible to generalise catMaybes: (Something f, SomethingElse t) = t (f a) - t a I have being doing some gymnastics with Traversable and Foldable and a couple of other things from category-extras to no avail. Perhaps someone else's brain is molded into an appropriate shape to reveal an answer! For example, import Control.Applicative import Data.Foldable as F import Control.Monad.Writer cat' :: (Applicative list, Foldable list, Monoid (list a), Foldable maybe) = list (maybe a) - list a cat' = fold . fmap (execWriter . F.mapM_ (\x - tell (pure x))) However, this looks rather useless -- there are probably not many containers which can be substituted instead of 'list'. I think catMaybes deserves its own typeclass, which would represent truncatable structures: class Truncatable struct where catMaybes :: struct (Maybe a) - Maybe a This would make perfect sense for Set, Map etc. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generalizing catMaybes
* Henning Thielemann lemm...@henning-thielemann.de [2011-01-08 12:06:33+0100] On Sat, 8 Jan 2011, Roman Cheplyaka wrote: I think catMaybes deserves its own typeclass, which would represent truncatable structures: class Truncatable struct where catMaybes :: struct (Maybe a) - Maybe a But catMaybes has the type catMaybes :: struct (Maybe a) - struct a for struct = [] Thanks, that was a typo. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't worry what people think, they don't do it very often. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [] == []
* Paul Keir pk...@dcs.gla.ac.uk [2009-05-29 10:47:26+0100] Hi all, GHC is not happy with this: f = [] == [] nor this: f' = ([]::(Eq a) = [a]) == ([]::(Eq a) = [a]) Here, there's no guarantee that the answer will be the same independent of what 'a' you choose. Potentially, you could define different instances [Int] and [Bool] for Eq, so that [] == [] = True for [Int] but [] == [] = False for [Bool]. Actually, instance Eq [a] is defined parametrically on 'a', which implies that equality of lists depends only on equality of underlying types, therefore [] == [] should be constant, but compiler doesn't use this information. If you just want to test a list for emptyness, use 'null'. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?
* Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 17:30:33+0800] Hi, I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by cabal, but my program needs it, and I want my program cabalized. So how to do this? Thanks. gtk2hs consists of several cabal packages, e.g. gtk, glib and so on. (See `ghc-pkg list`) Specify those of them you need as dependencies in cabal file. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
* Deniz Dogan deniz.a.m.do...@gmail.com [2009-06-13 16:17:57+0200] I remember needing a non-strict sum at least once, but I do not remember the exact application. We may agree that lazy sum is sometimes (rarely) needed, but then it can be always written as fold. However, in most cases user wants strict sum. So it's not really an excuse. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?
* Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 18:48:26+0800] My gtk2hs is install manually, `configure make make install`. So It's okay. when I add gtk to build-dependency, it tells me Setup.hs: At least the following dependencies are missing: gtk -any Installation of gtk2hs registers these packages for you. Again, check `ghc-pkg list gtk`. If you installed gtk2hs, it must be there. If you, say, upgraded your ghc after you installed gtk2hs, you have to reinstall gtk2hs. How to register my manual-installed gtk2hs to cabal? On Sun, Jun 14, 2009 at 6:25 PM, Roman Cheplyakar...@ro-che.info wrote: * Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 17:30:33+0800] Hi, I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by cabal, but my program needs it, and I want my program cabalized. So how to do this? Thanks. gtk2hs consists of several cabal packages, e.g. gtk, glib and so on. (See `ghc-pkg list`) Specify those of them you need as dependencies in cabal file. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- 竹密岂妨流水过 山高哪阻野云飞 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [cabal] How to deal with build-depency that not under cabal's control?
I'm CC:ing Duncan, probably he can help. * Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-15 10:01:03+0800] # ghc-pkg list gtk /var/lib/ghc-6.10.3/./package.conf: /home/shidaw/.ghc/i386-linux-6.10.3/package.conf: gtk-0.10.1 Well, still, I have the problem On Sun, Jun 14, 2009 at 6:52 PM, Roman Cheplyakar...@ro-che.info wrote: * Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 18:48:26+0800] My gtk2hs is install manually, `configure make make install`. So It's okay. when I add gtk to build-dependency, it tells me Setup.hs: At least the following dependencies are missing: gtk -any Installation of gtk2hs registers these packages for you. Again, check `ghc-pkg list gtk`. If you installed gtk2hs, it must be there. If you, say, upgraded your ghc after you installed gtk2hs, you have to reinstall gtk2hs. How to register my manual-installed gtk2hs to cabal? On Sun, Jun 14, 2009 at 6:25 PM, Roman Cheplyakar...@ro-che.info wrote: * Magicloud Magiclouds magicloud.magiclo...@gmail.com [2009-06-14 17:30:33+0800] Hi, I use gtk2hs in linux. Well, I have no idea how to install gtk2hs by cabal, but my program needs it, and I want my program cabalized. So how to do this? Thanks. gtk2hs consists of several cabal packages, e.g. gtk, glib and so on. (See `ghc-pkg list`) Specify those of them you need as dependencies in cabal file. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- 竹密岂妨流水过 山高哪阻野云飞 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain -- 竹密岂妨流水过 山高哪阻野云飞 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type families and polymorphism
* Brandon S. Allbery KF8NH allb...@ece.cmu.edu [2009-07-11 17:01:35-0400] On Jul 11, 2009, at 14:31 , Jeremy Yallop wrote: Why does compiling the following program give an error? {-# LANGUAGE TypeFamilies, RankNTypes #-} type family TF a identity :: (forall a. TF a) - (forall a. TF a) identity x = x The scope of each a is the surrounding parentheses, so the de facto type is TF a - TF b. Or, put otherwise, you're saying that for *any* type (TF a) No, for any (forall a. TF a), which should make the difference. you can produce *any* type (TF a) (because of the delimited forall-s), but then the code asserts that they are the same type. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: tkhs-0.1.* Presentation Utility
* Yusaku Hashimoto nonow...@gmail.com [2009-07-31 22:56:57+0900] Hi, I'm pleased to announce the release of tkhs-0.1.*, Simple presentation utility. If you are thinking PowerPoint is overkill for your presentation, Tkhs may fit the purpose. For real presentations one would probably use beamer or similar, but this tool indeed might be useful occasionally -- e.g. as notes for himself when talking about something. Thanks! -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Would you mind explain such a code ?
* zaxis z_a...@163.com [2009-09-10 00:51:21-0700] thanks for your quick answer! As I understand foldr (\x g - g . (`f`x)) id xs will return a function such as (`f` 3).(`f` 2).(`f` 1) . You have already made it clear ! However, why does the step function below has three parameters ? I think foldr will call step using two parameters, the 1st is list element and the 2nd is a funtion whose initial value is id). That's right. step x g a = g (f a x) is, thanks to currying, another way to write step x g = \a - g (f a x) This is what we want -- function of two arguments, which returns a new value of accumulator (which in this case is a function itself). And g (f a x) can be rewritten as g ((f a) x) = g (a `f` x) = g ((`f` x) a) = (g . (`f` x)) a, thus step x g = \a - g (f a x) = \a - (g . (`f` x)) a = g . (`f` x) (the last step is called 'eta-reduction'). Remember that g is a previous value of accumulator and step x g is its new value, so on each step we compose accumulator with (`f` x) to get the new value. So in the end it will look like you wrote above. myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) staafmeister wrote: zaxis wrote: myFoldl :: (a - b - a) - a - [b] - a myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) I know myFoldl implements foldl using foldr. However i really donot know how it can do it ? Please shed a light one me, thanks! Hi, Nice example! Well this is indeed an abstract piece of code. But basically foldl f z xs starts with z and keeps applying (`f`x) to it so for example foldl f z [1,2,3] = ((`f`3).(`f`2).(`f`1)) z Because functions are first-class in haskell, we can also perform a foldl where instead of calculating the intermediate values we calculate the total function, i.e. ((`f`3).(`f`2).(`f`1)) and apply it to z. When the list is empty z goes to z, so the start function must be id. So we can write (`f`3).(`f`2).(`f`1) = foldr (\x g - g . (`f`x)) id xs This is almost in your form. Hope this helps, Gerben -- View this message in context: http://www.nabble.com/Would-you-mind-explain-such-a-code---tp25377949p25378882.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 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Would you mind explain such a code ?
* Peter Verswyvelen bugf...@gmail.com [2009-09-10 14:43:10+0200] On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka r...@ro-che.info wrote: step x g a = g (f a x) is, thanks to currying, another way to write step x g = \a - g (f a x) I thought currying just meant curry f x y = f (x,y) Here you use 'currying' meaning the process of applying the 'curry' operation, i.e. transforming 'uncurried' function to a 'curried' one. (BTW, Wikipedia agrees with you.) Isn't the reason that f x y z = body is the same as f = \x - \y - \z - body just cause the former is syntactic sugar of the latter? Technically, yes. Generally speaking, currying is the idea of interchangeability of the function which takes several arguments and the function which returns another function (i.e. what is used here). -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] adding state in GUIs (qtHaskell)
* Duncan Coutts duncan.cou...@worc.ox.ac.uk [2009-09-10 20:43:54+] A personal favourite of mine is having the GUI event handler post data over a channel to a thread. That thread reads from the channel and deals with the events. The state of the GUI app is then held as local parameters in that thread. Doing this of course requires that the GUI lib you're using can cope with normal Haskell (forkIO) threads. This is possible with gtk2hs, I don't know about the others. I also would be happy to see some code. Recently I need to write a small app in gtk2hs which had to deal with state. I used Reader monad with IORef's in it, but got tired of mixing code in different monads. (It would help, btw, if gtk2hs functions were not in IO, but in MonadIO). So I'm curious how 'gtk2hs app done right' looks like. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: interval and polynomial enclosure arithmetics
* Michal Konecny [EMAIL PROTECTED] [2008-08-08 13:38:56+0100] and members of the KEG research group at Aston University have used it for reliably solving differential equations and numerical constraint satisfaction problems. This's very interesting. Do you have any published papers (or other sources of information) about it? -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: gsl-random 0.1 and monte-carlo-0.1
* Patrick Perry [EMAIL PROTECTED] [2008-08-28 04:24:21-0700] Hi everyone, I've started on bindings for the random number generators and random distributions provided by the gsl. The package is available here: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/gsl-random I've also written a monad and transformer for doing monte carlo computations that uses gsl-random internally. Here is that package: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/monte-carlo For a quick tutorial in the latter package, see my blog: http://quantile95.com/2008/08/27/a-monte-carlo-monad-for-haskell/ Should be http://quantile95.com/2008/08/26/a-monte-carlo-monad-for-haskell/ There is also a more complicated example in the examples directory. Currently, only normal, uniform, and poisson random variables are supported. I have no plans to add anything else unless I need it, but I will happily accept patches if someone else is willing to do the work. One thing you may need to watch out for is that gsl-random needs to link with cblas. If your cblas is not called cblas, you may have to edit gsl-random.cabal to get things to work correctly. To use the cblas that comes with the gsl, change cblas to gslcblas. To use ATLAS, change cblas to cblas atlas. Patrick ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Named field syntax
* Johannes Waldmann [EMAIL PROTECTED] [2008-08-29 15:39:15+0200] data Test = Test Integer {b::String} positional (= unnamed) record notation is a language design error :-) and its use should be discouraged. - J.W. Polluting namespace with unneeded functions should not be encouraged either. Consider for instance defining datatype for 3x3 matrix. Would the absence of unnamed record notation make you more happy? -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] OpenSPARC project applicant chosen
* Duncan Coutts [EMAIL PROTECTED] [2008-09-20 16:37:08+0100] If you want to follow the progress we will be using the existing ghc development mailing list: http://www.haskell.org/mailman/listinfo/cvs-ghc and a corner of the ghc development wiki: http://hackage.haskell.org/trac/ghc/wiki/OpenSPARC I hope Brent also will be publishing the news of the project in HWN. -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Injecting Haskell into C
I have a C function whose behaviour is customized by user-supplied function (think of libc qsort). Typically these user-supplied functions are written in C, but I'd like to use FFI to write them in Haskell. Precisely, I'd like to write high-order function which will generate these functions (e.g. mkCompare :: ... - (Ptr a - Ptr a - Int) for feeding the result to qsort). As I understand, there are two ways to do that. Either Haskell code is called from C, or C code is called for Haskell. So my questions are: 1. Are they both possible? 2. If yes, which is better performance-wise? (C function is performance-critical). If generated function is called many times, how big an overhead is going to be? -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Physics engines purely in Haskell?
* Mark Wassell [EMAIL PROTECTED] [2008-11-09 10:51:55+1100] Has anyone thought about or embarked on the task of developing a 2D or 3D physics engine purely in Haskell? There is Hipmunk but I'm wondering about a purely Haskell implementation; possibly a port of Chipmunk to Haskell. As Don said, there is a physics engine called Hpysics. There are still some issues to be solved, but if you're interested in using it, please drop me a line! -- Roman I. Cheplyaka :: http://ro-che.info/ kzm: My program contains a bug. How ungrateful, after all I've done for it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell haikus
* Gwern Branwen [EMAIL PROTECTED] [2008-12-05 18:18:48-0500] Hi everyone. So today I finally got around to something long on my todo list - a compilation of all the Haskell haikus I've seen around! It is at http://haskell.org/haskellwiki/Haiku But I'm afraid I only have 5, and Google doesn't turn up any more. So: does anybody have a haiku I missed? Or even better, is anyone feeling poetically inspired tonight? :) IIRC, Wouter Swierstra wrote some haikus for Summer of Code issue of The Monad Reader _last year_. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Pragmas (was: ANNOUNCE: haskell-src-exts 0.4.4)
* Neil Mitchell [EMAIL PROTECTED] [2008-12-08 08:29:03+] Apart from this, HSE now also parses any unrecognized pragma in option (e.g. LANGUAGE), declaration (e.g. RULES) or expression (e.g. SCC) position, allowing user-customized pragmas. Unrecognized pragmas in other positions will (unfortunately) give a parse error. If this ever means a problem for you - let me know! This is likely to be a problem for me :-) I certainly have OPTIONS_DERIVE and CATCH pragmas that I've inserted into various programs over time. I think failing on an unrecognised pragma is probably a bad idea, when ignoring a pragma is usually perfectly safe. Even more, An implementation is not required to respect any pragma, but the pragma should be ignored if an implementation is not prepared to handle it.[1] Related question: why does not Language.Haskell.Syntax[2] (from haskell-src) represent comments or pragmas in any way? 1. http://www.haskell.org/onlinereport/pragmas.html 2. http://www.haskell.org/ghc/docs/latest/html/libraries/haskell-src/Language-Haskell-Syntax.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function composition
* Oscar Picasso oscarpica...@gmail.com [2008-12-26 22:37:26-0500] Hi, I can write: *Main let yes = not . not *Main :t yes yes :: Bool - Bool But not: *Main let isNotEqual = not . (==) interactive:1:23: Couldn't match expected type `Bool' against inferred type `a - Bool' Probable cause: `==' is applied to too few arguments In the second argument of `(.)', namely `(==)' In the expression: not . (==) Why? You might want to read about currying[1]. This will explain why (==) does not take a pair of values, it rather takes one value and then another, and that's why it is not composable in the way you want. What you're trying to do is easier to do with uncurried functions: Prelude let isNotEqual = not . uncurry (==) Prelude :t isNotEqual isNotEqual :: (Eq a) = (a, a) - Bool Prelude isNotEqual (3,4) True Prelude isNotEqual (3,3) False (note that -XNoMonomorphismRestriction is used here) 1. http://www.haskell.org/haskellwiki/Currying -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Function composition
* Roman Cheplyaka r...@ro-che.info [2008-12-27 11:33:22+0200] * Oscar Picasso oscarpica...@gmail.com [2008-12-26 22:37:26-0500] Hi, I can write: *Main let yes = not . not *Main :t yes yes :: Bool - Bool But not: *Main let isNotEqual = not . (==) interactive:1:23: Couldn't match expected type `Bool' against inferred type `a - Bool' Probable cause: `==' is applied to too few arguments In the second argument of `(.)', namely `(==)' In the expression: not . (==) Why? You might want to read about currying[1]. This will explain why (==) does not take a pair of values, it rather takes one value and then another, and that's why it is not composable in the way you want. What you're trying to do is easier to do with uncurried functions: Prelude let isNotEqual = not . uncurry (==) Prelude :t isNotEqual isNotEqual :: (Eq a) = (a, a) - Bool Prelude isNotEqual (3,4) True Prelude isNotEqual (3,3) False (note that -XNoMonomorphismRestriction is used here) 1. http://www.haskell.org/haskellwiki/Currying ... and isNotEqual = curry $ not . uncurry (==) is curried version, which has type isNotEqual :: (Eq b) = b - b - Bool -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] bug in HPDF?
Here is a program which illustrates an unexpected behaviour: import Graphics.PDF main = runPdf bug.pdf standardDocInfo (PDFRect 0 0 100 100) pdf where pdf = do p - addPage Nothing drawWithPage p $ drawText $ sequence $ replicate 10 $ text (PDFFont Helvetica 10) 10 10 (toPDFString ABC) What I expect here is ABC printed 10 times on the same place (starting at (10,10)). What I see (in Okular) is ABC printed each time in the new place like this: ABC ABC ABC ABC What's happening here? I'm using HPDF-1.4.1 from Hackage. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell] ANN: ghci-haskeline 0.1
* Andrew Hunter ahun...@cs.hmc.edu [2009-01-12 13:41:03-0800] On Mon, Jan 12, 2009 at 12:57:57PM -0800, Judah Jacobson wrote: I'm pleased to announce the first release of ghci-haskeline. This package uses the GHC API to reimplement ghci with the Haskeline library as a backend. Haskeline is a library for line input in command-line programs, similar to readline or editline, which is written in Haskell and thus (hopefully) more easily integrated into other Haskell programs. Perhaps this has already been discussed at length, in which case I apologize but, well, why provide line input editing at all? A number of languages/programs (off the top of my head: sml, most Schemes) don't; the standard method to get line editing is rlwrap. And this works (in my limited experience) quite well. The disadvantage as I see it of using editline or Haskeline or whatever is that it's going to be sutbly different than other methods; presumably, people won't like the changes in behavior. It seems to me that from a UNIX-y separation of concern view, the right thing to do (as many languages have chosen) is to /not/ provide line editing, and just let the user do that with any number of convenient tools that focus on getting/that/ right (like rlwrap.) Is there a reason we've not taken that approach? For example, ghci does more intelligent completion than rlwrap probably can do: Xtab - no matches :m Xtab - XMonad -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell WikiProject
* Robin Green gree...@greenrd.org [2009-01-19 18:46:43+] Here's a good example to start with. The article on Eager evaluation could do with some improvement - and possibly should be merged into the Lazy evaluation article, I'm not sure: http://en.wikipedia.org/wiki/Eager_evaluation I was also disappointed with the article on Typed lambda calculus (compare it with the article on (untyped) Lambda calculus). http://en.wikipedia.org/wiki/Typed_lambda_calculus http://en.wikipedia.org/wiki/Lambda_calculus -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to define an operation in terms of itself (but of different type)?
* Olex P hoknam...@gmail.com [2009-01-24 15:35:22+] But you know it doesn't make too much sense because I also have to define addition Scalar + Vector (that means construct vector from scalar and add a vector), Vector + Scalar and so on. And as we are not able to overload operations in C++ like way we have to create several different operations even if their meaning is pretty close. Probably it's possible with ad hoc overloading but I don't know is it good idea. Consider defining functions with meaningful names (like scalarPlusVector), you then can use them as infix operators: 5 `scalarPlusVector` Vector 1 2 3 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Define variable types
* Tsunkiet Man temp.t...@gmail.com [2009-02-05 12:37:22+0100] Hello, I'm new to Haskell and it seems like a very nice language to learn. However I'm not really familiar with the errormessages it produces. I am using a Helium interpreter. I've created the following module (however it is just a small sketch). I've written the following code: fac :: Int - Int fac n = product[1..n] boven :: Int - Int - Int boven n k = (fac n) `div` fac k * fac (n-k) bin :: Int - Int - Int - Int bin n k p |(n-k)0 k0 = (boven n k) * (p^k) * (1-p)^(n-k) |(n-k)0 k0 = (boven n k) * (p^k) * (1/((1-p)^(-(n-k |(n-k)0 k0 = (boven n k) * (1/(p^(-k))) * (1/((1-p)^(-(n-k When I load this into my interpreter it says: Compiling ./Test.hs (11,55): Type error in infix application expression : 1 / ((1 - p) ^ (-(n - k))) operator : / type : Float - Float - Float does not match : Int - Int - Int (12,47): Type error in infix application expression : 1 / (p ^ (-k)) operator : / type : Float - Float - Float does not match : Int - Int - a (12,62): Type error in infix application expression : 1 / ((1 - p) ^ (-(n - k))) operator : / type : Float - Float - Float does not match : Int - Int - a You can't use fractional division (/) with integers. You can convert integers to fractions using fromIntegral. E.g.: 1 / fromIntegral ((1 - p) ^ (-(n - k))) (literals like 1 doesn't need to be converted because they are polymorphic) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] evaluation semantics of bind
* Gregg Reynolds d...@mobileink.com [2009-02-05 09:20:06-0600] I think I've just about got monads figured out, but there's one detail that still escapes me. As I understand it, a monad is a kind of programming trick the uses data dependency to force evaluation order. x = f means apply f to x; since the value of f x depends on the value of x, the evaluator must evaluate x before f x. However, consider: getChar = \x - getChar An optimizer can see that the result of the first getChar is discarded and replace the entire expression with one getChar without changing the formal semantics. But that would change the behavior, so to get the desired behavior, there must be some principle that prevents this from happening, ensuring that x = f always evaluates f x. x = f doesn't mean apply f to x. It means, roughly, construct (IO) action from actions x and f(..), so that they are executed sequentially and f depends on a resuls produced by x. Even if f does not depend on its argument, there's no reason for compiler to think that the first action may be ignored. If you think in terms of dependency, the second action depends on the state of the world left after executing x. So all IO actions take an implicit world argument and (=) operator implicitely passes modified world to the next action. I can see that the monad laws ensure this But I haven't found anything that states this. Am I missing something? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Switching from Mercurial to Darcs
* Peter Verswyvelen bugf...@gmail.com [2009-02-05 16:35:34+0100] On Thu, Feb 5, 2009 at 4:32 PM, Ketil Malde ke...@malde.org wrote: Peter Verswyvelen bugf...@gmail.com writes: 1) hg st darcs cha -s That seems to list all changes in the history. hg st lists local changes only. Can be done using darcs? darcs whatsnew -s -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to properly design a Haskell TK
* Luke Palmer lrpal...@gmail.com [2009-02-06 01:09:45-0700] On Fri, Feb 6, 2009 at 1:02 AM, Achim Schneider bars...@web.de wrote: I've been thinking a bit, and come to the conclusion that we should just do it as others did it before: Start off with application-specific tk's, figure out what's cool and what's compatible and then put them into libraries. In short: Stop building cathedrals. I don't know what you mean by TK, but whatever it means, I wholeheartedly support this sentiment! I guess TK stands for toolkit (probably a graphical one?), although I like Bulat's version :) -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Changing version numbering schemes for HackageDB packages?
* Corey O'Connor coreyocon...@gmail.com [2009-02-10 10:21:54-0800] I released a new version of data-spacepart that resolved some of the issues with the previous release. One issue I had was the previous release used the version numbering scheme I use at work: [date].[release] Which does not appear to work as well as the traditional X.Y.Z release numbering scheme with Cabal. As part of the new release I changed the version numbering scheme. An *obviously* bad idea if I thought it through. Any [date].[release] style version number is greater than a X.Y.Z version number until X gets rather large. So what to do? Continue using the [date].[release] version numbering scheme? Or is there a way to coax HackageDB to ignore the old release? From haxr changelog: Sun Feb 11 11:43:15 EET 2007 bj...@bringert.net * Changed haxr version number to 3000.0.0 to avoid ordering problems with old date-based version numbers. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] IO semantics and evaluation - summary
* Daryoush Mehrtash dmehrt...@gmail.com [2009-02-13 11:31:06-0800] Isn't the lambda expression a representation of something (potentially with recursion) that yields a value and not the value itself? The same terms may refer to different notions. If you think of values as mathematical objects, they are denotation of syntactic constructs (value 1 is denotation of 1, as well as of (\x - x-2) 3). However, in operational (rather than denotational) semantics, 1 is value (result of evaluation; normal form) of (\x - x-2) 3, and is itself a syntactic construct. So, you really need to define (and understand) your terms before talking about them. Even integer which we think of as values are represented in the same way: http://safalra.com/science/lambda-calculus/integer-arithmetic/ Church numerals are introduced in _untyped_ lambda calculus, while we are probably talking about _typed_ lambda calculus (as implemented in Haskell). In the later integers usually are introduced as a basic type. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: first Grapefruit release
* Wolfgang Jeltsch g9ks1...@acme.softbase.org [2009-02-14 17:19:09+0100] Dear friends of Haskell and Functional Reactive Programming, its my pleasure to announce the first official release of Grapefruit, a library for Functional Reactive Programming (FRP) with a focus on user interfaces. With Grapefruit, you can implement reactive and interactive systems in a declarative style. User interfaces are described as networks of communicating widgets and windows. Communication is done via different kinds of signals which describe temporal behavior. Greetings! Does this version not support Codebreaker and CircuitingObjects examples shown on the wiki page? Or there's another reason why they are not included in the grapefruit-examples? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: The Typeclassopedia, and request for feedback
* Wolfgang Jeltsch g9ks1...@acme.softbase.org [2009-02-17 13:30:22+0100] Am Dienstag, 17. Februar 2009 00:32 schrieb George Pollard: On Mon, 2009-02-16 at 15:30 +0100, Fraser Wilson wrote: Super! Also, best definition of bottom I've yet seen -- ignoring _| _, which is a party pooper. Like good code, it's short, to the point, and obviously correct. This brings up something I've thought about: On page 8, it is said that Pointed doesn't need to be checked because the theorem comes for free, but the free theorems paper was based upon total functions only; does having _|_ affect the free theorem for Pointed? This was my question to Janis Voigtländer after his HaL 3 talk. He said that the free theorem stuff also holds in the presence of _|_, it’s just a bit more complicated to prove it. At least, this is how I understood it. :-) This paper was recently cited in -cafe; doesn't it help here? http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.59.8232 -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] equational reasoning
* Wouter Swierstra w...@cs.nott.ac.uk [2009-02-19 11:58:38+0100] There are several problems with this approach. For example, I can show: const 0 (head []) = 0 But if I pretend that I don't know that Haskell is lazy: const 0 (head []) = const 0 (error ) = error ... Where does the last equality come from? Which would allow me to substitute each occurrence of 0 with error - which probably isn't a good idea. So to do proper equational reasoning in a lazy language you need to be extremely careful with evaluation order. Evaluation order matters for operational semantics, not for axiomatic. And even in operational semantics Church–Rosser theorem should prevent getting different results (e.g. 0 and error) for different evaluation orders. Please correct me if I'm wrong. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] equational reasoning
* Tillmann Rendel ren...@cs.au.dk [2009-02-19 22:43:24+0100] Roman Cheplyaka schrieb: Evaluation order matters for operational semantics, not for axiomatic. And even in operational semantics Church–Rosser theorem should prevent getting different results (e.g. 0 and error) for different evaluation orders. Let's consider omega = omega const omega 42 I guess you meant const 42 omega. which is evaluated to 42 in Haskell, but is nonterminating in an strict language. I would expect every kind of semantics to account for this difference. It's slightly different. I understand that error .. and omega have the same denotation, but the difference is that omega does not have normal form and error .. is in normal form. So non-termination of const 42 omega in a strict language is not surprising (we know that strict evaluation does not always find normal form, even if it exists), but const 42 (error ...) = error ... means that different evaluation orders give us different normal forms, which is denied by Church-Rosser. Second, who says Church-Rosser holds for Haskell? Now I see that exceptions magic can break it. Is this what you mean? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FRP + physics / status of hpysics
* Peter Verswyvelen bugf...@gmail.com [2009-03-06 11:17:50+0100] Regarding hpysics, did anybody did some experiments with this? Nothing I'm aware of. The blog seems to be inactive since december 2008; has development ceased? Sort of. One reason is that DPH does not seem to be ready for hpysics yet, another one is that I don't see any potential users around (read: I just need a kick in the ass). Integrating hpysics with Grapefruit might be a good topic for the Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using recursive signal functions, but with correct collision response and better-than-Euler integration, all handled by the physics engine. Other FRP engines could be tried, but Grapefruit hacking is already a topic on the Hackaton, so it would combine efforts. Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason of my interest in Grapefruit). But first of all we need to get graphics support into Grapefruit. Does your proposal re Hackathon indicate that you'd like to join? -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FRP + physics / status of hpysics
* Peter Verswyvelen bugf...@gmail.com [2009-03-07 18:34:10+0100] On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka r...@ro-che.info wrote: The blog seems to be inactive since december 2008; has development ceased? Sort of. One reason is that DPH does not seem to be ready for hpysics yet, another one is that I don't see any potential users around (read: I just need a kick in the ass). Is it a performance issue? Yes. As Roman Leshchinskiy explained it's because parallel arrays are not fused properly yet. But it's quite trivial to modify Hpysics to use ordinary lists or arrays, and I think it'll give reasonable performance. Integrating hpysics with Grapefruit might be a good topic for the Hackaton, trying to make a simple game (e.g. Pong or Breakout) without using recursive signal functions, but with correct collision response and better-than-Euler integration, all handled by the physics engine. Other FRP engines could be tried, but Grapefruit hacking is already a topic on the Hackaton, so it would combine efforts. Yes, I'm actively pondering Hpysics+Grapefruit (it's the primary reason of my interest in Grapefruit). But first of all we need to get graphics support into Grapefruit. Does your proposal re Hackathon indicate that you'd like to join? Yes, Thomas 'Bob' Davie and I already joined the Hackaton, but the wiki is not yet updated.I see you've joined too, cool Great! I'll have more free time after March 15, and we can arrange an IRC meeting to discuss this. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FRP + physics / status of hpysics
* Peter Verswyvelen bugf...@gmail.com [2009-03-08 12:00:23+0100] On Sat, Mar 7, 2009 at 6:49 PM, Roman Cheplyaka r...@ro-che.info wrote: * Peter Verswyvelen bugf...@gmail.com [2009-03-07 18:34:10+0100] On Fri, Mar 6, 2009 at 10:39 PM, Roman Cheplyaka r...@ro-che.info wrote: Is it a performance issue? Yes. As Roman Leshchinskiy explained it's because parallel arrays are not fused properly yet. But it's quite trivial to modify Hpysics to use ordinary lists or arrays, and I think it'll give reasonable performance. Personally I would not mind too much about performance initially; I'm very confident that lots of optimizations can be done afterwards - maybe even letting the GPU handle certain tasks. I wouldn't mind too if it was just 'inefficient'; however, it's practically unusable. Result was disappointing -- simple 2-step simulation with 10 bodies took 9 seconds and almost 1Gb of memory to complete. http://physics-dph.blogspot.com/2008/08/status-report-week-11-12.html -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: 3D Rendering Engine in Haskell (Re: FRP + physics / status of hpysics)
* Neal Alexander relapse@gmx.com [2009-03-08 10:49:52-0800] Anyway, it seems like theres quite a few people working on game/openGL related stuff for Haskell now. Would be nice to get a group of people working on something. Please go ahead! Personally, I've been working on a 2d isometric game for the past several months. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Natural Numbers: Best implementation?
* Alexander Dunlap alexander.dun...@gmail.com [2009-03-12 20:01:57-0700] Also, a lot of functions just take Integers so it would be more of a pain to use. AFAIK there are very few fuctions that take Integers. Many functions take instances of Integral, but it's not a problem to make your own type such an instance. -- Roman I. Cheplyaka :: http://ro-che.info/ Don't let school get in the way of your education. - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe