Re: [Haskell-cafe] Re: Are GADTs what I need?
On Mon, Jul 13, 2009 at 10:52 PM, Ashley Yakeley ash...@semantic.orgwrote: Ryan Ingram wrote: data Type a where TInt :: Type Int TBool :: Type Bool TChar :: Type Char TList :: Type a - Type [a] TFun :: Type a - Type b - Type (a - b) Type here is what I call a simple type witness. Simple type witnesses are useful because they can be compared by value, and if they have the same value, then they have the same type. So you can write this: data EqualType a b where MkEqualType :: EqualType t t Is there any reason to prefer this over: data EqualType a b where MkEqualType :: EqualType a a In the darcs source code we use a definition similar to the one I just gave. I never thought about making the definition like you gave. I wonder if it would have changed things, but I'm not sure what. Your example type checks the same with both versions of EqualType and a type signature is required for matchWitness with both definitions. Playing with the two, I don't really see any way in which they are different. Certainly, both versions of MkEqualType have the same type, but I'm just surprised you don't have to involve a or b in the type of MkEqualType. After playing with both definitions for a bit, I think I see why they have the same type and behave the same way. Initially I was thinking t was an existential type, but because of where it appears it is actually universally quantifed, like the type variable 'a' in my version, so they end up being equivalent. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Example for formatted show in HStringTemplate
+++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format=%d.%b.%Y$ But I only get toModifiedJulianDay: [54960] as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Are GADTs what I need?
On Mon, 2009-07-13 at 23:20 -0700, Jason Dagit wrote: data EqualType a b where MkEqualType :: EqualType t t Is there any reason to prefer this over: data EqualType a b where MkEqualType :: EqualType a a They're exactly the same. Yours just looks a bit left-biased, that's all. -- Ashley Yakeley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Are GADTs what I need?
On Mon, Jul 13, 2009 at 10:33 PM, Ashley Yakeley ash...@semantic.orgwrote: On Mon, 2009-07-13 at 23:20 -0700, Jason Dagit wrote: data EqualType a b where MkEqualType :: EqualType t t Is there any reason to prefer this over: data EqualType a b where MkEqualType :: EqualType a a They're exactly the same. Yours just looks a bit left-biased, that's all. For GADTs I prefer the kind color: data EqualType :: * - * - * where MkEqualType :: EqualType a a Except I don't usually use it, because I mostly use GADT syntax pedagogically, as introduction to algebraic data types, and introducing kinds just seems to confuse things further. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] RE: Haskell as a first language?
Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -Original Message- | From: Charles Turner [mailto:charlie.h.tur...@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems professional to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) | | Thank you very much for your time. | | Charles Turner. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
Simon Peyton-Jones wrote: Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -Original Message- | From: Charles Turner [mailto:charlie.h.tur...@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems professional to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) The biggest probelm with full Haskell for beginners is that many type error messages require some familiarity with the class system, which is not a beginner topic.. However, a good starting point perhaps is Helium - a stripped down version of Haskell designed for teaching, with special care gvien to producing useful helpful error messages... http://www.cs.uu.nl/wiki/Helium Then full Haskell could be introduced in semester 2/ year2 / whatever timeline suits (Anything is better than Java.. sigh ;-) | | Thank you very much for your time. | | Charles Turner. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andrew Butterfield Tel: +353-1-896-2517 Fax: +353-1-677-2204 Foundations and Methods Research Group Director. School of Computer Science and Statistics, Room F.13, O'Reilly Institute, Trinity College, University of Dublin http://www.cs.tcd.ie/Andrew.Butterfield/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
If only for the fact that our little Haskell community is composed of about the nicest set of people ever -- I mean, try asking a newbie question on #c sometime -- then Haskell is a great language to learn early. Not only is it great because of it's community, but it's also full of resources -- there are plenty of fun and interesting tutorials to learn with, among the best are Real World Haskell -- it's actually a print book, but you can read it in it's entirety online, give it a google. There's also a nice tutorial called, Learn you a Haskell for Great Good (or something like that), I've heard good things about it. By far the best things you can do are subscribe to the Haskell-Cafe mailing list, and get yourself in the #haskell chatroom on freenode. I believe it was Mrs. Frizzle who said it best, Ask Questions, Make Mistakes, get Haskell-y!!! /Joe Simon Peyton-Jones wrote: Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -Original Message- | From: Charles Turner [mailto:charlie.h.tur...@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems professional to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) | | Thank you very much for your time. | | Charles Turner. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe begin:vcard fn:Joseph Fredette n:Fredette;Joseph adr:Apartment #3;;6 Dean Street;Worcester;Massachusetts;01609;United States of America email;internet:jfred...@gmail.com tel;home:1-508-966-9889 tel;cell:1-508-254-9901 x-mozilla-html:FALSE url:lowlymath.net, humbuggery.net version:2.1 end:vcard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
Simon Peyton-Jones wrote: Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -Original Message- | From: Charles Turner [mailto:charlie.h.tur...@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems professional to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) | | Thank you very much for your time. | | Charles Turner. Charles, Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. My path into Haskell was roughly C - Python - Scheme - Ocaml - Haskell, and I think that this has a lot going for it (though for a beginner I would recommend Python over Haskell, and Scheme is suitable for beginners with the right textbooks, e.g. How To Design Programs and/or Structure and Interpretation of Computer Programs). If you're willing to work really hard, and don't mind that it may take you quite a bit longer before you are creating real applications in Haskell than it would in e.g. Python, you can start with Haskell (check out the book Real World Haskell: http://realworldhaskell.org). But if you get frustrated, feel free to shift down the list I gave. Scheme or Ocaml are good languages to learn the basics of functional programming, and then you just have to add on the Haskell-specific material (of which there is a lot). Haskell is kind of like a point in the language space that programmers evolve towards. Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Program with profiling runs faster than without
14.07.09, 12:37, Grigory Sarnitskiy sargrig...@ya.ru: Hello! I can't understand why the following happens. ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run -prof -auto-all and time ./Run TestSim seems to be much faster (I got ~4 times faster indeed) than just ghc --make -fforce-recomp -O2 -fexcess-precision -fvia-C -optc-O2 Run.lhs -o Run and time ./Run TestSim with ghc 6.8.2 on pentium 4 2.4 GHz under Ubuntu I was on my way to optimize the program when I've discovered this. The program is rather complicated and badly optimized but still I think it is quite strange to the profiled version to run faster. All necessary files I send with this letter (Tann.7z). Well, I've tested the code with ghc 6.10.3 under Windows --- the result is quite the same, however with the native binary compilier (not via C) the redult is even more drastic. I'm really interested how to obtain the same speed withput profiling compilation. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
I disagree. It was easy enough for me. OK, I do have some Category Theory background and it certainly helps a lot. Still, I think that for a beginner (without any experience with C or anything like that) Haskell would be relatively easy. It doesn't involve (at least at the start) an ugly notion of assignment. Michael Vanier wrote: Simon Peyton-Jones wrote: Haskell is a great language! Check out haskell.org. I'm ccing the Haskell Cafe which is read by many people better qualified to answer your question than me. (Since I've been working on Haskell for many years, I am not well qualified to say how it seems to a beginner.) S | -Original Message- | From: Charles Turner [mailto:charlie.h.tur...@googlemail.com] | Sent: 11 July 2009 22:52 | To: Simon Peyton-Jones | Subject: Haskell as a first language? | | I'll make this short! Do you think Haskell is a good language to start | with? I am brand new to programming and have been using Scheme, some of | my peers suggest I should use Haskell. It seems professional to me. | Has features that a beginner should not worry about. What would you | suggest. (I'm not worried about bias) | | Thank you very much for your time. | | Charles Turner. Charles, Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. My path into Haskell was roughly C - Python - Scheme - Ocaml - Haskell, and I think that this has a lot going for it (though for a beginner I would recommend Python over Haskell, and Scheme is suitable for beginners with the right textbooks, e.g. How To Design Programs and/or Structure and Interpretation of Computer Programs). If you're willing to work really hard, and don't mind that it may take you quite a bit longer before you are creating real applications in Haskell than it would in e.g. Python, you can start with Haskell (check out the book Real World Haskell: http://realworldhaskell.org). But if you get frustrated, feel free to shift down the list I gave. Scheme or Ocaml are good languages to learn the basics of functional programming, and then you just have to add on the Haskell-specific material (of which there is a lot). Haskell is kind of like a point in the language space that programmers evolve towards. Mike ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] RE: Haskell as a first language?
Hello Michael, Tuesday, July 14, 2009, 2:01:44 PM, you wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. i believe that Haskell is hard for intermediate programmers already knowing any imperative language, but for beginners it should be ideal -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] Re: 20 years ago
[redirected from hask...@] Benjamin L.Russell dekudekup...@yahoo.com writes: One often amusing outgrowth of this is that FP (OOP) fanatics anthropomorphize their functions (objects). Well, I don't think we do. Functions are just mappings of values to values, they may be opaque, but they're predictable, unchanging, and just...too boring to be antropomorphized. Objects contain all kinds of hidden state and dependencies, and the sheer unpredicatability of it all is the reason for the anthropomorphics - it a symptom of a disease, not a desirable quality. -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] AW: Example for formatted show in HStringTemplate
John, thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ;format= embedded in HTML? regards, Torsten -Ursprüngliche Nachricht- Von: John MacFarlane [mailto:fiddlosop...@gmail.com] Gesendet: Dienstag, 14. Juli 2009 08:20 An: Kemps-Benedix Torsten Cc: ha...@googlegroups.com; haskell-cafe@haskell.org Betreff: Re: Example for formatted show in HStringTemplate +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format=%d.%b.%Y$ But I only get toModifiedJulianDay: [54960] as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Program with profiling runs faster than without
On 14 Jul 2009, at 11:09, Grigory Sarnitskiy wrote: I think it is quite strange to the profiled version to run faster I'm really interested how to obtain the same speed withput profiling compilation. This is only a guess, but maybe there is a context-qualified CAF-like value that is being re-evaluated multiple times in the non-profiling case, but is appropriately monomorphised in the profiling case, so it is only evaluated once? Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: Charles, Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. As a contrary data-point, at Oxford we teach functional programming (using Haskell) as the first course at the very beginning of the computer science degree. I know several other universities also use FP and Haskell very early on in their CS courses. On the Oxford course about half the students have had significant previous programming experience. There does not appear to be a significant difference in how quickly students with little previous programming experience learn FP compared to those with more programming experience (keep in mind these are young people, not mature students with years of professional programming experience). The point is, it's not at all clear that it's a harder language for beginners. Unfortunately, it rather hard to gather decent evidence about learning on which one could base decisions on the choice of language. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What to say about Haskell?
Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Gergely -- http://www.fastmail.fm - Same, same, but different... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
On 14 Jul 2009, at 15:30, Patai Gergely wrote: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Lazyness and the many funky things it lets you do -- there's tons of elegant programs that are only possible because of lazyness :) Bob ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
On Tue, Jul 14, 2009 at 2:42 PM, Thomas Davietom.da...@gmail.com wrote: On 14 Jul 2009, at 15:30, Patai Gergely wrote: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Lazyness and the many funky things it lets you do -- there's tons of elegant programs that are only possible because of lazyness :) I'd add type-classes to that. /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
On Tue, Jul 14, 2009 at 3:42 PM, Thomas Davietom.da...@gmail.com wrote: On 14 Jul 2009, at 15:30, Patai Gergely wrote: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Lazyness and the many funky things it lets you do -- there's tons of elegant programs that are only possible because of lazyness :) I would like to know them. I'm looking for small snippets of code that are elegant when written in Haskell (which is lazy by default) but not in other languages supporting some form of laziness (like Python+Iterators). Can you post some? Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
2009/7/14 Patai Gergely patai_gerg...@fastmail.fm: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? When you create the presentation, please consider the big picture of Haskell, not only its technological features like laziness, curryfication, HOF, monadic syntax, type inference, type classes and so on. I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language (I'm thinking about so popular dynamic languages like Python and Ruby): hunting for semantic errors is a significantly shorter task. This comes directly from the technological features I mentioned above: they are in the language for a purpose. My 2 cents. Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
http://www.haskell.org/haskellwiki/Tying_the_Knot would seem to be relevant. On Tue, Jul 14, 2009 at 9:55 AM, Cristiano Paris fr...@theshire.org wrote: I would like to know them. I'm looking for small snippets of code that are elegant when written in Haskell (which is lazy by default) but not in other languages supporting some form of laziness (like Python+Iterators). Can you post some? Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
Domain theory semantics, I guess. I know, that if I (or rather a younger copy of me, not knowing a thing about Haskell) would be one of your students, and you tell me that there is such a clean and nice semantics for what we are doing, I'd be excited. Patai Gergely wrote: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? Gergely ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Program with profiling runs faster than without
14.07.09, 15:16, Malcolm Wallace malcolm.wall...@cs.york.ac.uk: This is only a guess, but maybe there is a context-qualified CAF-like value that is being re-evaluated multiple times in the non-profiling case, but is appropriately monomorphised in the profiling case, so it is only evaluated once? Regards, Malcolm And I guess you are quite right. I knew there is a poorly optimized place in my program, but I didn't touch it for some ideological reasons. But this morning I get how to optimize it in an ideological friendly manner, so now without profiling the program ~ 2 times faster. The speed of profiled version hasn't changed, hence I've manually done some work the compiler does during profiling. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: AW: [Haskell-cafe] Example for formatted show in HStringTemplate
What I suspect that you've encountered is an infelicity when importing GenericStandard. The ToSElem instance defaults to that provided by (Data a) context. However, there is no special handler for Data.Time types in the `extQ` chain. I could add one, but that would require relying on the Data.Time library being the latest (since Typeable isn't provided until then) or on conditional compilation and standalone deriving, which is a pain. As the new time package comes into widespread use, I'll fix up the gToSElem function with the appropriate handlers, but until then I'm afraid that standard generics won't play well with Data.Time. GenericWithClass, on the other hand, might yield better results. There is, by the way, (thanks to the efforts of Luke Plant) now an HStringTemplate page on the haskellwiki: http://www.haskell.org/haskellwiki/HStringTemplate. Edits, improvements, etc. of course welcome by all. You may want to post this question and answer there. By the way, I plan to have a new version with a real announcement and a fair share of bugfixes in the next week or so. Cheers, Sterl. Kemps-Benedix Torsten wrote: John, thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ;format= embedded in HTML? regards, Torsten -Ursprüngliche Nachricht- Von: John MacFarlane [mailto:fiddlosop...@gmail.com] Gesendet: Dienstag, 14. Juli 2009 08:20 An: Kemps-Benedix Torsten Cc: ha...@googlegroups.com; haskell-cafe@haskell.org Betreff: Re: Example for formatted show in HStringTemplate +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format=%d.%b.%Y$ But I only get toModifiedJulianDay: [54960] as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John ___ 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/Example-for-formatted-show-in-HStringTemplate-tp24470429p24480823.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
On Tue, Jul 14, 2009 at 3:01 PM, Cristiano Parisfr...@theshire.org wrote: 2009/7/14 Patai Gergely patai_gerg...@fastmail.fm: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? When you create the presentation, please consider the big picture of Haskell, not only its technological features like laziness, curryfication, HOF, monadic syntax, type inference, type classes and so on. I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language (I'm thinking about so popular dynamic languages like Python and Ruby): hunting for semantic errors is a significantly shorter task. This comes directly from the technological features I mentioned above: they are in the language for a purpose. My 2 cents. And maybe adding that Haskell seems to make it easy to concentrate on data flow rather than control flow. /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] What to say about Haskell?
Hello Cristiano, Tuesday, July 14, 2009, 6:01:14 PM, you wrote: When you create the presentation, please consider the big picture of Haskell, not only its technological features like laziness, curryfication, HOF, monadic syntax, type inference, type classes and so on. I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language the question is how to justify this in 1 hour. technical people don't buy such arguments with justification. but if it will be done, it would be best presentation possible -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problem resizing widget contained in window
I created a window, like so: Gtk.windowSetTitle win name Gtk.widgetSetName win Hieroglyph Gtk.onDestroy win (exitWith ExitSuccess) Gtk.windowSetDefaultSize win w h Gtk.containerResizeChildren win And an GLDrawingArea like so: config ← Gtk.glConfigNew [Gtk.GLModeRGBA, Gtk.GLModeMultiSample, Gtk.GLModeDouble, Gtk.GLModeDepth, Gtk.GLModeAlpha] area ← Gtk.glDrawingAreaNew config Gtk.onRealize area ◊ GL.drawBuffer $= GL.BackBuffers Gtk.onExpose area (λ_ → renderOnExpose bus ≫ return True) and finally show it like this: Gtk.containerAdd win area Gtk.widgetShowAll win Now, if someone resizes the window, the GLArea does not appear to resize along with it. Did I screw something up? -- Jeff ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
On Tue, Jul 14, 2009 at 4:46 PM, Bulat Ziganshinbulat.zigans...@gmail.com wrote: ... the question is how to justify this in 1 hour. technical people don't buy such arguments with justification. but if it will be done, it would be best presentation possible I think it's important to elaborate on this. Why don't we create a specific Wiki page about Haskell advocation, developing contents suitable for a presentation to be delivered to an Haskell-unware audience? That would be useful to those people spreading the word :) Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] RE: Haskell as a first language?
I agree -- I think the most major learning curve problem (for me) was not learning haskell directly, it was un-learning all those patterns and workarounds and so on from imperative/OOP languages. Of course, the only problem with learning haskell first is that one will probably be mildly annoyed by most of the more common programming languages ;-) -Ross On Jul 14, 2009, at 6:22 AM, Bulat Ziganshin wrote: Hello Michael, Tuesday, July 14, 2009, 2:01:44 PM, you wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. i believe that Haskell is hard for intermediate programmers already knowing any imperative language, but for beginners it should be ideal -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
On Tue, Jul 14, 2009 at 5:12 PM, Cristiano Parisfr...@theshire.org wrote: ... Why don't we create a specific Wiki page about Haskell advocation, http://haskell.org/haskellwiki/Advocation Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
Any chance of renaming it to Advocacy? On Jul 14, 2009, at 11:42 PM, Cristiano Paris wrote: On Tue, Jul 14, 2009 at 5:12 PM, Cristiano Parisfr...@theshire.org wrote: ... Why don't we create a specific Wiki page about Haskell advocation, http://haskell.org/haskellwiki/Advocation Cristiano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
On 14 Jul 2009, at 13:48, Duncan Coutts wrote: On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: Charles, Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. As a contrary data-point, at Oxford we teach functional programming (using Haskell) as the first course at the very beginning of the computer science degree. I know several other universities also use FP and Haskell very early on in their CS courses. On the Oxford course about half the students have had significant previous programming experience. There does not appear to be a significant difference in how quickly students with little previous programming experience learn FP compared to those with more programming experience (keep in mind these are young people, not mature students with years of professional programming experience). The point is, it's not at all clear that it's a harder language for beginners. Unfortunately, it rather hard to gather decent evidence about learning on which one could base decisions on the choice of language. What I'd be interested to see is how fast beginners pick up haskell compared to imperative language – is it actually hard to learn, or do we just forget how hard it was to learn a new paradigm when we first learned imperative programming. I guess it's rather hard to establish a metric for how fast the learning occurs though. Bob___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What to say about Haskell?
patai_gergely: Hello all, I was asked to give a one-hour 'introductory' seminar on Haskell. The audience is a bunch of very clever people with a wider than usual perspective on programming and mathematics, and my talk should be rather informational than evangelistic. Which topics do you think I should touch by all means given the short time? I'd concentrate on the getting things done aspect. E.g. the efficient production of programs that utilize parallelism in different ways, something Haskell's particularly well suited for. Here's the talk I gave at Supercomputing 08, based on Simon and Satnam's summer tutorial: http://www.galois.com/blog/2008/11/12/beautiful-parallelism-harnessing-multicores-with-haskell/ Parallel programs, multicore programs == real dollar value. Lazy programs, cute but not easy to quantify the benefit. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language the question is how to justify this in 1 hour. technical people don't buy such arguments with justification. but if it will be done, it would be best presentation possible That's not really the direction I'd like to take anyway, because as I said, the primary goal of this talk is not to convince these people to use Haskell, but to give them an overview that's more helpful than reading a book, and it should definitely introduce specific language features and important patterns besides the general talk. The question is which topics are noteworthy. But here's some more context for you: My talk will be the second (there's one every week). The first one will be a comparison of Prolog and Haskell by an expert of the former (not surprisingly a rather mathematically minded fellow), and the third one will be about monads in category theory. Also, the initiator of the seminars is mostly interested in processing natural languages, so it might be a good idea to bring up at least one relevant example -- for instance, the latest post on sigfpe's blog could be nice, but it comes with too many prerequisites. Gergely -- http://www.fastmail.fm - Access your email from home and the web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
Michael Vanier wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. I disagree, based on seeing my wife learn some Haskell with basically no previous experience programming. It was thrilling to see her learn some concepts almost instantly that it actually took me a while to understand because I had preconceived notions of how programming should work. When I talk about how other programming languages do things she thinks it's stupid. For example, I mentioned that you can actually change the values of variables in most other programming languages, and often have to, and she asked how anything understandable gets written that way. I also noticed that when I kept emphasizing that you can pass functions as parameters to other functions she was getting bored; it seemed that it simply would not have made sense any other way. I see no reason why learning more concepts on top of this foundation should be all that hard for her. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
Dear Gergely, Okasaki's Purely Functional Data Structures is a treasure trove of interesting things to demonstrate Haskell on. Especially the data structures based on numerical representations (skew binary numbers and so on) appealed to my mathematical side. Matthias. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] What to say about Haskell?
patai_gergely: I would concentrate on the fact that when you use Haskell, you write code that is less prone to errors and bugs. When you write a program in Haskell and it finally compiles, chances are that there are far less bugs than in a program written in another language the question is how to justify this in 1 hour. technical people don't buy such arguments with justification. but if it will be done, it would be best presentation possible That's not really the direction I'd like to take anyway, because as I said, the primary goal of this talk is not to convince these people to use Haskell, but to give them an overview that's more helpful than reading a book, and it should definitely introduce specific language features and important patterns besides the general talk. The question is which topics are noteworthy. But here's some more context for you: My talk will be the second (there's one every week). The first one will be a comparison of Prolog and Haskell by an expert of the former (not surprisingly a rather mathematically minded fellow), and the third one will be about monads in category theory. Also, the initiator of the seminars is mostly interested in processing natural languages, so it might be a good idea to bring up at least one relevant example -- for instance, the latest post on sigfpe's blog could be nice, but it comes with too many prerequisites. See also Simon Peyton Jones' intro to Haskell, recently: http://erlang-factory.com/upload/presentations/116/SimonPeyton-Jones-ErlangFactoryLondon2009-HaskellandErlangGrowinguptogether.pdf http://www.erlang-factory.com/conference/London2009/speakers/SimonPeytonJones And one big difference from Prolog: centralized community resources. One main implementation, one distribution mechanism, one build system, one central library archive. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: AW: Example for formatted show in HStringTemplate
Torsten, I'm not quite sure what you're asking -- but this simple example seems to work fine: Prelude Text.StringTemplate let (a :: StringTemplate String) = newSTMP $day;format=\%d.%b.%Y\$ Prelude Text.StringTemplate Data.Time render $ setAttribute day (ModifiedJulianDay 234) a 09.Jul.1859 John +++ Kemps-Benedix Torsten [Jul 14 09 12:20 ]: John, thanks for your answer, but HStringtemplate has instance definitions for Date.Time.Day. The question is more on the script side: How do I have to write the ST calls with ;format= embedded in HTML? regards, Torsten -Ursprüngliche Nachricht- Von: John MacFarlane [mailto:fiddlosop...@gmail.com] Gesendet: Dienstag, 14. Juli 2009 08:20 An: Kemps-Benedix Torsten Cc: ha...@googlegroups.com; haskell-cafe@haskell.org Betreff: Re: Example for formatted show in HStringTemplate +++ Kemps-Benedix Torsten [Jul 13 09 23:56 ]: Hello, is there a working example of how to use the format clause with HStringTemplate, e.g. for Data.Time.Day? I think, if there is a parameter $day$, a reasonable template might contain e.g.: $day;format=%d.%b.%Y$ But I only get toModifiedJulianDay: [54960] as the result which corresponds to the unformatted show. You probably need to define a StringTemplateShows instance for Data.Time.Day, and then use stShowsToSE to define a ToSElem instance. Something like instance StringTemplateShows Day where stringTemplateFormattedShow formatString = formatTime defaultTimeLocale formatString {- or whatever -- I'm not sure what the correct time-formatting function is -} instance ToSElem Day where toSElem = stShowsToSE John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell as a first language?
On Tue, 2009-07-14 at 03:01 -0700, Michael Vanier wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. Then Duncan said: As a contrary data-point, at Oxford we teach functional programming (using Haskell) as the first course at the very beginning of the computer science degree. I know several other universities also use FP and Haskell very early on in their CS courses. At Imperial College, Haskell's also the first language the undergrads touch and people seem to like it. I think it's easy to forget how reassuring it is to be surrounded by lots of other beginners when one is learning something completely new - like programming. A lot of people here seem to be suggesting that haskell is an advanced language for advanced programmers. I think it more likely that people whose first experience of haskell is online are likely to come into contact with mostly advanced programmers in here and on #haskell. This is great, because they can teach us things - but it can also be off-putting, because they can seem so far beyond us. Imagine trying to learn basic arithmetic in a university common room full of category theorists. Personally, I think that haskell is a great beginners language. Just don't feel that you have to be able to keep up with all the #haskellers. It's absolutely fine to not understand what a monad transformer is. G ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
At Tue, 14 Jul 2009 03:01:44 -0700, Michael Vanier wrote: Haskell is a wonderful language (my favorite language by far) but it is pretty difficult for a beginner. In fact, it is pretty difficult for anyone to learn in my experience, because it has so many advanced concepts that simply don't exist in other languages, and trying to absorb them all at once will likely be overwhelming. I think that all programming languages are hard to learn, because it involves a new way of thinking. It maybe be that Haskell is harder to learn as your *second* language because you have to unlearn things. Especially if your first language was something like C or Python. Additionally, I suspect people forget how hard it was to learn their first language. They get used to the idea that if they know Python, they can learn Ruby with out to much difficulty. But that is only because Python and Ruby share a lot in common. When moving from Python to Haskell, there is simply more to learn (and unlearn). But, if you start by knowing nothing, then it is not clear that you have to learn more to learn Haskell than you would some other language. Also, Haskell may be easier to learn because it's concepts are more 'pricipled' and 'sensible'. Imperative languages tend to allow all sorts of silly errors. For example, letting you use unitialized variables (nearly impossible to do in Haskell). And automatic type casting has burned me so many times. (Especially automatic conversion between floating ponit numbers and integers.) I seldom get off-by-one errors in Haskell, but I do get them in imperative/OOP languages. I suspect that if you don't know any language and want to become a Haskell expert as quickly as possible, then the quickest, straigtest path is to start with Haskell. Also, it depends on what you mean by 'learn' and 'Haskell'. Just as a beginning C++ programmer is not going to learn about templates on day one, a beginner Haskell programmer probably won't be learning type families on day one. Additionally, Haskell includes numerous libraries which are not part of the language itself. Things like parser combinators, pretty printing, applicative functors, etc, are all just libraries. But each of those libraries brings a bunch of new concepts. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Goldman Sachs - your home for OCaml and Erlang?
Max Cantor wrote: I know that this is a bit off topic, but thought it would interest several readers. Apparently, GS, which. AFAIK, doesn't make a lot of noise in the FP space compared to some other banks, does use some FP: http://www.zerohedge.com/article/aleynikov-code-dump-uncovered The link you gave seems controversial. But there is a more relative product based on OCaml that GS actually uses (or have used): http://www.lexifi.com/press_2002-09-02.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell as a first language?
Before teaching any data structure course, one MUST learn functional languages with ADTs. It makes everything so easy to understand. So, it MUST be a first language in every institution. The biggest reason that one should learn functional languages with algebraic data type(ADT)s first is because understanding recursive definitions. If you recursion first, understanding iteration and mutable data structures are dead simple and easy: they are just alternate representation or optimization. However, when you learn while loops and for loops first, your brain gets damaged and a lot of students gets stuck when they first see the Tower of Hanoi, the notorious in-place quicksort routine written in imperative languages, you'll get to think of recursion as some stack blowing up monster that must be unrolled and managed manually. Furthermore, learning data structures in most traditional imperative language literature gives you the impression that linked list and binary trees are brain-fucking spaghetti monsters of memory pointers all the cells, which is a dead simple recursive definition in functional languages with ADTs. Personally, I never really understood what linked list was before I learned ML and Haskell, although I've used doubly linked list in a C++ standard library, which was to me a black box that meets the specification in some huge standard document, for two years. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RE: Haskell as a first language?
It maybe be that Haskell is harder to learn as your *second* language because you have to unlearn things. Especially if your first language was something like C or Python. Python is not too bad. You can nearly use it a as a strict functional programming language. While this is not the idiomatic style to use python in, it sure eases transition to a real functional language (compared to say, C). Also Python has no pointers, but does have garbage collection. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Circular pure data structures?
Hello, Is it possible to create a circular pure data structure in Haskell? For example: a :: Data let b = getNext a let c = getNext b c == a -- Gives True Thanks, -John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Build 32-bit apps on 64-bit Windows?
If I am running GHC on 64-bit Windows, do I have a choice of building a 32-bit or 64-bit app? On a cursory glance through the command-line options, I didn't find anything. - Lyle ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
On Jul 14, 2009, at 18:27 , John Ky wrote: Is it possible to create a circular pure data structure in Haskell? For example: http://haskell.org/haskellwiki/Tying_the_knot -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
Yes, using lazy semantics. http://www.haskell.org/haskellwiki/Tying_the_Knot -Ross On Jul 14, 2009, at 6:27 PM, John Ky wrote: Hello, Is it possible to create a circular pure data structure in Haskell? For example: a :: Data let b = getNext a let c = getNext b c == a -- Gives True Thanks, -John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
On Wed, Jul 15, 2009 at 08:27:04AM +1000, John Ky wrote: a :: Data let b = getNext a let c = getNext b c == a -- Gives True What do you mean? This works type Data = () getNext = id but I guess this is not what you meant ;). -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. Pointer equality (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general pointer equality of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to Read this?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On Tue, Jul 14, 2009 at 1:49 AM, Magicloud Magiclouds wrote: Hi, I have a data structure, which shows like this: AttrBgColor {bgColor = Color 0 0 0} And the following is my Read code. But it failed parsing 31 instance Read Attribute where 32 readsPrec _ str = [ (mkAttr attr_ color, rest) | (attr_, rest1) 33 , (color, rest) 34 || (isPrefixOf {fgColor = rest1) 35 then case reads $ drop 12 rest1 of 36 [(color_, rest_)] - [(color_, rest_)] 37 _ - [(Color 0 0 0, rest1)] 38 else [(Color 0 0 0, rest1)] ] 39 where mkAttr AttrFgColor color = AttrFgColor color 40 mkAttr AttrBgColor color = AttrBgColor color 41 mkAttr AttrInverse _ = AttrInverse 42 mkAttr AttrWeak _ = AttrWeak 43 mkAttr AttrUnderline _ = AttrUnderline Perhaps I am mis-understanding you, but why aren't you just deriving Read Show? eg. data AttrBgColor = AttrBgColor { bgColor :: Color Int Int Int } deriving (Read, Show) It would certainly seem to be much easier and more reliable than hand-rolling an ad hoc parser. - -- gwern -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkpdJS8ACgkQvpDo5Pfl1oI/1QCfUgfHVsD/PMmgS6Z1sMMPljWt zOkAn0hQ3GBLFxHCO6ryoYyvPZ+nDJdp =qR5d -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] laziness blowup exercise
Challenge: change one function in the following pipeline so that t doesn't blow up when executed in ghci. import qualified Data.Set as S t = last . take (10^6) . iterate f $ S.empty f s = S.delete 1 . S.insert 1 $ s Please suggest more of these types of exercises if you have them and maybe we can collect the folk wisdom into a wiki page and/or exercise page for beginners. spoiler for the above problem below :) myiterate f x = let nxt = f x in nxt `seq` x : myiterate f nxt ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: iteratee enumHandle (and parsing)
Hello, This explanation is entirely correct. I'm not happy with this situation, because I think it's confusing for people just starting with iteratee. However, I do want something that will be unicode (and other possible encodings) aware. Currently, I'm waiting to see how unicode support in the base libraries works out. What seems the best possibility at this time is writing codecs that could be used with mapStream or convStream to handle this appropriately, but I'd prefer to re-use core unicode support if possible. I'm open to suggestions on this issue. At the very least, I should probably include the ASCII encoding in the iteratee package. I'd like to make the common case of reading ASCII text easier than it currently is. Until then, one approach is using mapStream as suggested below. Another is using a wrapped ByteString instead of the List chunk. The ByteString chunk forces the element to be an 8-bit ASCII character instead of using the Char storable instance. If the full polymorphism of the List chunk is required, the conversion can be done with either mapStream or convStream. convStream is probably more efficient for this at the moment. Regarding using Parsec with iteratees: unfortunately I don't really do much in the way of parsing myself so I'm not much help here. I think that Oleg intended for parsers to be written directly using the iteratee primitives, in particular the heads function would be useful (at least he found it so). I don't see an efficient way to generate a continuation on a partial parse with Parsec, using iteratees or not. I think you could just load data into a parser with setInput, but if you don't have enough data for a complete parse you'll just need to hold onto all the data until you've loaded enough to run it. If you tell me what functions you find lacking from iteratee, I'll look into implementing them. I'd rather not re-implement all of Parsec, but the text parsers should be simple enough, as well as some of the combinators. Cheers, John Lato From: Echo Nolan hell...@comcast.net Hi Paolino. What's happening is reading [Char] uses the Storable instance for Char which is 32-bit. Thus, you get gibberish. The below does what you want, by reading Word8s and converting them. import Control.Exception import Data.Char import Data.Iteratee.IO import Data.Iteratee.Base import Data.Word import System.IO main :: IO () main = do h - openFile mamma23 ReadWriteMode hPutStr h ciao hSeek h AbsoluteSeek 0 l - enumHandle h readString = run print $ assert (l == ciao) () -- This is declared on its own so I can give a type signature without making -- any of the above lines unmanageably long. readString :: IterateeG [] Word8 IO String readString = joinI $ mapStream (chr . fromIntegral) stream2list This only works for ASCII, of course. Someone should write some enumerators for the other encodings. Regards, Echo Nolan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
John Dorsey wrote: John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. That depends on what you mean by proof or comparison. Usually large proofs are constructed by induction (breaking the problem apart bit by bit), but that only works for arbitrarily large but nevertheless finite problems. If you try induction on a (possibly) infinite structure you'll get a (possibly) non-terminating proof/program. Instead, for infinite structures we must use coinduction to reason about them. In a sense, this changes the definition of proof from yes this is the case into yes this is the case as far as you know, since in finite time we can only look at a finite portion of any structure (and conversely, differences that we can't/don't observe don't matter). Often this results in semidecidable properties from the inductive world becoming co-semidecidable in the coinductive world (if two infinite streams are unequal this can be discovered in finite time, but discovering that they are equal is trickier). -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: AC-Vector, AC-Colour and AC-EasyRaster-GTK
On Jul 10, 2009, at 8:44 PM, Wolfgang Jeltsch wrote: Am Freitag, 10. Juli 2009 05:26 schrieb rocon...@theorem.ca: I find it amazing that you independently chose to spell colour with a `u'. It makes me feel better about my choice. I have to admit that it makes me unhappy. :-( Why do we use English for identifiers? Because English is the language of computer science. What English should we use? It’s tempting to say, we should use the original English, which is British English. But we should ask again what is the language of computer science. And the language of computer science is American English. It was possible to adopt such an attitude in the 20th century. But this is the 21st century. We have globalisation, internationalisation, localisation. We have Unicode, so that people are no longer limited to the set of characters that technicians from the USA found tolerable back in 1967. (Note that Americans includes French Canadians and lost of people who mainly speak Spanish.) Let's face it, by this argument we'd have to abandon the metric system when writing computer programs. There are good reasons to adopt American speling for a term or English spelling. They include the language that the author is most familiar with, the language the paying customers are most familiar with, the language of the laws that the program has to conform to, any number of things. But there is a way above this issue. Why can't we have BOTH Colour AND Color? What changes, if any, would it take for Haskell to support bidialectal naming practices (whether it is English -vs- American, insular/Brazilian Portuguese, Norwegian, Arabic dialects, or whatever)? We can create an alias for a type easily enough. We can create an alias for a defined function easily enough. We cannot create an alias for a constructor; there is no way to say data X = A | B Int constructor C = B so that C can be used for pattern matching just like B. We cannot create an alias for a module name; while we can create a module that re-exports everything from some module, there is no way to make them act the same as far as inheritance of dotted names is concerned. SML has similar limitations, but not quite the same. It lets us create alias for types and defined functions. It also lets us create aliases for modules, its structures and functors (more or less). But even SML doesn't allow the definition of aliases for constructors. To my knowledge, most early developments in computer science had their roots in the US. One consequence of this is that reserved words of programming languages are typically in American English. PASCAL uses “program”, not “programme”, and BASIC uses “COLOR”, not “COLOUR”. So, in my opinion, Haskell color packages should use the identifier Color, not Colour. By the way, I also write my papers and documentation in American English. Best wishes, Wolfgang (who is neither British nor American) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Leaner Haskell.org frontpage
On Jul 10, 2009, at 6:14 PM, Thomas Davie wrote: In my mind, the front page is for nothing more than enticing people to use Haskell for long enough to look at a second page where all the useful stuff is if you are a haskell programmer. I would have thought that a web page should serve its most frequent visitors best. By all means have an enticing paragraph at the top, pointing to a second page, but why make life hard for regular Haskellers visiting their site? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
Hello, Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward. I didn't actually care for equality. I think the tying the knot technique as mentioned by others is sufficient for this purpose. Cheers, -John On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey hask...@colquitt.org wrote: John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. Pointer equality (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general pointer equality of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
Sufficient, but not good. Try zippers instead. On 15 Jul 2009, at 08:29, John Ky wrote: Hello, Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward. I didn't actually care for equality. I think the tying the knot technique as mentioned by others is sufficient for this purpose. Cheers, -John On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey hask...@colquitt.org wrote: John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. Pointer equality (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general pointer equality of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
Hello, If I use zippers, do all my nodes need to be the same type? My tree doesn't have the same type for every node. For example: Modules - Module - Types - Type - Members - Member - Type - ... Thanks -John On Wed, Jul 15, 2009 at 2:41 PM, Miguel Mitrofanov miguelim...@yandex.ruwrote: Sufficient, but not good. Try zippers instead. On 15 Jul 2009, at 08:29, John Ky wrote: Hello, Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward. I didn't actually care for equality. I think the tying the knot technique as mentioned by others is sufficient for this purpose. Cheers, -John On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey hask...@colquitt.org wrote: John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. Pointer equality (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general pointer equality of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
Zippers come up as the derivative of the type; if you haven't yet encountered this trick, then first find it :) Try differentiating your datastructure. 2009/7/15 John Ky newho...@gmail.com: Hello, If I use zippers, do all my nodes need to be the same type? My tree doesn't have the same type for every node. For example: Modules - Module - Types - Type - Members - Member - Type - ... Thanks -John On Wed, Jul 15, 2009 at 2:41 PM, Miguel Mitrofanov miguelim...@yandex.ru wrote: Sufficient, but not good. Try zippers instead. On 15 Jul 2009, at 08:29, John Ky wrote: Hello, Actually, I wanted to be able to create a tree structure when I can navigate both leaf-ward and root-ward. I didn't actually care for equality. I think the tying the knot technique as mentioned by others is sufficient for this purpose. Cheers, -John On Wed, Jul 15, 2009 at 8:55 AM, John Dorsey hask...@colquitt.org wrote: John, Is it possible to create a circular pure data structure in Haskell? For example: Creating the data structure is easy; as other respondents have pointed out. A simple example is this... ones = 1 : ones ones' = 1 : ones' Comparing these values is harder. All of (ones), (ones'), (tail ones), and so forth are equal values. But I don't know how to compare them. My Spidey-sense tells me there's probably a simple proof that you can't, if you care about the comparison terminating. Pointer equality (ie. testing if the values are represented by the same bits in memory) is no good, since it's entirely up to the compiler whether ones and ones' use the same bits. (They won't, but that's not important.) In general pointer equality of Haskell values, such as ones and (tail ones) interferes with referential transparency, which is held in high regard around here. Although, for the record, when pointer equality is really what you want, I'm sure there's ways to Force It. For your purposes, does it matter if you can actually do the comparison? Is it enough to know that ones and (tail ones) are equal? Regards, John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Circular pure data structures?
On Wed, Jul 15, 2009 at 12:13 AM, Eugene Kirpichovekirpic...@gmail.com wrote: Zippers come up as the derivative of the type; if you haven't yet encountered this trick, then first find it :) Try differentiating your datastructure. Here's a paper with a good introduction to the concept and bibliography: http://strictlypositive.org/dfordata.pdf My take on it: A zipper is the one-hole-context of your data-type plus a focused-on payload. Data-structure differentiation is the method for deriving the one-hole-context. Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] Re: 20 years ago
On Tue, 14 Jul 2009 12:36:02 +0200, Ketil Malde ke...@malde.org wrote: [redirected from hask...@] Benjamin L.Russell dekudekup...@yahoo.com writes: One often amusing outgrowth of this is that FP (OOP) fanatics anthropomorphize their functions (objects). Well, I don't think we do. Functions are just mappings of values to values, they may be opaque, but they're predictable, unchanging, and just...too boring to be antropomorphized. Objects contain all kinds of hidden state and dependencies, and the sheer unpredicatability of it all is the reason for the anthropomorphics - it a symptom of a disease, not a desirable quality. Although I don't necessary agree with your choice of the term, I find it interesting that you should use the biological term disease; according to a post [1] entitled Re: Re: Smalltalk Data Structures and Algorithms, by K. K. Subramaniam, dated Mon, 29 Jun 2009 11:25:34 +0530, on the squeak-beginners mailing list (see http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html), Concepts in Squeak [a dialect and implementation of Smalltalk] have their origins in biology rather than in computational math See the reading list at http://www.squeakland.org/resources/books/readingList.jsp particularly The Selfish Gene by Richard Dawkins. It's an interesting coincidence that you should hit upon the term disease, which also derives from biology. It's not just the sheer unpredictability of it all that is the reason for the anthropomorphics; it is the fundamental difference of the basis in biology vs. computational mathematics. Haskell (and FP) derive from the latter; Smalltalk (and OOP) derive from the former. Biological structures also contain all kinds of hidden state and dependencies; in that sense, objects are similar to biological structures, and are more easily anthromorphized on that account. Functional programming functions, on the other hand, are not similar to biological structures, and hence are not easily anthromorphized; instead, they are similar to mathematical functions. I wouldn't necessarily say that anthromorphics ... [is] a symptom of a disease, though. Anthromorphics simply uses terms from biology, from which concepts in Squeak (and the OO paradigm thereof) derive. The closest counterpart for Haskell that I can think of is the puzzle game Alligator Eggs! [2] (see http://worrydream.com/AlligatorEggs/), by Bret Victor, which draws an analogy between various behaviors of alligators and operations in the lambda calculus--a collection of allomorphisms, perhaps? -- Benjamin L. Russell [1] Subramaniam, K. K. Re: Re: Smalltalk Data Structures and Algorithms. The Beginners Archives. Squeak.org. 29 June 2009. 15 July 2009. http://lists.squeakfoundation.org/pipermail/beginners/2009-June/006270.html. [2] Victor, Bret. Alligator Eggs! _Bret Victor's website._ Bret Victor. 11 May 2007. 15 July 2009. http://worrydream.com/AlligatorEggs/. -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Translator/Interpreter / Mobile: +011 81 80-3603-6725 Furuike ya, kawazu tobikomu mizu no oto. -- Matsuo Basho^ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe