Re: [Haskell-cafe] More on the random idea
On Sunday 27 May 2007 06:05, Andrew Coppin wrote: Um... what's GOA? GHCi on Acid: http://www.cse.unsw.edu.au/~dons/lambdabot.html Alexis. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
Alexis wrote: On Sunday 27 May 2007 06:05, Andrew Coppin wrote: Um... what's GOA? GHCi on Acid: http://www.cse.unsw.edu.au/~dons/lambdabot.html Ah, I see. I don't know about GHCi - I think the *lambdabot* logo looks like she's on something...! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
Donald Bruce Stewart wrote: claus.reinke: The #haskell people have been working on this for about 3 years now. The result is the 'runplugs' program, which I've talked about in previous mails. http://www.cse.unsw.edu.au/~dons/code/lambdabot/scripts/RunPlugs.hs It uses hs-plugins for the evaluation, along with the points about IO prevention via type checking, resource limits controlled by the OS, language extension preventions, and a trusted (audited) module base. great! and since it is presumably in daily use, there is both pressure to fix holes as soon as they are discovered, and ongoing discovery in a safe (or at least friendly) environment. I've listed the mechanisms we use, and exploits that have been thought of, or discovered, over the years, on the page: http://haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code I'm liking where this is going... ;-) Personally, I would think that denying access to dangerous funtions - or better yet, only allowing access to obviously safe functions - would be one half the problem, and using OS constraints to enforce resource limits would be the other half. But then, I'm no expert, so perhaps I've missed something... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Hugs
Neil Mitchell wrote: Hi I don't know about Linux, but Hugs is currently hopelessly unstable on Windoze. Have you filed bugs in the hugs bug tracker? No bugs have been filed from this. In general Windows and Hugs is rock solid, I use it every single day without issue - including to develop Yhc (an compiler). If Andrew is having any problems, please share them (hugs-bugs -at- haskell.org). IIRC, I did have a look at the bugtracker once, and several people seemed to have reported bugs similar to the ones I'm seeing. It's a shame really; the 2003 release of Hugs worked flawlessly. The new 2006 release has a much nicer UI, but... it behaves unpredictably. In particular, it has a habit of printing garbage instead of computation results. (Sometimes the correct result is truncated, sometimes parts of previous outputs - or the welcome banner - is reprinted instead of the output. Sometimes the output it printed multiple times. Sometimes valid Haskell generates spurious parse or type errors, but if you restart Hugs it works fine, etc.) Also, more than once I've been visited by Dr Watson. I don't care *what* you do to a program, it should _never_ crash that badly... There is also the minor detail that the uninstaller doesn't actually work. (The NTVDM CPU has encountered an illegal instruction...) So I can't even remove the program from my computer now. :-( ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Newbie list question
type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] This code works when I type in: credit [(1,2,3)] but doesn't work when I type in: credit [(1,2,3),(4,5,6)] Any help? Thanks in advance. -- View this message in context: http://www.nabble.com/Newbie-list-question-tf3823011.html#a10823175 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
junkywunky: type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] This code works when I type in: credit [(1,2,3)] but doesn't work when I type in: credit [(1,2,3),(4,5,6)] You're pattern matching in 'credit' on a list of a single element. Perhaps you mean to write: credit :: Bank - [Person] credit x = x or perhaps return just the first element of the list: credit [] = [] credit (x:xs) = x You might want to start with one of the tutorials on Haskell programming listed on haskell.org. The wikibook is quite a good start. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
junkywunky wrote: type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] This code works when I type in: credit [(1,2,3)] but doesn't work when I type in: credit [(1,2,3),(4,5,6)] Any help? Thanks in advance. The expression [(1,2,3),(4,5,6)] doesn't match the pattern [(a,b,c)]. Now, since Bank and [Person] are actually the exact same type and the credit function actually does nothing, you could simply write credit x = x (Or, for that matter, credit = id.) It would then work for both examples. I presume that the idea is that the credit function will eventually do something - in that case, it might be helpful to say exactly what you want it to actually do. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
That's the thing. I want to return a list of people who are not overdrawn. Something like: type NI = Int type Age = Int type Balance = Int type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] if c = 0 then [(a,b,c)] else error overdrawn customer except this doesn't work with things like: credit [(1,2,3),(4,5,6)] or credit [(1,2,3),(4,5,6),(7,8,-9)] Andrew Coppin wrote: junkywunky wrote: type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] This code works when I type in: credit [(1,2,3)] but doesn't work when I type in: credit [(1,2,3),(4,5,6)] Any help? Thanks in advance. The expression [(1,2,3),(4,5,6)] doesn't match the pattern [(a,b,c)]. Now, since Bank and [Person] are actually the exact same type and the credit function actually does nothing, you could simply write credit x = x (Or, for that matter, credit = id.) It would then work for both examples. I presume that the idea is that the credit function will eventually do something - in that case, it might be helpful to say exactly what you want it to actually do. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://www.nabble.com/Newbie-list-question-tf3823011.html#a10823244 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
junkywunky: That's the thing. I want to return a list of people who are not overdrawn. Something like: type NI = Int type Age = Int type Balance = Int type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] if c = 0 then [(a,b,c)] else error overdrawn customer except this doesn't work with things like: Right, you mean to write a list filter. List comprehensions are useful for this: credit xs = [ p | p@(a,b,c) - xs, c = 0 ] or maybe: credit xs = filter ok xs where ok (a,b,c) = c = 0 -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
Donald Bruce Stewart wrote: Don types faster than me. ;-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsec question
Greetings. I'd like to write a parser that takes some Haskell source code and seperates it into two piles - comments, and everything else. I have a parser that recognises single-line comments, and another that recognises multi-line comments. What I'd like to do is make a big parser that returns [Either String String], which all the comments in one side and all the rest in the other side. But I can't figure out how to construct such a parser... Any hints? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Newbie list question
type Person = (NI, Age, Balance) type Bank = [Person] credit :: Bank - [Person] credit [(a,b,c)] = [(a,b,c)] if c = 0 then [(a,b,c)] else error overdrawn customer except this doesn't work with things like: credit [(1,2,3),(4,5,6)] Hi, that's because Haskell syntax is made for brains with high modality. When you declare a type, writing a type signature in square brackets make it to be a list of arbitrary number of elements of the inner type; when you write a pattern, one with an element in square brackets matches a single-element list. What you want is to credit abcs = filter (\(a,b,c) - c=0) abcs And if you think it looks like a machine-level assembly language, then you are probably right. David ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hugs
Hi It's a shame really; the 2003 release of Hugs worked flawlessly. The new 2006 release has a much nicer UI, but... it behaves unpredictably. In particular, it has a habit of printing garbage instead of computation results. This is not in the bug tracker. Do you have a reproducible test case? I think I fixed one bug related to this a while back. Also, more than once I've been visited by Dr Watson. I don't care *what* you do to a program, it should _never_ crash that badly... I've never crashed WinHugs, ever. If you could say *what* crashes Hugs we'd have a much better chance and fixing it. There is also the minor detail that the uninstaller doesn't actually work. (The NTVDM CPU has encountered an illegal instruction...) So I can't even remove the program from my computer now. :-( Just delete the directory and you'll be fine, it doesn't install .dll's in Windows directories etc. This is a known bug, and on the bug tracker, and will be fixed in a new release shortly. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec question
Andrew Coppin [EMAIL PROTECTED] writes: I have a parser that recognises single-line comments, and another that recognises multi-line comments. What I'd like to do is make a big parser that returns [Either String String], which all the comments in one side and all the rest in the other side. But I can't figure out how to construct such a parser... Any hints? wholething = many comment comment = do fmap Left $ (linecomment `onFail` nestedcomment) `onFail` fmap Right $ noncomment ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memoization
sorear pointed me to this paper a while ago: http://citeseer.ist.psu.edu/peytonjones99stretching.html I never tried any of the code in the end, but it will probably be useful? On 27/05/07, Mark Engelberg [EMAIL PROTECTED] wrote: I'd like to write a memoization utility. Ideally, it would look something like this: memoize :: (a-b) - (a-b) memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. I've searched the web for memoization examples in Haskell, and all the examples use the trick of storing cached values in a lazy list. This only works for certain types of functions, and I'm looking for a more general solution. In other languages, one would maintain the cache in some sort of mutable map. Even better, in many languages you can rebind the name of the function to the memoized version, so recursive functions can be memoized without altering the body of the function. I don't see any elegant way to do this in Haskell, and I'm doubting its possible. Can someone prove me wrong? --Mark ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Memoization
Mark Engelberg wrote: I'd like to write a memoization utility. Ideally, it would look something like this: memoize :: (a-b) - (a-b) memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. Note that due to parametricity, any function of this type is necessarily either id or _|_. In other words, there are only two functions of type ∀a∀b. (a-b) - (a-b) That's because the functions has to work for all types a and b in the same way, i.e. it may not even inspect how the given types a or b look like. You need type classes to get a reasonable type for the function you want memoize :: Memoizable a = (a-b) - (a-b) Now, how to implement something like this? Of course, one needs a finite map that stores values b for keys of type a. It turns out that such a map can be constructed recursively based on the structure of a: Map ()b := b Map (Either a a') b := (Map a b, Map a' b) Map (a,a')b := Map a (Map a' b) Here, Map a b is the type of a finite map from keys a to values b. Its construction is based on the following laws for functions () - b =~= b (a + a') - b =~= (a - b) x (a' - b) -- = case analysis (a x a') - b =~= a - (a' - b) -- = currying For further and detailed explanations, see R. Hinze. Memo functions, polytypically! http://www.informatik.uni-bonn.de/~ralf/publications.html#P11 and R. Hinze. Generalizing generalized tries. http://www.informatik.uni-bonn.de/~ralf/publications.html#J4 Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI and multi-threading
Hello Mauricio, Saturday, May 26, 2007, 10:58:55 PM, you wrote: Do you guys know of a good example of Haskell calling functions to a thread-safe library i doesn't understand exactly your question, but i have a large program that use thread-safe calls: http://www.haskell.org/bz/FreeArc-sources.tar.gz please specify your question if you still need answer -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hugs
Neil Mitchell wrote: Hi It's a shame really; the 2003 release of Hugs worked flawlessly. The new 2006 release has a much nicer UI, but... it behaves unpredictably. In particular, it has a habit of printing garbage instead of computation results. This is not in the bug tracker. Do you have a reproducible test case? I think I fixed one bug related to this a while back. Unfortunately it seems very intermittent. Sometimes it works fine, sometimes it just acts weirdly at me. It is of course possible that the one bug you fixed is the one I'm seeing... Also, more than once I've been visited by Dr Watson. I don't care *what* you do to a program, it should _never_ crash that badly... I've never crashed WinHugs, ever. If you could say *what* crashes Hugs we'd have a much better chance and fixing it. Again, intermittent, can't reliably reproduce. This one is a lot rarer than the first, fortunately. There is also the minor detail that the uninstaller doesn't actually work. (The NTVDM CPU has encountered an illegal instruction...) So I can't even remove the program from my computer now. :-( Just delete the directory and you'll be fine, it doesn't install .dll's in Windows directories etc. This is a known bug, and on the bug tracker, and will be fixed in a new release shortly. OK. Thanks for that. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Curiose types
As I lay in bed last night, a curios fact occurred to me. (Yes, I don't get out very much...) Consider the map function: map :: (a - b) - [a] - [b] There are two ways you can think about this function. First, you can see it as meaning map :: (a - b) - ([a] - [b]) Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] Now this got me thinking: is (-) associative? x_x Well now, let's consider a general 3-argument function: foo :: a - b - c - d According to the rules, this is of course equivilent to foo :: a - (b - (c - d)) If you understand what currying is and how it works, this makes perfect sense. Now let's bracket that the other way: foo :: ((a - b) - c) - d Well, while that type *does* make sense, it's clearly a completely *different* type! So, clearly, (-) is not associative. Now I'm left wondering why you can bracket the type for map in two different ways, but not in general. Hmm... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Memoization
apfelmus wrote: Note that due to parametricity, any function of this type is necessarily either id or _|_. In other words, there are only two functions of type ∀a∀b. (a-b) - (a-b) You managed to type ∀ but you couldn't find ⊥ ? OOC, can anybody tell me what ∀ actually means anyway? That's because the functions has to work for all types a and b in the same way, i.e. it may not even inspect how the given types a or b look like. You need type classes to get a reasonable type for the function you want memoize :: Memoizable a = (a-b) - (a-b) Ah... most optimal! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Broadcast signals between threads
Hi, Am Samstag, den 26.05.2007, 14:29 +0200 schrieb Tomasz Zielonka: On Fri, May 25, 2007 at 07:57:45PM +0200, Joachim Breitner wrote: I???m writing a TCP server app ATM. It has one thread per client. Some of the clients want to be notified if the internal state changes, while others are happily chatting with the server, possible modifying the internal state. What I need now is a way for the chatting thread to signal ???anyone interested??? that the state has changed. Did you consider using STM for thread synchronisation and communication? STM uses change notifications (or something similar) internally to implement the retry operation. I might be just what you need, but more high level. No, I haven’t done anything with STM yet. Maybe I’ll look into that. Thanks, Joachim -- Joachim Breitner e-Mail: [EMAIL PROTECTED] Homepage: http://www.joachim-breitner.de ICQ#: 74513189 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curiose types
On Sun, May 27, 2007 at 11:12:47AM +0100, Andrew Coppin wrote: So, clearly, (-) is not associative. That's right. Now I'm left wondering why you can bracket the type for map in two different ways Are you sure you can? Best regards Tomasz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Memoization
You managed to type ∀ but you couldn't find ⊥ ? OOC, can anybody tell me what ∀ actually means anyway? It is called the 'universal quantifier' and means for all. It is often used implicitly in natural language. e.g. cars are red can be expanded to [for all elements of the set of cars] cars [all elements of the set] are red. This statement can be formally expressed (though i won't for now). The universal quantifier, although most often used implicitly in natural language, is most often used explicitly in formal logic. You might also be interested in knowing of the existential quantifier which means there exists. If I said there exists a car [an element from the set of all cars] that is blue, then I have refuted the earlier logical proposition (that cars are red). The existential quantifier looks like a backward capital E ∃ Look up first-order logic if you're interested in learning more about this topic. PS: What does OOC stand for? Out Of Curiosity? Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Broadcast signals between threads
Hello Joachim, Friday, May 25, 2007, 9:57:45 PM, you wrote: I’m writing a TCP server app ATM. It has one thread per client. Some of the clients want to be notified if the internal state changes, while others are happily chatting with the server, possible modifying the internal state. What I need now is a way for the chatting thread to signal “anyone interested” that the state has changed. i don't read your letter carefully but at least there is throwTo function what implement exactly what you said in subj. look Control.Exception module docs and read awkward squad paper: Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/marktoberdorf.ps.gz -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] New book: Real-World Haskell!
Hello Doug, Friday, May 25, 2007, 9:30:15 PM, you wrote: Last time I read O'Reilly's policy, it stated that you're free to suggest an animal, but that they have a full-time person that makes the decision on which animal is on the book. full-time person! i want to have such hard job :))) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Network.HTTP+ByteStrings Interface--Or: How to shepherd handles and go with the flow at the same time?
Hello Jules, Friday, May 25, 2007, 1:17:49 AM, you wrote: The key point under discussion was what kind of interface the HTTP library should expose: synchronous, asynchronous? Lazy, strict? isn't it possible to implement simplest (strict sync) interface as base and then add higher levels if they are complicated enough ? (otherwise it should be simpler to do the same in each application / 3rd-aprty lib) in particular, we have a long-standing problem of customized io manager (instead of current io thread) which should work with any async i/o method (kqueue and so on) and this manager should be used for low-level implementation (i.e. we will have sync interface but internally all i/o will be done async via this thread and many haskell lightweight thread can work simultaneously) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Memoization
Tony Morris wrote: You managed to type ∀ but you couldn't find ⊥ ? OOC, can anybody tell me what ∀ actually means anyway? It is called the 'universal quantifier' and means for all. It is often used implicitly in natural language. e.g. cars are red can be expanded to [for all elements of the set of cars] cars [all elements of the set] are red. This statement can be formally expressed (though i won't for now). The universal quantifier, although most often used implicitly in natural language, is most often used explicitly in formal logic. You might also be interested in knowing of the existential quantifier which means there exists. If I said there exists a car [an element from the set of all cars] that is blue, then I have refuted the earlier logical proposition (that cars are red). The existential quantifier looks like a backward capital E ∃ Look up first-order logic if you're interested in learning more about this topic. I see... I do recall that GHC has some weird extension called existential quantification, which makes absolutely no sense at all. So I looked up the term on Wikipedia, which says see predicate logic. So I looked up predicate logic, which says it's an extension of propositional logic, so I looked that up... and at this point I became increadibly confused! LOL. PS: What does OOC stand for? Out Of Curiosity? Indeed yes. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Broadcast signals between threads
Hi, Am Sonntag, den 27.05.2007, 14:07 +0400 schrieb Bulat Ziganshin: Hello Joachim, Friday, May 25, 2007, 9:57:45 PM, you wrote: I’m writing a TCP server app ATM. It has one thread per client. Some of the clients want to be notified if the internal state changes, while others are happily chatting with the server, possible modifying the internal state. What I need now is a way for the chatting thread to signal “anyone interested” that the state has changed. i don't read your letter carefully but at least there is throwTo function what implement exactly what you said in subj. look Control.Exception module docs and read awkward squad paper: Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/marktoberdorf.ps.gz I don’t like throwTo because then I need to keep track of which threads are currently interested in the signal, to not accidentally throw an exception to a thread that does not expect it. Just seems too dangerous to me :-) Greetings, Joachim -- Joachim Breitner e-Mail: [EMAIL PROTECTED] Homepage: http://www.joachim-breitner.de ICQ#: 74513189 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hugs
Hi This is not in the bug tracker. Do you have a reproducible test case? I think I fixed one bug related to this a while back. Unfortunately it seems very intermittent. Sometimes it works fine, sometimes it just acts weirdly at me. It was a multithreaded/locking bug, the worst kind to track down and rarely repeatable. I think I quashed it though, but if you see it again in the next release please let me know. Also, more than once I've been visited by Dr Watson. I don't care *what* you do to a program, it should _never_ crash that badly... I've never crashed WinHugs, ever. If you could say *what* crashes Hugs we'd have a much better chance and fixing it. Again, intermittent, can't reliably reproduce. This one is a lot rarer than the first, fortunately. Anything to do with the FFI? At load time or run time? If it reoccurs please jot down any details you have. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hugs
Neil Mitchell wrote: Hi This is not in the bug tracker. Do you have a reproducible test case? I think I fixed one bug related to this a while back. Unfortunately it seems very intermittent. Sometimes it works fine, sometimes it just acts weirdly at me. It was a multithreaded/locking bug, the worst kind to track down and rarely repeatable. I think I quashed it though, but if you see it again in the next release please let me know. Ah, God bless nondeterministic software! ;-) Also, more than once I've been visited by Dr Watson. I don't care *what* you do to a program, it should _never_ crash that badly... I've never crashed WinHugs, ever. If you could say *what* crashes Hugs we'd have a much better chance and fixing it. Again, intermittent, can't reliably reproduce. This one is a lot rarer than the first, fortunately. Anything to do with the FFI? At load time or run time? If it reoccurs please jot down any details you have. ...Hugs can do FFI?? o_O ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Donald Bruce Stewart wrote: I've listed the mechanisms we use, and exploits that have been thought of, or discovered, over the years, on the page: http://haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code The exception handling behavior is somewhat odd, I don't even understand it fully. Here's a lambdabot session... why is the behavior of the iter versions different from the explicitly iterated error? isaacd error hi lambdabot Exception: hi isaacd error (error hi) lambdabot Exception: hi isaacd error ('l':(error hi)) lambdabot Exception isaacd fix error lambdabot Exception: loop isaacd fix (error . ('a':)) lambdabot Exception isaacd fix (error . (replicate 5000 'a'++)) [ long lines clipped by me: ] lambdabot Exception: aa[...] lambdabot aa[...] lambdabot aa[...] lambdabot aa[...] lambdabot isaacd error (error (error hi)) :: String lambdabot Exception: hi isaacderror.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error . error.error.error $ hi lambdabot Exception: hi isaacd let iter 0 _ = id; iter n f = f . iter (n - 1) f in iter 0 error hi lambdabot hi isaacd let iter 0 _ = id; iter n f = f . iter (n - 1) f in iter 1 error hi lambdabot Exception: hi isaacd let iter 0 _ = id; iter n f = f . iter (n - 1) f in iter 2 error hi lambdabot Exception isaacd let iter 0 _ = id; iter n f = f . iter (n - 1) f in iter 1001 error hi lambdabot Exception isaacd let iter 0 _ = id; iter n f = f . iter (n - 1) f in iter 5 ('L':) hi lambdabot Lhi Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWWo/HgcxvIWYTTURAhYdAJsExQDI9191Q1y9u66H+gpWVlJv2ACfVEhZ IQWCLIgqWksbEcZ+g7gsjR0= =d4Lk -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Broadcast signals between threads
On Sun, May 27, 2007 at 12:22:54PM +0200, Joachim Breitner wrote: Hi, Am Samstag, den 26.05.2007, 14:29 +0200 schrieb Tomasz Zielonka: On Fri, May 25, 2007 at 07:57:45PM +0200, Joachim Breitner wrote: I???m writing a TCP server app ATM. It has one thread per client. Some of the clients want to be notified if the internal state changes, while others are happily chatting with the server, possible modifying the internal state. What I need now is a way for the chatting thread to signal ???anyone interested??? that the state has changed. Did you consider using STM for thread synchronisation and communication? STM uses change notifications (or something similar) internally to implement the retry operation. I might be just what you need, but more high level. Of course it is not I that you might need, but It - the STM :-) Writing I instead of It is one of the most frequent errors I make when writing in english - perhaps a sign of egocentrism...? No, I haven???t done anything with STM yet. Maybe I???ll look into that. If your threads just wait until the server state satisfies some condition, then STM should fit naturally. Best regards Tomek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Donald Bruce Stewart wrote: I've listed the mechanisms we use, and exploits that have been thought of, or discovered, over the years, on the page: http://haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code Lambdabot uses is the technique of using a space at the beginning of the line to make sure it doesn't do anything special. However, it seems currently for multiple lines (long string or error string) it only puts a space if the first character is '@' ('?', '', '/', '\001', '\000' are all sent literally). This behavior seems odd (why do it for '@'? and why not always a space?). In XChat the '\000' prevented the rest of the message from appearing, in the unescaped version produced by 'error'. Try (with any string in place of ?botsnack) @run (\str - replicate 198 'a' ++ str ++ replicate (199 - length str) ' ') ?botsnack or @run (\str - error (replicate 188 'a' ++ str)) ?botsnack (at least lambdabot doesn't respond to itself:) Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWXCmHgcxvIWYTTURAkrlAKCcxS/kjtqtJCwZl3SrV7q7QyOL0QCgpeKS 9crkBNfI4QYzCn9P+2f7gCk= =8Tsr -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsec question
Malcolm Wallace wrote: Andrew Coppin [EMAIL PROTECTED] writes: Any hints? wholething = many comment comment = do fmap Left $ (linecomment `onFail` nestedcomment) `onFail` fmap Right $ noncomment Haskell: The language of truely scary people(tm) :-} Thanks, I'll give that a go... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Curiose types
POST X-Face: H#SM:U1U-/6#NN83s6?Die557~]Dfifz~-|V:wSKGL6T-|!qk{U4/M7+k5Py!-{q=2Q/%0@ E29yc_kQC^ User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 Andrew Coppin [EMAIL PROTECTED] writes: As I lay in bed last night, a curios fact occurred to me. (Yes, I don't get out very much...) You probably ought to get out of bed from time to time, you know. Consider the map function: map :: (a - b) - [a] - [b] There are two ways you can think about this function. First, you can see it as meaning map :: (a - b) - ([a] - [b]) Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] No, if you think like that, you're wrong! That would be a function that takes an object of type ((a-b) - [a]) and returns a [b] (which if you think about it, would be an odd sort of function). (-) associates to the right. -- Jón Fairbairn [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curiose types
Andrew, Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] I am not following here: what do you mean? Clearly, this is not a valid typing for map. Moreover, modulo undefinedness, there are no functions with this typing. Cheers, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curiose types
On 5/27/07, Andrew Coppin [EMAIL PROTECTED] wrote: map :: (a - b) - [a] - [b] map :: (a - b) - ([a] - [b]) Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] No, now you're confusing things. The uncurried function looks like this: uncurry map :: (a - b, [a]) - [b] Note that map :: ( ) - [b] only takes one argument, not two HTH /Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Curiose types
Jon Fairbairn wrote: Andrew Coppin [EMAIL PROTECTED] writes: As I lay in bed last night, a curios fact occurred to me. (Yes, I don't get out very much...) You probably ought to get out of bed from time to time, you know. LOL! Thanks for the tip. :-P Consider the map function: map :: (a - b) - [a] - [b] There are two ways you can think about this function. First, you can see it as meaning map :: (a - b) - ([a] - [b]) Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] No, if you think like that, you're wrong! That would be a function that takes an object of type ((a-b) - [a]) and returns a [b] (which if you think about it, would be an odd sort of function). (-) associates to the right. Hmm... I see the error of my ways. (Someone was asking my why map takes a function from a to b and returns a function from [a] to [b], rather than taking a function and a [a] and returning a [b]. And I pointed out that it's *both* of those things. And it seems that shortly after this point I confused myself! LOL.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Memoization
Andrew Coppin wrote: OOC, can anybody tell me what ∀ actually means anyway? http://en.wikipedia.org/wiki/Universal_quantification http://en.wikipedia.org/wiki/System_F I do recall that GHC has some weird extension called existential quantification http://haskell.org/haskellwiki/Existential_types http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Slower with ByteStrings?
Hello Bryan, Sunday, May 27, 2007, 3:30:50 AM, you wrote: I think, given my simple algorithm that means that (==) for ByteStrings is slower than (==) for String. Is this possible? Yes indeed. Over ByteStrings, (==) is implemented as a call to memcmp. For small strings, this loses by a large margin because it has to go through the FFI. how about using *unsafe* memcmp import and more complex code for the case of large BS length? a==b | min (length a) (length b) 20 = memcmp a b -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Language extensions [was: Memoization]
apfelmus wrote: Andrew Coppin wrote: OOC, can anybody tell me what ∀ actually means anyway? http://en.wikipedia.org/wiki/Universal_quantification http://en.wikipedia.org/wiki/System_F So... ∀x . P means that P holds for *all* x, and ∃ x . P means that x holds for *some* x? (More precisely, at least 1 possible choice of x.) I do recall that GHC has some weird extension called existential quantification http://haskell.org/haskellwiki/Existential_types http://en.wikibooks.org/wiki/Haskell/Existentially_quantified_types Erm... oh...kay... That kind of makes *slightly* more sense now... Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. And yet, all nontrivial Haskell programs *require* the use of at least 3 language extensions. It's as if everyone thinks that Haskell 98 sucks so much that it can't be used for any useful programs. This makes me very sad. I think Haskell 98 is a wonderful language, and it's the language I use for almost all my stuff. I don't understand why people keep trying to take this small, simple, clean, elegant language and bolt huge, highly complex and mostly incomprehensible type system extensions onto it... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Distributing a program with support files
Hi, I'm wanting to release a Haskell program, but am confused how I should distribute the associated files it needs. On Windows I would use the functions to find the path of the executable, and find the support files relative to that - in Haskell (because of Linux) that isn't the case. The basic setup I have is: foo.exe - main binary library.hs - required by the binary examples\*.hs - a massive tree of examples, which can be used by the binary foo.exe also needs to create temporary files relative to library.hs and the examples. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Mysterious monads
Take a look at the following: data Writer o v = Writer [o] v instance Monad (Writer o) where return v = Writer [] v (Writer os v) = f = let (Writer os' v') = f v in Writer (os ++ os') v' write :: o - Writer o () write o = Writer [o] () writes :: [o] - Writer o () writes os = Writer os () By this code, I define a new monad where I can write stuff into a big list. (Although I notice this is going to get slower and slower as the list grows...) For example, test = do write 1 write 2 write 3 yields Writer [1,2,3] (). Now, how do I implement the following? data Reader i v = Reader [i] v instance Monad (Reader i) where return = ??? (=) = ??? read :: Reader o o such that a Reader is created with an initial list, and the read function fetches 1 element out of that list. That is, the expression x - read will take the head element of the list and put it into x, keeping the tail to be read later. (Oh yeah - and apparently that clashes with Prelude.read. Oh well!) I can't figure out how to implement this... The closest I managed was to make a Reader object also contain a function that tells (=) what to do to the Reader object you're binding against... But that seems to be horribly buggy. Any thoughs? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curiose types
On Sun, May 27, 2007 at 02:10:40PM +0200, Stefan Holdermans wrote: Andrew, Which is beautifully symmetric. Alternatively, you can think about how you actually use it: map :: ((a - b) - [a]) - [b] I am not following here: what do you mean? Clearly, this is not a valid typing for map. Moreover, modulo undefinedness, there are no functions with this typing. map _ = [] Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mysterious monads
On Sun, May 27, 2007 at 02:43:32PM +0100, Andrew Coppin wrote: Any thoughs? Take a look at MonadSupply on the wiki: http://haskell.org/haskellwiki/New_monads/MonadSupply Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
On 27/05/07, Andrew Coppin [EMAIL PROTECTED] wrote: So... ∀x . P means that P holds for *all* x, and ∃ x . P means that x holds for *some* x? (More precisely, at least 1 possible choice of x.) Exactly. There's also a lesser-used there exists a unique, typically written ∃!x. P, which means that P is true for one, and only one, value of x. For some examples of how these quantifiers are used: ∀x in R. x^2 = 0 (real numbers have a nonnegative square) ∃x in N. x 3 (there is at least one natural number less than 3) ∃!x in N. x 1 (there is only a single natural number less than 1) For the LaTeX versions, http://www.mathbin.net/11020. Erm... oh...kay... That kind of makes *slightly* more sense now... I wrote most of the second article, I'd appreciate any feedback you have on it. Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. And yet, all nontrivial Haskell programs *require* the use of at least 3 language extensions. It's as if everyone thinks that Haskell 98 sucks so much that it can't be used for any useful programs. This makes me very sad. I think Haskell 98 is a wonderful language, and it's the language I use for almost all my stuff. I don't understand why people keep trying to take this small, simple, clean, elegant language and bolt huge, highly complex and mostly incomprehensible type system extensions onto it... Ever tried writing a nontrivial Haskell program? Like you said, they require these type system extensions! :) Obviously they don't require them, Haskell 98 is a Turing-complete language, but they're useful to avoid things like code-reuse and coupling. One of Haskell's design aims is to act as a laboratory for type theory research, which is one of the reasons why there are so many cool features to Haskell's type system. Anyway, existential types (and higher-rank polymorphism), along with multi-parameter type classes, some kind of resolution to the MPTC dliemma -- so functional dependencies or associated types or something similar -- and perhaps GADTs are really the only large type system extensions likely to make it into Haskell-prime. They're really more part of the Haskell language than extensions now, so well-used are they. -- -David House, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
On May 27, 2007, at 9:19 , Andrew Coppin wrote: So... ∀x . P means that P holds for *all* x, and ∃ x . P means that x holds for *some* x? (More precisely, at least 1 possible choice of x.) Exactly. Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. And yet, all nontrivial Haskell programs *require* the use of at least 3 language extensions. It's as if everyone thinks that Haskell 98 sucks so much that it can't be used for any useful programs. This makes me very sad. I think Which ones? The only one that comes to mind is hierarchical libraries, which are a Good Thing --- the H98 flat namespace becomes increasingly restrictive as Haskell gains more libraries (both included ones, and from e.g. Hackage.) Keep in mind also that many of these extensions are part of Haskell Prime, which last I checked is supposed to become official sometime later this year. Haskell 98 is a wonderful language, and it's the language I use for almost all my stuff. I don't understand why people keep trying to take this small, simple, clean, elegant language and bolt huge, highly complex and mostly incomprehensible type system extensions onto it... Experimentation. There are things you can't do with straight Haskell 98 (even something as simple as the State monad benefits from functional dependencies; but fundeps are troublesome enough that associated types are being explored as a cleaner alternative). Haskell's in kind of a strange position, being simultaneously a research language and a language which is useful in the real world. The tension between these is one reason why there are standards (H98 and the upcoming H'): we real world types write to H98 or H' (increasingly the latter), while the researchers play with type system extensions and the like. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Distributing a program with support files
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Neil Mitchell wrote: Hi, I'm wanting to release a Haskell program, but am confused how I should distribute the associated files it needs. On Windows I would use the functions to find the path of the executable, and find the support files relative to that - in Haskell (because of Linux) that isn't the case. The basic setup I have is: foo.exe - main binary library.hs - required by the binary examples\*.hs - a massive tree of examples, which can be used by the binary foo.exe also needs to create temporary files relative to library.hs and the examples. I think the standard Unix technique (not that I like it) is: Find out at compile time (e.g. ./configure or later): -where to put the executable (e.g. /usr/local/bin/NAME or /usr/bin/NAME -where to put the library files (e.g. in /usr/local/share/NAME/ or /usr/share/NAME/) and embed this knowledge in the executable Find out at run time: where to put temporary files: environment-variable TMPDIR if it exists, otherwise /tmp . GHC/libraries might have utility functions for some of those, such as finding the temp-dir... or maybe Cabal for the build-time things... (If you can do without creating temporary files, that's usually a better approach for that :) Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWY4THgcxvIWYTTURAqNiAJ9HuwsYkYgFMv2iFt8Q+Cge6cQfVgCeKmRY ATVnn14r9e3iicdIyCXWS1A= =yQs7 -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Hi @all I am quite new to haskell ... But need to get the HaXml to work... Unfortunatly I dont know why ghc doesnt find the lib... Ghc is installed on my linux and it works it appears to be the ghc 6.6 I managed to compile the little hello world programm ... But as soon as i try to import HaXml ghc tells me that it could not find it... I followed the installation steps on the haxml homepage and it seemed to work just fine Thanx in advanced Yours Bjoern No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.0/819 - Release Date: 26.05.2007 10:47 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
Erm... oh...kay... That kind of makes *slightly* more sense now... I wrote most of the second article, I'd appreciate any feedback you have on it. If I'm understanding this correctly, existentially quantified types (couldn't you find a name that's any harder to remember/pronounce/spell?) provide an opaque and nonintuitive syntax for writing a type with a type variable hidden inside it. Is that about right? Ever tried writing a nontrivial Haskell program? Like you said, they require these type system extensions! :) Obviously they don't require them, Haskell 98 is a Turing-complete language, but they're useful to avoid things like code-reuse and coupling. One of Haskell's design aims is to act as a laboratory for type theory research, which is one of the reasons why there are so many cool features to Haskell's type system. (Nitpick: Code-reuse is not something to avoid. Perhaps you meant code duplication?) I'm curiose about your assertion that Haskell was designed for type system experiments. According to a paper I read recently, Haskell was actually designed to be a single, standardised functional language suitable for teaching. The fact that there are a lot of type system experiments is an unexpected accident, probably due to Haskell already having type classes. Or so the paper says anyway... Anyway, existential types (and higher-rank polymorphism), along with multi-parameter type classes, some kind of resolution to the MPTC dliemma -- so functional dependencies or associated types or something similar -- and perhaps GADTs are really the only large type system extensions likely to make it into Haskell-prime. They're really more part of the Haskell language than extensions now, so well-used are they. In my book, if it's difficult to explain what a feature even *does*, you have to wonder if that feature is really necessary... MPTCs are a simple enough extension to the existing type system - instead of 1 type, you can have several. I can think of an immediate application for this: class Convertable a b where convert :: a - b (I doubt I'm the first to hit upon this one.) Associated types look very interesting, useful and intuitive. I *swear* I read somewhere that they're in GHC 6.6.1... but apparently I'm mistaken. :-( This is probably *the* only extension I actually want to see in Haskell-Prime. Apart from that, we have GADTs (um... why?), rank-N polymorphism (er... what?), functional dependencies (I don't get it), overlapping instances (why?), impredictive exceptions (again, I can't even comprehend what this *is*)... the list just goes on and on! If there's a simple, comprehensible language extension that solves a big class of problems, sure, knock yourself out! But this just seems like every time somebody finds a small problem it's like hey, let's invent a whole new branch of type theory just to solve this particular edge case... Hmm. I'm ranting... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Mysterious monads
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Andrew Coppin wrote: Take a look at the following: data Writer o v = Writer [o] v instance Monad (Writer o) where return v = Writer [] v (Writer os v) = f = let (Writer os' v') = f v in Writer (os ++ os') v' write :: o - Writer o () write o = Writer [o] () writes :: [o] - Writer o () writes os = Writer os () By this code, I define a new monad where I can write stuff into a big list. (Although I notice this is going to get slower and slower as the list grows...) Try the dlist library instead of plain lists, for the speed issue. For example, test = do write 1 write 2 write 3 yields Writer [1,2,3] (). Now, how do I implement the following? data Reader i v = Reader [i] v instance Monad (Reader i) where return = ??? (=) = ??? read :: Reader o o such that a Reader is created with an initial list, and the read function fetches 1 element out of that list. That is, the expression x - read will take the head element of the list and put it into x, keeping the tail to be read later. (Oh yeah - and apparently that clashes with Prelude.read. Oh well!) You could call it Unwriter/unwrite since it's in some way the opposite in time of Writer (and since Reader monad conventionally refers to one where the input state isn't consumed when it's read). I can't figure out how to implement this... The closest I managed was to make a Reader object also contain a function that tells (=) what to do to the Reader object you're binding against... But that seems to be horribly buggy. you could try this (I haven't tested it but it looks okay to me) newtype Unwriter i v = Unwriter ([i] - (v, [i])) instance Monad (Unwriter i) where return v = \_ - v (Unwriter m) = f = Unwriter $ \i - let (v, i') = m i in let Unwriter m' = f v in m' i' unwrite :: Unwriter i i - --well, what do you want it to do when there is nothing more left in the input list? Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWZERHgcxvIWYTTURAtN4AJ4zXKL97Pg9jttb27hPxJiPhibpjQCgp4AA GWsftHiS6OL1VKINkZW1bGc= =3T/G -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Memoization
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 apfelmus wrote: Mark Engelberg wrote: I'd like to write a memoization utility. Ideally, it would look something like this: memoize :: (a-b) - (a-b) memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. Note that due to parametricity, any function of this type is necessarily either id or _|_. In other words, there are only two functions of type ∀a∀b. (a-b) - (a-b) That's because the functions has to work for all types a and b in the same way, i.e. it may not even inspect how the given types a or b look like. You need type classes to get a reasonable type for the function you want memoize :: Memoizable a = (a-b) - (a-b) Due to modified parametricity, we have not only id, ($), undefined :: ∀a∀b. (a-b) - (a-b) - --($) = id is a correct definition but also ($!) :: ∀a∀b. (a-b) - (a-b) , because of the decision not to require a type-class context for seq. Also GHC has special id-like functions such as 'lazy' and 'inline'... if memoize is indistinguishable from id except in space/time usage, it would be permissible as a compiler primitive. Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWZPSHgcxvIWYTTURAigfAJ0eOBSP5zcXFxj/E/IlhqZRj0y06gCggAjq We0TmsRK5jYHk9L3SEijEzE= =wO/L -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Timeout problems
On Sun, May 27, 2007 at 01:32:40AM +0100, Neil Mitchell wrote: Sadly, it doesn't seem to work for me. Here are the tests I've been using, the results I get, and what I would have liked. All are GHC 6.6 on Windows. -- TEST 1 import System.TimeoutGHC main :: IO () main = do r - timeout (5 * 10^6) (putStrLn here) print r Without -threaded: here Just () wait 5 seconds Without -threaded: here wait 5 seconds Just () So, either way, I get a 5 second delay - not something I want. Works for me with 6.6.1 on Windows and Linux, e.g. on Windows: $ ghc --make -threaded q.hs -o q [1 of 2] Compiling TimeoutGHC ( TimeoutGHC.hs, TimeoutGHC.o ) [2 of 2] Compiling Main ( q.hs, q.o ) Linking q.exe ... $ time ./q here Just () real0m0.070s user0m0.010s sys 0m0.010s $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.6.1 -- TEST 2 import System.TimeoutGHC main :: IO () main = do r - timeout (length [1..]) (putStrLn here) print r Now, with either -threaded, or without, it never terminates. This is expected, as it looks at n before doing anything. I'm not sure why it does so though; it would be nice if timeout just acted as if n was positive and left other cases to the caller. Thanks Ian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Björn wrote: Hi @all I am quite new to haskell ... But need to get the HaXml to work... Unfortunatly I dont know why ghc doesnt find the lib... Ghc is installed on my linux and it works it appears to be the ghc 6.6 I managed to compile the little hello world programm ... But as soon as i try to import HaXml ghc tells me that it could not find it... I followed the installation steps on the haxml homepage and it seemed to work just fine Thanx in advanced Yours Bjoern 1. To ghc-pkg list and see if HaXmL shows up in the listing. If yes, GHC knows it's installed. If no, something is wrong. 2. How are you compiling your program? IIRC, if you don't use the --make switch, you must manually specify that you want specific packages installed, whereas with --make it happens automatically. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Timeout problems
Hi $ ghc --version The Glorious Glasgow Haskell Compilation System, version 6.6.1 -- TEST 2 import System.TimeoutGHC main :: IO () main = do r - timeout (length [1..]) (putStrLn here) print r Now, with either -threaded, or without, it never terminates. This is expected, as it looks at n before doing anything. I'm not sure why it does so though; it would be nice if timeout just acted as if n was positive and left other cases to the caller. Woops, I intended to make length [1..] the action, and leave 5 seconds as the timeout... Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Hey, Ghc-pkg list says: ... HaXml-1.13.2, ... so that should be alright. yes I've compiled using the --make switch... My Programm is something simple right now: Module bjoern where Import HaXml Import IO Main = putStrLn hello world But it always fails to import the lib... This is what I type to compile it in the shell: ghc --make bjoern -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Andrew Coppin Gesendet: Sonntag, 27. Mai 2007 17:06 An: haskell-cafe@haskell.org Betreff: Re: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs Björn wrote: Hi @all I am quite new to haskell ... But need to get the HaXml to work... Unfortunatly I dont know why ghc doesnt find the lib... Ghc is installed on my linux and it works it appears to be the ghc 6.6 I managed to compile the little hello world programm ... But as soon as i try to import HaXml ghc tells me that it could not find it... I followed the installation steps on the haxml homepage and it seemed to work just fine Thanx in advanced Yours Bjoern 1. To ghc-pkg list and see if HaXmL shows up in the listing. If yes, GHC knows it's installed. If no, something is wrong. 2. How are you compiling your program? IIRC, if you don't use the --make switch, you must manually specify that you want specific packages installed, whereas with --make it happens automatically. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.0/819 - Release Date: 26.05.2007 10:47 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.0/819 - Release Date: 26.05.2007 10:47 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Björn wrote: Hey, Ghc-pkg list says: ... HaXml-1.13.2, ... so that should be alright. That's a good start - you've got further than I ever did! My Programm is something simple right now: Module bjoern where Import HaXml Import IO Main = putStrLn hello world But it always fails to import the lib... This is what I type to compile it in the shell: ghc --make bjoern OK, well, try changing it to import Text.XML.HaXml and see what that does... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
On Sun, May 27, 2007 at 04:48:10PM +0100, Andrew Coppin wrote: Björn wrote: My Programm is something simple right now: Module bjoern where Keywords like module must be lower case. Module names must be capitalized. module Bjoern where Import HaXml import Text.XML.HaXml Import IO import IO (which isn't needed here, but it's harmless) Main = putStrLn hello world Variable names such as main must be lowercase. main = putStrLn hello world But it always fails to import the lib... This is what I type to compile it in the shell: ghc --make bjoern The argument to --make must be a file name, and the file must have a .hs or .lhs extension. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Stefan O'Rear wrote: The argument to --make must be a file name, and the file must have a .hs or .lhs extension. Really? Over here GHC seems to accept module names... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
AW: AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs
Hi Now it finally worked... Atleast it does not complain anymore about the import... I guess one has to import Text.XML.HaXml and it seems to work... Thanx a lot !!! Cu B -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Stefan O'Rear Gesendet: Sonntag, 27. Mai 2007 17:56 An: Andrew Coppin Cc: haskell-cafe@haskell.org Betreff: Re: AW: [Haskell-cafe] Problems with HaXml -- ghc cant find the libs On Sun, May 27, 2007 at 04:48:10PM +0100, Andrew Coppin wrote: Björn wrote: My Programm is something simple right now: Module bjoern where Keywords like module must be lower case. Module names must be capitalized. module Bjoern where Import HaXml import Text.XML.HaXml Import IO import IO (which isn't needed here, but it's harmless) Main = putStrLn hello world Variable names such as main must be lowercase. main = putStrLn hello world But it always fails to import the lib... This is what I type to compile it in the shell: ghc --make bjoern The argument to --make must be a file name, and the file must have a .hs or .lhs extension. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.0/819 - Release Date: 26.05.2007 10:47 No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.472 / Virus Database: 269.8.0/819 - Release Date: 26.05.2007 10:47 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Donald Bruce Stewart wrote: I've listed the mechanisms we use, and exploits that have been thought of, or discovered, over the years, on the page: http://haskell.org/haskellwiki/Safely_running_untrusted_Haskell_code (Maybe some of the discussion should move to the talk page?) which is making me think. The expression is bound to a random top level identifier (harmless to guess) What about the non-recursive case ...expr... of x - take 2048 (show x) this way expr can't refer to x (it doesn't at all need to be randomly generated this way) and definitely can't bind other things like take and show (they probably should be qualified anyway) Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWbWYHgcxvIWYTTURAmI8AJ9cesD8W26GWjENhwVUpxU997c+SwCeO1F9 iPqHvwztBJH78S4PT4/TpNI= =0xzE -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Isaac Dupree wrote: The expression is bound to a random top level identifier (harmless to guess) What about the non-recursive case ...expr... of x - take 2048 (show x) this way expr can't refer to x (it doesn't at all need to be randomly generated this way) and definitely can't bind other things like take and show (they probably should be qualified anyway) er, wait, I'm confused. Is it top-level? If not, it could just be take 2048 (show ( ...expr... )) and it doesn't look top-level to me from the lambdabot code in scripts/RunPlugs.hs Isaac -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGWbi8HgcxvIWYTTURAqaMAKCxzKOW+6RDe2kTG6KX8lktQnwY1QCgyO5S jCJQKnGhAi3NLO1bzzbeLzI= =Innv -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Memoization
you may want to use a container like Array or Map. most times i use an Array myself to speed things up like this. with Map it will either be a bit tricky or you'll need to use an unsafeIO hack. here are some functions that may help you. my favorites are Array and MapMealey. - marc memoizeArrayUnsafe :: (Ix i) = (i,i) - (i-e) - (i-e) memoizeArrayUnsafe r f = (Data.Array.!) $ Data.Array.listArray r $ fmap f $ Data.Ix.range r memoizeArray :: (Ix i) = (i,i) - (i-e) - (i-e) memoizeArray r f i = if Data.Ix.inRange r i then memoizeArrayUnsafe r f i else f i data Mealey i o = Mealey { runMealey :: i - (o,Mealey i o) } memoizeMapMealey :: (Ord k) = (k-a) - (Mealey k a) memoizeMapMealey f = Mealey (fm Data.Map.empty) where fm m k = case Data.Map.lookup m k of (Just a) - (a,Mealey . fm $ m) Nothing - let a = f k in (a,Mealey . fm $ Data.Map.insert k a $ m) memoizeMapST :: (Ord k) = (k-ST s a) - ST s (k-ST s a) memoizeMapST f = do r - newSTRef (Data.Map.empty) return $ \k - do m - readSTRef r case Data.Map.lookup m k of (Just a) - return a Nothing - do a - f k writeSTRef r $ Data.Map.insert k a m return a or with inelegant unsafe hacks you get more elegant interfaces: memoizeMapUnsafeIO :: (Ord k) = (k-IO a) - (k-a) memoizeMapUnsafeIO f = unsafePerformIO $ do r - newIORef (Data.Map.empty) return $ \k - unsafePerformIO $ do m - readIORef r case Data.Map.lookup m k of (Just a) - return a Nothing - do a - f k writeIORef r $ Data.Map.insert k a m return a memoizeMap :: (Ord k) = (k-a) - (k-a) memoizeMap f = memoizeMapUnsafeIO (return . f) memoizeMap f = runST $ do f' - memoizeMapST (return . f) return $ runST . unsafeIOToST . unsafeSTToIO . f' Am Sonntag, 27. Mai 2007 04:34 schrieb Mark Engelberg: I'd like to write a memoization utility. Ideally, it would look something like this: memoize :: (a-b) - (a-b) memoize f gives you back a function that maintains a cache of previously computed values, so that subsequent calls with the same input will be faster. I've searched the web for memoization examples in Haskell, and all the examples use the trick of storing cached values in a lazy list. This only works for certain types of functions, and I'm looking for a more general solution. In other languages, one would maintain the cache in some sort of mutable map. Even better, in many languages you can rebind the name of the function to the memoized version, so recursive functions can be memoized without altering the body of the function. I don't see any elegant way to do this in Haskell, and I'm doubting its possible. Can someone prove me wrong? --Mark ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe pgpmBt6Z94b21.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curiose types
map :: ((a - b) - [a]) - [b] I am not following here: what do you mean? Clearly, this is not a valid typing for map. Moreover, modulo undefinedness, there are no functions with this typing. map _ = [] Ah, well, and that one, of course... :-) Cheers, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Language extensions [was: Memoization]
Andrew Coppin wrote: In my book, if it's difficult to explain what a feature even *does*, you have to wonder if that feature is really necessary... Well, difficulty is in the eye of the beholder. For the one familiar with formal logic, ∀ and ∃ are as basic as apples and eggplants. Nobody can stop you to become familiar as well. GADTs (um... why?) GADTs are awesome. They're the basic tool to derive data structures from their specification and they bring dependent types in reach. http://haskell.org/haskellwiki/GADT R. Hinze. Fun with Phantom Types. http://www.informatik.uni-bonn.de/~ralf/publications/With.pdf K. Claessen. Parallel Parsing Processes. http://www.cs.chalmers.se/~koen/pubs/entry-jfp04-parser.html (This paper is not about GADTs but about deriving data structures from their specification) rank-N polymorphism (er... what?) Actually, rank-N polymorphism came first and has been cut down to form the basis of Haskell. You may want to look for System F, perhaps in the book Girard, Lafont, Taylor. Proofs and Types. http://www.cs.man.ac.uk/~pt/stable/prot.pdf MPTC, functional dependencies Mark P. Jones. Type Classes with Functional Dependencies. http://web.cecs.pdx.edu/~mpj/pubs/fundeps.html Regards, apfelmus ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
On Sun, 27 May 2007, Andrew Coppin wrote: Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. And yet, all nontrivial Haskell programs *require* the use of at least 3 language extensions. It's as if everyone thinks that Haskell 98 sucks so much that it can't be used for any useful programs. This makes me very sad. I think Haskell 98 is a wonderful language, and it's the language I use for almost all my stuff. I don't understand why people keep trying to take this small, simple, clean, elegant language and bolt huge, highly complex and mostly incomprehensible type system extensions onto it... Yeah, who needed type classes anyway? By which I mean that that's always been the way with haskell, and once you get what the extensions do they tend to in fact be highly natural - sometimes to the extent that people forget that they were ever an extension (constructor classes, anyone?). For example, GADTs let you implement monads as interpreters by defining a datatype representing the abstract syntax tree that describes a computation - you can't get this to type without at a minimum existential types and for many monad operations you need the full power of GADTs to declare a corresponding constructor. I imagine it would never have occurred to you to try implementing a monad that way, right? Similarly, a lot of the developments with type classes and polymorphism have been about letting people write sufficiently general libraries - they're driven by the demands of code that people want to write, but often not so much by the demands of single, simple applications. Incidentally, Haskell 98 isn't that small a language itself - there's plenty of sugar around. -- [EMAIL PROTECTED] There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions
Philippa Cowderoy wrote: On Sun, 27 May 2007, Andrew Coppin wrote: Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. Yeah, who needed type classes anyway? By which I mean that that's always been the way with haskell, and once you get what the extensions do they tend to in fact be highly natural - sometimes to the extent that people forget that they were ever an extension (constructor classes, anyone?). Type classes are very easy to explain, and quite obviously useful. This, presumably, is why they're in the language. Almost all language extensions seem to be of the form hey, let's see what happens if we randomly change the type checking rules so that *this* is permitted. What would that be like? Usually it's an extreme struggle to even wrap my brain around what the extension *is*, never mind why this would be a useful thing... (OOC, what's a constructor class?) For example, GADTs let you implement monads as interpreters by defining a datatype representing the abstract syntax tree that describes a computation - you can't get this to type without at a minimum existential types and for many monad operations you need the full power of GADTs to declare a corresponding constructor. I imagine it would never have occurred to you to try implementing a monad that way, right? Indeed, I'm still figuring out why you would want to do something like this. (Beyond because you can.) Similarly, a lot of the developments with type classes and polymorphism have been about letting people write sufficiently general libraries - they're driven by the demands of code that people want to write, but often not so much by the demands of single, simple applications. Well, sure enough I've run across useful things the type checker won't let me do. (For example, you can't make Data.Set into a monad, since it demands that all elements be in Ord, but a monad is required to accept *all* possible element types.) It's pretty rare though. OTOH, given that I've never developed any significant Haskell applications or libraries, presumably everybody will simply conclude that I don't know what the I'm talking about and simply ignore me... Incidentally, Haskell 98 isn't that small a language itself - there's plenty of sugar around. Looks like a pretty simple language to me... I once read about this language called C++. It's supposed to be like C, but better. And it is - if by better you mean, exactly the same, but a lot more complicated. By comparison, Haskell is a *tiny* language. And yet, Haskell seems to allow you to express algorithms in a handful of lines of code that would take entire libraries in C, C++, Pascal, Java, Smalltalk, Tcl... and just about every other language I've ever seen in my life! Seriously. Haskell seems to be pretty much the apex of programming. I can't imagine how you could make it any better. (Well, appart from a few trivial things like changing some of the poor name choices in the Prelude, and adding more libraries for real world stuff - but nothing really deep or fundamental about the language itself.) And yet, people keep adding more and more and more and more extensions. If it was that somebody added one extension that really transformed the expressiveness of the language, then fine. But on the contrary, it seems to be millions of little bits and pieces being added. It just seems messy and complicated. (I also spent some time using a language called Eiffel. I read the book too. Long derrivation of why the language is the way it is, why each and every feature and detail is there, and how it forms a cohesive whole. And boy, I was pretty convinced. And Eiffel is a pretty powerful language. But... um... the type checking rules. OMG, *nobody* I know of can actually understand that stuff! I mean, in general it just does what you want, but if it doesn't... good luck figuring it out! Multiple inheritance, generics *and* specialisation in the same language? Hmm... good luck sorting all that out in your code! In short: a lovely language, but... almost too complicated to use.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
Brandon S. Allbery KF8NH wrote: Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. And yet, all nontrivial Haskell programs *require* the use of at least 3 language extensions. It's as if everyone thinks that Haskell 98 sucks so much that it can't be used for any useful programs. This makes me very sad. I think Which ones? The only one that comes to mind is hierarchical libraries, which are a Good Thing --- the H98 flat namespace becomes increasingly restrictive as Haskell gains more libraries (both included ones, and from e.g. Hackage.) Hierachical libraries are a very good extension - in fact, I can bearly believe they weren't in the original language spec. I was under the impression that this isn't an extension any more because it's been added to the official language report. (?) I'm thinking more about things like phantom types, rank-N polymorphism, functional dependencies, GADTs, etc etc etc that nobody actually understands. Keep in mind also that many of these extensions are part of Haskell Prime, which last I checked is supposed to become official sometime later this year. This worries me greatly. I'm really afraid that Haskell will go from being this wonderful, simple language that you can explain in a page or two of text to being this incomprehensible mass of complex type machinery that I and most other human beings will never be able to learn or use. :-( Also... sometime later this year? That's new to me... Haskell 98 is a wonderful language, and it's the language I use for almost all my stuff. I don't understand why people keep trying to take this small, simple, clean, elegant language and bolt huge, highly complex and mostly incomprehensible type system extensions onto it... Experimentation. There are things you can't do with straight Haskell 98 (even something as simple as the State monad benefits from functional dependencies; but fundeps are troublesome enough that associated types are being explored as a cleaner alternative). Haskell's in kind of a strange position, being simultaneously a research language and a language which is useful in the real world. The tension between these is one reason why there are standards (H98 and the upcoming H'): we real world types write to H98 or H' (increasingly the latter), while the researchers play with type system extensions and the like. People experimenting with the language I can live with. (Although I'd prefer it not to be called Haskell. Very confusing when people start asking me questions about this Haskell program that actually uses non-standard extensions that I've never heard of. And when I have to admit that even *I* can't comprehend what the code does, people go away with the notion that Haskell really *is* impossible to learn and it's not worth trying.) What worries me is the day when you'll need to understand set theory and propositional calculus just to use any of the standard libraries. (Already I can't use the State monad because it requires some extension or other. Not that I understand why - as far as I can tell, it's 100% possible to define a State monad without language extensions. The library just doesn't, that's all. Well, I can always define my own I guess...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions [was: Memoization]
On Sun, 27 May 2007, Andrew Coppin wrote: I'm thinking more about things like phantom types, rank-N polymorphism, functional dependencies, GADTs, etc etc etc that nobody actually understands. I think you'll find a fair number of people do in fact understand them! This worries me greatly. I'm really afraid that Haskell will go from being this wonderful, simple language that you can explain in a page or two of text to being this incomprehensible mass of complex type machinery that I and most other human beings will never be able to learn or use. :-( So don't use type extensions in your own code? It's comparatively rare to have any big problems using libraries that make use of them - I remember banging my head briefly the first time I used ST as a newbie, but that was about it. What worries me is the day when you'll need to understand set theory and propositional calculus just to use any of the standard libraries. It would be no bad thing if people were less scared of them and just learned - they're not complicated. (Already I can't use the State monad because it requires some extension or other. Not that I understand why - as far as I can tell, it's 100% possible to define a State monad without language extensions. The library just doesn't, that's all. Well, I can always define my own I guess...) The library doesn't because defining a sufficiently generic notion of State monad (enough so that we can treat a more complex monad that also has a notion of state the same way) requires the extensions. It's all about the polymorphism - one of the reasons Haskell code stays simple is that the amount of polymorphism possible makes people less keen on writing massive overbearing frameworks. -- [EMAIL PROTECTED] There is no magic bullet. There are, however, plenty of bullets that magically home in on feet when not used in exactly the right circumstances. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions
On May 27, 2007, at 17:23 , Andrew Coppin wrote: Personally, I try to avoid ever using list comprehensions. But every now and then I discover an expression which is apparently not expressible without them - which is odd, considering they're only sugar... They are. But they're sugar for monadic operations in the list monad, so you have to use (=) and company to desugar them. [x | filter even x, x - [1..10]] becomes do { x - [1..10]; return (filter even x) } becomes ([1..10] = return . filter even). (Aren't you glad you asked?) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions
Type classes are very easy to explain, and quite obviously useful. This, presumably, is why they're in the language. You'd be surprised, I've seen people twist their brains in knots before finally getting it. Given the long debate I've just had about why (/) 7 4 is a valid expression but / 7 4 isn't, nothing would surprise me... *sigh* Almost all language extensions seem to be of the form hey, let's see what happens if we randomly change the type checking rules so that *this* is permitted. What would that be like? Usually it's an extreme struggle to even wrap my brain around what the extension *is*, never mind why this would be a useful thing... The proposer almost invariably has a use case - often a pretty big one. But usually one that's vastly too mind-bending to comprehend, it must be said... I suppose it's like when mathematitions say that the Gamma function is of fundamental importance - and yet they can't explain what it's actually important for. (OOC, what's a constructor class?) It's a type class that's really a class of type constructors rather than one of types - if you like, a class whose parameter isn't of kind *. The canonical example is Monad. These days they're just type classes, there's no distinction made. Oh, right. I thought that was called higher-kinded classes? Indeed, I'm still figuring out why you would want to do something like this. (Beyond because you can.) It's much easier to understand than the 'traditional' style of implementation (which fuses the constructors with the interpreter). It's even more useful if you work with structures like arrows where there are useful things you can do with a computation without actually running it, as you don't have to bake the various analyses into the arrow type. I wouldn't chose it as the ideal release version, but I'd mechanically build the release code by doing everything with the GADT and then fusing once I'm done - and if compilers ever get good enough at deforesting, I'd happily elide that step! If you're fond of the Knuth quote, then the 'traditional' implementation may smell a lot like premature optimisation enforced by an inflexible type system. Well, sure enough I've run across useful things the type checker won't let me do. (For example, you can't make Data.Set into a monad, since it demands that all elements be in Ord, but a monad is required to accept *all* possible element types.) It's pretty rare though. For me, working in Haskell 98, it tends to happen as my apps grow above a certain size (and it's less than a thousand lines). That, and I find the ST monad pretty invaluable so if I'm doing something where it fits I won't blink before using it. Perhaps it depends on the kind of code you write or something... I've found very few occasions where the type system defeats me. (Heterogenous lists, the Set monad I mentioned, a few bits like that.) Mostly I can't make my programs work properly because I can't come up with a working algorithm. Looks like a pretty simple language to me... It can be stripped significantly further. True. But I mean, useful little bits of syntax aside, the semantics are pretty simple. (Indeed, that's what I love about the language. Figure out function definition, function application, currying, parametric polymorphism, and type classes and you've basically learned almost all of it.) you can retain pretty much everything with variables, applications, lambdas and simple let and case statements. I wish I had a parser that would parse Haskell this way... heh. Things like do blocks and list comprehensions aren't strictly speaking necessary at all, and an awful lot of complexity's added to parsing Haskell 98 by everything that can be done with infix operators. Yeah, parsing Haskell is pretty simple until you add comments, and do-blocks, and list comprehensions, and infix operators, and where bindings, and guards, and... Personally, I try to avoid ever using list comprehensions. But every now and then I discover an expression which is apparently not expressible without them - which is odd, considering they're only sugar... You're missing a lot of the conceptual background Possibly. I find that most of what is written about Haskell tends to be aimed at absolute beginners, or at people with multiple PhDs. (As in, people to whom arcane terms like denotational semantics actually *means* something.) I remember seeing somebody wrote a game (!!) in Haskell - despite the fact that this is obviously impossible. So I went to read the paper about how they did it... and rapidly become completely lost. I get that they used something called funtional reactive programming, but I am still mystified as to what on earth that actually is, or how it functions. But an awful lot of the more popular extensions are primarily about relaxing constraints and picking
Re: [Haskell-cafe] Language extensions [was: Memoization]
Hello Andrew, Sunday, May 27, 2007, 5:19:51 PM, you wrote: Seriously. Haskell seems to attract weird and wonderful type system extensions like a 4 Tesla magnet attracts iron nails... And most of these extensions seem to serve no useful purpose, as far as I can determine. existentials is something like OOP objects but without inheritance - they pack data plus code together and make only methods available. you can find more info here: http://haskell.org/haskellwiki/OOP_vs_type_classes there is also recent Simon Marlow paper about implementing dynamic extensible extensions and, in fact, OOP with inheritance using these existentials recursively -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Language extensions
Andrew Coppin wrote: [snip] You're missing a lot of the conceptual background Possibly. I find that most of what is written about Haskell tends to be aimed at absolute beginners, or at people with multiple PhDs. (As in, people to whom arcane terms like denotational semantics actually *means* something.) I remember seeing somebody wrote a game (!!) in Haskell - despite the fact that this is obviously impossible. So I went to read the paper about how they did it... and rapidly become completely lost. I get that they used something called funtional reactive programming, but I am still mystified as to what on earth that actually is, or how it functions. But an awful lot of the more popular extensions are primarily about relaxing constraints and picking the most natural way to follow through. Hey, let's make it so that classes can have several parameters! Um... OK, that more or less makes sense. I can see uses for that. Hey, let's make it so a class instance can have one or more types associated with it! Er... well, that seems straight forward enough. Alright. Hey, let's make it so that class methods can have completely arbitrary types! Wait, what the hell? How does *that* make sense?! o_O Speaking as someone who, like you, came to the language recently and for whom many of haskell's outer corners are still confusing, I should firstly say that I can see where you're coming from but that it puzzles me as to why you think things ought to be obvious or why, when something isn't obvious to you, it must be useless? Could the answer be that it will take some time before you understand the motivation for features that don't seem natural to you? You might need some patience and study along with everything else, I know I do (and people have been generous with links to work that explains the motivation). I only say this because you seem, bizarrely, to be suggesting that you could improve things by undoing the work of all these scary people as you call them in another post, whilst admitting that you don't understand it. Hey, let's make it so you can use a type variable on the RHS that doesn't even appear on the LHS! Um... that's going to be tricky, but sure, OK. Hey, let's make it so you can implement Prolog programs inside the type system! Right, I'm getting my coat now... :-P In short, some of these relax restrictions in fairly obvious directions, and others just seem downright bizzare. It helps if you can picture a matching explicitly-typed language. I don't really understand that statement. An idea you might find helps: what you're finding with algorithms, I find with architecture when I have the extensions that let me type it. ...or that one... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- View this message in context: http://www.nabble.com/Memoization-tf3822500.html#a10829748 Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Help with terminal IO
I was hoping that hSetBuffering would turn off the line buffering for stdin, but it doesn't seem to work. module Main where import System.IO main :: IO () main = do hSetBuffering stdin NoBuffering hSetBuffering stdout NoBuffering hPutChar stdout '' c - hGetChar stdin hPutChar stdout '' This program should terminate immediately after the first character is typed into the terminal, but it waits until I type a newline. It also looks like it's using GNU readline (it handles the up down arrow keys.) How do I turn this off and use raw character-based IO? I'm using GHC6.6 on Win32 if that makes a difference. -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GADT and typeclasses [was: Language extensions]
Philippa Cowderoy wrote: For example, GADTs let you implement monads as interpreters by defining a datatype representing the abstract syntax tree that describes a computation - you can't get this to type without at a minimum existential types and for many monad operations you need the full power of GADTs to declare a corresponding constructor. I'm yet to see the example of that need. I have seen the examples that the need for GADT was _claimed_ -- but then it turns out the example is implementable without GADT after all. Here are a few such examples: implementing State monad in a free term algebra Initial (term) algebra for a state monad http://www.haskell.org/pipermail/haskell-cafe/2005-January/008241.html Implementing an interpreter in HOAS with fix Even higher-order abstract syntax: typeclasses vs GADT http://www.haskell.org/pipermail/haskell/2007-January/019012.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GADT and typeclasses [was: Language extensions]
On Sun, 27 May 2007, [EMAIL PROTECTED] wrote: Philippa Cowderoy wrote: For example, GADTs let you implement monads as interpreters by defining a datatype representing the abstract syntax tree that describes a computation - you can't get this to type without at a minimum existential types and for many monad operations you need the full power of GADTs to declare a corresponding constructor. I'm yet to see the example of that need. I have seen the examples that the need for GADT was _claimed_ -- but then it turns out the example is implementable without GADT after all. If I remember correctly, the final result is that the full power of GADTs can be obtained via a sufficiently powerful type class mechanism instead. I'm not sure this strictly speaking contradicts what I wrote, though it's a point worth reiterating. Here are a few such examples: implementing State monad in a free term algebra Initial (term) algebra for a state monad http://www.haskell.org/pipermail/haskell-cafe/2005-January/008241.html Implementing an interpreter in HOAS with fix Even higher-order abstract syntax: typeclasses vs GADT http://www.haskell.org/pipermail/haskell/2007-January/019012.html I would say that while these are very much doable, the GADT-based code is clearly a lighter-weight encoding and certainly a more natural extension of a beginner's techniques for implementing interpreters. -- [EMAIL PROTECTED] The reason for this is simple yet profound. Equations of the form x = x are completely useless. All interesting equations are of the form x = y. -- John C. Baez ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] More on the random idea
isaacdupree: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Isaac Dupree wrote: The expression is bound to a random top level identifier (harmless to guess) What about the non-recursive case ...expr... of x - take 2048 (show x) this way expr can't refer to x (it doesn't at all need to be randomly generated this way) and definitely can't bind other things like take and show (they probably should be qualified anyway) er, wait, I'm confused. Is it top-level? If not, it could just be take 2048 (show ( ...expr... )) and it doesn't look top-level to me from the lambdabot code in scripts/RunPlugs.hs Ah right. No, it is bound to a top level value, but is itself not -- its a local binding so we can use {-# #-} pragmas to get more precise error messages (if I recall correctly). -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Building error Gtk2Hs under GHC 6.6.1 on Solaris 10 x86
Hi, haskell-caffe! I'm trying to build Gtk2Hs 0.9.11 under GHC 6.6.1 on Solaris 10 x86: ./configure --with-hcflags=-O0 --disable-split-objs OK! gmake if test -f glib/libHSglib_a.deps; then touch glib/libHSglib_a.deps; else touch glib/libHSglib_a.deps; gmake glib/System/Glib/FFI.hs glib/System/Glib/UTFString.hs glib/System/Glib/Types.hs glib/System/Glib/GType.hs glib/System/Glib/GValue.hs glib/System/Glib/GValueTypes.hs glib/System/Glib/GObject.hs glib/System/Glib/Properties.hs glib/System/Glib/GError.hs glib/System/Glib/GList.hs glib/System/Glib/Signals.hs glib/System/Glib/MainLoop.hs glib/System/Glib/GTypeConstants.hs glib/System/Glib/GParameter.hs glib/System/Glib/StoreValue.hs glib/System/Glib.hs glib/System/Glib/Attributes.hs glib/System/Glib/Flags.hs; /usr/local/bin/ghc -M -optdep-f -optdepglib/libHSglib_a.deps -fglasgow-exts -O0 -fffi -iglib -package-conf package.conf.inplace -hide-all-packages -ignore-package glib -package base -package haskell98 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include glib/System/Glib/FFI.hs glib/System/Glib/UTFString.hs glib/System/Glib/Types.hs glib/System/Glib/GType.hs glib/System/Glib/GValue.hs glib/System/Glib/GValueTypes.hs glib/System/Glib/GObject.hs glib/System/Glib/Properties.hs glib/System/Glib/GError.hs glib/System/Glib/GList.hs glib/System/Glib/Signals.hs glib/System/Glib/MainLoop.hs glib/System/Glib/GTypeConstants.hs glib/System/Glib/GParameter.hs glib/System/Glib/StoreValue.hs glib/System/Glib.hs glib/System/Glib/Attributes.hs glib/System/Glib/Flags.hs; fi; gmake[1]: Entering directory `/usr/export/home/lebed/tmp/gtk2hs-0.9.11' ./mk/chsDepend -iglib:gtk:sourceview sourceview/Graphics/UI/Gtk/SourceView/Types.chs could not find {#import.chs on search path glib gtk sourceview gmake[1]: *** [sourceview/Graphics/UI/Gtk/SourceView/Types.dep] Error 1 gmake[1]: Leaving directory `/usr/export/home/lebed/tmp/gtk2hs-0.9.11' no location info: can't find file: glib/System/Glib/FFI.hs gmake: *** [glib/libHSglib_a.deps] Error 1 gmake: *** Deleting file `glib/libHSglib_a.deps' Where is my mistake? (I've got the same error under GHC 6.6 on Solaris 10 sparc.) -- View this message in context: http://www.nabble.com/Building-error-Gtk2Hs-under-GHC-6.6.1-on-Solaris-10-x86-tf3807947.html#a10777303 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