From ekirpichov at gmail.com Tue Sep 1 00:45:46 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Sep 1 00:25:12 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251627255.6592.30.camel@localhost> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> Message-ID: <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> Hm, on my machine Don's code has exactly the same performance my code above. Also, replacing the 'test' and 'parse' functions with this one add :: Int -> Int -> S.ByteString -> Int add k i s = fst $ S.foldl' f (i, 0) s where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) | otherwise = (i, 0) f (!i, !n) w = (i, 10*n+ord w-ord '0') increases performance by another 15% (0.675s vs 0.790s) 2009/9/1 Jason Dusek : > ?I've updated Don Stewart's solution to compile with the modern > ?ByteString libs. I'll be looking at ways to improve the > ?performance of the `bytestring-nums` package. > > -- > Jason Dusek > > > http://github.com/jsnx/bytestring-nums/blob/d7de9db83e44ade9958fb3bfad0b29ede065b5dd/SPOJDons.hs > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bulat.ziganshin at gmail.com Tue Sep 1 00:43:11 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Sep 1 00:28:59 2009 Subject: [Haskell-cafe] GUI library In-Reply-To: References: <4A994339.6000201@alumni.caltech.edu> Message-ID: <478661913.20090901084311@gmail.com> Hello Job, Tuesday, September 1, 2009, 1:16:38 AM, you wrote: > I recommend qtHaskell. how it's in areas of - memory deallocation when it's no more need - is it automatic or manual? - unicode support - compatibiliy with latest ghc versions - does it build by Cabal or we need to wait while gurus release installers for Windows? - does it use native GUI controls on Windows or draws them itself? i'm asking because those questions arise when using other libs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From z_axis at 163.com Tue Sep 1 01:01:44 2009 From: z_axis at 163.com (zaxis) Date: Tue Sep 1 00:41:10 2009 Subject: [Haskell-cafe] How to fix such a TYPE problem ? In-Reply-To: <7ca3f0160908312054x708c590frc281c73e31f996fe@mail.gmail.com> References: <25233906.post@talk.nabble.com> <7ca3f0160908312054x708c590frc281c73e31f996fe@mail.gmail.com> Message-ID: <25234336.post@talk.nabble.com> thanks! Luke Palmer-2 wrote: > > On Mon, Aug 31, 2009 at 9:47 PM, zaxis wrote: >> >>>let [y,m,d] = map (\x -> read x::Int) $ splitRegex (mkRegex "-") >> "2009-08-31" >>>fromGregorian y m d >> >> Couldn't match expected type `Integer' against inferred type `Int' >> ? ?In the first argument of `fromGregorian', namely `y' >> ? ?In the expression: fromGregorian y m d >> ? ?In the definition of `it': it = fromGregorian y m d > > fromGregorian is expecting an Integer for y, and you gave it an Int. > You just need to convert; fromIntegral works fine for this. > > fromGregorian (fromIntegral y) m d > _______________________________________________ > 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/How-to-fix-such-a-TYPE-problem---tp25233906p25234336.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Tue Sep 1 01:40:21 2009 From: dons at galois.com (Don Stewart) Date: Tue Sep 1 01:21:59 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251627255.6592.30.camel@localhost> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> Message-ID: <20090901054021.GD31996@whirlpool.galois.com> Good work guys. If you can abstract out a common function for lexing ints out of bytestrings, we could add it to the bytestring-lexing package. ekirpichov: > Hm, on my machine Don's code has exactly the same performance my code above. > > Also, replacing the 'test' and 'parse' functions with this one > > add :: Int -> Int -> S.ByteString -> Int > add k i s = fst $ S.foldl' f (i, 0) s > where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) > | otherwise = (i, 0) > f (!i, !n) w = (i, 10*n+ord w-ord '0') > > increases performance by another 15% (0.675s vs 0.790s) > > 2009/9/1 Jason Dusek : > > ?I've updated Don Stewart's solution to compile with the modern > > ?ByteString libs. I'll be looking at ways to improve the > > ?performance of the `bytestring-nums` package. > > > > -- > > Jason Dusek > > > > > > http://github.com/jsnx/bytestring-nums/blob/d7de9db83e44ade9958fb3bfad0b29ede065b5dd/SPOJDons.hs > > _______________________________________________ > > 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 > From bugfact at gmail.com Tue Sep 1 03:40:26 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 1 03:19:55 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: Message-ID: but without that function, stable names are not that useful I guess? they would cause a space leak? On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: > I also would like a isStableNameTargetAlive function. > Though if you had such a function then you probably _could_ make a > deRefStableName function, which, since there isn't one, probably means > that such a function would be hard to make. > > - Job > > On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen wrote: > >> >From the documentation, I don't think I grasp how stable names work. >> From the docs: >> "There is no deRefStableName operation. You can't get back from a stable >> name to the original Haskell object. The reason for this is that the >> existence of a stable name for an object does not guarantee the existence of >> the object itself; it can still be garbage collected." >> >> From this I can conclude that stable names behave a bit like weak >> pointers. >> >> However, suppose I have a hash table of these stable names. How can I >> remove the redundant stable names from the table? I mean removing stable >> names that refer to an object that is garbage collected? I don't see any >> function for checking that (e.g. isStableNameTargetAlive or something) >> >> Thanks, >> Peter >> >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/c9f31291/attachment.html From Christian.Maeder at dfki.de Tue Sep 1 04:14:43 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Tue Sep 1 03:54:12 2009 Subject: [Haskell-cafe] Re: Snow Leopard Breaks GHC In-Reply-To: References: <3e1162e60908281615u3b2840beh32b89dac378e9808@mail.gmail.com> <20090829043049.GA18159@whirlpool.galois.com> <74D31B67-76FC-4CFA-9124-D9FC8842296D@gmail.com> <74C174C8-F693-4775-8C5C-25D2EE12AB3C@gmail.com> <3e1162e60908290910k344c4926p3a4bf1b2f27e1cd7@mail.gmail.com> <3e1162e60908300706k7997c21flc385e5ed6aa34317@mail.gmail.com> <4A9BADE3.8020201@dfki.de> <5C4479A6-F74F-4CEF-B492-A3DBBBA701B2@gmail.com> Message-ID: <4A9CD7F3.9010703@dfki.de> It seems, bootstrapping cabal went wrong. Does http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg work? Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) may be used. These options may also be passed to "./Setup configure" C. Tom Tobin wrote: > Hmm ... running Snow Leopard here, I added these arguments to my > /usr/bin/ghc (and my /usr/bin/ghci, and /usr/bin/runhaskell, for good > measure), and I end up getting the following error on "cabal update" > after installing cabal-install: > > ***** > cabal: user error (Codec.Compression.Zlib: incompatible version) > ***** > > Earlier in the cabal-install bootstrap process, I get the following line: > > ***** > ld: warning: in > /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/libgmp.a, > file is not of required architecture > ***** > > I'm guessing something's still not being set to 32-bit? From jeffzaroyko at gmail.com Tue Sep 1 04:25:19 2009 From: jeffzaroyko at gmail.com (Jeff Zaroyko) Date: Tue Sep 1 04:04:43 2009 Subject: [Haskell-cafe] Takusen - is anyone currently using it on Win32 - ODBC? In-Reply-To: References: <79d7c4980908231347i630c29fdk147ab17303e56368@mail.gmail.com> <4A9C0C9C.5090609@appsolutions.com> Message-ID: 2009/9/1 G?nther Schmidt : > > One of the files for instance has 298 k lines. A glance over sushi revealed > that parsec is involved so I can only presume it is read into memory all at > once. That would certainly be a problem. > There is nothing inherent about parsec that would cause all input to be read into memory, TxtSushi uses parsec for parsing SQL, not for CSV, by the way. From g.c.stavenga at uu.nl Tue Sep 1 05:05:42 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Tue Sep 1 04:45:07 2009 Subject: [Haskell-cafe] Question about Lazy.IO Message-ID: <25236848.post@talk.nabble.com> Hi, I've been wondering about Lazy IO for a while. Suppose we have a program like main = interact (unlines . somefunction . lines) then somefunction is a pure function. With the semantic interpretation of: given a input list return an output list. However I, the user, can change my input depending on the output of this function. Now in simple cases like this, this will not be a problem. But suppose you are reading and writing to a file. Now the result of pure functions become dependent on the order of execution, breaking (I think) referential transparency. Am I wrong here or how could you prove that Lazy IO is consistent nonetheless? Greetings, Gerben -- View this message in context: http://www.nabble.com/Question-about-Lazy.IO-tp25236848p25236848.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From lrpalmer at gmail.com Tue Sep 1 06:10:34 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Sep 1 05:49:58 2009 Subject: [Haskell-cafe] Question about Lazy.IO In-Reply-To: <25236848.post@talk.nabble.com> References: <25236848.post@talk.nabble.com> Message-ID: <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> On Tue, Sep 1, 2009 at 3:05 AM, staafmeister wrote: > Hi, > > I've been wondering about Lazy IO for a while. Suppose we have a program > like > > main = interact (unlines . somefunction . lines) > > then somefunction is a pure function. With the semantic interpretation of: > given a input list > return an output list. However I, the user, can change my input depending on > the output of this > function. Now in simple cases like this, this will not be a problem. But > suppose you are reading > and writing to a file. Now the result of pure functions become dependent on > the order of execution, > breaking (I think) referential transparency. Am I wrong here or how could > you prove that Lazy IO > is consistent nonetheless? Ignoring timeliness in responses (which our theory doesn't talk about), you are allowed to change your input based on its output in exactly the same way as any other function could. The reason this is okay is in the realm of domain theory. There is a good introductory tutorial in the Haskell wikibook: http://en.wikibooks.org/wiki/Haskell/Denotational_semantics Here is an intuition. Let's forget you are a user, and just call you a function "user". user :: String -> String program :: String -> String The input and output of a program is related to these functions like so: let input = user output output = program input in (input, output) Now, user could certainly be a function like: user ('a':rest) = 'x':rest user ('b':rest) = 'y':rest Which makes a decision about what to "type" before seeing all the output. Program could make use of this: program inp = 'a':case inp of { 'x':_ -> "hello"; 'y':_ -> "world" } This mutual recursion would not be well-defined if all of the output must be seen before the input can be known, because the output depends on the input and the input depends on the output. However, this is a perfectly valid Haskell program, without considering I/O, and will compute (input, output) to be ("xhello", "ahello"). I have now tried twice to explain why this is possible more deeply in terms of domain theory, but it has bloated the message to three times this size. If you would like me to include my response, I'd be more than happy to, but it does get rather technical. Luke From g.c.stavenga at uu.nl Tue Sep 1 06:38:33 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Tue Sep 1 06:17:56 2009 Subject: [Haskell-cafe] Question about Lazy.IO In-Reply-To: <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> References: <25236848.post@talk.nabble.com> <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> Message-ID: <25238044.post@talk.nabble.com> Dear Luke, Thanks for your reply. I am interested in a more detailed explanation. If it's to long for this forum you can also mail it to me. In response to your answer. In your program the user is also a pure function. But I, as a user, am not pure so I can do side effects. More specific suppose I program something like this ss <- hGetContent handle (lazy IO) dosomethingweird handle ss (a function that alters the file at will) Now as a programmer I should be positive that ss will be the file as it was before dosomethingweird modifies it. But this can never be guaranteed if ss is lazy. And now things start to depend on the order of evaluation breaking referential transparency, or do I overlook something. For concreteness suppose dosomethingweird appends ss to the end of the file. If ss is strict then it just copies the whole file, if ss is lazy it copies the whole file an infinite number of times. Gerben -- View this message in context: http://www.nabble.com/Question-about-Lazy.IO-tp25236848p25238044.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From colinpauladams at googlemail.com Tue Sep 1 10:23:48 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Tue Sep 1 10:03:13 2009 Subject: [Haskell-cafe] Problems installing documentation and sources using Cabal on Mac OSX Message-ID: <1afdeaec0909010723q1a11e04fk7912389a962026d2@mail.gmail.com> I noticed today on the train (no internet connection!) that the documentation for packages I had installed with cabal was missing, and that there was no source in .cabal/packages for them. Now I'm in the offiice, I tried --reinstall --enable-documentation. There was a warning about haddock and ghc version mismatch (so much for the haskell platform install), so I did a --reinstall of haddock. Now the message I see is: cabal: can't find source for module Paths_happstack_server (happstack_server is the first package I'm trying to reinstall to get docs). So I think the documentation failure is because haddock can't find the source code (nor can I), but I don't know why there is no source installed in .cabal/packages - what should I do to further track this problem down? -- Colin Adams Preston, Lancashire, ENGLAND From jvranish at gmail.com Tue Sep 1 11:59:35 2009 From: jvranish at gmail.com (Job Vranish) Date: Tue Sep 1 11:39:00 2009 Subject: [Haskell-cafe] GUI library In-Reply-To: <478661913.20090901084311@gmail.com> References: <4A994339.6000201@alumni.caltech.edu> <478661913.20090901084311@gmail.com> Message-ID: Deallocation is automatic (just like C++ Qt) C++ Qt has excellent unicode support. I haven't explicit tried it in qtHaskell, but as far as I know it should work just fine. Unfortunatly it does not currently build just with cabal, however the build scripts are very clean (no configure) and the haskell half is cabalized. To build on windows you only need the haskell platform and the Qt SDK (and then you either have to put the ghc path into Qts qtEnv.bat (what I did), or you have to put the Qt paths into the system path) and then you run the qtHaskells build.bat and you're done. To build on linux you need the haskell platform and Qt4 dev libraries (they are probably in your distros package manager) and then you run the qtHaskells build script, and your done. Umm, with one gotcha, on my system I had to replace two instances of 'gmake' in the build script with 'make'. You might not have to do that on your system. Qt uses the native APIs to draw controls, so your apps look appropriate on different platforms. - Job On Tue, Sep 1, 2009 at 12:43 AM, Bulat Ziganshin wrote: > Hello Job, > > Tuesday, September 1, 2009, 1:16:38 AM, you wrote: > > > I recommend qtHaskell. > > how it's in areas of > - memory deallocation when it's no more need - is it automatic or > manual? > - unicode support > - compatibiliy with latest ghc versions - does it build by Cabal or we > need to wait while gurus release installers for Windows? > - does it use native GUI controls on Windows or draws them itself? > > i'm asking because those questions arise when using other libs > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/5f0625a9/attachment.html From jvranish at gmail.com Tue Sep 1 11:59:43 2009 From: jvranish at gmail.com (Job Vranish) Date: Tue Sep 1 11:39:09 2009 Subject: [Haskell-cafe] GUI library In-Reply-To: <4A9CB5F5.2070209@alumni.caltech.edu> References: <4A994339.6000201@alumni.caltech.edu> <4A9CB5F5.2070209@alumni.caltech.edu> Message-ID: If you're already used to C++ Qt and PyQt, qtHaskell should be relatively straightforward (though probably with a few gotchas). You could download qtHaskell and look at the examples to get an idea for the feel of it. If you're already used to Qt they should look familiar. Subclassing _is_ done a little weird: First you declare a dummy datatype: data MyQPushButton = MyQPushButton And then you use the qSubClass function: myQPushButton :: String -> IO (QPushButton MyQPushButton) myQPushButton s = qSubClass $ qPushButton1 s The type signature here is necessary. It's the only thing that forces the new (QPushButton a) to be a QPushButton MyQPushButton. Then you can use your subclassed buttons like so: main :: IO () main = do app <- qApplication dialog <- qDialog button1 <- myQPushButton "Click for Stuff" qObject_connectSlot1 button1 "clicked()" button1 "click()" $ on_pbutton_clicked dialog mainLayout <- qVBoxLayout qLayout_addWidget mainLayout button1 qWidget_setLayout dialog mainLayout qWidget_setWindowTitle dialog "Stuff Test" ok <- qDialog_exec dialog return() on_pbutton_clicked :: QDialog () -> QPushButton MyQPushButton -> IO () on_pbutton_clicked _dlg _this = do mb <- qMessageBox1 _dlg qMessageBox_setText mb $ "Stuff" qWidget_show mb return () Hmmm, though it doesn't look like you can currently overload methods of your parent class, usually you don't need too though as you can just tie into a signal (so you still can do things like paint). Though I'm kinda suprised I didn't notice this before, I'll have to email the guy and see if this is actually an issue. Also, qtHaskell doesn't fully support all the Qt widgets (though it covers most of them) but there is a new version coming out soon that should be more complete. Overall qtHaskell has served my perposes well. There is also a good listing of GUI toolkits for Haskell at http://www.haskell.org/haskellwiki/Applications_and_libraries/GUI_libraries - Job On Tue, Sep 1, 2009 at 1:49 AM, Michael Mossey wrote: > Thanks for the info. Interesting. I'm already familiar with C++ Qt and also > PyQt. I am also a fan of Qt. > > However, as a beginner to Haskell, I want to be sure I don't get myself > into trouble. I hope that qtHaskell is straightforward. > > Qt depends on deriving user classes. How is this handled in qtHaskell? > > Thanks, > > -Mike > > > Job Vranish wrote: > >> I recommend qtHaskell. >> I am a big fan of Qt in general. It has good documentation and extensive >> examples, is very well designed, and has a good license. I'd even say the >> C++ version is good choice for beginners (certainly easier to understand/use >> than say GTK). >> The qtHaskell bindings are also pretty good. The documentation and >> examples are not as extensive, but you can usually use the C++ documentation >> to fill in the gaps. >> Being already familiar with C++ Qt, using qtHaskell was a snap. However, >> if you're unfamiliar with both Qt and Haskell it will probably be confusing >> at first. Though I'd bet money the GTK bindings aren't any better in that >> regard. >> I'd still say you'd be more productive with qtHaskell in the long run. >> >> - Job >> >> >> On Sat, Aug 29, 2009 at 11:03 AM, Michael Mossey > mpm@alumni.caltech.edu>> wrote: >> >> I want to choose a GUI library for my project. Some background: I'm >> a beginner to functional programming and have been working through >> Haskell books for a few months now. I'm not just learning Haskell >> for s**ts and giggles; my purpose is to write >> music-composition-related code; in particular, I want to write a >> graphical musical score editor. (Why write my own editor, you may >> ask? Because I want to fully integrate it with >> computer-assisted-composition algorithms that I plan to write, also >> in Haskell.) I decided to use Haskell for its great features as a >> functional programming language. >> >> Regarding a choice of GUI library, I want these factors: >> >> - it needs to provide at a minimum a drawing surface, a place I can >> draw lines and insert characters, in addition to all the standard >> widgets and layout capabilities we have to come to expect from a GUI >> library. >> >> - This is a Windows application. >> >> - it needs to be non-confusing for an intermediate-beginner >> Haskeller. Hopefully good documentation and examples will exist on >> the web. >> >> - It might be nice to have advanced graphics capability such as Qt >> provides, things like antialiasied shapes, and a canvas with >> efficient refresh (refereshes only the area that was exposed, and if >> your canvas items are only primitives, it can do refreshes from >> within C++ (no need to touch your Haskell code at all). However I'm >> wondering if qtHaskell fits my criteria "well-documented" and "lots >> of examples aimed at beginners". >> >> Thanks, >> Mike >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/05aa7189/attachment.html From jvranish at gmail.com Tue Sep 1 12:09:21 2009 From: jvranish at gmail.com (Job Vranish) Date: Tue Sep 1 11:48:52 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: Message-ID: Well usually, when I've used stable names, I've just used them to check if things are the same, and then thrown them away. So no chance for a space leak. It's usually unsafe to keep stable names around for very long as they can lose their ability to tell if two things are the same (if this surprises you, you should carefully reread http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName). Out of curiosity, how are you planning on using them? - Job On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen wrote: > but without that function, stable names are not that useful I guess? they > would cause a space leak? > > On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: > >> I also would like a isStableNameTargetAlive function. >> Though if you had such a function then you probably _could_ make a >> deRefStableName function, which, since there isn't one, probably means >> that such a function would be hard to make. >> >> - Job >> >> On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen wrote: >> >>> >From the documentation, I don't think I grasp how stable names work. >>> From the docs: >>> "There is no deRefStableName operation. You can't get back from a stable >>> name to the original Haskell object. The reason for this is that the >>> existence of a stable name for an object does not guarantee the existence of >>> the object itself; it can still be garbage collected." >>> >>> From this I can conclude that stable names behave a bit like weak >>> pointers. >>> >>> However, suppose I have a hash table of these stable names. How can I >>> remove the redundant stable names from the table? I mean removing stable >>> names that refer to an object that is garbage collected? I don't see any >>> function for checking that (e.g. isStableNameTargetAlive or something) >>> >>> Thanks, >>> Peter >>> >>> >>> >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/ef707461/attachment-0001.html From bugfact at gmail.com Tue Sep 1 13:02:13 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 1 12:41:38 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: Message-ID: I was planning to use them for caching OpenGL display lists and render targets. These are generated from a pure scene graph description, and if the same description is handed over to the render engine, it would just reuse the previously cached OpenGL object. I can of course just embedding and IORef inside the pure structures, that would also work I guess On Tue, Sep 1, 2009 at 6:09 PM, Job Vranish wrote: > Well usually, when I've used stable names, I've just used them to check if > things are the same, and then thrown them away. So no chance for a space > leak. It's usually unsafe to keep stable names around for very long as they > can lose their ability to tell if two things are the same (if this surprises > you, you should carefully reread > http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName > ). > > Out of curiosity, how are you planning on using them? > > - Job > > On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen wrote: >> >> but without that function, stable names are not that useful I guess? they >> would cause a space leak? >> On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: >>> >>> I also would like a isStableNameTargetAlive function. >>> Though if you had such a function then you probably _could_ make a >>> deRefStableName function, which, since there isn't one, probably means that >>> such a function would be hard to make. >>> >>> - Job >>> >>> On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen >>> wrote: >>>> >>>> >From the documentation, I don't think I grasp how stable names work. >>>> From the docs: >>>> "There is no?deRefStableName?operation. You can't get back from a stable >>>> name to the original Haskell object. The reason for this is that the >>>> existence of a stable name for an object does not guarantee the existence of >>>> the object itself; it can still be garbage collected." >>>> From this I can conclude that stable names behave a bit like weak >>>> pointers. >>>> However, suppose I have a hash table of these stable names. How can I >>>> remove the redundant stable names from the table? I mean removing stable >>>> names that refer to an object that is garbage collected? I don't see any >>>> function for checking that (e.g. isStableNameTargetAlive or something) >>>> Thanks, >>>> Peter >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >> > > From colinpauladams at googlemail.com Tue Sep 1 13:34:54 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Tue Sep 1 13:14:19 2009 Subject: [Haskell-cafe] Can't get my head round monad transformers Message-ID: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> I'm trying to add a state monad onto the IO monad for use in a happstack application. I thought this should involve using StateT and Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to plumb it all together. Any tips will be welcome. -- Colin Adams Preston, Lancashire, ENGLAND From jason.dusek at gmail.com Tue Sep 1 14:06:19 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Sep 1 13:45:42 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <20090901054021.GD31996@whirlpool.galois.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> <20090901054021.GD31996@whirlpool.galois.com> Message-ID: <42784f260909011106t736ad09asc0e3ad6300f7cc61@mail.gmail.com> 2009/08/31 Don Stewart : > If you can abstract out a common function for lexing ints out of > bytestrings, we could add it to the bytestring-lexing package. All the really performant implementations operate on strings with multiple ints in them; I suspect this reduces memory traffic -- and indeed, Eugene's code using my libs allocates about twice as much memory as Don's code. I've tried a few different things with strictness annotations to no avail. I'm having some trouble understanding the meaning of "entries" in the profiler's output. I have a file with 5 million random integers in it, totalling 26210408 bytes (21210408 bytes of which are not newlines). The relevant part is here: COST CENTRE MODULE entries MAIN MAIN 0 main Main 1 bint Main 5000001 lazy_int Data.ByteString.Nums.Careless.Int 41211385 digitize Data.ByteString.Nums.Careless.Int 21210408 The number of "entries" to `lazy_int` is puzzling. Eugene's `bint` is called for each line of the file -- once for the header and then 5 million times for each of the integers. (There are two numbers on the first line but Eugene's program only uses `k` so `bint` is only actually entered once.) However, `bint` just calls my `int` and `int` calls `lazy_int` so why are there 41 million plus "entries" of `lazy_int`? -- Jason Dusek -------------- next part -------------- A non-text attachment was scrubbed... Name: spoj-eugene-prof-opt-bang-acc-scc-dfold.prof Type: application/octet-stream Size: 2874 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/ba7a2ea8/spoj-eugene-prof-opt-bang-acc-scc-dfold.obj From bugfact at gmail.com Tue Sep 1 14:21:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 1 14:00:37 2009 Subject: [Haskell-cafe] Can't get my head round monad transformers In-Reply-To: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> References: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> Message-ID: Maybe the chapter on monad transformers in RWH can help? http://book.realworldhaskell.org/read/monad-transformers.html On Tue, Sep 1, 2009 at 7:34 PM, Colin Adams wrote: > I'm trying to add a state monad onto the IO monad for use in a > happstack application. I thought this should involve using StateT and > Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to > plumb it all together. Any tips will be welcome. > > -- > Colin Adams > Preston, > Lancashire, > ENGLAND > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From lrpalmer at gmail.com Tue Sep 1 14:31:42 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Sep 1 14:11:06 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: Message-ID: <7ca3f0160909011131j63cb000vc4908a90e846e7f6@mail.gmail.com> Have you considered computing a hash of the scene graph description (compositionally)? This gives you all the same advantages, including re-using shared subparts of the graph (which would be unlikely to stay around for very long as stable names). Luke On Tue, Sep 1, 2009 at 11:02 AM, Peter Verswyvelen wrote: > I was planning to use them for caching OpenGL display lists and render > targets. These are generated from a pure scene graph description, and > if the same description is handed over to the render engine, it would > just reuse the previously cached OpenGL object. ?I can of course just > embedding and IORef inside the pure structures, that would also work I > guess > > > > > On Tue, Sep 1, 2009 at 6:09 PM, Job Vranish wrote: >> Well usually, when I've used stable names, I've just used them to check if >> things are the same, and then thrown them away. So no chance for a space >> leak. It's usually unsafe to keep stable names around for very long as they >> can lose their ability to tell if two things are the same (if this surprises >> you, you should carefully reread >> http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName >> ). >> >> Out of curiosity, how are you planning on using them? > >> >> - Job >> >> On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen wrote: >>> >>> but without that function, stable names are not that useful I guess? they >>> would cause a space leak? >>> On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: >>>> >>>> I also would like a isStableNameTargetAlive function. >>>> Though if you had such a function then you probably _could_ make a >>>> deRefStableName function, which, since there isn't one, probably means that >>>> such a function would be hard to make. >>>> >>>> - Job >>>> >>>> On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen >>>> wrote: >>>>> >>>>> >From the documentation, I don't think I grasp how stable names work. >>>>> From the docs: >>>>> "There is no?deRefStableName?operation. You can't get back from a stable >>>>> name to the original Haskell object. The reason for this is that the >>>>> existence of a stable name for an object does not guarantee the existence of >>>>> the object itself; it can still be garbage collected." >>>>> From this I can conclude that stable names behave a bit like weak >>>>> pointers. >>>>> However, suppose I have a hash table of these stable names. How can I >>>>> remove the redundant stable names from the table? I mean removing stable >>>>> names that refer to an object that is garbage collected? I don't see any >>>>> function for checking that (e.g. isStableNameTargetAlive or something) >>>>> Thanks, >>>>> Peter >>>>> >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> 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 > From bugfact at gmail.com Tue Sep 1 14:57:50 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 1 14:42:57 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: <7ca3f0160909011131j63cb000vc4908a90e846e7f6@mail.gmail.com> References: <7ca3f0160909011131j63cb000vc4908a90e846e7f6@mail.gmail.com> Message-ID: Yes that is possible too. But it feels "obvious" to first lookup by stable name. I had no idea stable names were so volatile. They should be called unstable names then :-) In .NET it is possible to assign an identifier to an object, and that identifier will always be the same for the same object, no matter where to garbage collectors moves the object in memory. For Haskell, at first sight it would feel natural to have something like that too. On Tue, Sep 1, 2009 at 8:31 PM, Luke Palmer wrote: > Have you considered computing a hash of the scene graph description > (compositionally)? ?This gives you all the same advantages, including > re-using shared subparts of the graph (which would be unlikely to stay > around for very long as stable names). > > Luke > > On Tue, Sep 1, 2009 at 11:02 AM, Peter Verswyvelen wrote: >> I was planning to use them for caching OpenGL display lists and render >> targets. These are generated from a pure scene graph description, and >> if the same description is handed over to the render engine, it would >> just reuse the previously cached OpenGL object. ?I can of course just >> embedding and IORef inside the pure structures, that would also work I >> guess >> >> >> >> >> On Tue, Sep 1, 2009 at 6:09 PM, Job Vranish wrote: >>> Well usually, when I've used stable names, I've just used them to check if >>> things are the same, and then thrown them away. So no chance for a space >>> leak. It's usually unsafe to keep stable names around for very long as they >>> can lose their ability to tell if two things are the same (if this surprises >>> you, you should carefully reread >>> http://haskell.org/ghc/docs/latest/html/libraries/base/System-Mem-StableName.html#v%3AmakeStableName >>> ). >>> >>> Out of curiosity, how are you planning on using them? >> >>> >>> - Job >>> >>> On Tue, Sep 1, 2009 at 3:40 AM, Peter Verswyvelen wrote: >>>> >>>> but without that function, stable names are not that useful I guess? they >>>> would cause a space leak? >>>> On Mon, Aug 31, 2009 at 10:59 PM, Job Vranish wrote: >>>>> >>>>> I also would like a isStableNameTargetAlive function. >>>>> Though if you had such a function then you probably _could_ make a >>>>> deRefStableName function, which, since there isn't one, probably means that >>>>> such a function would be hard to make. >>>>> >>>>> - Job >>>>> >>>>> On Sun, Aug 30, 2009 at 4:54 PM, Peter Verswyvelen >>>>> wrote: >>>>>> >>>>>> >From the documentation, I don't think I grasp how stable names work. >>>>>> From the docs: >>>>>> "There is no?deRefStableName?operation. You can't get back from a stable >>>>>> name to the original Haskell object. The reason for this is that the >>>>>> existence of a stable name for an object does not guarantee the existence of >>>>>> the object itself; it can still be garbage collected." >>>>>> From this I can conclude that stable names behave a bit like weak >>>>>> pointers. >>>>>> However, suppose I have a hash table of these stable names. How can I >>>>>> remove the redundant stable names from the table? I mean removing stable >>>>>> names that refer to an object that is garbage collected? I don't see any >>>>>> function for checking that (e.g. isStableNameTargetAlive or something) >>>>>> Thanks, >>>>>> Peter >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> 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 >> > From jason.dusek at gmail.com Tue Sep 1 15:34:46 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Sep 1 15:14:11 2009 Subject: [Haskell-cafe] Question about Lazy.IO In-Reply-To: <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> References: <25236848.post@talk.nabble.com> <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> Message-ID: <42784f260909011234u2a2bc9bdj399513e93409cd2e@mail.gmail.com> 2009/09/01 Luke Palmer : > I have now tried twice to explain why this is possible more > deeply in terms of domain theory, but it has bloated the > message to three times this size. ?If you would like me to > include my response, I'd be more than happy to, but it does > get rather technical. I'm sure I'm not alone when I say I'd like to see the longer, more technical response. -- Jason Dusek From jason.dusek at gmail.com Tue Sep 1 18:58:26 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Sep 1 18:37:50 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <5e0214850908300340m558e3936w7ea96143def11f3d@mail.gmail.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251627255.6592.30.camel@localhost> <5e0214850908300340m558e3936w7ea96143def11f3d@mail.gmail.com> Message-ID: <42784f260909011558r2780fa0cj763dfab49c8369de@mail.gmail.com> I've uploaded a new version of bytestring-nums that, while still slower than the fast/custom codes, allows Eugene's earlier program to a little more than 20% faster than it did before. It no longer handles spurious characters in the input by skipping over them (this is probably not a common requirement, anyways). http://hackage.haskell.org/package/bytestring-nums-0.3.0 I suspect that splitting the string into pieces and then mapping the parser over the pieces will never be faster than an all-in-one parser/tester/incrementer like the fast programs have. -- Jason Dusek From allbery at ece.cmu.edu Tue Sep 1 19:25:14 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Sep 1 19:04:55 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: <7ca3f0160909011131j63cb000vc4908a90e846e7f6@mail.gmail.com> Message-ID: On Sep 1, 2009, at 14:57 , Peter Verswyvelen wrote: > In .NET it is possible to assign an identifier to an object, and that > identifier will always be the same for the same object, no matter > where to garbage collectors moves the object in memory. For Haskell, > at first sight it would feel natural to have something like that too. Hm. I'd think such names would have to live in a monad (which then leads you to either Reader or ST, I think). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090901/459ef63b/PGP.bin From z_axis at 163.com Tue Sep 1 22:40:55 2009 From: z_axis at 163.com (zaxis) Date: Tue Sep 1 22:20:18 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? Message-ID: <25250783.post@talk.nabble.com> data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) (GenParser tok st b) please shed a light on me, thanks! -- View this message in context: http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dsouza at bitforest.org Tue Sep 1 22:43:25 2009 From: dsouza at bitforest.org (Diego Souza) Date: Tue Sep 1 22:26:29 2009 Subject: [Haskell-cafe] Question about Lazy.IO In-Reply-To: <42784f260909011234u2a2bc9bdj399513e93409cd2e@mail.gmail.com> References: <25236848.post@talk.nabble.com> <7ca3f0160909010310r167a1a9dsf37477421280b79f@mail.gmail.com> <42784f260909011234u2a2bc9bdj399513e93409cd2e@mail.gmail.com> Message-ID: <20090902024325.GA4881@mephisto.bitforest.org> > I'm sure I'm not alone when I say I'd like to see the longer, > more technical response. No, you aren't. Please `flood in' :-) -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From korpios at korpios.com Tue Sep 1 23:12:33 2009 From: korpios at korpios.com (Tom Tobin) Date: Tue Sep 1 22:51:55 2009 Subject: [Haskell-cafe] Re: Snow Leopard Breaks GHC In-Reply-To: <4A9CD7F3.9010703@dfki.de> References: <3e1162e60908281615u3b2840beh32b89dac378e9808@mail.gmail.com> <74C174C8-F693-4775-8C5C-25D2EE12AB3C@gmail.com> <3e1162e60908290910k344c4926p3a4bf1b2f27e1cd7@mail.gmail.com> <3e1162e60908300706k7997c21flc385e5ed6aa34317@mail.gmail.com> <4A9BADE3.8020201@dfki.de> <5C4479A6-F74F-4CEF-B492-A3DBBBA701B2@gmail.com> <4A9CD7F3.9010703@dfki.de> Message-ID: On Tue, Sep 1, 2009 at 3:14 AM, Christian Maeder wrote: > > It seems, bootstrapping cabal went wrong. Does > http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg > work? Installing the Haskell Platform package, combined with adding the previously mentioned options to /usr/bin/ghc (-optc-m32 -opta-m32 -optl-m32), seems to have done the trick. Thank you! From ekirpichov at gmail.com Tue Sep 1 23:20:38 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Sep 1 23:00:00 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <25250783.post@talk.nabble.com> References: <25250783.post@talk.nabble.com> Message-ID: <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> This means that for any type 'b' you can construct a value of type 'Branch tok st a' by passing to Branch an argument of type '(PermParser tok st (b -> a))' and 'GenParser tok st b'. This also means that when you're given a value of type Branch tok st a, you don't know what that 'b' type was; the only thing you know is that the 'b' in 'b -> a' in the first argument of Branch is the same as the 'b' in 'GenParser tok st b'. See also: the haskellwiki page on existential types. 2009/9/2 zaxis : > > data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) > (GenParser tok st b) > > please shed a light on me, thanks! > -- > View this message in context: http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From stevech1097 at yahoo.com.au Tue Sep 1 23:55:41 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Tue Sep 1 23:33:41 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251627255.6592.30.camel@localhost> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> Message-ID: <1251863741.2602.10.camel@localhost> On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote: > Hm, on my machine Don's code has exactly the same performance my code above. That's strange. > Also, replacing the 'test' and 'parse' functions with this one > > add :: Int -> Int -> S.ByteString -> Int > add k i s = fst $ S.foldl' f (i, 0) s > where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) > | otherwise = (i, 0) > f (!i, !n) w = (i, 10*n+ord w-ord '0') > > increases performance by another 15% (0.675s vs 0.790s) On my system I get a 50% slowdown using this add function! I guess is just shows that benchmarking code on one single CPU/memory/OS/ghc combination does not give results that apply widely. I'm using: AMD Athlon X2 4800 2GB memory Linux (Fedora 11, 64-bit version) ghc 6.10.3 Steve From ekirpichov at gmail.com Wed Sep 2 00:26:23 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Sep 2 00:05:45 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <1251863741.2602.10.camel@localhost> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> <1251863741.2602.10.camel@localhost> Message-ID: <5e0214850909012126k22253ef9wc8cc51788105bd5e@mail.gmail.com> 2009/9/2 Steve : > On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote: >> Hm, on my machine Don's code has exactly the same performance my code above. > That's strange. > >> Also, replacing the 'test' and 'parse' functions with this one >> >> add :: Int -> Int -> S.ByteString -> Int >> add k i s = fst $ S.foldl' f (i, 0) s >> ? where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) >> ? ? ? ? ? ? ? ? ? ? ? ? | otherwise ? ? ? = (i, ? 0) >> ? ? ? ? f (!i, !n) w ?= (i, 10*n+ord w-ord '0') >> >> increases performance by another 15% (0.675s vs 0.790s) > > On my system I get a 50% slowdown using this add function! > > I guess is just shows that benchmarking code on one single > CPU/memory/OS/ghc combination does not give results that apply widely. > I'm using: > AMD Athlon X2 4800 > 2GB memory > Linux (Fedora 11, 64-bit version) > ghc 6.10.3 > I've got a Centrino Duo 2000 (I'm on a notebook), Ubuntu 9.04 and ghc 6.10.2. However, we have not set up on what exact input file we're using :) I'm using one where it is written "10000000 3" and then 10000000 lines of "999999999" follow. Also, I wonder what one'd get if one compiled this program with jhc, but I don't know whether jhc is able to compile Data.ByteString. > Steve > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From stevech1097 at yahoo.com.au Wed Sep 2 00:46:02 2009 From: stevech1097 at yahoo.com.au (Steve) Date: Wed Sep 2 00:23:52 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <1251863741.2602.10.camel@localhost> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251627255.6592.30.camel@localhost> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> <1251863741.2602.10.camel@localhost> Message-ID: <1251866762.3217.8.camel@localhost> On Wed, 2009-09-02 at 11:55 +0800, Steve wrote: > On Tue, 2009-09-01 at 08:45 +0400, Eugene Kirpichov wrote: > > Hm, on my machine Don's code has exactly the same performance my code above. > That's strange. > > > Also, replacing the 'test' and 'parse' functions with this one > > > > add :: Int -> Int -> S.ByteString -> Int > > add k i s = fst $ S.foldl' f (i, 0) s > > where f (!i, !n) '\n' | n`divisibleBy`k = (i+1, 0) > > | otherwise = (i, 0) > > f (!i, !n) w = (i, 10*n+ord w-ord '0') > > > > increases performance by another 15% (0.675s vs 0.790s) > > On my system I get a 50% slowdown using this add function! > > I guess is just shows that benchmarking code on one single > CPU/memory/OS/ghc combination does not give results that apply widely. > I'm using: > AMD Athlon X2 4800 > 2GB memory > Linux (Fedora 11, 64-bit version) > ghc 6.10.3 I should have also said that the test method and test data is important too. This is what I have been using: $ time ./0450 < 0450.input.data and looking at the 'real' value. The file 0450.input.data is generated with a Python script: #!/usr/bin/env python ''' generate a data file for problem 0450 ''' from __future__ import division # new in 2.2, redundant in 3.0 from __future__ import absolute_import # new in 2.5, redundant in 2.7/3.0 from __future__ import print_function # new in 2.6, redundant in 3.0 import io import random inFile = '0450.input.data' #n, k, tiMax = 10**6, 3, 10**9 n, k, tiMax = 10**7, 3, 10**9 with io.open(inFile, 'wb') as f: f.write('%d %d\n' % (n, k)) for i in xrange(n): ti = random.randint(1, tiMax) f.write('%d\n' % (ti,)) Steve From mwotton at gmail.com Wed Sep 2 01:08:57 2009 From: mwotton at gmail.com (Mark Wotton) Date: Wed Sep 2 00:48:26 2009 Subject: [Haskell-cafe] Slow IO? In-Reply-To: <5e0214850909012126k22253ef9wc8cc51788105bd5e@mail.gmail.com> References: <20090829221255.81C2F3243DA@www.haskell.org> <1251633293.2207.16.camel@localhost> <5e0214850908300534m450c23e0m639cc97fe48928ab@mail.gmail.com> <1251643642.2207.53.camel@localhost> <5e0214850908300750o62f42811v2bf9eafa06e6cd60@mail.gmail.com> <1251744019.4914.14.camel@localhost> <42784f260908311443q50865d40w2bde69e69eb034e5@mail.gmail.com> <5e0214850908312145m587264abudf07bcd4181bb0bf@mail.gmail.com> <1251863741.2602.10.camel@localhost> <5e0214850909012126k22253ef9wc8cc51788105bd5e@mail.gmail.com> Message-ID: <57EB5CBF-A190-4A7C-8CC2-D4E5C8928C51@gmail.com> On 02/09/2009, at 2:26 PM, Eugene Kirpichov wrote: >> > > I've got a Centrino Duo 2000 (I'm on a notebook), Ubuntu 9.04 and > ghc 6.10.2. > > However, we have not set up on what exact input file we're using :) > I'm using one where it is written "10000000 3" and then 10000000 lines > of "999999999" follow. > > Also, I wonder what one'd get if one compiled this program with jhc, > but I don't know whether jhc is able to compile Data.ByteString. It couldn't last time I tried - choked on some INLINE pragmas. Might not be a massive job, but there aren't enough hours in the day... mark From z_axis at 163.com Wed Sep 2 01:16:54 2009 From: z_axis at 163.com (zaxis) Date: Wed Sep 2 00:56:16 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> Message-ID: <25251783.post@talk.nabble.com> Isnot it clear without the 'forall' ? data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok st b) thanks! jkff wrote: > > This means that for any type 'b' you can construct a value of type > 'Branch tok st a' by passing to Branch an argument of type > '(PermParser tok st (b -> a))' and 'GenParser tok st b'. > This also means that when you're given a value of type Branch tok st > a, you don't know what that 'b' type was; the only thing you know is > that the 'b' in 'b -> a' in the first argument of Branch is the same > as the 'b' in 'GenParser tok st b'. > > See also: the haskellwiki page on existential types. > > 2009/9/2 zaxis : >> >> data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) >> (GenParser tok st b) >> >> please shed a light on me, thanks! >> -- >> View this message in context: >> http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.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 >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > _______________________________________________ > 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/How-to-understand-the-%27forall%27---tp25250783p25251783.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ryani.spam at gmail.com Wed Sep 2 01:17:20 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Sep 2 00:56:41 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> Message-ID: <2f9b2d30909012217g71ef4fbdi7b6183f879dc5fea@mail.gmail.com> You can also look at it in terms of the "deconstruction" operation on this data type. For example, lists: > data List a = Nil | Cons a (List a) > > case_list :: r -> (a -> List a -> r) -> List a -> r > case_list nil_case cons_case Nil = nil_case > case_list nil_case cons_case (Cons x xs) = cons_case x xs Now, given the "Branch" type: > data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) (GenParser tok st b) what is the type of its "case" construct? Here's the answer: > case_branch :: (forall b. PermParser tok st (b -> a) -> GenParser tok st b -> r) -> Branch tok st a -> r > case_branch k (Branch pparser gparser) = k pparser gparser Notice the higher-rank type on the argument k; it has to be able to accept *any* type b, because the constructor hid an object of *some* type which is no longer known. So unless you can accept *any* b, you can't operate on this object. -- ryan From ekirpichov at gmail.com Wed Sep 2 01:57:18 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Sep 2 01:36:42 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <25251783.post@talk.nabble.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> Message-ID: <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> 2009/9/2 zaxis : > > Isnot it clear without the 'forall' ? > data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok st > b) > > thanks! > The situation is not so simple. Consider, for example, a procedure that takes as input a *generic* sorting algorithm: sortThem :: (forall a. Ord a => [a] -> [a]) -> [Int] -> [String] -> ([Int], [String]) sortThem sortAlgo ints strings = (sortAlgo ints, sortAlgo strings) Here you can't omit the 'forall' because if you do, then inside the body of the sortThem function the 'a' type variable has a fixed value and can't be both Int and String! This is a somewhat esoteric example, but one could consider, for instance, a procedure that takes as input some trees of different types and a generic tree traversal algorithm. Well, have a look at the haskellwiki page, there's a pile of examples :) P.S. I tried to write up the difference between datatype and function declarations in this respect, but my explanations turned into a mess, so I erased them in the hope that someone will explain it better than me. > > jkff wrote: >> >> This means that for any type 'b' you can construct a value of type >> 'Branch tok st a' by passing to Branch an argument of type >> '(PermParser tok st (b -> a))' and 'GenParser tok st b'. >> This also means that when you're given a value of type Branch tok st >> a, you don't know what that 'b' type was; the only thing you know is >> that the 'b' in 'b -> a' in the first argument of Branch is the same >> as the 'b' in 'GenParser tok st b'. >> >> See also: the haskellwiki page on existential types. >> >> 2009/9/2 zaxis : >>> >>> data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) >>> (GenParser tok st b) >>> >>> please shed a light on me, thanks! >>> -- >>> View this message in context: >>> http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.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 >>> >> >> >> >> -- >> Eugene Kirpichov >> Web IR developer, market.yandex.ru >> _______________________________________________ >> 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/How-to-understand-the-%27forall%27---tp25250783p25251783.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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bugfact at gmail.com Wed Sep 2 02:03:08 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Sep 2 01:42:31 2009 Subject: [Haskell-cafe] Cleaning up stable names? In-Reply-To: References: <7ca3f0160909011131j63cb000vc4908a90e846e7f6@mail.gmail.com> Message-ID: A monad can surely handle this, but then this is purely for caching, and enforcing a monad just for getting caching sounds like overkill. Caching is something you typically add in the end, and using a monad for that seems akward no? Since all "objects" in Haskell are readonly, it looks line an ideal opportunity to associate a cached object with another object without needing to wrap a lot of code in a monad On Wed, Sep 2, 2009 at 1:25 AM, Brandon S. Allbery KF8NH wrote: > On Sep 1, 2009, at 14:57 , Peter Verswyvelen wrote: >> >> In .NET it is possible to assign an identifier to an object, and that >> identifier will always be the same for the same object, no matter >> where to garbage collectors moves the object in memory. For Haskell, >> at first sight it would feel natural to have something like that too. > > > Hm. I'd think such names would have to live in a monad (which then leads you > to either Reader or ST, I think). > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university ? ?KF8NH > > > From z_axis at 163.com Wed Sep 2 05:00:26 2009 From: z_axis at 163.com (zaxis) Date: Wed Sep 2 04:39:48 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> Message-ID: <25254016.post@talk.nabble.com> seems a bit understanding, i still need to think it for a while thanks! jkff wrote: > > 2009/9/2 zaxis : >> >> Isnot it clear without the 'forall' ? >> data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok >> st >> b) >> >> thanks! >> > > The situation is not so simple. > Consider, for example, a procedure that takes as input a *generic* > sorting algorithm: > > sortThem :: (forall a. Ord a => [a] -> [a]) -> [Int] -> [String] -> > ([Int], [String]) > sortThem sortAlgo ints strings = (sortAlgo ints, sortAlgo strings) > > Here you can't omit the 'forall' because if you do, then inside the > body of the sortThem function the 'a' type variable has a fixed value > and can't be both Int and String! > > This is a somewhat esoteric example, but one could consider, for > instance, a procedure that takes as input some trees of different > types and a generic tree traversal algorithm. Well, have a look at the > haskellwiki page, there's a pile of examples :) > > P.S. I tried to write up the difference between datatype and function > declarations in this respect, but my explanations turned into a mess, > so I erased them in the hope that someone will explain it better than > me. > >> >> jkff wrote: >>> >>> This means that for any type 'b' you can construct a value of type >>> 'Branch tok st a' by passing to Branch an argument of type >>> '(PermParser tok st (b -> a))' and 'GenParser tok st b'. >>> This also means that when you're given a value of type Branch tok st >>> a, you don't know what that 'b' type was; the only thing you know is >>> that the 'b' in 'b -> a' in the first argument of Branch is the same >>> as the 'b' in 'GenParser tok st b'. >>> >>> See also: the haskellwiki page on existential types. >>> >>> 2009/9/2 zaxis : >>>> >>>> data Branch tok st a = forall b. Branch (PermParser tok st (b -> a)) >>>> (GenParser tok st b) >>>> >>>> please shed a light on me, thanks! >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/How-to-understand-the-%27forall%27---tp25250783p25250783.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 >>>> >>> >>> >>> >>> -- >>> Eugene Kirpichov >>> Web IR developer, market.yandex.ru >>> _______________________________________________ >>> 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/How-to-understand-the-%27forall%27---tp25250783p25251783.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 >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > _______________________________________________ > 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/How-to-understand-the-%27forall%27---tp25250783p25254016.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From martijn at van.steenbergen.nl Wed Sep 2 05:53:12 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Sep 2 05:32:43 2009 Subject: [Haskell-cafe] Can't get my head round monad transformers In-Reply-To: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> References: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> Message-ID: <4A9E4088.4030206@van.steenbergen.nl> Hi Colin, Colin Adams wrote: > I'm trying to add a state monad onto the IO monad for use in a > happstack application. I thought this should involve using StateT and > Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to > plumb it all together. Any tips will be welcome. I'm not familiar with Happstack, but looking at the documentation: > simpleHTTP' :: (Monad m, ToMessage b) => > (m (Maybe (Either Response a, FilterFun Response)) -> > IO (Maybe (Either Response b, FilterFun Response))) -> > Conf -> > ServerPartT m a -> > IO () Do I understand correctly you will be working with a > myAction :: ServerPartT (StateT S IO) A ? Then it seems that you may call simpleHTTP' like this: > simpleHTTP' > (\action -> evalStateT action initState) > myConf > myAction The first argument (the lambda) has type > forall a m. Monad m => StateT S m a -> m a which can be specialised to what simpleHTTP' is expecting. I hope this helps! Martijn. From perikov at gmail.com Wed Sep 2 06:09:50 2009 From: perikov at gmail.com (Pavel Perikov) Date: Wed Sep 2 05:49:14 2009 Subject: [Haskell-cafe] Can GHC produce dylib on MacOSX/Intel? Message-ID: <3099572F-8667-477B-BFE0-0EE3A894A1AA@gmail.com> Is it possible? Is it possible with binary distribution? Regards, Pavel From kwangyul.seo at gmail.com Wed Sep 2 08:38:24 2009 From: kwangyul.seo at gmail.com (KwangYul Seo) Date: Wed Sep 2 08:17:44 2009 Subject: [Haskell-cafe] Documentation on the internals of Hugs Message-ID: <7beb12420909020538o31457f01l67107bfeaa141546@mail.gmail.com> Hello, I want to study the internals lof Hugs, but the only document I got is: The implementation of the Gofer functional programming system http://web.cecs.pdx.edu/~mpj/pubs/goferimp.html I see Gofer is the predecessor of Hugs, but I am not sure how much the code base has been changed since then. Are there more recent documents on the internals of Hugs? Regards, Kwang Yul Seo From frodo at theshire.org Wed Sep 2 08:49:54 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Sep 2 08:29:35 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <25254016.post@talk.nabble.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> <25254016.post@talk.nabble.com> Message-ID: On Wed, Sep 2, 2009 at 11:00 AM, zaxis wrote: > > seems a bit understanding, i still need to think it ?for a while > thanks! I think I've understood the existential types thing, but I still can't put them to work when I think to a solution for a particular problem, i.e. it's not among my programming tools yet. Thank you Eugene, that was one of the most enlighting examples I say about existential types. Cristiano From leather at cs.uu.nl Wed Sep 2 09:30:14 2009 From: leather at cs.uu.nl (Sean Leather) Date: Wed Sep 2 09:09:58 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> <25254016.post@talk.nabble.com> Message-ID: <3c6288ab0909020630t18ee08cfie0a8d9bdfeb79e8e@mail.gmail.com> > I think I've understood the existential types thing, but I still can't > put them to work when I think to a solution for a particular problem, > i.e. it's not among my programming tools yet. > Here's another commonly found, easy-to-understand example that's useful. > {-# LANGUAGE ExistentialQuantification #-} > > module Main where > > data Showable = forall a . Show a => S a > > instance Show Showable where > show (S x) = show x > > main = print [S 1, S 'a', S 9.4, S (Just 2)] -- prints [1,'a',9.4,Just 2] The datatype says that for any type 'a' with an instance of 'Show a', we can construct a value of 'Showable'. While we normally wouldn't be able to build a list with different types, we can now create a [Showable] list with existential types. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090902/82a6cc41/attachment-0001.html From mwotton at gmail.com Wed Sep 2 09:37:11 2009 From: mwotton at gmail.com (Mark Wotton) Date: Wed Sep 2 09:16:42 2009 Subject: [Haskell-cafe] Can GHC produce dylib on MacOSX/Intel? In-Reply-To: <3099572F-8667-477B-BFE0-0EE3A894A1AA@gmail.com> References: <3099572F-8667-477B-BFE0-0EE3A894A1AA@gmail.com> Message-ID: <3ED8B9E5-2B1F-41F8-930A-AEE28E9440E2@gmail.com> On 02/09/2009, at 8:09 PM, Pavel Perikov wrote: > Is it possible? Is it possible with binary distribution? My understanding: It was possible with ghc 6.8. It's not with 6.10. Duncan's managed to get it going at some point on Linux (I assume) with GHC HEAD (http://blog.well-typed.com/2009/05/buildings-plugins-as-haskell-shared-libs/ ). I haven't been able to replicate that on either Mac or Linux, but getting HEAD working is always slightly iffy. It does work with jhc rather nicely, but most libraries don't build with jhc, sadly. If anyone's got it going, I'd be really keen to know. mark From per.vognsen at gmail.com Wed Sep 2 10:04:12 2009 From: per.vognsen at gmail.com (Per Vognsen) Date: Wed Sep 2 09:43:35 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <3c6288ab0909020630t18ee08cfie0a8d9bdfeb79e8e@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> <25254016.post@talk.nabble.com> <3c6288ab0909020630t18ee08cfie0a8d9bdfeb79e8e@mail.gmail.com> Message-ID: You can of course achieve the same thing by reifying the Show dictionary as a record and having Showable's Show instance forward to the dictionary. A really good paper for an overview of the strengths and weaknesses of different object encodings (recursive records vs existentials vs recursive existentials vs bounded existentials) for cases more complicated than the one below is Comparing Object Encodings by Bruce, Cardelli and Pierce. Much of the same discussion is also replicated in Pierce's Types and Programming Languages in a less technical, more readable form. -Per On Wed, Sep 2, 2009 at 10:30 PM, Sean Leather wrote: > >> I think I've understood the existential types thing, but I still can't >> put them to work when I think to a solution for a particular problem, >> i.e. it's not among my programming tools yet. > > Here's another commonly found, easy-to-understand example that's useful. > >> {-# LANGUAGE ExistentialQuantification #-} >> >> module Main where >> >> data Showable = forall a . Show a => S a >> >> instance Show Showable where >> ? show (S x) = show x >> >> main = print [S 1, S 'a', S 9.4, S (Just 2)] -- prints [1,'a',9.4,Just 2] > > The datatype says that for any type 'a' with an instance of 'Show a', we can > construct a value of 'Showable'. While we normally wouldn't be able to build > a list with different types, we can now create a [Showable] list with > existential types. > > Sean > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jvranish at gmail.com Wed Sep 2 10:22:29 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Sep 2 10:01:51 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> <4A717B80.3060207@physics.org> <174c72ef0908311143g171d3e38w416b3ac72d85f3ac@mail.gmail.com> Message-ID: Did you by chance use the prebuilt ghc binaries? or build ghc manually? - Job On Mon, Aug 31, 2009 at 5:23 PM, Paulo Tanimoto wrote: > Hello, > > On Mon, Aug 31, 2009 at 3:29 PM, Job Vranish wrote: > > I got around this problem by downgrading to 6.10.3 (I think I rebuilt > cabal > > as well) > > > > I'm not sure if the problem is with cabal, GHC, or some 64bit ubuntu > > library. (probably a combination of ghc+64bit ubuntu) > > > > Does anybody have ghc 6.10.4 working on 64bit Ubuntu? > > > > - Job > > > > I'm using GHC 6.10.4 from HQ + Platform on Ubuntu Jaunty 64bit and > don't have this problem. Let me know if you want to compare settings. > > Paulo > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090902/39d44c10/attachment.html From tanimoto at arizona.edu Wed Sep 2 10:33:49 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Sep 2 10:13:30 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> <4A717B80.3060207@physics.org> <174c72ef0908311143g171d3e38w416b3ac72d85f3ac@mail.gmail.com> Message-ID: Hi Job, On Wed, Sep 2, 2009 at 9:22 AM, Job Vranish wrote: > Did you by chance use the prebuilt ghc binaries? or build ghc manually? > > - Job > Good question, I need to check that at home. Now that you mention it, I remember considering using a repository (PPA) somebody had put together, that had the latest GHC for Ubuntu Jaunty. I'm not sure I used it though. I'll get back to you. Paulo From brad.larsen at gmail.com Wed Sep 2 10:40:41 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Wed Sep 2 10:20:02 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: <174c72ef0908311143g171d3e38w416b3ac72d85f3ac@mail.gmail.com> References: <910ddf450907170817l108bacc6m6563eb49e02b3636@mail.gmail.com> <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> <4A717B80.3060207@physics.org> <174c72ef0908311143g171d3e38w416b3ac72d85f3ac@mail.gmail.com> Message-ID: I had the same issue, using the ghc 6.10.4 "generic linux" tarball on Ubuntu Jaunty x86_64. I attempted to install a newer Haskell Platform over the older one. I'm not sure what causes the issue. After several attempts to remedy it without success, I ended up completely reinstalling ghc and ghc-related things on my system, and not using the Haskell Platform. Drastic, but I don't get those cabal errors any more. Regards, Bradford Larsen On Aug 31, 2009 2:43 PM, "Fernando Henrique Sanches" < fernandohsanches@gmail.com> wrote: Sorry for ressurecting the thread, my I'm having the same problem here. Deleting the .cabal/config file shows only temporary results, and -v3 isn't helping: ~/sources/haskell-platform-2009.2.0.2 % cabal update Config file /home/fernando/.cabal/config not found. Writing default configuration to /home/fernando/.cabal/config Downloading the latest package list from hackage.haskell.org ~/sources/haskell-platform-2009.2.0.2 % cabal update cabal: :: openFile: does not exist (No such file or directory) ~/sources/haskell-platform-2009.2.0.2 % cabal update -v3 cabal: ?: openFile: does not exist (No such file or directory) I'm on Ubuntu 9.04 x64. ghc 6.10.4 This is the output of the mentioned describe-parsec command, but I don't know what to do with it: ~/sources/haskell-platform-2009.2.0.2 % ghc-pkg describe parsec-2.1.0.1 name: parsec version: 2.1.0.1 license: BSD3 copyright: maintainer: Daan Leijen stability: homepage: http://www.cs.uu.nl/~daan/parsec.html package-url: description: Parsec is designed from scratch as an industrial-strength parser library. It is simple, safe, well documented (on the package homepage), has extensive libraries and good error messages, and is also fast. category: Parsing author: Daan Leijen exposed: True exposed-modules: Text.ParserCombinators.Parsec.Language Text.ParserCombinators.Parsec.Token Text.ParserCombinators.Parsec.Error Text.ParserCombinators.Parsec.Char Text.ParserCombinators.Parsec.Combinator Text.ParserCombinators.Parsec.Expr Text.ParserCombinators.Parsec.Perm Text.ParserCombinators.Parsec.Pos Text.ParserCombinators.Parsec.Prim Text.ParserCombinators.Parsec hidden-modules: import-dirs: /usr/local/lib/parsec-2.1.0.1/ghc-6.10.4 library-dirs: /usr/local/lib/parsec-2.1.0.1/ghc-6.10.4 hs-libraries: HSparsec-2.1.0.1 extra-libraries: extra-ghci-libraries: include-dirs: includes: depends: base-4.1.0.0 hugs-options: cc-options: ld-options: framework-dirs: frameworks: haddock-interfaces: /usr/local/share/doc/parsec-2.1.0.1/html/parsec.haddock haddock-html: /usr/local/share/doc/parsec-2.1.0.1/html Fernando Henrique Sanches On Thu, Jul 30, 2009 at 7:52 AM, Mike Pentney wrote: > > I had a simil... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090902/6405cf3d/attachment.html From sargrigory at ya.ru Wed Sep 2 13:12:19 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Wed Sep 2 12:51:41 2009 Subject: [Haskell-cafe] Cabal install specific version of a package Message-ID: <14591251911539@webmail114.yandex.ru> How to install specific version of a package (derive 0.1.4)? From jvranish at gmail.com Wed Sep 2 13:19:52 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Sep 2 12:59:18 2009 Subject: [Haskell-cafe] Cabal install specific version of a package In-Reply-To: <14591251911539@webmail114.yandex.ru> References: <14591251911539@webmail114.yandex.ru> Message-ID: cabal install derive-0.1.4 On Wed, Sep 2, 2009 at 1:12 PM, Grigory Sarnitskiy wrote: > How to install specific version of a package (derive 0.1.4)? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090902/39d717ac/attachment.html From mf-hcafe-15c311f0c at etc-network.de Wed Sep 2 16:44:25 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Wed Sep 2 16:23:57 2009 Subject: [Haskell-cafe] cannot build greencard Message-ID: <20090902204425.GZ3247@yoyo> hi, i am stuck with a linker error in greencard, and haven't found anything online, so i am addressing you for fresh ideas. as soon as i get this sorted out, i will try to turn the answer into a patch that you can consider for the next release. SYMPTOMS: greencard 3.0.3 and 3.01 do not compile with ghc-6.8 (debian lenny package) and 6.10 (darcs copy, checked out yesterday). here is what happens: 4 (0) 19:27:19 mf@yoyo:/tmp2 $ tar xvpzf greencard-3.0.3.tar.gz greencard-3.0.3/ greencard-3.0.3/ANNOUNCE greencard-3.0.3/dist/ greencard-3.0.3/dist/build/ greencard-3.0.3/dist/build/greencard/ greencard-3.0.3/dist/build/greencard/greencard-tmp/ greencard-3.0.3/dist/build/greencard/greencard-tmp/Parse.hs greencard-3.0.3/examples/ greencard-3.0.3/examples/Gdbm/ greencard-3.0.3/examples/Gdbm/diffs greencard-3.0.3/examples/Gdbm/Gdbm.gc greencard-3.0.3/examples/Gdbm/gdbmplus.h greencard-3.0.3/examples/Gdbm/Main.hs greencard-3.0.3/examples/Gdbm/Makefile greencard-3.0.3/examples/Gdbm/README greencard-3.0.3/examples/Makefile greencard-3.0.3/examples/world/ greencard-3.0.3/examples/world/Main.hs greencard-3.0.3/examples/world/Makedefs.ghc greencard-3.0.3/examples/world/Makedeps greencard-3.0.3/examples/world/Makefile.ghc-linux greencard-3.0.3/examples/world/Makefile.ghc-win32 greencard-3.0.3/examples/world/Makefile.hugs-linux greencard-3.0.3/examples/world/Makefile.hugs-win32 greencard-3.0.3/examples/world/README.txt greencard-3.0.3/examples/world/World.gc greencard-3.0.3/greencard.cabal greencard-3.0.3/INSTALL greencard-3.0.3/lib/ greencard-3.0.3/lib/Foreign/ greencard-3.0.3/lib/Foreign/GreenCard.hs greencard-3.0.3/lib/GreenCard.gc greencard-3.0.3/lib/Makefile greencard-3.0.3/lib/package.conf.in greencard-3.0.3/LICENSE greencard-3.0.3/Makefile greencard-3.0.3/README greencard-3.0.3/Setup.hs greencard-3.0.3/src/ greencard-3.0.3/src/Casm.lhs greencard-3.0.3/src/Decl.lhs greencard-3.0.3/src/DIS.lhs greencard-3.0.3/src/ErrMonad.lhs greencard-3.0.3/src/ErrorHook.c greencard-3.0.3/src/FillIn.lhs greencard-3.0.3/src/FillInMonad.lhs greencard-3.0.3/src/GCToken.lhs greencard-3.0.3/src/greencard.ghc.in greencard-3.0.3/src/greencard.hugs.in greencard-3.0.3/src/GreenCard.lhs greencard-3.0.3/src/Lex.lhs greencard-3.0.3/src/LexM.lhs greencard-3.0.3/src/ListUtils.lhs greencard-3.0.3/src/Makefile greencard-3.0.3/src/MarshallMonad.lhs greencard-3.0.3/src/Name.lhs greencard-3.0.3/src/NameSupply.lhs greencard-3.0.3/src/Package.lhs greencard-3.0.3/src/Package.lhs.in greencard-3.0.3/src/Parse.ly greencard-3.0.3/src/PrettyUtils.lhs greencard-3.0.3/src/Proc.lhs greencard-3.0.3/src/Process.lhs greencard-3.0.3/src/Target.lhs greencard-3.0.3/src/Type.lhs 5 (0) 19:27:22 mf@yoyo:/tmp2 $ cd greencard-3.0.3 6 (0) 19:27:24 mf@yoyo:/tmp2/greencard-3.0.3 $ make prefix=/tmp2/ make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' happy Parse.ly unused terminals: 1 rm -f .depend touch .depend ghc -M -optdep-f -optdep.depend -optdep-xFiniteMap -optdep-xPretty -recomp -O -fglasgow-exts Casm.lhs DIS.lhs Decl.lhs ErrMonad.lhs FillIn.lhs FillInMonad.lhs GCToken.lhs GreenCard.lhs Lex.lhs LexM.lhs ListUtils.lhs MarshallMonad.lhs Name.lhs NameSupply.lhs Package.lhs PrettyUtils.lhs Proc.lhs Process.lhs Target.lhs Type.lhs Parse.hs make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' ghc -recomp -O -fglasgow-exts -c Target.lhs -o Target.o ghc -recomp -O -fglasgow-exts -c PrettyUtils.lhs -o PrettyUtils.o ghc -recomp -O -fglasgow-exts -c Casm.lhs -o Casm.o Casm.lhs:544:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... Casm.lhs:577:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... Casm.lhs:616:4: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... Casm.lhs:631:5: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... ghc -recomp -O -fglasgow-exts -c ListUtils.lhs -o ListUtils.o ghc -recomp -O -fglasgow-exts -c ErrMonad.lhs -o ErrMonad.o ghc -recomp -O -fglasgow-exts -c Name.lhs -o Name.o ghc -recomp -O -fglasgow-exts -c DIS.lhs -o DIS.o ghc -recomp -O -fglasgow-exts -c Type.lhs -o Type.o ghc -recomp -O -fglasgow-exts -c Decl.lhs -o Decl.o ghc -recomp -O -fglasgow-exts -c FillInMonad.lhs -o FillInMonad.o ghc -recomp -O -fglasgow-exts -c NameSupply.lhs -o NameSupply.o ghc -recomp -O -fglasgow-exts -c FillIn.lhs -o FillIn.o ghc -recomp -O -fglasgow-exts -c GCToken.lhs -o GCToken.o ghc -recomp -O -fglasgow-exts -c MarshallMonad.lhs -o MarshallMonad.o ghc -recomp -O -fglasgow-exts -c Proc.lhs -o Proc.o ghc -recomp -O -fglasgow-exts -c LexM.lhs -o LexM.o ghc -recomp -O -fglasgow-exts -c Lex.lhs -o Lex.o ghc -recomp -O -fglasgow-exts -Onot -c Parse.hs -o Parse.o Parse.hs:1733:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... ghc -recomp -O -fglasgow-exts -c Process.lhs -o Process.o ghc -recomp -O -fglasgow-exts -c Package.lhs -o Package.o ghc -recomp -O -fglasgow-exts -cpp -DBEGIN_GHC_ONLY='-}' -DEND_GHC_ONLY='{-' -DBEGIN_NOT_FOR_GHC='{-' -DEND_NOT_FOR_GHC='-}' -DPURE_WIN32=0 -c GreenCard.lhs -o GreenCard.o ghc -c ErrorHook.c -o ErrorHook.o ghc -recomp -O -fglasgow-exts -o greencard-bin Casm.o DIS.o Decl.o ErrMonad.o FillIn.o FillInMonad.o GCToken.o GreenCard.o Lex.o LexM.o ListUtils.o MarshallMonad.o Name.o NameSupply.o Package.o PrettyUtils.o Proc.o Process.o Target.o Type.o Parse.o ErrorHook.o Casm.o: In function `s201_info': (.text+0x168): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' Casm.o: In function `s201_info': (.text+0x17b): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' Casm.o: In function `s201_info': (.text+0x19d): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' Casm.o: In function `s201_info': (.text+0x1b7): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' Casm.o: In function `s201_info': (.text+0x1ca): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' Casm.o: In function `s201_info': (.text+0x1e9): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' Casm.o: In function `s201_info': (.text+0x1f0): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' [... these continue for every object file on the command line; a bit over 2000 message of the same type in total...] Type.o: In function `sBv_info': (.text+0x1b2b): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' Type.o: In function `sZT_info': (.text+0x1ed3): undefined reference to `__stginit_prettyzm1zi0zi0zi0_TextziPrettyPrint_' Type.o: In function `sBb_info': (.text+0x1988): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' Type.o: In function `sBf_info': (.text+0x1a12): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' Type.o: In function `sZU_info': (.text+0x1b96): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_text_info' Type.o: In function `rvv_closure': (.data+0x8): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Chr_static_info' Type.o: In function `rvH_closure': (.data+0x64): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_static_info' Type.o: In function `rvH_closure': (.data+0x6c): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_lvl3_closure' Type.o: In function `rvH_closure': (.data+0x70): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' Type.o: In function `rvN_closure': (.data+0xb0): undefined reference to `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_static_info' collect2: ld returned 1 exit status make[1]: *** [greencard-bin] Error 1 make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls -c Foreign/GreenCard.hs -o Foreign/GreenCard.o -hisuf hi ghc-6.8.2: unrecognised flags: -fno-prune-tydecls Usage: For basic information, try the `--help' option. make[1]: *** [Foreign/GreenCard.o] Error 1 make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls -prof -c Foreign/GreenCard.hs -o Foreign/GreenCard.p_o -hisuf p_hi ghc-6.8.2: unrecognised flags: -fno-prune-tydecls Usage: For basic information, try the `--help' option. make[1]: *** [Foreign/GreenCard.p_o] Error 1 make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' make: *** [all] Error 2 the errors about no-prune-tydecls are easy enough to fix: $ diff -r greencard-3.0.3{,-patched} diff -r greencard-3.0.3/examples/Gdbm/Makefile greencard-3.0.3-patched/examples/Gdbm/Makefile 28d27 < HC_OPTS += -fno-prune-tydecls diff -r greencard-3.0.3/lib/Makefile greencard-3.0.3-patched/lib/Makefile 6c6 < GHC_OPTS = -cpp -fglasgow-exts -fno-prune-tydecls --- > GHC_OPTS = -cpp -fglasgow-exts $ this helps, but the linker errors are unrealted, and i don't know what to make of them. (I guess I should study how ghc generates C code at this point? it does feel like something obvious...) thanks, cheers, matthias From bulat.ziganshin at gmail.com Wed Sep 2 17:10:14 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 2 16:49:56 2009 Subject: [Haskell-cafe] cannot build greencard In-Reply-To: <20090902204425.GZ3247@yoyo> References: <20090902204425.GZ3247@yoyo> Message-ID: <1385741724.20090903011014@gmail.com> Hello mf-hcafe-15c311f0c, Thursday, September 3, 2009, 12:44:25 AM, you wrote: to the best of my knowledge, GC was developed in the days of ghc 0.20 or so and last 10 years it's superceded by FFI addendum to Haskell'98 standard. there is also more high-level tools like hsc2hs and HSFFIG > hi, > i am stuck with a linker error in greencard, and haven't found > anything online, so i am addressing you for fresh ideas. as soon as i > get this sorted out, i will try to turn the answer into a patch that > you can consider for the next release. > SYMPTOMS: greencard 3.0.3 and 3.01 do not compile with ghc-6.8 (debian > lenny package) and 6.10 (darcs copy, checked out yesterday). here is > what happens: > 4 (0) 19:27:19 mf@yoyo:/tmp2 $ tar xvpzf greencard-3.0.3.tar.gz > greencard-3.0.3/ > greencard-3.0.3/ANNOUNCE > greencard-3.0.3/dist/ > greencard-3.0.3/dist/build/ > greencard-3.0.3/dist/build/greencard/ > greencard-3.0.3/dist/build/greencard/greencard-tmp/ > greencard-3.0.3/dist/build/greencard/greencard-tmp/Parse.hs > greencard-3.0.3/examples/ > greencard-3.0.3/examples/Gdbm/ > greencard-3.0.3/examples/Gdbm/diffs > greencard-3.0.3/examples/Gdbm/Gdbm.gc > greencard-3.0.3/examples/Gdbm/gdbmplus.h > greencard-3.0.3/examples/Gdbm/Main.hs > greencard-3.0.3/examples/Gdbm/Makefile > greencard-3.0.3/examples/Gdbm/README > greencard-3.0.3/examples/Makefile > greencard-3.0.3/examples/world/ > greencard-3.0.3/examples/world/Main.hs > greencard-3.0.3/examples/world/Makedefs.ghc > greencard-3.0.3/examples/world/Makedeps > greencard-3.0.3/examples/world/Makefile.ghc-linux > greencard-3.0.3/examples/world/Makefile.ghc-win32 > greencard-3.0.3/examples/world/Makefile.hugs-linux > greencard-3.0.3/examples/world/Makefile.hugs-win32 > greencard-3.0.3/examples/world/README.txt > greencard-3.0.3/examples/world/World.gc > greencard-3.0.3/greencard.cabal > greencard-3.0.3/INSTALL > greencard-3.0.3/lib/ > greencard-3.0.3/lib/Foreign/ > greencard-3.0.3/lib/Foreign/GreenCard.hs > greencard-3.0.3/lib/GreenCard.gc > greencard-3.0.3/lib/Makefile > greencard-3.0.3/lib/package.conf.in > greencard-3.0.3/LICENSE > greencard-3.0.3/Makefile > greencard-3.0.3/README > greencard-3.0.3/Setup.hs > greencard-3.0.3/src/ > greencard-3.0.3/src/Casm.lhs > greencard-3.0.3/src/Decl.lhs > greencard-3.0.3/src/DIS.lhs > greencard-3.0.3/src/ErrMonad.lhs > greencard-3.0.3/src/ErrorHook.c > greencard-3.0.3/src/FillIn.lhs > greencard-3.0.3/src/FillInMonad.lhs > greencard-3.0.3/src/GCToken.lhs > greencard-3.0.3/src/greencard.ghc.in > greencard-3.0.3/src/greencard.hugs.in > greencard-3.0.3/src/GreenCard.lhs > greencard-3.0.3/src/Lex.lhs > greencard-3.0.3/src/LexM.lhs > greencard-3.0.3/src/ListUtils.lhs > greencard-3.0.3/src/Makefile > greencard-3.0.3/src/MarshallMonad.lhs > greencard-3.0.3/src/Name.lhs > greencard-3.0.3/src/NameSupply.lhs > greencard-3.0.3/src/Package.lhs > greencard-3.0.3/src/Package.lhs.in > greencard-3.0.3/src/Parse.ly > greencard-3.0.3/src/PrettyUtils.lhs > greencard-3.0.3/src/Proc.lhs > greencard-3.0.3/src/Process.lhs > greencard-3.0.3/src/Target.lhs > greencard-3.0.3/src/Type.lhs > 5 (0) 19:27:22 mf@yoyo:/tmp2 $ cd greencard-3.0.3 > 6 (0) 19:27:24 mf@yoyo:/tmp2/greencard-3.0.3 $ make prefix=/tmp2/ > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' > happy Parse.ly > unused terminals: 1 > rm -f .depend > touch .depend > ghc -M -optdep-f -optdep.depend -optdep-xFiniteMap -optdep-xPretty > -recomp -O -fglasgow-exts Casm.lhs DIS.lhs Decl.lhs ErrMonad.lhs > FillIn.lhs FillInMonad.lhs GCToken.lhs GreenCard.lhs Lex.lhs > LexM.lhs ListUtils.lhs MarshallMonad.lhs Name.lhs NameSupply.lhs > Package.lhs PrettyUtils.lhs Proc.lhs Process.lhs Target.lhs Type.lhs Parse.hs > make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' > ghc -recomp -O -fglasgow-exts -c Target.lhs -o Target.o > ghc -recomp -O -fglasgow-exts -c PrettyUtils.lhs -o PrettyUtils.o > ghc -recomp -O -fglasgow-exts -c Casm.lhs -o Casm.o > Casm.lhs:544:1: > Warning: Pattern match(es) are overlapped > In a case alternative: _ -> ... > Casm.lhs:577:1: > Warning: Pattern match(es) are overlapped > In a case alternative: _ -> ... > Casm.lhs:616:4: > Warning: Pattern match(es) are overlapped > In a case alternative: _ -> ... > Casm.lhs:631:5: > Warning: Pattern match(es) are overlapped > In a case alternative: _ -> ... > ghc -recomp -O -fglasgow-exts -c ListUtils.lhs -o ListUtils.o > ghc -recomp -O -fglasgow-exts -c ErrMonad.lhs -o ErrMonad.o > ghc -recomp -O -fglasgow-exts -c Name.lhs -o Name.o > ghc -recomp -O -fglasgow-exts -c DIS.lhs -o DIS.o > ghc -recomp -O -fglasgow-exts -c Type.lhs -o Type.o > ghc -recomp -O -fglasgow-exts -c Decl.lhs -o Decl.o > ghc -recomp -O -fglasgow-exts -c FillInMonad.lhs -o FillInMonad.o > ghc -recomp -O -fglasgow-exts -c NameSupply.lhs -o NameSupply.o > ghc -recomp -O -fglasgow-exts -c FillIn.lhs -o FillIn.o > ghc -recomp -O -fglasgow-exts -c GCToken.lhs -o GCToken.o > ghc -recomp -O -fglasgow-exts -c MarshallMonad.lhs -o MarshallMonad.o > ghc -recomp -O -fglasgow-exts -c Proc.lhs -o Proc.o > ghc -recomp -O -fglasgow-exts -c LexM.lhs -o LexM.o > ghc -recomp -O -fglasgow-exts -c Lex.lhs -o Lex.o > ghc -recomp -O -fglasgow-exts -Onot -c Parse.hs -o Parse.o > Parse.hs:1733:1: > Warning: Pattern match(es) are overlapped > In a case alternative: _ -> ... > ghc -recomp -O -fglasgow-exts -c Process.lhs -o Process.o > ghc -recomp -O -fglasgow-exts -c Package.lhs -o Package.o > ghc -recomp -O -fglasgow-exts -cpp -DBEGIN_GHC_ONLY='-}' > -DEND_GHC_ONLY='{-' -DBEGIN_NOT_FOR_GHC='{-' -DEND_NOT_FOR_GHC='-}' > -DPURE_WIN32=0 -c GreenCard.lhs -o GreenCard.o > ghc -c ErrorHook.c -o ErrorHook.o > ghc -recomp -O -fglasgow-exts -o greencard-bin Casm.o DIS.o > Decl.o ErrMonad.o FillIn.o FillInMonad.o GCToken.o GreenCard.o Lex.o > LexM.o ListUtils.o MarshallMonad.o Name.o NameSupply.o Package.o > PrettyUtils.o Proc.o Process.o Target.o Type.o Parse.o ErrorHook.o > Casm.o: In function `s201_info': > (.text+0x168): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' > Casm.o: In function `s201_info': > (.text+0x17b): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' > Casm.o: In function `s201_info': > (.text+0x19d): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' > Casm.o: In function `s201_info': > (.text+0x1b7): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' > Casm.o: In function `s201_info': > (.text+0x1ca): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' > Casm.o: In function `s201_info': > (.text+0x1e9): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' > Casm.o: In function `s201_info': > (.text+0x1f0): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' > [... these continue for every object file on the command line; a bit > over 2000 message of the same type in total...] > Type.o: In function `sBv_info': > (.text+0x1b2b): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' > Type.o: In function `sZT_info': > (.text+0x1ed3): undefined reference to > `__stginit_prettyzm1zi0zi0zi0_TextziPrettyPrint_' > Type.o: In function `sBb_info': > (.text+0x1988): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' > Type.o: In function `sBf_info': > (.text+0x1a12): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' > Type.o: In function `sZU_info': > (.text+0x1b96): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_text_info' > Type.o: In function `rvv_closure': > (.data+0x8): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Chr_static_info' > Type.o: In function `rvH_closure': > (.data+0x64): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_static_info' > Type.o: In function `rvH_closure': > (.data+0x6c): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_lvl3_closure' > Type.o: In function `rvH_closure': > (.data+0x70): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' > Type.o: In function `rvN_closure': > (.data+0xb0): undefined reference to > `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_static_info' > collect2: ld returned 1 exit status > make[1]: *** [greencard-bin] Error 1 > make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' > ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls > -c Foreign/GreenCard.hs -o Foreign/GreenCard.o -hisuf hi > ghc-6.8.2: unrecognised flags: -fno-prune-tydecls > Usage: For basic information, try the `--help' option. > make[1]: *** [Foreign/GreenCard.o] Error 1 > make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' > make[1]: Nothing to be done for `all'. > make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' > ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls > -prof -c Foreign/GreenCard.hs -o Foreign/GreenCard.p_o -hisuf p_hi > ghc-6.8.2: unrecognised flags: -fno-prune-tydecls > Usage: For basic information, try the `--help' option. > make[1]: *** [Foreign/GreenCard.p_o] Error 1 > make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' > make: *** [all] Error 2 > the errors about no-prune-tydecls are easy enough to fix: > $ diff -r greencard-3.0.3{,-patched} > diff -r greencard-3.0.3/examples/Gdbm/Makefile > greencard-3.0.3-patched/examples/Gdbm/Makefile > 28d27 > < HC_OPTS += -fno-prune-tydecls > diff -r greencard-3.0.3/lib/Makefile > greencard-3.0.3-patched/lib/Makefile > 6c6 > < GHC_OPTS = -cpp -fglasgow-exts -fno-prune-tydecls > --- >> GHC_OPTS = -cpp -fglasgow-exts > $ > this helps, but the linker errors are unrealted, and i don't know what > to make of them. (I guess I should study how ghc generates C code at > this point? it does feel like something obvious...) > thanks, > cheers, > matthias > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From westondan at imageworks.com Wed Sep 2 17:23:47 2009 From: westondan at imageworks.com (Dan Weston) Date: Wed Sep 2 17:03:13 2009 Subject: [Haskell-cafe] cannot build greencard In-Reply-To: <1385741724.20090903011014@gmail.com> References: <20090902204425.GZ3247@yoyo> <1385741724.20090903011014@gmail.com> Message-ID: <4A9EE263.70202@imageworks.com> Yet strangely, the last upload was Sun Apr 19 21:42:04 UTC 2009 and hackage claims it builds without failure with ghc-6.10. And in fact it builds just fine for me, so maybe it is worth finding out why it doesn't build for you. Are you using ghc-6.10.4 and the latest version of cabal? I get: > ghc --version The Glorious Glasgow Haskell Compilation System, version 6.10.4 > cabal --version cabal-install version 0.6.2 using version 1.6.0.3 of the Cabal library > cabal install greencard Resolving dependencies... Downloading greencard-3.0.3... Configuring greencard-3.0.3... Preprocessing library greencard-3.0.3... Preprocessing executables for greencard-3.0.3... Building greencard-3.0.3... [1 of 1] Compiling Foreign.GreenCard ( lib/Foreign/GreenCard.hs, dist/build/Foreign/GreenCard.o ) /usr/bin/ar: creating dist/build/libHSgreencard-3.0.3.a [ 1 of 21] Compiling Package ( src/Package.lhs, dist/build/greencard/greencard-tmp/Package.o ) [ 2 of 21] Compiling ErrMonad ( src/ErrMonad.lhs, dist/build/greencard/greencard-tmp/ErrMonad.o ) [ 3 of 21] Compiling PrettyUtils ( src/PrettyUtils.lhs, dist/build/greencard/greencard-tmp/PrettyUtils.o ) [ 4 of 21] Compiling Target ( src/Target.lhs, dist/build/greencard/greencard-tmp/Target.o ) [ 5 of 21] Compiling Casm ( src/Casm.lhs, dist/build/greencard/greencard-tmp/Casm.o ) src/Casm.lhs:544:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... src/Casm.lhs:577:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... src/Casm.lhs:616:4: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... src/Casm.lhs:631:5: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... [ 6 of 21] Compiling GCToken ( src/GCToken.lhs, dist/build/greencard/greencard-tmp/GCToken.o ) [ 7 of 21] Compiling ListUtils ( src/ListUtils.lhs, dist/build/greencard/greencard-tmp/ListUtils.o ) [ 8 of 21] Compiling Name ( src/Name.lhs, dist/build/greencard/greencard-tmp/Name.o ) [ 9 of 21] Compiling Type ( src/Type.lhs, dist/build/greencard/greencard-tmp/Type.o ) [10 of 21] Compiling DIS ( src/DIS.lhs, dist/build/greencard/greencard-tmp/DIS.o ) [11 of 21] Compiling FillInMonad ( src/FillInMonad.lhs, dist/build/greencard/greencard-tmp/FillInMonad.o ) [12 of 21] Compiling NameSupply ( src/NameSupply.lhs, dist/build/greencard/greencard-tmp/NameSupply.o ) [13 of 21] Compiling Decl ( src/Decl.lhs, dist/build/greencard/greencard-tmp/Decl.o ) [14 of 21] Compiling FillIn ( src/FillIn.lhs, dist/build/greencard/greencard-tmp/FillIn.o ) [15 of 21] Compiling LexM ( src/LexM.lhs, dist/build/greencard/greencard-tmp/LexM.o ) [16 of 21] Compiling Lex ( src/Lex.lhs, dist/build/greencard/greencard-tmp/Lex.o ) [17 of 21] Compiling MarshallMonad ( src/MarshallMonad.lhs, dist/build/greencard/greencard-tmp/MarshallMonad.o ) [18 of 21] Compiling Proc ( src/Proc.lhs, dist/build/greencard/greencard-tmp/Proc.o ) [19 of 21] Compiling Parse ( dist/build/greencard/greencard-tmp/Parse.hs, dist/build/greencard/greencard-tmp/Parse.o ) dist/build/greencard/greencard-tmp/Parse.hs:1122:1: Warning: Pattern match(es) are overlapped In a case alternative: _ -> ... [20 of 21] Compiling Process ( src/Process.lhs, dist/build/greencard/greencard-tmp/Process.o ) [21 of 21] Compiling Main ( src/GreenCard.lhs, dist/build/greencard/greencard-tmp/Main.o ) Linking dist/build/greencard/greencard ... Installing library in /net/homedirs/westondan/.cabal/lib/greencard-3.0.3/ghc-6.10.4 Installing executable(s) in /net/homedirs/westondan/.cabal/bin Registering greencard-3.0.3... Reading package info from "dist/installed-pkg-config" ... done. Writing new package config file... done. Bulat Ziganshin wrote: > Hello mf-hcafe-15c311f0c, > > Thursday, September 3, 2009, 12:44:25 AM, you wrote: > > to the best of my knowledge, GC was developed in the days of ghc 0.20 > or so and last 10 years it's superceded by FFI addendum to Haskell'98 > standard. there is also more high-level tools like hsc2hs and HSFFIG > > >> hi, > >> i am stuck with a linker error in greencard, and haven't found >> anything online, so i am addressing you for fresh ideas. as soon as i >> get this sorted out, i will try to turn the answer into a patch that >> you can consider for the next release. > >> SYMPTOMS: greencard 3.0.3 and 3.01 do not compile with ghc-6.8 (debian >> lenny package) and 6.10 (darcs copy, checked out yesterday). here is >> what happens: > > >> 4 (0) 19:27:19 mf@yoyo:/tmp2 $ tar xvpzf greencard-3.0.3.tar.gz >> greencard-3.0.3/ >> greencard-3.0.3/ANNOUNCE >> greencard-3.0.3/dist/ >> greencard-3.0.3/dist/build/ >> greencard-3.0.3/dist/build/greencard/ >> greencard-3.0.3/dist/build/greencard/greencard-tmp/ >> greencard-3.0.3/dist/build/greencard/greencard-tmp/Parse.hs >> greencard-3.0.3/examples/ >> greencard-3.0.3/examples/Gdbm/ >> greencard-3.0.3/examples/Gdbm/diffs >> greencard-3.0.3/examples/Gdbm/Gdbm.gc >> greencard-3.0.3/examples/Gdbm/gdbmplus.h >> greencard-3.0.3/examples/Gdbm/Main.hs >> greencard-3.0.3/examples/Gdbm/Makefile >> greencard-3.0.3/examples/Gdbm/README >> greencard-3.0.3/examples/Makefile >> greencard-3.0.3/examples/world/ >> greencard-3.0.3/examples/world/Main.hs >> greencard-3.0.3/examples/world/Makedefs.ghc >> greencard-3.0.3/examples/world/Makedeps >> greencard-3.0.3/examples/world/Makefile.ghc-linux >> greencard-3.0.3/examples/world/Makefile.ghc-win32 >> greencard-3.0.3/examples/world/Makefile.hugs-linux >> greencard-3.0.3/examples/world/Makefile.hugs-win32 >> greencard-3.0.3/examples/world/README.txt >> greencard-3.0.3/examples/world/World.gc >> greencard-3.0.3/greencard.cabal >> greencard-3.0.3/INSTALL >> greencard-3.0.3/lib/ >> greencard-3.0.3/lib/Foreign/ >> greencard-3.0.3/lib/Foreign/GreenCard.hs >> greencard-3.0.3/lib/GreenCard.gc >> greencard-3.0.3/lib/Makefile >> greencard-3.0.3/lib/package.conf.in >> greencard-3.0.3/LICENSE >> greencard-3.0.3/Makefile >> greencard-3.0.3/README >> greencard-3.0.3/Setup.hs >> greencard-3.0.3/src/ >> greencard-3.0.3/src/Casm.lhs >> greencard-3.0.3/src/Decl.lhs >> greencard-3.0.3/src/DIS.lhs >> greencard-3.0.3/src/ErrMonad.lhs >> greencard-3.0.3/src/ErrorHook.c >> greencard-3.0.3/src/FillIn.lhs >> greencard-3.0.3/src/FillInMonad.lhs >> greencard-3.0.3/src/GCToken.lhs >> greencard-3.0.3/src/greencard.ghc.in >> greencard-3.0.3/src/greencard.hugs.in >> greencard-3.0.3/src/GreenCard.lhs >> greencard-3.0.3/src/Lex.lhs >> greencard-3.0.3/src/LexM.lhs >> greencard-3.0.3/src/ListUtils.lhs >> greencard-3.0.3/src/Makefile >> greencard-3.0.3/src/MarshallMonad.lhs >> greencard-3.0.3/src/Name.lhs >> greencard-3.0.3/src/NameSupply.lhs >> greencard-3.0.3/src/Package.lhs >> greencard-3.0.3/src/Package.lhs.in >> greencard-3.0.3/src/Parse.ly >> greencard-3.0.3/src/PrettyUtils.lhs >> greencard-3.0.3/src/Proc.lhs >> greencard-3.0.3/src/Process.lhs >> greencard-3.0.3/src/Target.lhs >> greencard-3.0.3/src/Type.lhs >> 5 (0) 19:27:22 mf@yoyo:/tmp2 $ cd greencard-3.0.3 >> 6 (0) 19:27:24 mf@yoyo:/tmp2/greencard-3.0.3 $ make prefix=/tmp2/ >> make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' >> happy Parse.ly >> unused terminals: 1 >> rm -f .depend >> touch .depend >> ghc -M -optdep-f -optdep.depend -optdep-xFiniteMap -optdep-xPretty >> -recomp -O -fglasgow-exts Casm.lhs DIS.lhs Decl.lhs ErrMonad.lhs >> FillIn.lhs FillInMonad.lhs GCToken.lhs GreenCard.lhs Lex.lhs >> LexM.lhs ListUtils.lhs MarshallMonad.lhs Name.lhs NameSupply.lhs >> Package.lhs PrettyUtils.lhs Proc.lhs Process.lhs Target.lhs Type.lhs Parse.hs >> make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' >> make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' >> ghc -recomp -O -fglasgow-exts -c Target.lhs -o Target.o >> ghc -recomp -O -fglasgow-exts -c PrettyUtils.lhs -o PrettyUtils.o >> ghc -recomp -O -fglasgow-exts -c Casm.lhs -o Casm.o > >> Casm.lhs:544:1: >> Warning: Pattern match(es) are overlapped >> In a case alternative: _ -> ... > >> Casm.lhs:577:1: >> Warning: Pattern match(es) are overlapped >> In a case alternative: _ -> ... > >> Casm.lhs:616:4: >> Warning: Pattern match(es) are overlapped >> In a case alternative: _ -> ... > >> Casm.lhs:631:5: >> Warning: Pattern match(es) are overlapped >> In a case alternative: _ -> ... >> ghc -recomp -O -fglasgow-exts -c ListUtils.lhs -o ListUtils.o >> ghc -recomp -O -fglasgow-exts -c ErrMonad.lhs -o ErrMonad.o >> ghc -recomp -O -fglasgow-exts -c Name.lhs -o Name.o >> ghc -recomp -O -fglasgow-exts -c DIS.lhs -o DIS.o >> ghc -recomp -O -fglasgow-exts -c Type.lhs -o Type.o >> ghc -recomp -O -fglasgow-exts -c Decl.lhs -o Decl.o >> ghc -recomp -O -fglasgow-exts -c FillInMonad.lhs -o FillInMonad.o >> ghc -recomp -O -fglasgow-exts -c NameSupply.lhs -o NameSupply.o >> ghc -recomp -O -fglasgow-exts -c FillIn.lhs -o FillIn.o >> ghc -recomp -O -fglasgow-exts -c GCToken.lhs -o GCToken.o >> ghc -recomp -O -fglasgow-exts -c MarshallMonad.lhs -o MarshallMonad.o >> ghc -recomp -O -fglasgow-exts -c Proc.lhs -o Proc.o >> ghc -recomp -O -fglasgow-exts -c LexM.lhs -o LexM.o >> ghc -recomp -O -fglasgow-exts -c Lex.lhs -o Lex.o >> ghc -recomp -O -fglasgow-exts -Onot -c Parse.hs -o Parse.o > >> Parse.hs:1733:1: >> Warning: Pattern match(es) are overlapped >> In a case alternative: _ -> ... >> ghc -recomp -O -fglasgow-exts -c Process.lhs -o Process.o >> ghc -recomp -O -fglasgow-exts -c Package.lhs -o Package.o >> ghc -recomp -O -fglasgow-exts -cpp -DBEGIN_GHC_ONLY='-}' >> -DEND_GHC_ONLY='{-' -DBEGIN_NOT_FOR_GHC='{-' -DEND_NOT_FOR_GHC='-}' >> -DPURE_WIN32=0 -c GreenCard.lhs -o GreenCard.o >> ghc -c ErrorHook.c -o ErrorHook.o >> ghc -recomp -O -fglasgow-exts -o greencard-bin Casm.o DIS.o >> Decl.o ErrMonad.o FillIn.o FillInMonad.o GCToken.o GreenCard.o Lex.o >> LexM.o ListUtils.o MarshallMonad.o Name.o NameSupply.o Package.o >> PrettyUtils.o Proc.o Process.o Target.o Type.o Parse.o ErrorHook.o >> Casm.o: In function `s201_info': >> (.text+0x168): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' >> Casm.o: In function `s201_info': >> (.text+0x17b): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' >> Casm.o: In function `s201_info': >> (.text+0x19d): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' >> Casm.o: In function `s201_info': >> (.text+0x1b7): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_con_info' >> Casm.o: In function `s201_info': >> (.text+0x1ca): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_con_info' >> Casm.o: In function `s201_info': >> (.text+0x1e9): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' >> Casm.o: In function `s201_info': >> (.text+0x1f0): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' > >> [... these continue for every object file on the command line; a bit >> over 2000 message of the same type in total...] > >> Type.o: In function `sBv_info': >> (.text+0x1b2b): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Beside_con_info' >> Type.o: In function `sZT_info': >> (.text+0x1ed3): undefined reference to >> `__stginit_prettyzm1zi0zi0zi0_TextziPrettyPrint_' >> Type.o: In function `sBb_info': >> (.text+0x1988): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' >> Type.o: In function `sBf_info': >> (.text+0x1a12): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_go6_info' >> Type.o: In function `sZU_info': >> (.text+0x1b96): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_text_info' >> Type.o: In function `rvv_closure': >> (.data+0x8): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Chr_static_info' >> Type.o: In function `rvH_closure': >> (.data+0x64): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_TextBeside_static_info' >> Type.o: In function `rvH_closure': >> (.data+0x6c): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_lvl3_closure' >> Type.o: In function `rvH_closure': >> (.data+0x70): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Empty_closure' >> Type.o: In function `rvN_closure': >> (.data+0xb0): undefined reference to >> `prettyzm1zi0zi0zi0_TextziPrettyPrintziHughesPJ_Str_static_info' >> collect2: ld returned 1 exit status >> make[1]: *** [greencard-bin] Error 1 >> make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' >> make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' >> ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls >> -c Foreign/GreenCard.hs -o Foreign/GreenCard.o -hisuf hi >> ghc-6.8.2: unrecognised flags: -fno-prune-tydecls >> Usage: For basic information, try the `--help' option. >> make[1]: *** [Foreign/GreenCard.o] Error 1 >> make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' >> make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' >> make[1]: Nothing to be done for `all'. >> make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/src' >> make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/lib' >> ghc -package-name greencard -cpp -fglasgow-exts -fno-prune-tydecls >> -prof -c Foreign/GreenCard.hs -o Foreign/GreenCard.p_o -hisuf p_hi >> ghc-6.8.2: unrecognised flags: -fno-prune-tydecls >> Usage: For basic information, try the `--help' option. >> make[1]: *** [Foreign/GreenCard.p_o] Error 1 >> make[1]: Leaving directory `/hime/tmp2/greencard-3.0.3/lib' >> make: *** [all] Error 2 > >> the errors about no-prune-tydecls are easy enough to fix: > >> $ diff -r greencard-3.0.3{,-patched} >> diff -r greencard-3.0.3/examples/Gdbm/Makefile >> greencard-3.0.3-patched/examples/Gdbm/Makefile >> 28d27 >> < HC_OPTS += -fno-prune-tydecls >> diff -r greencard-3.0.3/lib/Makefile >> greencard-3.0.3-patched/lib/Makefile >> 6c6 >> < GHC_OPTS = -cpp -fglasgow-exts -fno-prune-tydecls >> --- >>> GHC_OPTS = -cpp -fglasgow-exts >> $ > > >> this helps, but the linker errors are unrealted, and i don't know what >> to make of them. (I guess I should study how ghc generates C code at >> this point? it does feel like something obvious...) > > >> thanks, >> cheers, >> matthias >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From daniel.is.fischer at web.de Wed Sep 2 17:27:50 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Sep 2 17:08:13 2009 Subject: [Haskell-cafe] cannot build greencard In-Reply-To: <20090902204425.GZ3247@yoyo> References: <20090902204425.GZ3247@yoyo> Message-ID: <200909022327.50455.daniel.is.fischer@web.de> Am Mittwoch 02 September 2009 22:44:25 schrieb mf-hcafe-15c311f0c@etc-network.de: > hi, > > i am stuck with a linker error in greencard, and haven't found > anything online, so i am addressing you for fresh ideas. as soon as i > get this sorted out, i will try to turn the answer into a patch that > you can consider for the next release. > > SYMPTOMS: greencard 3.0.3 and 3.01 do not compile with ghc-6.8 (debian > lenny package) and 6.10 (darcs copy, checked out yesterday). here is > what happens: > > 6 (0) 19:27:24 mf@yoyo:/tmp2/greencard-3.0.3 $ make prefix=/tmp2/ > make[1]: Entering directory `/hime/tmp2/greencard-3.0.3/src' don't install with make, try cabal update && cabal install greencard if you have a cabal binary, otherwise ghc --make Steup ./Setup configure --user --prefix=$HOME (or whatever configure options you want) ./Setup build ./Setup install From daniel.is.fischer at web.de Wed Sep 2 17:41:34 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Wed Sep 2 17:21:58 2009 Subject: [Haskell-cafe] cannot build greencard In-Reply-To: <4A9EE263.70202@imageworks.com> References: <20090902204425.GZ3247@yoyo> <1385741724.20090903011014@gmail.com> <4A9EE263.70202@imageworks.com> Message-ID: <200909022341.34543.daniel.is.fischer@web.de> Am Mittwoch 02 September 2009 23:23:47 schrieb Dan Weston: > Yet strangely, the last upload was Sun Apr 19 21:42:04 UTC 2009 and > hackage claims it builds without failure with ghc-6.10. > > And in fact it builds just fine for me, so maybe it is worth finding out > why it doesn't build for you. Are you using ghc-6.10.4 and the latest > version of cabal? He used make, not cabal. My guess is that the makefiles haven't been updated because we now have Cabal and cabal. Formerly, Text.PrettyPrint.HughesPJ was in base, now it's in pretty, since --make is none of the HC_OPTIONS in the makefiles, ghc can't find HughesPJ, thus the linker errors. From mf-hcafe-15c311f0c at etc-network.de Wed Sep 2 18:52:34 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Wed Sep 2 18:32:27 2009 Subject: Solved (Was: [Haskell-cafe] cannot build greencard) In-Reply-To: <200909022341.34543.daniel.is.fischer@web.de> References: <20090902204425.GZ3247@yoyo> <1385741724.20090903011014@gmail.com> <4A9EE263.70202@imageworks.com> <200909022341.34543.daniel.is.fischer@web.de> Message-ID: <20090902225234.GA3247@yoyo> Yes, it works: $ greencard -V greencard, version 3.00 (Daniel: You were right; I made the mistake of following the instructions in the README :). Now I've finally switched to Cabal, and that did the trick. Bulat: Yes, I am aware of all the other projects, but greencard seems to be a front-end to FFI, and it looks alive enough to me right now, right?) (Btw the "report-bugs-to" e-mail doesn't work.) (Btw2: diff -r cabal-install-0.6.2/bootstrap.sh cabal-install-0.6.2-/bootstrap.sh 166c166 < dep_pkg "parsec" "2\." --- > dep_pkg "parsec" "3\." shouldn't be a problem, right?) Thanks everybody, Cheers, Matthias On Wed, Sep 02, 2009 at 11:41:34PM +0200, Daniel Fischer wrote: > To: haskell-cafe@haskell.org > Cc: Dan Weston , > "mf-hcafe-15c311f0c@etc-network.de" > From: Daniel Fischer > Date: Wed, 2 Sep 2009 23:41:34 +0200 > Subject: Re: [Haskell-cafe] cannot build greencard > > Am Mittwoch 02 September 2009 23:23:47 schrieb Dan Weston: > > Yet strangely, the last upload was Sun Apr 19 21:42:04 UTC 2009 and > > hackage claims it builds without failure with ghc-6.10. > > > > And in fact it builds just fine for me, so maybe it is worth finding out > > why it doesn't build for you. Are you using ghc-6.10.4 and the latest > > version of cabal? > > He used make, not cabal. > My guess is that the makefiles haven't been updated because we now have Cabal and cabal. > Formerly, Text.PrettyPrint.HughesPJ was in base, now it's in pretty, since --make is none > of the HC_OPTIONS in the makefiles, ghc can't find HughesPJ, thus the linker errors. > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** > CLASSIFY succeeds; success probability: 1.0000 pR: 11.1886 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 11.1886 > Total features in input file: 2456 > #0 (nonspam.css): features: 758386, hits: 2553116, prob: 1.00e+00, pR: 11.19 > #1 (spam.css): features: 1686574, hits: 2754260, prob: 6.48e-12, pR: -11.19 > From jvranish at gmail.com Wed Sep 2 22:21:37 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Sep 2 22:00:59 2009 Subject: [Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses Message-ID: A simple but powerful implementation of function lenses (aka functional references, accessors, etc..). This library provides a convenient way to access and update the elements of a structure. It is very similar to Data.Accessors, but simpler, a bit more generic and has fewer dependencies. I particularly like how cleanly it handles nested structures in state monads. It also contains a couple simple functions that can be used to easily convert a function that fetches data from a structure to a function that modifies data in the structure. Hackage hasn't generated the haddock documentation yet, but there is a mini-tutorial in Data.Lenses that explains it's use. Also for those that are interested it's also hosted on github here: http://github.com/jvranish/Lenses/tree/master Let me know what you think, Criticism is welcome, - Job -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090902/ce650abf/attachment.html From tanimoto at arizona.edu Thu Sep 3 00:18:34 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Sep 2 23:58:12 2009 Subject: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory) In-Reply-To: References: <910ddf450907280744j6e1b7635kdb1c68760718ac44@mail.gmail.com> <4A717B80.3060207@physics.org> <174c72ef0908311143g171d3e38w416b3ac72d85f3ac@mail.gmail.com> Message-ID: Job, On Wed, Sep 2, 2009 at 9:33 AM, Paulo Tanimoto wrote: > Hi Job, > > On Wed, Sep 2, 2009 at 9:22 AM, Job Vranish wrote: >> Did you by chance use the prebuilt ghc binaries? or build ghc manually? >> >> - Job >> > > Good question, I need to check that at home. ?Now that you mention it, > I remember considering using a repository (PPA) somebody had put > together, that had the latest GHC for Ubuntu Jaunty. ?I'm not sure I > used it though. > > I'll get back to you. > > Paulo > It looks like I did go with GHC from a PPA: $ dpkg -l | grep ghc ii ghc6 6.10.4-1.0~ppa2 GHC - the Glasgow Haskell Compilation system ii ghc6-doc 6.10.4-1.0~ppa2 Documentation for the Glasgow Haskell Compil ii ghc6-prof 6.10.4-1.0~ppa2 Profiling libraries for the Glasgow Haskell $ cat /etc/apt/sources.list.d/ghc.list deb http://ppa.launchpad.net/someone561/ppa/ubuntu jaunty main deb-src http://ppa.launchpad.net/someone561/ppa/ubuntu jaunty main $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 9.04 Release: 9.04 Codename: jaunty $ uname -r -v -m 2.6.28-11-generic #42-Ubuntu SMP Fri Apr 17 01:58:03 UTC 2009 x86_64 I definitely think we should file a bug report, because a lot of people have reported the same issue with Ubuntu Jaunty 64-bit, GHC 6.10.4, and Haskell Platform. Can anybody help providing the information? Or do we already have everything we need? Thanks, Paulo From colinpauladams at googlemail.com Thu Sep 3 02:17:37 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Thu Sep 3 01:56:56 2009 Subject: [Haskell-cafe] Can't get my head round monad transformers In-Reply-To: <4A9E4088.4030206@van.steenbergen.nl> References: <1afdeaec0909011034p773d46c7i34f057b4c9c82a2c@mail.gmail.com> <4A9E4088.4030206@van.steenbergen.nl> Message-ID: <1afdeaec0909022317x4045c339l501dc90c14f49de3@mail.gmail.com> Thanks. That was all I needed to sort it out. 2009/9/2 Martijn van Steenbergen : > Hi Colin, > > Colin Adams wrote: >> >> I'm trying to add a state monad onto the IO monad for use in a >> happstack application. I thought this should involve using StateT and >> Happstack.Server.SimpleHTTP.simpleHTTP', but I can't figure out how to >> plumb it all together. Any tips will be welcome. > > I'm not familiar with Happstack, but looking at the documentation: > >> simpleHTTP' :: (Monad m, ToMessage b) => >> ?(m ?(Maybe (Either Response a, FilterFun Response)) -> >> ? IO (Maybe (Either Response b, FilterFun Response))) -> >> ?Conf -> >> ?ServerPartT m a -> >> ?IO () > > Do I understand correctly you will be working with a >> >> myAction :: ServerPartT (StateT S IO) A > > ? > > Then it seems that you may call simpleHTTP' like this: >> >> simpleHTTP' >> ?(\action -> evalStateT action initState) >> ?myConf >> ?myAction > > The first argument (the lambda) has type >> >> forall a m. Monad m => StateT S m a -> m a > > which can be specialised to what simpleHTTP' is expecting. > > I hope this helps! > > Martijn. > -- Colin Adams Preston, Lancashire, ENGLAND From skluft at gmail.com Thu Sep 3 05:36:30 2009 From: skluft at gmail.com (Seb) Date: Thu Sep 3 05:15:53 2009 Subject: [Haskell-cafe] WXHaskell problem Message-ID: <44d0adef-141c-4184-a712-9b569ea276b5@j4g2000yqa.googlegroups.com> I just installed WXHaskell via Cabal and tried one of the examples BouncingBalls.hs. But every time I run it I get this error message in a dialog saying: "assert "m_dynamicEvents" failed in SearchDynamicEventTable(): caller should check that we have dynamic events" It also asks me if I want to stop the program or suppress further warnings. And if I press Cancel in the dialog to suppress further warnings the BouncingBalls-program seems to work just fine. How can i make this warning message go away? From martijn at van.steenbergen.nl Thu Sep 3 05:50:47 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Sep 3 05:30:07 2009 Subject: [Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses In-Reply-To: References: Message-ID: <4A9F9177.9030906@van.steenbergen.nl> Job Vranish wrote: > A simple but powerful implementation of function lenses (aka functional > references, accessors, etc..). Nice! I will definitely give it a whirl when I pick up my MUD again. I'm currently using accessors there. I see your functions are limited to use in the state monad--you're right, I've never used accessors outside of a state monad yet. I'm somewhat sad that you didn't capture lenses in a datatype, because it is such a nice example of a Category instance. I would like to see how to compose lenses to access deeper fields--I use nested data structures and would like to modify fields that are hidden deeper in the state. Can you perhaps add an example to show that? Thanks! Martijn. From Christian.Maeder at dfki.de Thu Sep 3 09:12:48 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Thu Sep 3 08:52:07 2009 Subject: [Haskell-cafe] Re: Snow Leopard Breaks GHC In-Reply-To: References: Message-ID: <4A9FC0D0.5050407@dfki.de> It might help to add -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci, too. (TH uses ghci) Cheers Christian Brian Sniffen wrote: > Having edit the Haskell Platform's /usr/bin/ghc in place, most > packages install fine. I'm still having trouble with Pandoc, even > given the advice: > >> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >> may be used. These options may also be passed to "./Setup configure" > > The problem appears to come when linking an incompatible zlib version: > > src/Text/Pandoc/ODT.hs:49:26: > Exception when trying to run compile-time code: > user error (Codec.Compression.Zlib: incompatible zlib version) > Code: ($) makeZip "data" "odt-styles" > In the first argument of `read', namely > `$(makeZip $ "data" "odt-styles")' > In the expression: read ($(makeZip $ "data" "odt-styles")) > In the definition of `refArchive': > refArchive = read ($(makeZip $ "data" "odt-styles")) > > I do have a universal zlib installed by MacPorts, as well as the > universal zlib that shipped with Snow Leopard and the universal zlib > that came with Cabal. I'm not sure whether this message indicates > that TH code is searching a different library path than non-TH code or > what. Advice is most welcome. > From jvranish at gmail.com Thu Sep 3 09:34:10 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Sep 3 09:13:28 2009 Subject: [Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses In-Reply-To: <4A9F9177.9030906@van.steenbergen.nl> References: <4A9F9177.9030906@van.steenbergen.nl> Message-ID: Actually they are _not_ limited to only the state monad, they just work naturally there. There are a few functions that allow you to easily use them outside a state monad (fetch, update, alter). It looks like the haddock documentation is generated now. There are a couple simple examples for accessing nested state in the tutorial in the module documentation here: http://hackage.haskell.org/packages/archive/lenses/0.1.2/doc/html/Data-Lenses.html Would a more complex example be helpful? I don't have time to post one now, but perhaps in an hour or two. Yeah, I decided to go with the state monad over making my own mathematically beautiful datatype. The state monad worked just too well all by itself. It also has the advantage of not really needed any helper functions (other than fromGetSet). All the important ones are already exist. - Job On Thu, Sep 3, 2009 at 5:50 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > Job Vranish wrote: > >> A simple but powerful implementation of function lenses (aka functional >> references, accessors, etc..). >> > > Nice! I will definitely give it a whirl when I pick up my MUD again. I'm > currently using accessors there. I see your functions are limited to use in > the state monad--you're right, I've never used accessors outside of a state > monad yet. > > I'm somewhat sad that you didn't capture lenses in a datatype, because it > is such a nice example of a Category instance. I would like to see how to > compose lenses to access deeper fields--I use nested data structures and > would like to modify fields that are hidden deeper in the state. Can you > perhaps add an example to show that? > > Thanks! > > Martijn. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090903/4cf05491/attachment.html From dav.vire+haskell at gmail.com Thu Sep 3 15:52:13 2009 From: dav.vire+haskell at gmail.com (david48) Date: Thu Sep 3 15:31:31 2009 Subject: [Haskell-cafe] ANNOUNCE: lenses -- Simple Functional Lenses In-Reply-To: References: <4A9F9177.9030906@van.steenbergen.nl> Message-ID: <4c88418c0909031252h356171d9v3fdac9617fcc1237@mail.gmail.com> On Thu, Sep 3, 2009 at 3:34 PM, Job Vranish wrote: > It looks like the haddock documentation is generated now. There are a couple > simple examples for accessing nested state in the tutorial in the module > documentation here: > http://hackage.haskell.org/packages/archive/lenses/0.1.2/doc/html/Data-Lenses.html Kudos for the documentation. Explanations, examples. You did a fine job there. From ravi at bluespec.com Thu Sep 3 15:53:02 2009 From: ravi at bluespec.com (Ravi Nanavati) Date: Thu Sep 3 15:32:20 2009 Subject: [Haskell-cafe] Fwd: [BostonHaskell] Next meeting: September 16th at MIT (32G-882) In-Reply-To: <161d443c0909031251x33fc5465n42d2430021892250@mail.gmail.com> References: <161d443c0909031251x33fc5465n42d2430021892250@mail.gmail.com> Message-ID: <7b977d860909031253g42cd2ad9y9e64e97a6b6f2288@mail.gmail.com> I'm pleased to announce the September meeting of the Boston Area Haskell Users' Group. Based on the feedback from the meeting polls and the constraints of our speaker, the September meeting has been scheduled for Wednesday, September 16th from 7pm - 9pm. I've decided to move the meeting time back half an hour since that seems closer to what we've ended up doing in practice. Like the past three meetings, it will be held in the MIT CSAIL Reading Room (32-G882, i.e. a room on the 8th floor of the Gates Tower of the MIT's Stata Center at 32 Vassar St in Cambridge, MA). Based on the topic poll, our featured speaker will be Edward Kmett, who will be presenting the second part of his monoids and parsing presentation: "A Parallel Parsing Trifecta: Iteratees, Parsec, and Monoids". Edward's slides from August are here: http://comonad.com/reader/wp-content/uploads/2009/08/IntroductionToMonoids.pdf I'd recommend looking at them if you weren't at the August meeting (or want a refresher on the material) since the two parts of his presentation were originally designed to go concurrently. There's also a preview of the September presentation as part of this post on Edward's blog: http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ We don't have any other presenters for September, so there are still openings for Lightning Talks or other relevant announcements / advertisements. If you're interested in one of those openings or in presenting something (large or small) at a future meeting, please let me know as we're still very hungry for content overall. The September attendance poll is at: http://doodle.com/gew97steggwhrnue As always, responding to this poll will help with two things: 1. Getting an idea of what fraction of the Boston-area Haskell community can and can't attend this meeting (to help with future scheduling). 2. Giving me an estimated count of attendees, so my wife can scale her baking of goodies appropriately. Sponsorship of or other assistance with refreshments is still being eagerly solicited. I'm also still having trouble embedding this poll in a page on our Google Group, so if anyone has any ideas about that, please feel free to try (any group member can edit pages) and/or offer other assistance or suggestions. If you have any questions about the meeting please send them to the BostonHaskell mailing list: bostonhaskell@googlegroups.com or contact me directly. I look forward to seeing many Boston-area Haskellers at the September meeting! Thank you, ?- Ravi Nanavati From niklas.broberg at gmail.com Thu Sep 3 17:57:42 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Thu Sep 3 17:36:58 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.1.4 Message-ID: Fellow Haskelleers, I'm pleased to announce the release of haskell-src-exts-1.1.4! * On hackage: http://hackage.haskell.org/package/haskell-src-exts * Via cabal: cabal install haskell-src-exts * Via darcs: darcs get http://code.haskell.org/haskell-src-exts * Report bugs: http://trac.haskell.org/haskell-src-exts haskell-src-exts is a package for Haskell source code manipulation. In particular it defines an abstract syntax tree representation, and a parser and pretty-printer to convert between this representation and String. It handles (almost) all syntactic extensions to the Haskell 98 standard implemented by GHC, and the parsing can be parametrised on what extensions to recognise. haskell-src-exts-1.1.4 follows version 1.1.3 in being a mostly experimental release. From a PVP perspective, the version number indicates that no incompatible changes have been made to the *stable* portion of the package, i.e. anything that doesn't contain Annotated in its module name. The experimental stuff in Language.Haskell.Annotated{.*} has changed quite a lot, but those of you who depend on it already must obviously know what you're doing. ;-) haskell-src-exts-1.1.4: =================== * For the stable part, the only new thing in haskell-src-exts-1.1.4 is a bug fix that allows declaration headers surrounded by parentheses to be parsed, e.g. "data (a :< b) = ...". * For the experimental part, the new and cool feature is a full exact-printer, allowing full round-tripping of parsing plus printing. In other words, using the parser and the exact-printer in conjunction gives the same result back: exactPrint . parse == id . (Well, that's half a lie since you need to use parseWithComments and some uncurrying if you want to so easily compose, but that's the gist of it anyway. :-)) * There have also been a number of further changes to the (annotated) AST to allow it to retain enough source information to allow for said exact-printing. In particular there have been changes to the way contexts and declaration heads are treated, and literals have been embellished to remember just how they were given (e.g. did we use 0xFF or 255? \BEL or \a?). * With a few small caveats, the round-tripping works over the full (alas somewhat small) test suite that comes with (the darcs version of) haskell-src-exts: - Trailing whitespace on a line is not retained. (The test suite uses reverse . dropWhile (isSpace) . reverse on each line to disregard that issue.) - Tab characters in the source are converted to (8) spaces (except when they appear inside comments or literals). (The test suite doesn't contain tabs.) - Exact specification of literals is only remembered for literals used as literals :-). What I mean is, source literals appearing in other positions in the source than as Haskell literals will be converted to a basic form. E.g. 'infixl 0x02 %%' will become 'infixl 2 %%'. Apart from infix declarations (tell me you never considered writing them that way!) this mostly matters for various pragmas. - Parentheses used around the function symbol in a function declaration will not be remembered (I can't figure out how to make a non-outrageous change to the AST to cope with them). E.g. '(foo a) b = ...' will be printed as 'foo a b = ...'. If anyone has an idea for a neat (or at least non-outrageous) AST fix that could handle these cases, drop me a line. - Literate source files are not handled by the exact-printer (can't re-literate them). Please, help me test this on your source code! If you grab a darcs version of the package from the repository, you can put any and all source files you want to test in the "haskell-src-exts/Test/examples" directory and then just run 'cabal test'. Please report any failing cases to my trac! :-) Cheers and Happy Haskelling, /Niklas From john at n-brain.net Thu Sep 3 18:05:13 2009 From: john at n-brain.net (John A. De Goes) Date: Thu Sep 3 17:44:36 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.1.4 In-Reply-To: References: Message-ID: <06CE42D0-5229-47D7-9E1D-3CBE151CEC20@n-brain.net> Roundtrip is an important milestone for automated refactoring tools. Nice work! Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 3, 2009, at 2:57 PM, Niklas Broberg wrote: > Fellow Haskelleers, > > I'm pleased to announce the release of haskell-src-exts-1.1.4! > > * On hackage: http://hackage.haskell.org/package/haskell-src-exts > * Via cabal: cabal install haskell-src-exts > * Via darcs: darcs get http://code.haskell.org/haskell-src-exts > > * Report bugs: http://trac.haskell.org/haskell-src-exts > > haskell-src-exts is a package for Haskell source code manipulation. In > particular it defines an abstract syntax tree representation, and a > parser and pretty-printer to convert between this representation and > String. It handles (almost) all syntactic extensions to the Haskell 98 > standard implemented by GHC, and the parsing can be parametrised on > what extensions to recognise. > > haskell-src-exts-1.1.4 follows version 1.1.3 in being a mostly > experimental release. From a PVP perspective, the version number > indicates that no incompatible changes have been made to the *stable* > portion of the package, i.e. anything that doesn't contain Annotated > in its module name. The experimental stuff in > Language.Haskell.Annotated{.*} has changed quite a lot, but those of > you who depend on it already must obviously know what you're doing. > ;-) > > haskell-src-exts-1.1.4: > =================== > > * For the stable part, the only new thing in haskell-src-exts-1.1.4 is > a bug fix that allows declaration headers surrounded by parentheses to > be parsed, e.g. "data (a :< b) = ...". > > * For the experimental part, the new and cool feature is a full > exact-printer, allowing full round-tripping of parsing plus printing. > In other words, using the parser and the exact-printer in conjunction > gives the same result back: exactPrint . parse == id . (Well, that's > half a lie since you need to use parseWithComments and some uncurrying > if you want to so easily compose, but that's the gist of it anyway. > :-)) > > * There have also been a number of further changes to the (annotated) > AST to allow it to retain enough source information to allow for said > exact-printing. In particular there have been changes to the way > contexts and declaration heads are treated, and literals have been > embellished to remember just how they were given (e.g. did we use 0xFF > or 255? \BEL or \a?). > > * With a few small caveats, the round-tripping works over the full > (alas somewhat small) test suite that comes with (the darcs version > of) haskell-src-exts: > - Trailing whitespace on a line is not retained. (The test suite > uses reverse . dropWhile (isSpace) . reverse on each line to disregard > that issue.) > - Tab characters in the source are converted to (8) spaces (except > when they appear inside comments or literals). (The test suite doesn't > contain tabs.) > - Exact specification of literals is only remembered for literals > used as literals :-). What I mean is, source literals appearing in > other positions in the source than as Haskell literals will be > converted to a basic form. E.g. 'infixl 0x02 %%' will become 'infixl 2 > %%'. Apart from infix declarations (tell me you never considered > writing them that way!) this mostly matters for various pragmas. > - Parentheses used around the function symbol in a function > declaration will not be remembered (I can't figure out how to make a > non-outrageous change to the AST to cope with them). E.g. '(foo a) b = > ...' will be printed as 'foo a b = ...'. If anyone has an idea for a > neat (or at least non-outrageous) AST fix that could handle these > cases, drop me a line. > - Literate source files are not handled by the exact-printer (can't > re-literate them). > > Please, help me test this on your source code! If you grab a darcs > version of the package from the repository, you can put any and all > source files you want to test in the "haskell-src-exts/Test/examples" > directory and then just run 'cabal test'. Please report any failing > cases to my trac! :-) > > Cheers and Happy Haskelling, > > /Niklas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From uzytkownik2 at gmail.com Thu Sep 3 18:34:07 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Thu Sep 3 18:14:06 2009 Subject: [Haskell-cafe] [Long] 'Fun' with types Message-ID: <1252017247.2330.4.camel@kirk> I'm somehow experimenting with GADT. I'm implementing FRP system and I get such error: Occurs check: cannot construct the infinite type: a = (a, b) In the pattern: CircuitSplit f g In the definition of `createChannel': createChannel (CircuitSplit f g) = let (df, cf) = createChannel f (dg, cg) = createChannel g .... in (df <<< dg, Map.map merge $ Map.unionWith (\ (First x) (Second y) -> Both x y) (Map.map First cf) (Map.map Second cf)) On code: import Control.Applicative import Control.Arrow import Control.Category (Category) import qualified Control.Category import Control.Monad import Control.Monad.Fix import Data.IORef import Data.Monoid hiding (First) import Data.Map (Map) import qualified Data.Map as Map import Data.Unique import Foreign import Foreign.C import Unsafe.Coerce -- | "CSignal" is a continous signal - i.e. signal which have a value at each -- point of time data CSignal a = CSignal (IO a) instance Functor CSignal where f `fmap` (CSignal v) = CSignal $ f <$> v instance Applicative CSignal where pure x = CSignal $ pure x (CSignal f) <*> (CSignal v) = CSignal $ f <*> v -- | "DSignal" is a discret signal - i.e. signal which is point-like. data DSignal a = DSignal (Map Unique ((a -> IO ()) -> IO ())) instance Functor DSignal where f `fmap` (DSignal l) = DSignal $ Map.map (. (. f)) l instance Monoid (DSignal a) where mempty = DSignal Map.empty (DSignal l) `mappend` (DSignal s) = DSignal $ Map.union l s -- | Convers the discret signal into a continous signal readAndCacheSignal :: a -- ^ Inital value -> DSignal a -- ^ Discret signal -> IO (CSignal a) -- ^ Continous signal readAndCacheSignal v (DSignal l) = do vr <- newIORef v Map.fold (>>) (return ()) $ Map.map ($ writeIORef vr) l return $ CSignal $ readIORef vr data Circuit a b where CircuitCSignal :: CSignal a -> Circuit () a CircuitDSignal :: DSignal a -> Circuit () (Maybe a) CircuitArr :: Kleisli IO a b -> Circuit a b CircuitJoint :: Circuit b c -> Circuit a b -> Circuit a c CircuitSplit :: Circuit a c -> Circuit b d -> Circuit (a, b) (c, d) CircuitChoice :: Circuit a c -> Circuit b d -> Circuit (Either a b) (Either c d) CircuitLoop :: Circuit (a, c) (b, c) -> Circuit a b instance Category Circuit where id = CircuitArr returnA f . g = CircuitJoint f g instance Arrow Circuit where arr f = CircuitArr $ arr f first = flip CircuitSplit returnA second = CircuitSplit returnA (***) = CircuitSplit instance ArrowChoice Circuit where left = flip CircuitChoice returnA right = CircuitChoice returnA (+++) = CircuitChoice instance ArrowLoop Circuit where loop = CircuitLoop data CircuitChannel a b where CircuitChannel :: Kleisli IO (c, a) b -> ((c -> IO ()) -> IO ()) -> CircuitChannel a b data ChannelJoin a b = First a | Second b | Both a b createChannel :: Circuit a b -> (Kleisli IO a b, Map Unique (CircuitChannel a b)) createChannel (CircuitCSignal (CSignal v)) = (Kleisli (const v), Map.empty) createChannel (CircuitDSignal (DSignal l)) = (arr $ const Nothing, Map.map (CircuitChannel (arr $ Just . snd)) l) createChannel (CircuitArr a) = (a, Map.empty) createChannel (CircuitJoint f g) = let (df, cf) = createChannel f (dg, cg) = createChannel g merge (First (CircuitChannel a r)) = CircuitChannel (dg <<< a) r merge (Second (CircuitChannel a r)) = CircuitChannel (a <<< second df) r merge (Both (CircuitChannel a r) (CircuitChannel b _)) = CircuitChannel (proc (d, v) -> do v' <- b -< (d, v) a -< (d, v')) r in (df <<< dg, Map.map merge $ Map.unionWith (\(First x) (Second y) -> Both x y) (Map.map First cf) (Map.map Second cf)) createChannel (CircuitSplit f g) = let (df, cf) = createChannel f (dg, cg) = createChannel g merge (First (CircuitChannel a r)) = CircuitChannel (proc (e, (c, d)) -> do c' <- a -< (e, c) d' <- dg -< d returnA -< (c', d')) r merge (Second (CircuitChannel b r)) = CircuitChannel (proc (e, (c, d)) -> do c' <- df -< c d' <- b -< (e, d) returnA -< (c', d')) r merge (Both (CircuitChannel a r) (CircuitChannel b _)) = CircuitChannel (proc (e, (c, d)) -> do c' <- a -< (e, c) d' <- b -< (e, d) returnA -< (c', d')) r in (df <<< dg, Map.map merge $ Map.unionWith (\(First x) (Second y) -> Both x y) (Map.map First cf) (Map.map Second cf)) createChannel (CircuitChoice f g) = let (df, cf) = createChannel f (dg, cg) = createChannel g merge (First (CircuitChannel a r)) = CircuitChannel (proc (e, c) -> case c of Left x -> a -< (e, x) Right x -> dg -< x) r merge (Second (CircuitChannel a r)) = CircuitChannel (proc (e, c) -> case c of Left x -> df -< x Right x -> a -< (e, x)) r merge (Both (CircuitChannel a r) (CircuitChannel b _)) = CircuitChannel (proc (e, c) -> case c of Left x -> a -< (e, x) Right x -> b -< (e, x)) r in (df ||| dg, Map.map merge $ Map.unionWith (\(First x) (Second y) -> Both x y) (Map.map First cf) (Map.map Second cf)) createChannel (CircuitLoop f) = let (df, cf) = createChannel f in (loop df, Map.map (\(CircuitChannel a r) -> CircuitChannel (proc (e, a) -> do rec (b, c) <- a -< (e, (a, c)) returnA -< b) r) cf) I know that it will require some sort of type voodoo but where's error now? Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090903/8e99940a/attachment.bin From niklas.broberg at gmail.com Thu Sep 3 18:43:32 2009 From: niklas.broberg at gmail.com (Niklas Broberg) Date: Thu Sep 3 18:22:50 2009 Subject: [Haskell-cafe] ANN: haskell-src-exts-1.1.4 In-Reply-To: <06CE42D0-5229-47D7-9E1D-3CBE151CEC20@n-brain.net> References: <06CE42D0-5229-47D7-9E1D-3CBE151CEC20@n-brain.net> Message-ID: > Roundtrip is an important milestone for automated refactoring tools. Nice > work! Thanks a lot! Refactoring was indeed the 'killer app' in mind when writing the exact-printer. For instance I don't expect it to be hard to get HLint to apply suggestions automatically now, instead of just suggesting them. :-) Cheers, /Niklas From coreyoconnor at gmail.com Thu Sep 3 21:51:06 2009 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Thu Sep 3 21:30:25 2009 Subject: [Haskell-cafe] ANN: vty-4.0.0.1 released Message-ID: Vty is a terminal UI library. Release 4.0.0.1 brings a number of important fixes, features, and performance enhancements. - Completely rewritten output backend. - Efficient, "scanline rasterization" style output span generator. Has not been fully optimized, but should be fast enough. - Terminfo based display terminal implementation. With specialized derivitives for xterm, Terminal.app, and iTerm.app. - Attempts to robustly handle even terminals that don't support all display attributes. - I've tested the following terminals with success: iTerm.app, Terminal.app, xterm, rxvt, mlterm, Eterm, gnome-terminal, konsole, screen, linux vty. Hopefully you will be as successfull. - Improved unicode support. Double wide characters will display as expected. - 256 color support. See Graphics.Vty.Attributes.Color240. The actual output color is adjusted according to the number of colors the terminal supports. - The Graphics.Vty.Image combinators no longer require matching dimensions to arguments! Unspecified areas are filled in with a user-customizable background pattern. See Graphics.Vty.Picture. - output picture will be cropped to display size as expected. - GHC 6.8 support is broken :-( - Unknown Windows platform support. - API changes: - "getSize" has been removed. Use "terminal vty >>= display_bounds" where "vty" is an instance of the Vty data structure. - added a "terminal" field to the Vty data structure. Accesses the TerminalHandle associated with the Vty instance. See Graphics.Vty.Terminal for details on the API usable with a TerminalHandle. - Graphics.Vty.Types has undergone a number of changes. Summary: - Partitioned into Graphics.Vty.Attributes for display attributes. Graphics.Vty.Image for image combinators. Graphics.Vty.Picture for final picture construction. - Graphics.Vty.Attributes: - "setFG" and "setBG" are now "with_fore_color" and "with_back_color" - All other "set.." equations similarly replaced. - "attr" is now "def_attr", short for "default display attributes" Also added a "current_attr" for "currently applied display attributes" - Graphics.Vty.Image: - "horzcat" is now "horiz_cat" - "vertcat" is now "vert_cat" - "renderBS" is now "utf8_bytestring" - "renderChar" is now "char" - "renderFill" is now "char_fill" - added a "utf8_string" and "string" (AKA "iso_10464_string") for UTF-8 encoded Strings and ISO-10464 encoded Strings. String literals in GHC have an ISO-10464 runtime representation. - Graphics.Vty.Picture: - exports Graphics.Vty.Image - "pic" is now "pic_for_image" - added API for setting background fill pattern. issues resolved: - "gnome terminal displays non-basic attributes as strikethrough" - http://trac.haskell.org/vty/ticket/14 - "Multi-byte characters are not displayed correctly on update" - http://trac.haskell.org/vty/ticket/10 - "Redraw does not handle rendering a line that extends beyond screen width characters" - http://trac.haskell.org/vty/ticket/13 - "The <|> and <-> combinators should be more forgiving of mismatched dimensions" - http://trac.haskell.org/vty/ticket/9 - "256-color support" - http://trac.haskell.org/vty/ticket/19 From dave at zednenem.com Thu Sep 3 23:39:38 2009 From: dave at zednenem.com (David Menendez) Date: Thu Sep 3 23:18:55 2009 Subject: [Haskell-cafe] [Long] 'Fun' with types In-Reply-To: <1252017247.2330.4.camel@kirk> References: <1252017247.2330.4.camel@kirk> Message-ID: <49a77b7a0909032039v40e51a05w674c5f943600a00e@mail.gmail.com> On Thu, Sep 3, 2009 at 6:34 PM, Maciej Piechotka wrote: > I'm somehow experimenting with GADT. I'm implementing FRP system and I > get such error: > ? ?Occurs check: cannot construct the infinite type: a = (a, b) > ? ?In the pattern: CircuitSplit f g > ? ?In the definition of `createChannel': > ? ? ? ?createChannel (CircuitSplit f g) > ? ? ? ? ? ? ? ? ? ? ? ?= let > ? ? ? ? ? ? ? ? ? ? ? ? ? ?(df, cf) = createChannel f > ? ? ? ? ? ? ? ? ? ? ? ? ? ?(dg, cg) = createChannel g > ? ? ? ? ? ? ? ? ? ? ? ? ? ?.... > ? ? ? ? ? ? ? ? ? ? ? ? ?in > ? ? ? ? ? ? ? ? ? ? ? ? ? ?(df <<< dg, Should that be "df *** dg"? -- Dave Menendez From magicloud.magiclouds at gmail.com Fri Sep 4 02:05:23 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Fri Sep 4 01:44:39 2009 Subject: [Haskell-cafe] Problem on existential type. Message-ID: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> Hi, I am trying out existential type, some sample code works well. Well, my own code could not be compiled with message: Grid.hs:45:11: Kind error: `GridWidget' is applied to too many type arguments In the type `GridWidget widget' In the type `(GridWidget widget) -> (widget -> t) -> t' In the type signature for `liftGW': liftGW :: (GridWidget widget) -> (widget -> t) -> t The code is: {-# OPTIONS -fglasgow-exts #-} module Grid where import Graphics.UI.Gtk data GridWidgetType = GridLabel | GridTextView data GridWidget = forall widget. (WidgetClass widget) => GridWidget widget --GWLabel Label -- | GWTextView TextView gridNew defaultWidget = do self <- fixedNew -- gw <- gridWidgetNew defaultWidget -- gridAddWidget self gw (0, 0) -- self `on` realize $ do -- (ww, wh) <- liftGW gw widgetGetSize -- (w, h) <- widgetGetSize self -- mapM_ (\x -> -- mapM_ (\y -> do -- gw <- gridWidgetNew defaultWidget -- liftGW gw $ \gw -> fixedPut self gw (x * ww, y * wh) -- ) [0..floor (h / wh)] -- ) [0..floor (w / ww)] return self -- gridSetWidget self (x, y) widget = do -- w <- gridGetWidget self (x, y) -- if w == widget -- then return () -- else do -- (w, h) <- widgetGetSize w -- gw <- gridWidgetNew widget -- fixedPut self gw (x * w, y * h) -- widgetDestroy w -- gridWidgetNew GridLabel = labelNew Nothing >>= return . GW -- gridWidgetNew GridTextView = textViewNew >>= return . GW -- gridAddWidget grid (GWLabel label) (x, y) = fixedPut grid label (x, y) -- gridAddWidget grid (GWTextView textView) (x, y) = fixedPut grid textView (x, y) liftGW :: (GridWidget widget) -> (widget -> t) -> t liftGW (GridWidget label) f = f label liftGW (GridWidget textView) f = f textView -- ??????? ??????? From colinpauladams at googlemail.com Fri Sep 4 02:13:33 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Fri Sep 4 01:52:50 2009 Subject: [Haskell-cafe] [Long] 'Fun' with types In-Reply-To: <49a77b7a0909032039v40e51a05w674c5f943600a00e@mail.gmail.com> References: <1252017247.2330.4.camel@kirk> <49a77b7a0909032039v40e51a05w674c5f943600a00e@mail.gmail.com> Message-ID: <1afdeaec0909032313x17b76439sa1611eb4b5b2dde5@mail.gmail.com> 2009/9/4 David Menendez : > On Thu, Sep 3, 2009 at 6:34 PM, Maciej Piechotka wrote: >> ? ? ? ? ? ? ? ? ? ? ? ? ? ?(df <<< dg, > > Should that be "df *** dg"? Is swearing allowed on this mailing list? :-) -- Colin Adams Preston, Lancashire, ENGLAND From miguelimo38 at yandex.ru Fri Sep 4 02:13:12 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Sep 4 01:52:56 2009 Subject: [Haskell-cafe] Problem on existential type. In-Reply-To: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> References: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> Message-ID: Your data type GridWidget doesn't have a parameter, yet you use it like it has one. > data GridWidget = forall widget. (WidgetClass widget) => GridWidget > widget ^ | NB:-------------+ > liftGW :: (GridWidget widget) -> (widget -> t) -> t From dons at galois.com Fri Sep 4 02:20:23 2009 From: dons at galois.com (Don Stewart) Date: Fri Sep 4 02:01:48 2009 Subject: [Haskell-cafe] Parallel programming in Haskell : a reading list Message-ID: <20090904062023.GE14439@whirlpool.galois.com> Here's a reading list for parallel programming in Haskell (via GHC) I've collected while preparing a tutorial. Might be interesting to those trying to get into multicore Haskell right now, http://donsbot.wordpress.com/2009/09/03/parallel-programming-in-haskell-a-reading-list/ Are there any good resources I'm missing? -- Don From matthew at brecknell.net Fri Sep 4 02:56:57 2009 From: matthew at brecknell.net (Matthew Brecknell) Date: Fri Sep 4 02:36:28 2009 Subject: [Haskell-cafe] Parallel programming in Haskell : a reading list In-Reply-To: <20090904062023.GE14439@whirlpool.galois.com> References: <20090904062023.GE14439@whirlpool.galois.com> Message-ID: <1252047417.8686.5.camel@localhost> Don Stewart wrote: > http://donsbot.wordpress.com/2009/09/03/parallel-programming-in-haskell-a-reading-list/ > > Are there any good resources I'm missing? http://www.haskell.org/~simonmar/papers/concurrent-data.pdf From vandijk.roel at gmail.com Fri Sep 4 03:12:41 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Fri Sep 4 02:51:58 2009 Subject: [Haskell-cafe] Problem on existential type. In-Reply-To: References: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> Message-ID: The only knowledge the type system has about a GridWidget is that it contains /some thing/ which is a member of the WidgetClass typeclass. So the only thing you can do with the thing inside the GridWidget is to apply functions of the WidgetClass. It might be easier to see with the Show class instead of your WidgetClass. data GridWidget = forall w. (Show w) => GridWidget w foo :: GridWidget -> String foo (GridWidget w) = show w foo $ GridWidget "hi there" > "hi there" foo $ GridWidget (3, 5) > "(3,5)" map foo [GridWidget True, GridWidget 3.14159] >["True", "3.14159"] But 'show' is the only function you can apply to values inside of a GridWidget because it is the only function of the Show class. The same holds for you WidgetClass. On Fri, Sep 4, 2009 at 8:13 AM, Miguel Mitrofanov wrote: > Your data type GridWidget doesn't have a parameter, yet you use it like it > has one. > >> data GridWidget = forall widget. (WidgetClass widget) => GridWidget widget > > ? ? ? ? ? ? ? ?^ > ? ? ? ? ? ? ? ?| > NB:-------------+ > >> liftGW :: (GridWidget widget) -> (widget -> t) -> t From maydwell at gmail.com Fri Sep 4 03:13:01 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Fri Sep 4 02:52:16 2009 Subject: [Haskell-cafe] Native windowing for glut applications on OS X. Message-ID: Hi haskell-cafe. I recently updated glut through cabal to version GLUT-2.2.1.0, and where once I had native windowing, now I can only seem to use X11. Does anyone know how to use native windowing? From jochem at functor.nl Fri Sep 4 03:14:52 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Fri Sep 4 02:53:46 2009 Subject: [Haskell-cafe] Problem on existential type. In-Reply-To: References: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> Message-ID: <4AA0BE6C.3050000@functor.nl> Miguel Mitrofanov wrote: > Your data type GridWidget doesn't have a parameter, yet you use it like > it has one. > >> data GridWidget = forall widget. (WidgetClass widget) => GridWidget >> widget > ^ > | > NB:-------------+ This is allowed as long as you have enabled the ExistentialTypes extension. This declares a so-called existential type, see the wiki for details, http://www.haskell.org/haskellwiki/Existential_types . Note that the second occurrence of "GridWidget" defines a data constructor, not a type constructor. Cheers, Jochem -- Jochem Berndsen | jochem@functor.nl GPG: 0xE6FABFAB From sfvisser at cs.uu.nl Fri Sep 4 06:56:25 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Fri Sep 4 06:35:41 2009 Subject: [Haskell-cafe] ANN: fclabels-0.4.0 - First class accessor labels. Message-ID: Hello all, IFCP is a really inspiring place to hang/hack around with your fellow Haskell hackers. So, straight from Edinburgh, I proudly present a new release of fclabels[1,2], your favourite record selector package. This version is joint work with Chris Eidhof and Sjoerd Visscher. This package has been around for a while but has been changed almost entirely now. Naming is different and has a far more consistent usage. This library might look cryptic at first sight, but give it a try it is not that hard. There are more package around that serve the same purpose (like the Lenses package which was uploaded a few days ago), but I'm convinced the simplicity and elegance of fclabels will strike you all. ;-) The package description is included below. Documentation can be found in the package itself or on Hackage. Gr, -- Sebastiaan Visser [1] Hackage: http://hackage.haskell.org/package/fclabels [2] Github: http://github.com/sebastiaanvisser/fclabels/tree/master * package description * First class labels that act as bidirectional records fields. The labels are fully composable and can be used to get, set and modify part of datatypes in a consistent way. The label datatype, conveniently called `:->', is an instance of the `Category' type class meaning it has a proper identity and composition. The library has support for automatically deriving labels from record selectors that start with an underscore. Labels can be used in a pure functional setting or be applied to mutable state in some state monad. From sargrigory at ya.ru Fri Sep 4 07:58:00 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Fri Sep 4 07:37:17 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? Message-ID: <715271252065480@webmail25.yandex.ru> In System.Random StdGen is defined as data StdGen = StdGen Int32 Int32 but its constructor StdGen is not exported. How to make StdGen to be an instance of Binary? The following won't work: instance Data.Binary.Binary StdGen where put (StdGen aa ab) = do Data.Binary.put aa Data.Binary.put ab get = do aa <- get ab <- get return (StdGen aa ab) From miguelimo38 at yandex.ru Fri Sep 4 08:16:32 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Sep 4 07:57:33 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <715271252065480@webmail25.yandex.ru> References: <715271252065480@webmail25.yandex.ru> Message-ID: <4AA10520.9050603@yandex.ru> Well, normally - you can't (unless there is some equivalent to the constructor exported). But there is a trick. You can use generic classes: {-# OPTIONS_GHC -fglasgow-exts -XGenerics -package lang #-} import Generics class Binary' a where put' :: a -> Put get' :: Get a put' {| Unit |} Unit = return () get' {| Unit |} = return Unit put' {| a :+: b |} (Inl x) = putWord8 0 >> put' x put' {| a :+: b |} (Inr y) = putWord8 1 >> put' y get' {| a :+: b |} = do w <- getWord8 case w of 0 -> liftM Left get' _ -> liftM Right get' put' {| a :*: b |} (x :*: y) = put' x >> put' y get' {| a :*: b |} = do x <- get' y <- get' return $ x :*: y instance Binary' Int32 where put' = put get' = get instance Binary' StdGen instance Binary StdGen where put = put' get = get' Last time I've checked it worked fine. A friend of mine have used it to create "instance Eq Chan", if I remember correctly. Grigory Sarnitskiy wrote: > In System.Random StdGen is defined as > > data StdGen = StdGen Int32 Int32 > > but its constructor StdGen is not exported. How to make StdGen to be an instance of Binary? The following won't work: > > instance Data.Binary.Binary StdGen where > put (StdGen aa ab) = do > Data.Binary.put aa > Data.Binary.put ab > get = do > aa <- get > ab <- get > return (StdGen aa ab) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bts at alum.mit.edu Fri Sep 4 08:50:17 2009 From: bts at alum.mit.edu (Brian Sniffen) Date: Fri Sep 4 08:29:54 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC Message-ID: Having edited the Haskell Platform's /usr/bin/ghc in place, most packages install fine. I'm still having trouble with Pandoc, even given the advice: > Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) > may be used. These options may also be passed to "./Setup configure" The problem appears to come when linking an incompatible zlib version: src/Text/Pandoc/ODT.hs:49:26: Exception when trying to run compile-time code: user error (Codec.Compression.Zlib: incompatible zlib version) Code: ($) makeZip "data" "odt-styles" In the first argument of `read', namely `$(makeZip $ "data" "odt-styles")' In the expression: read ($(makeZip $ "data" "odt-styles")) In the definition of `refArchive': refArchive = read ($(makeZip $ "data" "odt-styles")) The same problem occurs when making any call to Codec.Archive.Zip or Codec.Compression.Zlib. I do have a universal zlib installed by MacPorts, as well as the universal zlib that shipped with Snow Leopard and the universal zlib that came with Cabal. I'm not sure whether this message indicates that TH code is searching a different library path than non-TH code or what. Advice is most welcome. I'm particularly interested in finding out which zlib versions are being found at the construction of Codec.Compression.Zlib and at runtime (Pandoc compile time). -- Brian Sniffen http://evenmere.org/~bts/ From Christian.Maeder at dfki.de Fri Sep 4 09:51:22 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Sep 4 09:30:41 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: References: Message-ID: <4AA11B5A.50308@dfki.de> Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci as well not help? (as I've posted before) Cheers Christian Brian Sniffen wrote: > Having edited the Haskell Platform's /usr/bin/ghc in place, most > packages install fine. I'm still having trouble with Pandoc, even > given the advice: > >> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >> may be used. These options may also be passed to "./Setup configure" > > The problem appears to come when linking an incompatible zlib version: > > src/Text/Pandoc/ODT.hs:49:26: > Exception when trying to run compile-time code: > user error (Codec.Compression.Zlib: incompatible zlib version) > Code: ($) makeZip "data" "odt-styles" > In the first argument of `read', namely > `$(makeZip $ "data" "odt-styles")' > In the expression: read ($(makeZip $ "data" "odt-styles")) > In the definition of `refArchive': > refArchive = read ($(makeZip $ "data" "odt-styles")) > > The same problem occurs when making any call to Codec.Archive.Zip or > Codec.Compression.Zlib. > > I do have a universal zlib installed by MacPorts, as well as the > universal zlib that shipped with Snow Leopard and the universal zlib > that came with Cabal. I'm not sure whether this message indicates > that TH code is searching a different library path than non-TH code or > what. Advice is most welcome. I'm particularly interested in finding > out which zlib versions are being found at the construction of > Codec.Compression.Zlib and at runtime (Pandoc compile time). > > > > From sargrigory at ya.ru Fri Sep 4 10:40:48 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Fri Sep 4 10:20:04 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <4AA10520.9050603@yandex.ru> References: <715271252065480@webmail25.yandex.ru> <4AA10520.9050603@yandex.ru> Message-ID: <114791252075248@webmail52.yandex.ru> > {-# OPTIONS_GHC -fglasgow-exts -XGenerics -package lang #-} Got some problems: Could not find module `Generics': it is a member of package ghc-6.8.2, which is hidden Failed, modules loaded: none. and for ghci test.hs -fglasgow-exts -XGenerics -package lang ghc-6.8.2: unknown package: lang From miguelimo38 at yandex.ru Fri Sep 4 11:03:58 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Sep 4 10:44:59 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <4AA10520.9050603@yandex.ru> References: <715271252065480@webmail25.yandex.ru> <4AA10520.9050603@yandex.ru> Message-ID: <4AA12C5E.2060801@yandex.ru> You're right. The issue you've mentioned can be fixed easily - import Data.Generics instead of Generics and get rid of -package lang (I've copied them from the documentation without checking, seems like it's a bit outdated). The real problem is that you can't use "Get a" in generics! And you have the same problem here, because "Get" constructor isn't exported either! But we can make it work using a continuation trick: {-# OPTIONS_GHC -fglasgow-exts -XGenerics #-} module Test where import Control.Monad import Data.Binary import Data.Generics import Data.Int import System.Random class Binary' a where put' :: a -> Put get' :: (a -> Get StdGen) -> Get StdGen put' {| Unit |} Unit = return () get' {| Unit |} f = f Unit put' {| a :+: b |} (Inl x) = putWord8 0 >> put' x put' {| a :+: b |} (Inr y) = putWord8 1 >> put' y get' {| a :+: b |} f = do w <- getWord8 case w of 0 -> get' $ \x -> f $ Inl x _ -> get' $ \y -> f $ Inr y put' {| a :*: b |} (x :*: y) = put' x >> put' y get' {| a :*: b |} f = get' $ \x -> get' $ \y -> f (x :*: y) instance Binary' Int32 where put' = put get' f = get >>= f instance Binary' StdGen instance Binary StdGen where put = put' get = get' return This time I've checked that it really compiles. Pretty much sure it works. From bts at alum.mit.edu Fri Sep 4 11:30:52 2009 From: bts at alum.mit.edu (Brian Sniffen) Date: Fri Sep 4 11:10:26 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: <4AA11B5A.50308@dfki.de> References: <4AA11B5A.50308@dfki.de> Message-ID: No, my ghci is now "exec /Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4 -optc-m32 -opta-m32 -optl-m32 --interactive ${1+"$@"}" and I still see the same result. Also, I have switched to "--ld-options" instead of "--ld-option," which appears to have been a typo---cabal and setup never parsed it. -Brian On Fri, Sep 4, 2009 at 9:51 AM, Christian Maeder wrote: > Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci > as well not help? (as I've posted before) > > Cheers Christian > > Brian Sniffen wrote: >> Having edited the Haskell Platform's /usr/bin/ghc in place, most >> packages install fine. ?I'm still having trouble with Pandoc, even >> given the advice: >> >>> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >>> may be used. These options may also be passed to "./Setup configure" >> >> The problem appears to come when linking an incompatible zlib version: >> >> src/Text/Pandoc/ODT.hs:49:26: >> ? Exception when trying to run compile-time code: >> ? ? user error (Codec.Compression.Zlib: incompatible zlib version) >> ? ? Code: ($) makeZip "data" "odt-styles" >> ? In the first argument of `read', namely >> ? ? ? `$(makeZip $ "data" "odt-styles")' >> ? In the expression: read ($(makeZip $ "data" "odt-styles")) >> ? In the definition of `refArchive': >> ? ? ? refArchive = read ($(makeZip $ "data" "odt-styles")) >> >> The same problem occurs when making any call to Codec.Archive.Zip or >> Codec.Compression.Zlib. >> >> I do have a universal zlib installed by MacPorts, as well as the >> universal zlib that shipped with Snow Leopard and the universal zlib >> that came with Cabal. ?I'm not sure whether this message indicates >> that TH code is searching a different library path than non-TH code or >> what. ?Advice is most welcome. ?I'm particularly interested in finding >> out which zlib versions are being found at the construction of >> Codec.Compression.Zlib and at runtime (Pandoc compile time). >> >> >> >> > -- Brian Sniffen http://evenmere.org/~bts/ From Christian.Maeder at dfki.de Fri Sep 4 11:36:47 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Sep 4 11:16:06 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: References: <4AA11B5A.50308@dfki.de> Message-ID: <4AA1340F.7030109@dfki.de> Maybe runhaskell is used for template haskell? HTH Christian Brian Sniffen wrote: > No, my ghci is now "exec > /Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4 > -optc-m32 -opta-m32 -optl-m32 --interactive ${1+"$@"}" and I still see > the same result. Also, I have switched to "--ld-options" instead of > "--ld-option," which appears to have been a typo---cabal and setup > never parsed it. > > -Brian > > On Fri, Sep 4, 2009 at 9:51 AM, Christian Maeder > wrote: >> Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci >> as well not help? (as I've posted before) >> >> Cheers Christian >> >> Brian Sniffen wrote: >>> Having edited the Haskell Platform's /usr/bin/ghc in place, most >>> packages install fine. I'm still having trouble with Pandoc, even >>> given the advice: >>> >>>> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >>>> may be used. These options may also be passed to "./Setup configure" >>> The problem appears to come when linking an incompatible zlib version: >>> >>> src/Text/Pandoc/ODT.hs:49:26: >>> Exception when trying to run compile-time code: >>> user error (Codec.Compression.Zlib: incompatible zlib version) >>> Code: ($) makeZip "data" "odt-styles" >>> In the first argument of `read', namely >>> `$(makeZip $ "data" "odt-styles")' >>> In the expression: read ($(makeZip $ "data" "odt-styles")) >>> In the definition of `refArchive': >>> refArchive = read ($(makeZip $ "data" "odt-styles")) >>> >>> The same problem occurs when making any call to Codec.Archive.Zip or >>> Codec.Compression.Zlib. >>> >>> I do have a universal zlib installed by MacPorts, as well as the >>> universal zlib that shipped with Snow Leopard and the universal zlib >>> that came with Cabal. I'm not sure whether this message indicates >>> that TH code is searching a different library path than non-TH code or >>> what. Advice is most welcome. I'm particularly interested in finding >>> out which zlib versions are being found at the construction of >>> Codec.Compression.Zlib and at runtime (Pandoc compile time). >>> >>> >>> >>> > > > From Christian.Maeder at dfki.de Fri Sep 4 11:38:59 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Fri Sep 4 11:18:19 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: <4AA1340F.7030109@dfki.de> References: <4AA11B5A.50308@dfki.de> <4AA1340F.7030109@dfki.de> Message-ID: <4AA13493.20705@dfki.de> Or "runghc" form /usr/bin? Christian Maeder wrote: > Maybe runhaskell is used for template haskell? > > HTH Christian > > Brian Sniffen wrote: >> No, my ghci is now "exec >> /Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4 >> -optc-m32 -opta-m32 -optl-m32 --interactive ${1+"$@"}" and I still see >> the same result. Also, I have switched to "--ld-options" instead of >> "--ld-option," which appears to have been a typo---cabal and setup >> never parsed it. >> >> -Brian >> >> On Fri, Sep 4, 2009 at 9:51 AM, Christian Maeder >> wrote: >>> Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci >>> as well not help? (as I've posted before) >>> >>> Cheers Christian >>> >>> Brian Sniffen wrote: >>>> Having edited the Haskell Platform's /usr/bin/ghc in place, most >>>> packages install fine. I'm still having trouble with Pandoc, even >>>> given the advice: >>>> >>>>> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >>>>> may be used. These options may also be passed to "./Setup configure" >>>> The problem appears to come when linking an incompatible zlib version: >>>> >>>> src/Text/Pandoc/ODT.hs:49:26: >>>> Exception when trying to run compile-time code: >>>> user error (Codec.Compression.Zlib: incompatible zlib version) >>>> Code: ($) makeZip "data" "odt-styles" >>>> In the first argument of `read', namely >>>> `$(makeZip $ "data" "odt-styles")' >>>> In the expression: read ($(makeZip $ "data" "odt-styles")) >>>> In the definition of `refArchive': >>>> refArchive = read ($(makeZip $ "data" "odt-styles")) >>>> >>>> The same problem occurs when making any call to Codec.Archive.Zip or >>>> Codec.Compression.Zlib. >>>> >>>> I do have a universal zlib installed by MacPorts, as well as the >>>> universal zlib that shipped with Snow Leopard and the universal zlib >>>> that came with Cabal. I'm not sure whether this message indicates >>>> that TH code is searching a different library path than non-TH code or >>>> what. Advice is most welcome. I'm particularly interested in finding >>>> out which zlib versions are being found at the construction of >>>> Codec.Compression.Zlib and at runtime (Pandoc compile time). >>>> >>>> >>>> >>>> >> >> > From kyrab at mail.ru Fri Sep 4 11:46:00 2009 From: kyrab at mail.ru (kyra) Date: Fri Sep 4 11:25:15 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <4AA10520.9050603@yandex.ru> References: <715271252065480@webmail25.yandex.ru> <4AA10520.9050603@yandex.ru> Message-ID: <4AA13638.80204@mail.ru> Miguel Mitrofanov wrote: > Well, normally - you can't (unless there is some equivalent to the > constructor exported). > > But there is a trick. You can use generic classes: > > {-# OPTIONS_GHC -fglasgow-exts -XGenerics -package lang #-} > import Generics > class Binary' a where > put' :: a -> Put > get' :: Get a > put' {| Unit |} Unit = return () > get' {| Unit |} = return Unit > put' {| a :+: b |} (Inl x) = putWord8 0 >> put' x > put' {| a :+: b |} (Inr y) = putWord8 1 >> put' y > get' {| a :+: b |} = > do w <- getWord8 > case w of > 0 -> liftM Left get' > _ -> liftM Right get' > put' {| a :*: b |} (x :*: y) = put' x >> put' y > get' {| a :*: b |} = > do x <- get' > y <- get' > return $ x :*: y > instance Binary' Int32 where > put' = put > get' = get > instance Binary' StdGen > instance Binary StdGen where > put = put' > get = get' > Isn't it to define an isomorphic type and unsafeCoerce to it pretty much equivalent? At least the following simplest example works just fine: module Main where import Unsafe.Coerce class Test a where test :: a -> Int data Foo = Foo Int Int data Bar = Bar Int Int instance Test Bar where test (Bar a b) = a + b instance Test Foo where test foo = test (unsafeCoerce foo :: Bar) main :: IO () main = print $ test (Foo 123 345) Cheers, Kyra From colin at colina.demon.co.uk Fri Sep 4 11:53:26 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Fri Sep 4 11:32:42 2009 Subject: [Haskell-cafe] haskelldb + sqlite problem. In-Reply-To: (Colin Paul Adams's message of "Fri\, 04 Sep 2009 16\:31\:18 +0100") References: <3bd412d40906212215y36cbe76o6fa89db8f4ae7204@mail.gmail.com> Message-ID: >>>>> "Magicloud" == Magicloud Magiclouds writes: Magicloud> Hi, I am using haskelldb and Magicloud> haskelldb-hdbc-sqlite3. Well, I finally got the source Magicloud> compiled and ran, I got this error: App: user error Magicloud> (SQL error: SqlError {seState = "", seNativeError = 21, Magicloud> seErrorMsg = "prepare 74: SELECT subject,\n Magicloud> timestamp\nFROM notes as T1\nORDER BY timestamp DESC: Magicloud> library routine called out of sequence"}) Any clue what Magicloud> I should check? Did you get this working? If so, what was the problem and how did you go about resolving it. I have the identical problem. I had the database code working fine, but then I added a state monad into the monad stack for the program, and now I get this problem. I see that John Goerzen suggested it might be a result of reading the data lazily. So I tried changing my import statements from import Control.Monad.State to import Control.Monad.State.Strict in case the StateT was indirectly causing the problem, but that doesn't make any difference. -- Colin Adams Preston Lancashire From korpios at korpios.com Fri Sep 4 12:02:46 2009 From: korpios at korpios.com (Tom Tobin) Date: Fri Sep 4 11:42:01 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: <4AA13493.20705@dfki.de> References: <4AA11B5A.50308@dfki.de> <4AA1340F.7030109@dfki.de> <4AA13493.20705@dfki.de> Message-ID: On Fri, Sep 4, 2009 at 10:38 AM, Christian Maeder wrote: > Or "runghc" form /usr/bin? /usr/bin/runghc is a symlink to the same file as runhaskell. From sargrigory at ya.ru Fri Sep 4 12:05:53 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Fri Sep 4 11:45:07 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <4AA12C5E.2060801@yandex.ru> References: <715271252065480@webmail25.yandex.ru> <4AA10520.9050603@yandex.ru> <4AA12C5E.2060801@yandex.ru> Message-ID: <160331252080353@webmail55.yandex.ru> > This time I've checked that it really compiles. Pretty much sure it works. But how?! I'can't compile it: test.hs:11:2: Conflicting definitions for `put'' Bound at: test.hs:11:2-5 test.hs:13:2-5 test.hs:20:2-5 In the default-methods for class Binary' test.hs:12:2: Conflicting definitions for `get'' Bound at: test.hs:12:2-5 test.hs:15:2-5 test.hs:21:2-5 In the default-methods for class Binary' From sargrigory at ya.ru Fri Sep 4 13:07:18 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Fri Sep 4 12:46:37 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <715271252065480@webmail25.yandex.ru> References: <715271252065480@webmail25.yandex.ru> Message-ID: <144501252084038@webmail24.yandex.ru> Well, I've managed to produce a solution, quite ugly and unefficient. Still it works (and I really need it). StdGen serialization occurs only once during computation that lasts several hours, so the speed is not vital for me. Here is my solution: module Main where import System.Random import Data.Binary import Data.Int data StdGen' = StdGen' Int32 Int32 deriving (Show) gen2gen' :: StdGen -> StdGen' gen2gen' gen = let [g1, g2] = words $ show $ gen g1' = read g1 :: Int32 g2' = read g2 :: Int32 in StdGen' g1' g2' gen'2gen :: StdGen' -> StdGen gen'2gen (StdGen' g1' g2') = let gen = read $ show g1' ++ ' ':(show g2') :: StdGen in gen instance Data.Binary.Binary StdGen' where put (StdGen' aa ab) = do Data.Binary.put aa Data.Binary.put ab get = do aa <- get ab <- get return (StdGen' aa ab) instance Data.Binary.Binary StdGen where put gen = put $ gen2gen' gen get = do gen' <- get return (gen'2gen gen') From miguelimo38 at yandex.ru Fri Sep 4 13:30:48 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Fri Sep 4 13:10:03 2009 Subject: [Haskell-cafe] How to derive instance for type without exported constructor? In-Reply-To: <160331252080353@webmail55.yandex.ru> References: <715271252065480@webmail25.yandex.ru> <4AA10520.9050603@yandex.ru> <4AA12C5E.2060801@yandex.ru> <160331252080353@webmail55.yandex.ru> Message-ID: <79CAB723-E4E5-4905-B9F3-203244BE483A@yandex.ru> Just copypasted it from my own email. Works fine. On 4 Sep 2009, at 20:05, Grigory Sarnitskiy wrote: > >> This time I've checked that it really compiles. Pretty much sure it >> works. > > But how?! I'can't compile it: > > test.hs:11:2: > Conflicting definitions for `put'' > Bound at: test.hs:11:2-5 > test.hs:13:2-5 > test.hs:20:2-5 > In the default-methods for class Binary' > > test.hs:12:2: > Conflicting definitions for `get'' > Bound at: test.hs:12:2-5 > test.hs:15:2-5 > test.hs:21:2-5 > In the default-methods for class Binary' > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mf-hcafe-15c311f0c at etc-network.de Fri Sep 4 14:06:40 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Fri Sep 4 13:46:10 2009 Subject: [Haskell-cafe] greencard error message Message-ID: <20090904180640.GG3247@yoyo> greetings, greencard is confusing me: I copied an example from the command line and was hoping to look at some generated Haskell code to understand what's going on, but got this instead: | $ cat M1.gc | module M1 where | %enum PosixError Int [EACCES, ENOENT] | $ greencard M1.gc | greencard: user error (, line : | Don't know how to unmarshall (int res1) | | , line : | Don't know how to unmarshall (int res1) | | ) (is there any live code out there that i could use as an example to study? most of the links from haskell.org/greencard are dead. anybody agree to earlier comments that greencard is obsolete? i really like it so far and would be glad to hear otherwise.) thanks, mattias From slehuitouze at telisma.com Fri Sep 4 15:23:35 2009 From: slehuitouze at telisma.com (Serge LE HUITOUZE) Date: Fri Sep 4 15:02:52 2009 Subject: [Haskell-cafe] Is this Parsec code idiomatic? Message-ID: Hi Haskellers, I'm asking some advice on a small piece of code representing a simplified version of a treatment I need to perform. I have a line-oriented string/file, from which I want to extract only a substring of those lines starting with char '+' (the detail of the extraction is irrelevant here, I'll just return what follows the '+'). [I also simplified the "eol" parser for shorter code.] I came out with the code below. The line parser returns a "Maybe String". The complete parser return a "[Maybe String]" by mere concatenation. The main function filters the 'Nothing' with 'catMaybes'. > import Text.ParserCombinators.Parsec > import Data.Maybe > > maybePlusFile :: GenParser Char st [Maybe String] > maybePlusFile = endBy maybePlusLine eol > > maybePlusLine :: GenParser Char st (Maybe String) > maybePlusLine = try (do char('+') > result <- many (noneOf "\n") > return $ Just result) > <|> do many (noneOf "\n") > return $ Nothing > > eol = char '\n' > > selectPlus :: String -> Either ParseError [String] > selectPlus input = > case parse maybePlusFile "(input)" input of > Left e -> Left e > Right mblist -> Right $ catMaybes mblist This works as expected (or so it seems), as the ghci dump shows: > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > ... > Prelude> :l selectPlus.hs > [1 of 1] Compiling Main ( selectPlus.hs, interpreted ) > Ok, modules loaded: Main. > *Main> selectPlus "abc\n+123\ndef\n+456\n" > Loading package parsec-2.1.0.1 ... linking ... done. > Right ["123","456"] > *Main> I'd like to know if this code is good style, and how you would possibly improve it. Thanks in advance. --Serge -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090904/ce2c2fe2/attachment.html From martijn at van.steenbergen.nl Fri Sep 4 15:40:36 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Fri Sep 4 15:19:55 2009 Subject: [Haskell-cafe] Is this Parsec code idiomatic? In-Reply-To: References: Message-ID: <4AA16D34.5070608@van.steenbergen.nl> Hi Serge, Serge LE HUITOUZE wrote: > I'm asking some advice on a small piece of code representing a > simplified version of a treatment I need to perform. > I have a line-oriented string/file, from which I want to extract > only a substring of those lines starting with char '+' (the detail > of the extraction is irrelevant here, I'll just return what follows > the '+'). This isn't really answering your question, but I thought I'd share anyway: why use Parsec to retrieve those lines? It seems a simple function is a lot easier: selectPlus :: String -> [String] selectPlus = map tail . filter ((== '+') . head) . lines I hope this helps you. Martijn. From bugfact at gmail.com Fri Sep 4 15:57:27 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Sep 4 15:36:41 2009 Subject: [Haskell-cafe] NFData question Message-ID: When ones makes an ADT with data constructors that has strict (and maybe unpacked) fields, e.g. data Vec2 a = Vec2 {-# UNPACK #-} !a {-# UNPACK #-} !a how does one define an NFData instance? Like this? instance NFData a => NFData (Vec2 a) where rnf (Vec2 x y) = rnf x `seq` rnf y Or is it enough to just do instance NFData a => NFData (Vec2 a) since Vec2 is fully strict anyway, so that default rnf implementation will do? Thanks, Peter From ben_moseley at mac.com Fri Sep 4 16:03:00 2009 From: ben_moseley at mac.com (Ben Moseley) Date: Fri Sep 4 15:42:29 2009 Subject: [Haskell-cafe] Is this Parsec code idiomatic? In-Reply-To: <4AA16D34.5070608@van.steenbergen.nl> References: <4AA16D34.5070608@van.steenbergen.nl> Message-ID: Or for a bit of variety: selectPlus s = [cs | ('+':cs) <- lines s] --Ben On 4 Sep 2009, at 20:40, Martijn van Steenbergen wrote: > Hi Serge, > > Serge LE HUITOUZE wrote: >> I'm asking some advice on a small piece of code representing a >> simplified version of a treatment I need to perform. >> I have a line-oriented string/file, from which I want to extract >> only a substring of those lines starting with char '+' (the detail >> of the extraction is irrelevant here, I'll just return what follows >> the '+'). > > This isn't really answering your question, but I thought I'd share > anyway: why use Parsec to retrieve those lines? It seems a simple > function is a lot easier: > > selectPlus :: String -> [String] > selectPlus = map tail . filter ((== '+') . head) . lines > > I hope this helps you. > > Martijn. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From dagit at codersbase.com Fri Sep 4 16:04:44 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Sep 4 15:43:58 2009 Subject: [Haskell-cafe] NFData question In-Reply-To: References: Message-ID: On Fri, Sep 4, 2009 at 12:57 PM, Peter Verswyvelen wrote: > When ones makes an ADT with data constructors that has strict (and > maybe unpacked) fields, > > e.g. > > data Vec2 a ?= Vec2 {-# UNPACK #-} !a {-# UNPACK #-} !a > > how does one define an NFData instance? > > Like this? > > instance NFData a => NFData (Vec2 a) where > ?rnf (Vec2 x y) = rnf x `seq` rnf y I think you need your definition here because if you had: Vec2 (String, String) I think the declaration of Vec2 just ensures that the tuple is constructed. But to ensure that the strings are evaluated, you need to recursively call rnf (I think). That's my understanding, but I could be wrong. Jason From daniel.is.fischer at web.de Fri Sep 4 16:05:18 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Sep 4 15:48:36 2009 Subject: [Haskell-cafe] Is this Parsec code idiomatic? In-Reply-To: References: Message-ID: <200909042205.19971.daniel.is.fischer@web.de> Am Freitag 04 September 2009 21:23:35 schrieb Serge LE HUITOUZE: > Hi Haskellers, > > I'm asking some advice on a small piece of code representing a > simplified version of a treatment I need to perform. > I have a line-oriented string/file, from which I want to extract > only a substring of those lines starting with char '+' (the detail > of the extraction is irrelevant here, I'll just return what follows > the '+'). > [I also simplified the "eol" parser for shorter code.] > > I came out with the code below. > The line parser returns a "Maybe String". > The complete parser return a "[Maybe String]" by mere concatenation. > The main function filters the 'Nothing' with 'catMaybes'. > > > import Text.ParserCombinators.Parsec > > import Data.Maybe > > > > maybePlusFile :: GenParser Char st [Maybe String] > > maybePlusFile = endBy maybePlusLine eol > > > > maybePlusLine :: GenParser Char st (Maybe String) > > maybePlusLine = try (do char('+') No need for try here, char '+' either fails without consuming input or the whole branch succeeds. > > result <- many (noneOf "\n") > > return $ Just result) > > <|> do many (noneOf "\n") > > return $ Nothing > > > > eol = char '\n' maybePlusLine = do char '+' fmap Just $ manyTill anyChar eol <|> do skipMany (noneOf "\n") return Nothing maybePlusFile = many maybePlusLine > > > > selectPlus :: String -> Either ParseError [String] > > selectPlus input = > > case parse maybePlusFile "(input)" input of > > Left e -> Left e > > Right mblist -> Right $ catMaybes mblist > > This works as expected (or so it seems), as the ghci dump shows: > > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > > ... > > Prelude> :l selectPlus.hs > > [1 of 1] Compiling Main ( selectPlus.hs, interpreted ) > > Ok, modules loaded: Main. > > *Main> selectPlus "abc\n+123\ndef\n+456\n" > > Loading package parsec-2.1.0.1 ... linking ... done. > > Right ["123","456"] > > *Main> > > I'd like to know if this code is good style, and how you would > possibly improve it. Except for the superfluous try, it's good. Unless you can't guarantee that the input ends with a newline. Then you should take care of that (for example eol = char '\n' <|> (eof >> return '\n') ). If it's such a simple extraction, there's no need for a parser, however, map tail . filter startsPlus . lines $ input where startsPlus ('+':_) = True startsPlus _ = False will do fine. > > > Thanks in advance. > > --Serge From daniel.is.fischer at web.de Fri Sep 4 16:16:23 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Sep 4 15:56:41 2009 Subject: [Haskell-cafe] NFData question In-Reply-To: References: Message-ID: <200909042216.23611.daniel.is.fischer@web.de> Am Freitag 04 September 2009 21:57:27 schrieb Peter Verswyvelen: > When ones makes an ADT with data constructors that has strict (and > maybe unpacked) fields, > > e.g. > > data Vec2 a = Vec2 {-# UNPACK #-} !a {-# UNPACK #-} !a > > how does one define an NFData instance? > > Like this? > > instance NFData a => NFData (Vec2 a) where > rnf (Vec2 x y) = rnf x `seq` rnf y Yep. > > Or is it enough to just do > instance NFData a => NFData (Vec2 a) > > since Vec2 is fully strict anyway, so that default rnf implementation will > do? Not necessarily. It will do if a is a simple type for which whnf == nf, like Int, but otherwise the components of Vec2 are only forced to whnf by the strictness annotations and the default implementation of rnf won't do anything more. module Vec2 where import Control.Parallel.Strategies data Vec2 a = Vec2 {-# UNPACK #-} !a {-# UNPACK #-} !a deriving Show instance NFData (Vec2 a) ghci> let v = Vec2 [True,False] [False,True,undefined] ghci> case v `using` rnf of { Vec2 l1 l2 -> (l1,take 2 l2) } ([True,False],[False,True]) ghci> v Vec2 [True,False] [False,True,*** Exception: Prelude.undefined > > Thanks, > Peter From mvanier42 at gmail.com Fri Sep 4 17:03:47 2009 From: mvanier42 at gmail.com (Michael Vanier) Date: Fri Sep 4 16:43:05 2009 Subject: [Haskell-cafe] How do I fix this error message? In-Reply-To: References: Message-ID: <4AA180B3.7020104@cs.caltech.edu> Hi everyone, I ran into this error when recompiling some code I hadn't worked on in a while: Foo.hs:19:7: Could not find module `Control.Monad.Error': it was found in multiple packages: monads-fd-0.0.0.1 mtl-1.1.0.2 I gather that monads-fd is supposed to be a replacement for mtl, but I have both of them (mtl from the normal GHC 6.10.4 install, monads-fd from cabal). I don't really care which one I use, though mtl has been fine in the past. In the past, I had to manually uninstall cabal packages that used incompatible libraries. Is this still the case? TIA, Mike From bugfact at gmail.com Fri Sep 4 17:07:40 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Sep 4 16:46:55 2009 Subject: [Haskell-cafe] How do I fix this error message? In-Reply-To: <4AA180B3.7020104@cs.caltech.edu> References: <4AA180B3.7020104@cs.caltech.edu> Message-ID: Although also a bit of a global hack, you could also hide one of the packages using ghc-pkg hide mtl-1.1.02 instead of uninstalling them I think. Also, if you make a cabal file, you could specify the exact module you want to use. On Fri, Sep 4, 2009 at 11:03 PM, Michael Vanier wrote: > Hi everyone, > > I ran into this error when recompiling some code I hadn't worked on in a > while: > > Foo.hs:19:7: > ? Could not find module `Control.Monad.Error': > ? ? it was found in multiple packages: monads-fd-0.0.0.1 mtl-1.1.0.2 > > I gather that monads-fd is supposed to be a replacement for mtl, but I have > both of them (mtl from the normal GHC 6.10.4 install, monads-fd from cabal). > ?I don't really care which one I use, though mtl has been fine in the past. > ?In the past, I had to manually uninstall cabal packages that used > incompatible libraries. ?Is this still the case? > > TIA, > > Mike > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From s.clover at gmail.com Fri Sep 4 17:49:59 2009 From: s.clover at gmail.com (Sterling Clover) Date: Fri Sep 4 17:29:14 2009 Subject: [Haskell-cafe] ANN: HStringTemplate 0.6.2 Message-ID: I haven't sent out a release announcement for HStringTemplate in some time. In that time, there's been a host of new users, and consequently a host of feature requests and bug reports. Among the relatively recent changes: * Simple quasiquotation. * Proper unicode support (files are read in UTF-8, Data.Text templates are supported). * Creation of groups from hierarchies of directories. * Separators are applied within iterated template application. * Chained iterated template application now occurs depthwise rather than breadthwise. * Encoding functions generalized from String -> String to (Stringable a) => a -> a * Trailing newlines stripped from templates. * Initial newlines stripped after conditionals. * Functions to check templates for proper parsing, and existence of all necessary parameters and invoked templates. Current version is, as always, on Hackage: http://hackage.haskell.org/package/HStringTemplate User-maintained documentation on the wiki: http://www.haskell.org/haskellwiki/HStringTemplate Patches, bug reports, requests, and especially additional work on the documentation always welcome. Cheers, Sterl. From agocorona at gmail.com Fri Sep 4 18:06:50 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Fri Sep 4 17:46:04 2009 Subject: [Haskell-cafe] forkM fails Message-ID: Hi I need to execute a procedure not in the IO monad, but in an any monad: I defined: forkM :: Monad m=> m a -> IO ThreadId forkM proc=forkIO $ proc `seq` return() I assumed that seq will force the evaluation of proc and after, it will discard his type (m a) and return () in the IO monad.as forkIO expect. however proc is not executed Prelude> Control.Concurrent.forkIO $ print "hola" ThreadId 331 "hola" Prelude> Prelude> let forkM p=Control.Concurrent.forkIO $ p `seq` return () Prelude> forkM $ print "hola" ThreadId 493 Prelude> Any idea?. Thanks in advance From westondan at imageworks.com Fri Sep 4 18:56:37 2009 From: westondan at imageworks.com (Dan Weston) Date: Fri Sep 4 18:35:57 2009 Subject: [Haskell-cafe] forkM fails In-Reply-To: References: Message-ID: <4AA19B25.2050501@imageworks.com> Try >> instead of `seq`. Alberto G. Corona wrote: > Hi > > I need to execute a procedure not in the IO monad, but in an any monad: > > I defined: > > forkM :: Monad m=> m a -> IO ThreadId > forkM proc=forkIO $ proc `seq` return() > > I assumed that seq will force the evaluation of proc and after, it > will discard his type (m a) and return () in the IO monad.as forkIO > expect. > > however proc is not executed > > Prelude> Control.Concurrent.forkIO $ print "hola" > ThreadId 331 > "hola" > Prelude> > Prelude> let forkM p=Control.Concurrent.forkIO $ p `seq` return () > Prelude> forkM $ print "hola" > ThreadId 493 > Prelude> > > Any idea?. Thanks in advance > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From daniel.is.fischer at web.de Fri Sep 4 18:57:56 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Sep 4 18:38:13 2009 Subject: [Haskell-cafe] forkM fails In-Reply-To: References: Message-ID: <200909050057.56559.daniel.is.fischer@web.de> Am Samstag 05 September 2009 00:06:50 schrieb Alberto G. Corona: > Hi > > I need to execute a procedure not in the IO monad, but in an any monad: > > I defined: > > forkM :: Monad m=> m a -> IO ThreadId > forkM proc=forkIO $ proc `seq` return() > > I assumed that seq will force the evaluation of proc and after, it > will discard his type (m a) and return () in the IO monad.as forkIO > expect. > > however proc is not executed > > Prelude> Control.Concurrent.forkIO $ print "hola" > ThreadId 331 > "hola" > Prelude> > Prelude> let forkM p=Control.Concurrent.forkIO $ p `seq` return () > Prelude> forkM $ print "hola" > ThreadId 493 > Prelude> > > Any idea?. Thanks in advance seq forces proc to weak head normal form, that could be e.g. a lambda. You would have to force the value returned by proc, like class (Monad m) => RunnableMonad m where runM :: m a -> a forkM :: (RunnableMonad m) => m a -> IO () forkM proc = let a = runM proc in forkIO $ a `seq` return () (untested, might also not work) From allbery at ece.cmu.edu Fri Sep 4 20:57:25 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Fri Sep 4 20:36:55 2009 Subject: [Haskell-cafe] Native windowing for glut applications on OS X. In-Reply-To: References: Message-ID: <6BD93A0B-7DEF-4C91-948F-34C645C89DD1@ece.cmu.edu> On Sep 4, 2009, at 03:13 , Lyndon Maydwell wrote: > I recently updated glut through cabal to version GLUT-2.2.1.0, and > where once I had native windowing, now I can only seem to use X11. > > Does anyone know how to use native windowing? Do you use Fink or MacPorts? Check for OpenGL libraries installed via those; they're probably shadowing the native libraries. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090904/84f5759e/PGP.bin From z_axis at 163.com Fri Sep 4 21:08:25 2009 From: z_axis at 163.com (zaxis) Date: Fri Sep 4 20:47:40 2009 Subject: [Haskell-cafe] How to preload the module of my own Message-ID: <25304154.post@talk.nabble.com> I want to preload the module automatically when starting ghci. The module located in ~/work directory contains some functions i use everyday. Now i use an alias: alias ghci='ghci -i ~/money/Money.hs' which works fine. However i feel there maybe are more elegant way. thanks! -- View this message in context: http://www.nabble.com/How-to-preload-the-module-of-my-own-tp25304154p25304154.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From alexander.dunlap at gmail.com Fri Sep 4 21:14:50 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Fri Sep 4 20:54:23 2009 Subject: [Haskell-cafe] How to preload the module of my own In-Reply-To: <25304154.post@talk.nabble.com> References: <25304154.post@talk.nabble.com> Message-ID: <57526e770909041814q660c99b3h3859bddde6d0497d@mail.gmail.com> On Fri, Sep 4, 2009 at 6:08 PM, zaxis wrote: > > I want to preload the module automatically when starting ghci. The module > located in ~/work directory contains some functions i use everyday. > > Now i use an alias: alias ghci='ghci -i ~/money/Money.hs' which works fine. > However i feel there maybe are more elegant way. > > thanks! > If the module is part of a package you can put 'import NameOfModule' in your ~/.ghc/.ghci file. That file contains commands that are run when ghci starts. I'm not sure if you can load a module that isn't installed. Alex From mf-hcafe-15c311f0c at etc-network.de Fri Sep 4 22:21:21 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Fri Sep 4 22:00:45 2009 Subject: [Haskell-cafe] How to preload the module of my own In-Reply-To: <57526e770909041814q660c99b3h3859bddde6d0497d@mail.gmail.com> References: <25304154.post@talk.nabble.com> <57526e770909041814q660c99b3h3859bddde6d0497d@mail.gmail.com> Message-ID: <20090905022121.GA3384@yoyo> echo ':load ~/money/Money.hs' >> ~/.ghci works for me. this adds a line to the startup script that loads a file that is not in any package. if this module loads other modules, you may need to play with ':cd' in addition to ':load'. hope this helps, matthias On Fri, Sep 04, 2009 at 06:14:50PM -0700, Alexander Dunlap wrote: > To: zaxis , Haskell Cafe > Cc: > From: Alexander Dunlap > Date: Fri, 4 Sep 2009 18:14:50 -0700 > Subject: Re: [Haskell-cafe] How to preload the module of my own > > On Fri, Sep 4, 2009 at 6:08 PM, zaxis wrote: > > > > I want to preload the module automatically when starting ghci. The module > > located in ~/work directory contains some functions i use everyday. > > > > Now i use an alias: alias ghci='ghci -i ~/money/Money.hs' which works fine. > > However i feel there maybe are more elegant way. > > > > thanks! > > > > If the module is part of a package you can put 'import NameOfModule' > in your ~/.ghc/.ghci file. That file contains commands that are run > when ghci starts. I'm not sure if you can load a module that isn't > installed. > > Alex > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** > CLASSIFY succeeds; success probability: 1.0000 pR: 11.8869 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 11.8869 > Total features in input file: 2936 > #0 (nonspam.css): features: 758386, hits: 2835097, prob: 1.00e+00, pR: 11.89 > #1 (spam.css): features: 1686574, hits: 2959087, prob: 1.30e-12, pR: -11.89 > From z_axis at 163.com Fri Sep 4 22:56:46 2009 From: z_axis at 163.com (zaxis) Date: Fri Sep 4 22:35:59 2009 Subject: [Haskell-cafe] How to preload the module of my own In-Reply-To: <20090905022121.GA3384@yoyo> References: <25304154.post@talk.nabble.com> <57526e770909041814q660c99b3h3859bddde6d0497d@mail.gmail.com> <20090905022121.GA3384@yoyo> Message-ID: <25304648.post@talk.nabble.com> My module is not in any package. Your solution is VERY elegant. thanks! mf-hcafe-15c311f0c wrote: > > > echo ':load ~/money/Money.hs' >> ~/.ghci > > works for me. this adds a line to the startup script that loads a > file that is not in any package. if this module loads other modules, > you may need to play with ':cd' in addition to ':load'. > > hope this helps, > matthias > > > On Fri, Sep 04, 2009 at 06:14:50PM -0700, Alexander Dunlap wrote: >> To: zaxis , Haskell Cafe >> Cc: >> From: Alexander Dunlap >> Date: Fri, 4 Sep 2009 18:14:50 -0700 >> Subject: Re: [Haskell-cafe] How to preload the module of my own >> >> On Fri, Sep 4, 2009 at 6:08 PM, zaxis wrote: >> > >> > I want to preload the module automatically when starting ghci. The >> module >> > located in ~/work directory contains some functions i use everyday. >> > >> > Now i use an alias: alias ghci='ghci -i ~/money/Money.hs' which works >> fine. >> > However i feel there maybe are more elegant way. >> > >> > thanks! >> > >> >> If the module is part of a package you can put 'import NameOfModule' >> in your ~/.ghc/.ghci file. That file contains commands that are run >> when ghci starts. I'm not sure if you can load a module that isn't >> installed. >> >> Alex >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> >> ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** >> CLASSIFY succeeds; success probability: 1.0000 pR: 11.8869 >> Best match to file #0 (nonspam.css) prob: 1.0000 pR: 11.8869 >> Total features in input file: 2936 >> #0 (nonspam.css): features: 758386, hits: 2835097, prob: 1.00e+00, pR: >> 11.89 >> #1 (spam.css): features: 1686574, hits: 2959087, prob: 1.30e-12, pR: >> -11.89 >> > _______________________________________________ > 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/How-to-preload-the-module-of-my-own-tp25304154p25304648.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From colin at colina.demon.co.uk Sat Sep 5 03:01:59 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sat Sep 5 02:41:12 2009 Subject: [Haskell-cafe] haskelldb + sqlite problem. In-Reply-To: (Colin Paul Adams's message of "Fri\, 04 Sep 2009 16\:53\:26 +0100") References: <3bd412d40906212215y36cbe76o6fa89db8f4ae7204@mail.gmail.com> Message-ID: >>>>> "Colin" == Colin Paul Adams writes: >>>>> "Magicloud" == Magicloud Magiclouds writes: Magicloud> Hi, I am using haskelldb and Magicloud> haskelldb-hdbc-sqlite3. Well, I finally got the source Magicloud> compiled and ran, I got this error: App: user error Magicloud> (SQL error: SqlError {seState = "", seNativeError = 21, Magicloud> seErrorMsg = "prepare 74: SELECT subject,\n Magicloud> timestamp\nFROM notes as T1\nORDER BY timestamp DESC: Magicloud> library routine called out of sequence"}) Any clue what Magicloud> I should check? Colin> Did you get this working? If so, what was the problem and Colin> how did you go about resolving it. Colin> I have the identical problem. I had the database code Colin> working fine, but then I added a state monad into the monad Colin> stack for the program, and now I get this problem. I see Colin> that John Goerzen suggested it might be a result of reading Colin> the data lazily. So I tried changing my import statements Colin> from import Control.Monad.State to import Colin> Control.Monad.State.Strict Colin> in case the StateT was indirectly causing the problem, but Colin> that doesn't make any difference. As I suspected, the problem is something to do with my putting the Database.HaskellDB.Database.Database into the state monad, and getting it from there, rather than passing it around explicitly. So I guess I have too much laziness in: ApplicationState db _ <- lift get How do I force db in this situation? -- Colin Adams Preston Lancashire From g.c.stavenga at uu.nl Sat Sep 5 05:52:50 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Sat Sep 5 05:32:02 2009 Subject: [Haskell-cafe] memoization Message-ID: <25306687.post@talk.nabble.com> Hi, I participating in de google code jam this year and I want to try to use haskell. The following simple http://code.google.com/codejam/contest/dashboard?c=90101#s=p2 problem would have the beautiful haskell solution. import Data.MemoTrie import Data.Char import Data.Word import Text.Printf newtype ModP = ModP Integer deriving Eq p=10000 instance Show ModP where show (ModP x) = printf "%04d" x instance Num ModP where ModP x + ModP y = ModP ((x + y) `mod` p) fromInteger x = ModP (x `mod` p) ModP x * ModP y = ModP ((x * y) `mod` p) abs = undefined signum = undefined solve _ [] = 1::ModP solve [] _ = 0::ModP solve (hs:ts) t@(ht:tt) | hs==ht = solve ts tt + solve ts t | otherwise = solve ts t go (run, line) = "Case #"++show run++": "++show (solve line "welcome to code jam") main = interact $ unlines . map go . zip [1..] . tail . lines Which is unfortunately exponential. Now in earlier thread I argued for a compiler directive in the lines of {-# Memoize function -#}, but this is not possible (it seems to be trivial to implement though). Now I used memotrie which runs hopelessly out of memory. I looked at some other haskell solutions, which were all ugly and more clumsy compared to simple and concise C code. So it seems to me that haskell is very nice and beautiful until your are solving real algorithmic problems when you want to go back to some imperative language. How would experienced haskellers solve this problem? Thanks -- View this message in context: http://www.nabble.com/memoization-tp25306687p25306687.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From gracjanpolak at gmail.com Sat Sep 5 07:18:24 2009 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Sat Sep 5 06:58:01 2009 Subject: [Haskell-cafe] Don't =?utf-8?b?4oCcYWNjaWRlbnRhbGx5cGFyYWxsZWxpemXigJ0=?= Message-ID: Hi all, In "DEFUN 2009: Multicore Programming in Haskell Now!" (http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/), slide 30 I see: Don't ?accidentally parallelize?: ? f `par` f + e and that the correct way of achieving parallelism is: ? f `par` e `pseq` f + e Actually I don't understand the difference between these two forms. Could any brave soul explain it to me, please? As a bonus question: what is the difference between `seq` and `pseq`? -- Gracjan From jwlato at gmail.com Sat Sep 5 07:24:16 2009 From: jwlato at gmail.com (John Lato) Date: Sat Sep 5 07:03:28 2009 Subject: [Haskell-cafe] Re: Problem on existential type. Message-ID: <9979e72e0909050424x1210a4encf83145ea2162a7b@mail.gmail.com> Also, the two definitions for liftGW are exactly equivalent. You have: liftGW (GridWidget label) f = f label liftGW (GridWidget textView) f = f textView The only difference between the two is name to which the data parameter to GridWidget is bound, which doesn't change the meaning at all. You should properly have liftGW (GridWidget widget) f = f widget There's no way to determine if that widget is a label or textView, which is the whole point of existential types. Cheers, John > From: Miguel Mitrofanov > Subject: Re: [Haskell-cafe] Problem on existential type. > To: Magicloud Magiclouds > > Your data type GridWidget doesn't have a parameter, yet you use it > like it has one. > >> data GridWidget = forall widget. (WidgetClass widget) => GridWidget >> widget > ? ? ? ? ? ? ? ? ^ > ? ? ? ? ? ? ? ? | > NB:-------------+ > >> liftGW :: (GridWidget widget) -> (widget -> t) -> t > From byorgey at seas.upenn.edu Sat Sep 5 08:39:18 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Sep 5 08:18:30 2009 Subject: [Haskell-cafe] Don't =?utf-8?B?4oCc?= =?utf-8?Q?accidentallyparallelize=E2=80=9D?= In-Reply-To: References: Message-ID: <20090905123918.GB13688@seas.upenn.edu> On Sat, Sep 05, 2009 at 11:18:24AM +0000, Gracjan Polak wrote: > > Hi all, > > In "DEFUN 2009: Multicore Programming in Haskell Now!" > (http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/), > slide 30 I see: > > Don't ?accidentally parallelize?: > ? f `par` f + e This creates a spark (potential speculative execution) to evaluate 'f', but whether this actually gets instantiated in another thread depends on the order in which the main thread evaluates (f + e): if we get lucky and it decides to work on evaluating 'e' first, then another thread may get a chance to evaluate 'f' in parallel. But if the main thread decides to work on 'f' first then the spark to evaluate 'f' will never get run and we end up with a sequential computation. > > and that the correct way of achieving parallelism is: > ? f `par` e `pseq` f + e This means: create a spark to evaluate 'f', then evaluate 'e', and then finally evaluate f + e. This ensures that the main thread will work on 'e' first so that the spark for 'f' has a chance to run in parallel. > > As a bonus question: what is the difference between `seq` and `pseq`? x `pseq` y guarantees to evaluate x before y. There is no such guarantee with x `seq` y; the only guarantee with `seq` is that x `seq` y will be _|_ if x is. -Brent From gue.schmidt at web.de Sat Sep 5 08:42:14 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sat Sep 5 08:21:51 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates Message-ID: Hi all, I'm reading in a data of 216k records into a map of Key, Values Pairs, the values being strings. As it happens out of 216k String values there really are only about 6.6k distinct string values, so I could save a lot of RAM if I was able to "insert" only actually *new* string values into the map and use references to (string) values that already are in memory instead. Is there a container that would, if I wanted to insert an element, return a pair of either the previously inserted, equal value and the container unchanged, or the new, previously unknown value and the new container amended by that element? G?nther From sjoerd at w3future.com Sat Sep 5 09:07:02 2009 From: sjoerd at w3future.com (Sjoerd Visscher) Date: Sat Sep 5 08:46:18 2009 Subject: =?windows-1252?Q?Re:_[Haskell-cafe]_Don't_=93accidentallyparalle?= =?windows-1252?Q?lize=94?= In-Reply-To: <20090905123918.GB13688@seas.upenn.edu> References: <20090905123918.GB13688@seas.upenn.edu> Message-ID: This could be a way to parallelize code (which would prevent such mistakes): newtype Par a = Par { doPar :: a } instance Functor Par where fmap = liftA instance Applicative Par where pure = Par Par f <*> Par x = Par $ f `par` x `pseq` f x then instead of: fun `par` arg1 `par` arg2 `pseq` fun arg1 arg2 you can write: doPar $ fun <$> pure arg1 <*> pure arg2 Sjoerd On Sep 5, 2009, at 2:39 PM, Brent Yorgey wrote: > On Sat, Sep 05, 2009 at 11:18:24AM +0000, Gracjan Polak wrote: >> >> Hi all, >> >> In "DEFUN 2009: Multicore Programming in Haskell Now!" >> (http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/ >> ), >> slide 30 I see: >> >> Don't ?accidentally parallelize?: >> ? f `par` f + e > > This creates a spark (potential speculative execution) to evaluate > 'f', but whether this actually gets instantiated in another thread > depends on the order in which the main thread evaluates (f + e): if we > get lucky and it decides to work on evaluating 'e' first, then another > thread may get a chance to evaluate 'f' in parallel. But if the main > thread decides to work on 'f' first then the spark to evaluate 'f' > will never get run and we end up with a sequential computation. > >> >> and that the correct way of achieving parallelism is: >> ? f `par` e `pseq` f + e > > This means: create a spark to evaluate 'f', then evaluate 'e', and > then finally evaluate f + e. This ensures that the main thread will > work on 'e' first so that the spark for 'f' has a chance to run in > parallel. > >> >> As a bonus question: what is the difference between `seq` and `pseq`? > > x `pseq` y guarantees to evaluate x before y. There is no such > guarantee with x `seq` y; the only guarantee with `seq` is that x > `seq` y will be _|_ if x is. > > -Brent > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Sjoerd Visscher sjoerd@w3future.com From gracjanpolak at gmail.com Sat Sep 5 09:13:50 2009 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Sat Sep 5 08:53:31 2009 Subject: [Haskell-cafe] Re: Don't =?utf-8?b?4oCcYWNjaWRlbnRhbGx5cGFyYWxsZWxpemXigJ0=?= References: <20090905123918.GB13688@seas.upenn.edu> Message-ID: Thanks for great response! Brent Yorgey seas.upenn.edu> writes: > > x `pseq` y guarantees to evaluate x before y. There is no such > guarantee with x `seq` y; the only guarantee with `seq` is that x > `seq` y will be _|_ if x is. > I found an old thread here http://www.mail-archive.com/glasgow-haskell-users@haskell.org/msg11022.html where Simon states [quote] Indeed, if GHC was in the habit of causing the second argument of seq to be evaluated before the first, then a lot of people would probably be surprised. eg. imagine what happens to foldl': foldl' f a [] = a foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs It wouldn't do what you want at all. [/quote] So... seems foldl' relies on `seq` having unstated evaluation order in GHC. So, what guarantees does foldl' have in turn? Semantics only or operational? Shouldn't it be written using `pseq`? Seems I have always used (this `seq` that) when I meant (this `before` that). Is it time to revisit my code and use `pseq` more? What does Haskell' say about this? -- Gracjan From ekirpichov at gmail.com Sat Sep 5 09:36:58 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Sep 5 09:16:10 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: References: Message-ID: <5e0214850909050636l4dba0b25p3c4da23857c40e1@mail.gmail.com> Should be easy to implement one. Something like this: class (Monad m) => MonadIntern e m | e -> m where intern :: e -> m e instance (Ord e) => MonadIntern e (State (M.Map e e)) where intern = modify . insertWith (\old new -> old)) 2009/9/5 G?nther Schmidt : > Hi all, > > I'm reading in a data of 216k records into a map of Key, Values Pairs, the > values being strings. > > As it happens out of 216k String values there really are only about 6.6k > distinct string values, so I could save a lot of RAM if I was able to > "insert" only actually *new* string values into the map and use references > to (string) values that already are in memory instead. > > Is there a container that would, if I wanted to insert an element, return a > pair of either the previously inserted, equal value and the container > unchanged, or the new, previously unknown value and the new container > amended by that element? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From ekirpichov at gmail.com Sat Sep 5 09:38:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Sat Sep 5 09:17:55 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: <5e0214850909050636l4dba0b25p3c4da23857c40e1@mail.gmail.com> References: <5e0214850909050636l4dba0b25p3c4da23857c40e1@mail.gmail.com> Message-ID: <5e0214850909050638s7c24a94fu83583c6fdbf53bdc@mail.gmail.com> 2009/9/5 Eugene Kirpichov : > Should be easy to implement one. Something like this: > > class (Monad m) => MonadIntern e m | e -> m where > ?intern :: e -> m e > > instance (Ord e) => MonadIntern e (State (M.Map e e)) where > ?intern = modify . insertWith (\old new -> old)) I mean, intern e = (modify . insertWith const $ e) >> (fromJust . (`lookup`e)) `fmap` get. However, that probably also won't compile, but I think you get the idea. > > 2009/9/5 G?nther Schmidt : >> Hi all, >> >> I'm reading in a data of 216k records into a map of Key, Values Pairs, the >> values being strings. >> >> As it happens out of 216k String values there really are only about 6.6k >> distinct string values, so I could save a lot of RAM if I was able to >> "insert" only actually *new* string values into the map and use references >> to (string) values that already are in memory instead. >> >> Is there a container that would, if I wanted to insert an element, return a >> pair of either the previously inserted, equal value and the container >> unchanged, or the new, previously unknown value and the new container >> amended by that element? >> >> G?nther >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > -- Eugene Kirpichov Web IR developer, market.yandex.ru From daniel.is.fischer at web.de Sat Sep 5 09:51:45 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Sep 5 09:33:18 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25306687.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> Message-ID: <200909051551.45730.daniel.is.fischer@web.de> Am Samstag 05 September 2009 11:52:50 schrieb staafmeister: > Hi, > > I participating in de google code jam this year and I want to try to use > haskell. The following > simple http://code.google.com/codejam/contest/dashboard?c=90101#s=p2 > problem > would have the beautiful haskell solution. > > import Data.MemoTrie > import Data.Char > import Data.Word > import Text.Printf > > newtype ModP = ModP Integer deriving Eq > > p=10000 > > instance Show ModP where > show (ModP x) = printf "%04d" x > > instance Num ModP where > ModP x + ModP y = ModP ((x + y) `mod` p) > fromInteger x = ModP (x `mod` p) > ModP x * ModP y = ModP ((x * y) `mod` p) > abs = undefined > signum = undefined > > solve _ [] = 1::ModP > solve [] _ = 0::ModP > solve (hs:ts) t@(ht:tt) | hs==ht = solve ts tt + solve ts t > > | otherwise = solve ts t > > go (run, line) = "Case #"++show run++": "++show (solve line "welcome to > code jam") > > main = interact $ unlines . map go . zip [1..] . tail . lines > > > Which is unfortunately exponential. > > Now in earlier thread I argued for a compiler directive in the lines of {-# > Memoize function -#}, > but this is not possible (it seems to be trivial to implement though). Not really. Though a heck of a lot easier than automatic memoisation. > Now I used memotrie which > runs hopelessly out of memory. I looked at some other haskell solutions, > which were all ugly and > more clumsy compared to simple and concise C code. So it seems to me that > haskell is very nice > and beautiful until your are solving real algorithmic problems when you > want to go back to some > imperative language. > > How would experienced haskellers solve this problem? > > Thanks completely unoptimised: ---------------------------------------------------------------------- module Main (main) where import Text.Printf import Data.List out :: Integer -> String out n = printf "%04d" (n `mod` 10000) update :: [(String,Integer)] -> Char -> [(String,Integer)] update ((p@((h:_),n)):tl) c = case update tl c of ((x,m):more) | c == h -> p:(x,m+n):more other -> p:other update xs _ = xs solve pattern = snd . last . foldl' update (zip (tails pattern) (1:repeat 0)) solveLine :: String -> (Integer,String) -> String solveLine pattern (i,str) = "Case# " ++ show i ++ ": " ++ out (solve pattern str) main :: IO () main = interact $ unlines . map (solveLine "welcome to code jam") . zip [1 .. ] . tail . lines ---------------------------------------------------------------------- ./codeJam +RTS -sstderr -RTS < C-large-practice.in Case# 98: 4048 Case# 99: 8125 Case# 100: 0807 15,022,840 bytes allocated in the heap 789,028 bytes copied during GC 130,212 bytes maximum residency (1 sample(s)) 31,972 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 28 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.04s ( 0.03s elapsed) GC time 0.00s ( 0.01s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.04s ( 0.04s elapsed) %GC time 0.0% (13.8% elapsed) Alloc rate 417,277,929 bytes per MUT second Productivity 100.0% of total user, 98.6% of total elapsed From rwbarton at math.harvard.edu Sat Sep 5 13:16:06 2009 From: rwbarton at math.harvard.edu (Reid Barton) Date: Sat Sep 5 12:55:30 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25306687.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> Message-ID: <20090905171605.GB26512@rwbarton.mit.edu> On Sat, Sep 05, 2009 at 02:52:50AM -0700, staafmeister wrote: > How would experienced haskellers solve this problem? You could just memoize using an array, like in C. import Data.Array occurrences :: Num a => String -> String -> a occurrences key buf = grid ! (0, 0) -- grid ! (i, j) = occurrences (drop i key) (drop j buf) where grid = listArray ((0, 0), (nk, nb)) [ if i == nk then 1 else if j == nb then 0 else (if key !! i == buf !! j then grid ! (i+1, j+1) else 0) + grid ! (i, j+1) | i <- [0..nk], j <- [0..nb] ] nk = length key nb = length buf Regards, Reid From lrpalmer at gmail.com Sat Sep 5 13:38:02 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Sep 5 13:17:14 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: References: Message-ID: <7ca3f0160909051038o3e57df4ft1c61112f91ac2066@mail.gmail.com> 2009/9/5 G?nther Schmidt : > Hi all, > > I'm reading in a data of 216k records into a map of Key, Values Pairs, the > values being strings. > > As it happens out of 216k String values there really are only about 6.6k > distinct string values, so I could save a lot of RAM if I was able to > "insert" only actually *new* string values into the map and use references > to (string) values that already are in memory instead. > > Is there a container that would, if I wanted to insert an element, return a > pair of either the previously inserted, equal value and the container > unchanged, or the new, previously unknown value and the new container > amended by that element? I believe a memoization of the identity function will do what you want: import qualified Data.MemoCombinators as Memo share = Memo.list Memo.char id Then pass any string through share to make/get a cached version. You might want to limit the scope of share -- eg. put it in a where clause for the function where you're using it -- so that it doesn't eat memory for the lifetime of your program, only for when you need it. Luke From uzytkownik2 at gmail.com Fri Sep 4 17:17:53 2009 From: uzytkownik2 at gmail.com (Maciej Piechotka) Date: Sat Sep 5 13:41:20 2009 Subject: [Haskell-cafe] [Long] 'Fun' with types In-Reply-To: <1afdeaec0909032313x17b76439sa1611eb4b5b2dde5@mail.gmail.com> References: <1252017247.2330.4.camel@kirk> <49a77b7a0909032039v40e51a05w674c5f943600a00e@mail.gmail.com> <1afdeaec0909032313x17b76439sa1611eb4b5b2dde5@mail.gmail.com> Message-ID: <1252099073.7282.40.camel@kirk> On Fri, 2009-09-04 at 07:13 +0100, Colin Adams wrote: > 2009/9/4 David Menendez : > > On Thu, Sep 3, 2009 at 6:34 PM, Maciej Piechotka wrote: > > >> (df <<< dg, > > > > Should that be "df *** dg"? > Yes > Is swearing allowed on this mailing list? > :-) Well - errare humanum est... Regards -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090905/ecdf55ea/attachment.bin From ryani.spam at gmail.com Sat Sep 5 14:53:14 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Sat Sep 5 14:32:33 2009 Subject: [Haskell-cafe] Problem on existential type. In-Reply-To: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> References: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> Message-ID: <2f9b2d30909051153h30714274pc8579134ff42b6@mail.gmail.com> On Thu, Sep 3, 2009 at 11:05 PM, Magicloud Magiclouds wrote: > data GridWidget = forall widget. (WidgetClass widget) => GridWidget widget > > liftGW :: (GridWidget widget) -> (widget -> t) -> t > liftGW (GridWidget label) f = f label > liftGW (GridWidget textView) f = f textView The type signature on liftGW is wrong. Also, as mentioned elsewhere, the two matches overlap; the second case never gets called. The correct type signature for "liftGW" is: liftGW :: GridWidget -> (forall widget. WidgetClass widget => widget -> t) -> t Note that the "f" passed in has to accept *any* widget type, so it's possible that existential types aren't what you want. -- ryan From byorgey at seas.upenn.edu Sat Sep 5 16:56:10 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Sep 5 16:35:20 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 129 - September 5, 2009 Message-ID: <20090905205610.GB4041@seas.upenn.edu> --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090905 Issue 129 - September 05, 2009 --------------------------------------------------------------------------- Welcome to issue 129 of HWN, a newsletter covering developments in the [1]Haskell community. The [2]Haskell Symposium was a great success, with many [3]interesting talks and a good discussion on the future of Haskell. Watch this space for links to video from the Symposium as it becomes available! Announcements HStringTemplate 0.6.2. Sterling Clover [4]announced some new features in the [5]HStringTemplate library, including simple quasiquotation; proper Unicode support; creation of groups from hierarchies of directories; separators applied within iterated template application; depthwise chained iterated template application; generalized encoding functions; and more. fclabels-0.4.0 - First class accessor labels. Sebastiaan Visser [6]announced a new release of the [7]fclabels package, straight from ICFP in Edinburgh. The package provides first-class labels which act as fully composable, bidirectional record fields, as well as support for automatically generating them from record types. vty-4.0.0.1 released. Corey O'Connor [8]announced release 4.0.0.1 of [9]vty, a terminal UI library. This release brings a number of important fixes, features, and performance enhancements, including a completely rewritten output backend; efficient, "scanline rasterization" style output span generator; terminfo based display terminal implementation; improved Unicode support; 256 color support; and more. haskell-src-exts-1.1.4. Niklas Broberg [10]announced the release of [11]haskell-src-exts-1.1.4, a package for Haskell source code manipulation. The experimental code in Language.Haskell.Annotated{.*} has changed quite a lot, although the stable portion of the package interface has not changed. Significantly, the package now includes an exact-printer which allows round-tripping between parsing and pretty-printing to be the identity. Next BostonHaskell meeting: September 16th at MIT (32G-882). Ravi Nanavati [12]announced the September meeting of the Boston Area Haskell Users' Group, to be held Wednesday, September 16th from 7pm - 9pm. As usual, it will be held in the MIT CSAIL Reading Room (32-G882, on the 8th floor of the Gates Tower of the MIT's Stata Center at 32 Vassar St in Cambridge, MA). The featured speaker will be Edward Kmett, who will be presenting the second part of his monoids and parsing presentation: "A Parallel Parsing Trifecta: Iteratees, Parsec, and Monoids". lenses -- Simple Functional Lenses. Job Vranish [13]announced the release of [14]lenses, a simple but powerful implementation of function lenses (aka functional references/accessors). This library provides a convenient way to access and update the elements of a structure. It is very similar to Data.Accessors, but simpler, a bit more generic and has fewer dependencies. Dutch HUG: meeting next week (September 11th) in Utrecht. Tom Lokhorst [15]invited functional programmers in The Netherlands to the [16]Dutch Haskell User Group, meeting Friday, September 11 at 19:00 in the [17]Booth Hall of the Utrecht University Library. Thomas (noknok) will be talking about his system for doing propositional logic in Haskell. Pedro will give an introductory talk about generic programming, and Sean will talk about xformat, a library for extensible and type-safe formatting with scanf- and printf-like functions. There is also still space for short 5-minute lighting talk about something related to Haskell or functional programming; contact Tom if you're interested. moe html combinator. Jinjing Wang [18]announced the release of [19]moe, a DSL for generating HTML. jail-0.0.1 - Jailed IO monad. Sebastiaan Visser [20]announced the first release of the [21]jail package, a jailed IO monad that can restrict filesystem access for your code. scion 0.1. Thomas Schilling [22]announced the first release of [23]Scion, a Haskell library that aims to implement those parts of a Haskell IDE which are independent of a particular front-end. Scion is based on the GHC API and Cabal. It provides both a Haskell API and a server for non-Haskell clients such as Emacs and Vim. Blog noise [24]Haskell news from the [25]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Don Stewart (dons): [26]DEFUN 2009: Multicore Programming in Haskell Now!. * Bryan O'Sullivan: [27]Slides from my CUFP 2009 keynote talk. * LHC Team: [28]Yet another unfair benchmark.. * Alex McLean: [29]Hackpact documentation. * >>> Jeff Foster: [30]Exploring Haskell's List Functions. * Don Stewart (dons): [31]Parallel Programming in Haskell: A Reading List. * David Amos: [32]Finite fields, part 2. * >>> Jeff Foster: [33]Debugging in Haskell. * apfelmus: [34]Fun with Morse Code. * Ketil Malde: [35]Parsing ints. * Alex McLean: [36]Hackpact. * Greg Bacon: [37]Finding duplicates with Perl and Haskell. * Colin Adams: [38]Selecting software for a replacement for this website. * Don Stewart (dons): [39]Haskell Popularity Rankings: September 2009. * Mikael Vejdemo-Johansson: [40][Stanford] MATH 198: Category Theory and Functional Programming. * Jeff Heard: [41]HDR imaging library for Haskell based on pfsutils. * David Amos: [42]Extension fields. * Magnus Therning: [43]Trying to work out iteratees. Quotes of the Week * benmachine: ho hum. I understand both your positions. but i don't understand mine, now :( * ksf: agda is actually a secret mindwar-weapon of the illuminati, who want to wrack your nerves with excessively big symbol sets requiring a keyboard with 10 modifier keys. just like APL. * Axman6: does anyone else think that C++ looks like a dead fish? (C++<) * Cale: The difference between Many Worlds and Copenhagen is a garbage collector ;) * apfelmus: Lambda Fu, form 72 - three way dragon zip: 'averages3 xs = zipWith3 avg xs (drop 1 xs) (drop 2 xs); where avg a b c = (a+b+c) / 3' About the Haskell Weekly News New editions are posted to [44]the Haskell mailing list as well as to [45]the Haskell Sequence and [46]Planet Haskell. [47]RSS is also available, and headlines appear on [48]haskell.org. To help create new editions of this newsletter, please see the information on [49]how to contribute. Send stories to byorgey at cis dot upenn dot edu. The darcs repository is available at darcs get [50]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://www.haskell.org/haskell-symposium/2009/ 3. http://www.haskell.org/haskell-symposium/2009/schedule.html 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63108 5. http://hackage.haskell.org/package/HStringTemplate 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63082 7. http://hackage.haskell.org/package/fclabels 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63072 9. http://hackage.haskell.org/package/vty 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63068 11. http://hackage.haskell.org/package/haskell-src-exts 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63067 13. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63059 14. http://hackage.haskell.org/package/lenses 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63000 16. http://www.haskell.org/haskellwiki/Dutch_HUG 17. http://www.uu.nl/EN/library/contact/university_library/zaalverhuur/Pages/default.aspx#booth 18. http://article.gmane.org/gmane.comp.lang.haskell.cafe/62865 19. http://hackage.haskell.org/package/moe 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/62839 21. http://hackage.haskell.org/package/jail 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/62820 23. http://hackage.haskell.org/package/scion 24. http://planet.haskell.org/ 25. http://haskell.org/haskellwiki/Blog_articles 26. http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/ 27. http://www.serpentine.com/blog/2009/09/04/slides-from-my-cufp-2009-keynote-talk/ 28. http://lhc-compiler.blogspot.com/2009/09/yet-another-unfair-benchmark.html 29. http://yaxu.org/hackpact-documentation/ 30. http://www.fatvat.co.uk/2009/09/exploring-haskells-list-functions.html 31. http://donsbot.wordpress.com/2009/09/03/parallel-programming-in-haskell-a-reading-list/ 32. http://haskellformaths.blogspot.com/2009/09/finite-fields-part-2.html 33. http://www.fatvat.co.uk/2009/09/debugging-in-haskell.html 34. http://apfelmus.nfshost.com/fun-with-morse-code.html 35. http://blog.malde.org/index.php/2009/08/31/parsing-ints/ 36. http://yaxu.org/hackpact/ 37. http://feedproxy.google.com/~r/gbacon/~3/aaZePz6Gv2Q/finding-duplicates-with-perl-and.html 38. http://colina.demon.co.uk/?q=node/753 39. http://donsbot.wordpress.com/2009/08/29/haskell-popularity-rankings-september-2009/ 40. http://blog.mikael.johanssons.org/archive/2009/08/stanford-math-198-category-theory-and-functional-programming/ 41. http://vis.renci.org/jeff/2009/08/28/hdr-imaging-library-for-haskell-based-on-pfsutils/ 42. http://haskellformaths.blogspot.com/2009/08/extension-fields.html 43. http://therning.org/magnus/archives/735 44. http://www.haskell.org/mailman/listinfo/haskell 45. http://sequence.complete.org/ 46. http://planet.haskell.org/ 47. http://sequence.complete.org/node/feed 48. http://haskell.org/ 49. http://haskell.org/haskellwiki/HWN 50. http://code.haskell.org/~byorgey/code/hwn/ From byorgey at seas.upenn.edu Sat Sep 5 17:26:08 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Sep 5 17:05:18 2009 Subject: [Haskell-cafe] Looking for a new HWN editor Message-ID: <20090905212608.GA379@seas.upenn.edu> Executive summary: * I'm looking for someone to take over as HWN editor * It is highly automated and doesn't take as much time as you might think (about 3-4 hours/week on average) * You DON'T need to be a Haskell guru * It is far from a thankless job and is a fun way to provide an appreciated service to the community! Read on for more details! ------------------------------------------------------------------------- Hi all, As you probably know, I've been the editor of the Haskell Weekly News for a little over a year now, and I've decided that it's time for me to move on to other things. So, I'm looking for someone to volunteer to take over as HWN editor. Why might you want to do this? It's true that there is no concrete reward. But judging from the number of comments I have received from people over the past year, the HWN provides a valuable and appreciated service to the Haskell community: there are many who simply don't have time to read the mailing lists, but like to know about new libraries, compiler releases, interesting discussions, and other major goings-on in the community. What does the editorship entail? Thanks to some automated tools developed specifically for the job, it doesn't take as much time as you might think: usually about 4 hours per week; most of that is spent simply reading/skimming various Haskell mailing lists to pick out items for the HWN. The process generally goes like this: * pick out funny quotes from the IRC channel using an automated tool * pick out Haskell-related blog posts using an automated tool * pick out announcements and discussions from the mailing list with an automated tool, writing a short blurb for each (usually this just involves cutting and pasting from the announcement itself, with a bit of editing to make it flow * compile text and HTML versions with an automated tool * post to sequence.complete.org and the mailing list. There are much more detailed instructions written up, and of course I'll be happy to provide detailed help and support for the first few weeks of the new editor's tenure. I should emphasize that the HWN editor does NOT need to be a Haskell guru. In fact, this could be an ideal job for someone who is relatively new to Haskell and the community, but would like to contribute in a tangible way. I also want to emphasize that with the change in editorship, the HWN need not remain exactly the same: if you have exciting ideas about changes to make to the format or content, be my guest! The HWN will be whatever you make of it. So, let me know if you are interested! There won't be any formal interview process; the first person to contact me who wants to do it, gets the job. But of course, if you are not sure and want more information, feel free to email me with questions. -Brent From john at pybus.org Sat Sep 5 17:30:58 2009 From: john at pybus.org (John Pybus) Date: Sat Sep 5 17:14:15 2009 Subject: [Haskell-cafe] Re: ANN: vty-4.0.0.1 released References: Message-ID: Corey O'Connor gmail.com> writes: > > Vty is a terminal UI library. Release 4.0.0.1 brings a number of > important fixes, > features, and performance enhancements. > - added a "utf8_string" and "string" (AKA "iso_10464_string") for UTF-8 > encoded Strings and ISO-10464 encoded Strings. String literals in GHC > have an ISO-10464 runtime representation. Err, I haven't paid my 86 Francs to find out, but ISO-10464 appears to specify testing regimes for gas cylinders -- a very worthy thing to do, but seemingly unrelated to terminal output. http://www.iso.org/iso/catalogue_detail.htm?csnumber=34234 I suspect you mean ISO-10646, if so you might want to correct its appearance in the API. John PS: Typos aside, I'm excited to see the progress in vty. Thanks. From mauricio.antunes at gmail.com Sat Sep 5 18:51:59 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Sat Sep 5 18:31:34 2009 Subject: [Haskell-cafe] ForeignFunPtr Message-ID: Hi, We have ForeignPtr. Why isn't there a corresponding ForeignFunPtr? Thanks, Maur?cio From byorgey at seas.upenn.edu Sat Sep 5 19:34:24 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Sat Sep 5 19:13:35 2009 Subject: [Haskell-cafe] Re: [Haskell] Looking for a new HWN editor In-Reply-To: <20090905212608.GA379@seas.upenn.edu> References: <20090905212608.GA379@seas.upenn.edu> Message-ID: <20090905233424.GA29650@seas.upenn.edu> On Sat, Sep 05, 2009 at 05:26:08PM -0400, Brent Yorgey wrote: > Executive summary: > > * I'm looking for someone to take over as HWN editor > * It is highly automated and doesn't take as much time as you might > think (about 3-4 hours/week on average) > * You DON'T need to be a Haskell guru > * It is far from a thankless job and is a fun way to provide an > appreciated service to the community! The position has been filled! More details to come. -Brent From gue.schmidt at web.de Sat Sep 5 19:35:08 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sat Sep 5 19:14:20 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: <7ca3f0160909051038o3e57df4ft1c61112f91ac2066@mail.gmail.com> References: <7ca3f0160909051038o3e57df4ft1c61112f91ac2066@mail.gmail.com> Message-ID: Hi Luke, thanks, this is some very good advice as I find many duplicates in the data I have to iterate over. However so far I'm unable to tell wether this actually works or not, I tried it a couple of times under different settings but it showed to difference in memory consumption. The same mem peeks as before. Do you have some code that where you could see a before and after? G?nther Am 05.09.2009, 19:38 Uhr, schrieb Luke Palmer : > 2009/9/5 G?nther Schmidt : >> Hi all, >> >> I'm reading in a data of 216k records into a map of Key, Values Pairs, >> the >> values being strings. >> >> As it happens out of 216k String values there really are only about 6.6k >> distinct string values, so I could save a lot of RAM if I was able to >> "insert" only actually *new* string values into the map and use >> references >> to (string) values that already are in memory instead. >> >> Is there a container that would, if I wanted to insert an element, >> return a >> pair of either the previously inserted, equal value and the container >> unchanged, or the new, previously unknown value and the new container >> amended by that element? > > I believe a memoization of the identity function will do what you want: > > import qualified Data.MemoCombinators as Memo > > share = Memo.list Memo.char id > > Then pass any string through share to make/get a cached version. > > You might want to limit the scope of share -- eg. put it in a where > clause for the function where you're using it -- so that it doesn't > eat memory for the lifetime of your program, only for when you need > it. > > Luke From felipe.lessa at gmail.com Sat Sep 5 19:57:16 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sat Sep 5 19:36:31 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: References: <7ca3f0160909051038o3e57df4ft1c61112f91ac2066@mail.gmail.com> Message-ID: <20090905235716.GA20700@kira.casa> On Sun, Sep 06, 2009 at 01:35:08AM +0200, G?nther Schmidt wrote: > However so far I'm unable to tell wether this actually works or not, > I tried it a couple of times under different settings but it showed > to difference in memory consumption. The same mem peeks as before. You may want to use 'vacuum', it shows how data is internally represented on GHC, including sharing. -- Felipe. From dan.doel at gmail.com Sat Sep 5 19:57:48 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sat Sep 5 19:37:02 2009 Subject: [Haskell-cafe] Re: Don't =?utf-8?q?=E2=80=9Caccidentallyparallelize=E2=80=9D?= In-Reply-To: References: <20090905123918.GB13688@seas.upenn.edu> Message-ID: <200909051957.48679.dan.doel@gmail.com> On Saturday 05 September 2009 9:13:50 am Gracjan Polak wrote: > [quote] > Indeed, if GHC was in the habit of causing the second argument of seq to be > evaluated before the first, then a lot of people would probably be > surprised. eg. imagine what happens to foldl': > > foldl' f a [] = a > foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs > > It wouldn't do what you want at all. > [/quote] > > So... seems foldl' relies on `seq` having unstated evaluation order in GHC. > So, what guarantees does foldl' have in turn? Semantics only or > operational? Shouldn't it be written using `pseq`? > > Seems I have always used (this `seq` that) when I meant (this `before` > that). Is it time to revisit my code and use `pseq` more? > What does Haskell' say about this? I suppose technically, what foldl' has over foldl is that it is more readily subject to optimization. Each recursive call is artificially made strict in the accumulator, so it is legal for GHC to optimize the function by keeping the accumulator evaluated, instead of delaying it. When GHC is run with optimizations on, it does analysis on all code that tries to determine such things, and seq can be seen as making such analysis easier for the compiler. This is, of course, not what really happens in GHC. What really happens is that the first argument to seq is evaluated before the second (which is why it even has the intended effect when optimizations aren't on). But that doesn't have to be the case, strictly speaking. -- Dan From wren at freegeek.org Sat Sep 5 20:31:28 2009 From: wren at freegeek.org (wren ng thornton) Date: Sat Sep 5 20:10:45 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates In-Reply-To: References: Message-ID: <4AA302E0.5090606@freegeek.org> G?nther Schmidt wrote: > Hi all, > > I'm reading in a data of 216k records into a map of Key, Values Pairs, > the values being strings. > > As it happens out of 216k String values there really are only about 6.6k > distinct string values, so I could save a lot of RAM if I was able to > "insert" only actually *new* string values into the map and use > references to (string) values that already are in memory instead. > > Is there a container that would, if I wanted to insert an element, > return a pair of either the previously inserted, equal value and the > container unchanged, or the new, previously unknown value and the new > container amended by that element? If by "strings" you allow ByteStrings, then you could use the bytestring-trie package[1]. This will be more worthwhile than other approaches if your 6.6k strings have a lot of repeated prefixes, since repeated prefixes will be shared among the unique strings. Something like the following should work: intern :: ByteString -> Trie ByteString -> (ByteString, Trie ByteString) intern s t = (fromJust (lookup s t'), t') where t' = alterBy (\_ _ -> maybe (Just s) Just) s s t [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/bytestring-trie -- Live well, ~wren From coreyoconnor at gmail.com Sat Sep 5 22:17:36 2009 From: coreyoconnor at gmail.com (Corey O'Connor) Date: Sat Sep 5 21:56:45 2009 Subject: [Haskell-cafe] Re: ANN: vty-4.0.0.1 released In-Reply-To: References: Message-ID: On Sat, Sep 5, 2009 at 2:30 PM, John Pybus wrote: > Corey O'Connor gmail.com> writes: > Err, I haven't paid my 86 Francs to find out, but ISO-10464 appears to specify > testing regimes for gas cylinders -- a very worthy thing to do, but seemingly > unrelated to terminal output. > > http://www.iso.org/iso/catalogue_detail.htm?csnumber=34234 > > I suspect you mean ISO-10646, if so you might want to correct its appearance in > the API. lol. You are correct :-) I'll push out an update soon with this and a few other small changes. Cheers, Corey O'Connor From lazycat.manatee at gmail.com Sun Sep 6 01:41:00 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Sun Sep 6 01:47:40 2009 Subject: [Haskell-cafe] How to customize dyre recompile? Message-ID: <87bplo7hqr.fsf@ubuntu.domain> Hi all, I use below params for configure dyre: rebootParams :: Params Config rebootParams = defaultParams {projectName = "Main" ,realMain = manatee ,showError = rebootShowError ,cacheDir = Just $ return "/test/Download/cache/" ,configDir = Just getCurrentDirectory } There have two version of function `reboot` to reboot Master binary: reboot :: IORefObject -> IO () reboot ioRefObject = do rs <- rebootGetState ioRefObject relaunchWithBinaryState rs Nothing reboot :: IORefObject -> IO () reboot ioRefObject = do output <- customCompile rebootParams case output of Just o -> putStrLn o -- output recompile error Nothing -> do -- otherwise relaunch rs <- rebootGetState ioRefObject relaunchWithBinaryState rs Nothing Becuase i setup `projectName` with `Main`, so i want `dyre` recompile NECESSARY module when i change any module in my project. In first version of function `reboot`, i just use `relauncheWithBinaryState`, i found `dyre` just recompile all project when i modified Main.hs, if i modified any others module in project, `dyre` won't recompile those modified modules. In second version, i use `customCompile` for recompile, but this have another problem, `customComiple` use `-fforce-recomp` flags to remove all object files, so function `customComiple` will recompile all modules in project, and not just recompile NECESSARY modules. So how to make `dyre` just recompile NECCESSARY modules whatever i change any modules in project? Maybe add new option "--dyre-reconf-necessary" in `dyre`? Thanks! -- Andy From dave at zednenem.com Sun Sep 6 02:18:31 2009 From: dave at zednenem.com (David Menendez) Date: Sun Sep 6 01:57:40 2009 Subject: =?windows-1252?Q?Re=3A_=5BHaskell=2Dcafe=5D_Re=3A_Don=27t_=93accidentallyparallel?= =?windows-1252?Q?ize=94?= In-Reply-To: <200909051957.48679.dan.doel@gmail.com> References: <20090905123918.GB13688@seas.upenn.edu> <200909051957.48679.dan.doel@gmail.com> Message-ID: <49a77b7a0909052318j7281ccf2oc3eddd0bc8eaa9c6@mail.gmail.com> On Sat, Sep 5, 2009 at 7:57 PM, Dan Doel wrote: > > I suppose technically, what foldl' has over foldl is that it is more readily > subject to optimization. Each recursive call is artificially made strict in > the accumulator, so it is legal for GHC to optimize the function by keeping > the accumulator evaluated, instead of delaying it. When GHC is run with > optimizations on, it does analysis on all code that tries to determine such > things, and seq can be seen as making such analysis easier for the compiler. It turns out, pseq limits the effectiveness of strictness analysis, because it forces the order of evaluation. John Meacham described this pretty well last week in the Haskell' list . > This is, of course, not what really happens in GHC. What really happens is > that the first argument to seq is evaluated before the second (which is why it > even has the intended effect when optimizations aren't on). But that doesn't > have to be the case, strictly speaking. It's entirely possible for optimized code to end up evaluating the second argument to seq before the first. -- Dave Menendez From dan.doel at gmail.com Sun Sep 6 03:08:14 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Sep 6 02:47:28 2009 Subject: [Haskell-cafe] Re: Don't =?utf-8?q?=E2=80=9Caccidentallyparallelize=E2=80=9D?= In-Reply-To: <49a77b7a0909052318j7281ccf2oc3eddd0bc8eaa9c6@mail.gmail.com> References: <200909051957.48679.dan.doel@gmail.com> <49a77b7a0909052318j7281ccf2oc3eddd0bc8eaa9c6@mail.gmail.com> Message-ID: <200909060308.14712.dan.doel@gmail.com> On Sunday 06 September 2009 2:18:31 am David Menendez wrote: > On Sat, Sep 5, 2009 at 7:57 PM, Dan Doel wrote: > > I suppose technically, what foldl' has over foldl is that it is more > > readily subject to optimization. Each recursive call is artificially made > > strict in the accumulator, so it is legal for GHC to optimize the > > function by keeping the accumulator evaluated, instead of delaying it. > > When GHC is run with optimizations on, it does analysis on all code that > > tries to determine such things, and seq can be seen as making such > > analysis easier for the compiler. > > It turns out, pseq limits the effectiveness of strictness analysis, > because it forces the order of evaluation. John Meacham described this > pretty well last week in the Haskell' list > . Interesting. I hadn't thought of this before, but it certainly makes sense. > > This is, of course, not what really happens in GHC. What really happens > > is that the first argument to seq is evaluated before the second (which > > is why it even has the intended effect when optimizations aren't on). But > > that doesn't have to be the case, strictly speaking. > > It's entirely possible for optimized code to end up evaluating the > second argument to seq before the first. Yeah, I suppose I should have been more precise. In the absence of optimizations, I assume seq translates to core something like: seq x y = case x of { z -> y } where the core version of case evaluates things regardless of patterns and such. That explains why foldl' works even if you don't compile it with optimizations. But yes, it wouldn't surprise me if the optimizer rearranged the above, since the case statement is a no-op other than forcing x, and it might see ways to better evaluate things without altering the results. By contrast, pseq would be like the above, but the optimizer would be unable to rewrite it. Perhaps that's still misleading, though. The difference between them is rather like the difference between: xor False False = False xor False True = True xor True False = True xor True True = False (verbose definition meant to emphasize the symmetry of the arguments) and or True _ = True or False b = b xor is strict in both its arguments, whereas or is strict in its first argument, and only strict in its second argument if its first argument is False. Similarly, seq is meant to be strict in both its arguments, whereas pseq needs to be strict in its first argument, and only strict in its second argument if its first argument is non-bottom. -- Dan From lane at downstairspeople.org Sun Sep 6 03:57:15 2009 From: lane at downstairspeople.org (Christopher Lane Hinson) Date: Sun Sep 6 03:36:25 2009 Subject: [Haskell-cafe] Averting QuickCheck Madness Message-ID: There are some libraries that depend on QuickCheck 2, and others that depend on QuickCheck 1. This can be a problem. AIUI, the Haskell Platform current depends on QC1, but intends to move to QC2 soon. I also know that the cabal mailing list has talked about some kind of private-depends capability to mitigate this kind of thing in the future. However, I don't see how it can possibly be a best practice to depend on QuickCheck from a shipping library. End users never use this, and for users of upstream packages who may compile from source and contribute the occasional (but valuable!) patch, this is nothing but a compile-time problem waiting to happen. (Note that a user who contributes to a library should be encouraged to run test suites, but I'm talking about users of upstream packages.) There are some good ideas discussed on this list last year*, but none of them seem to have been blessed by the community. * http://www.haskell.org/pipermail/haskell-cafe/2008-September/047216.html Friendly, --Lane From gracjanpolak at gmail.com Sun Sep 6 04:49:20 2009 From: gracjanpolak at gmail.com (Gracjan Polak) Date: Sun Sep 6 04:28:52 2009 Subject: [Haskell-cafe] Re: Don't =?utf-8?b?CeKAnGFjY2lkZW50YWxseXBhcmFsbGVsaXpl4oCd?= References: <200909051957.48679.dan.doel@gmail.com> <49a77b7a0909052318j7281ccf2oc3eddd0bc8eaa9c6@mail.gmail.com> <200909060308.14712.dan.doel@gmail.com> Message-ID: Dan Doel gmail.com> writes: > On Sunday 06 September 2009 2:18:31 am David Menendez wrote: > > > > It turns out, pseq limits the effectiveness of strictness analysis, > > because it forces the order of evaluation. John Meacham described this > > pretty well last week in the Haskell' list > > . > > Interesting. I hadn't thought of this before, but it certainly makes sense. Thank to all of you! This thread is fascinating! :) I used `seq` to duct tape my space leaks and stack overflow issues. Now looked for `pseq` for parallelism. And I think I understand enough to use both reasonably. Thanks! Gracjan From jwlato at gmail.com Sun Sep 6 06:38:18 2009 From: jwlato at gmail.com (John Lato) Date: Sun Sep 6 06:17:28 2009 Subject: [Haskell-cafe] Re: memoization Message-ID: <9979e72e0909060338o3c97ed98s34ca7b25a33b71bb@mail.gmail.com> Hello, I agree that your answer is elegant, but it's not an efficient algorithm in any language. How about this, keeping the rest of your code the same? import Data.Array.Diff import Data.IArray update :: (Char -> [Int]) -> DiffArray Int ModP -> Char -> DiffArray Int ModP update lookup arr c = arr // (map calc . lookup $ c) where calc i = (i, (arr ! i) + (arr ! (i-1))) solve line sol = (foldl' (update lookup) iArray line) ! snd (bounds iArray) where iArray = listArray (0, length sol) $ 1 : map (const 0) sol lookup c = map (+1) . findIndices (== c) $ sol I would expect that at least some of the C programs would use the same algorithm. It's not the most efficient Haskell implementation, but on my computer it runs the large dataset in a little under 3 seconds, which is probably good enough. Cheers, John > > Hi, > > I participating in de google code jam this year and I want to try to use > haskell. The following > simple ?http://code.google.com/codejam/contest/dashboard?c=90101#s=p2 > problem > would have the beautiful haskell solution. > > import Data.MemoTrie > import Data.Char > import Data.Word > import Text.Printf > > newtype ModP = ModP Integer deriving Eq > > p=10000 > > instance Show ModP where > ?show (ModP x) = printf "%04d" x > > instance Num ModP where > ?ModP x + ModP y = ModP ((x + y) `mod` p) > ?fromInteger x = ModP (x `mod` p) > ?ModP x * ModP y = ModP ((x * y) `mod` p) > ?abs = undefined > ?signum = undefined > > solve _ [] = 1::ModP > solve [] _ = 0::ModP > solve (hs:ts) t@(ht:tt) | hs==ht = solve ts tt + solve ts t > ? ? ? ? ? ? ? ? ? ? ? ?| otherwise = solve ts t > > go (run, line) = "Case #"++show run++": "++show (solve line "welcome to code > jam") > > main = interact $ unlines . map go . zip [1..] . tail . lines > > > Which is unfortunately exponential. > > Now in earlier thread I argued for a compiler directive in the lines of {-# > Memoize function -#}, > but this is not possible (it seems to be trivial to implement though). Now I > used memotrie which > runs hopelessly out of memory. I looked at some other haskell solutions, > which were all ugly and > more clumsy compared to simple and concise C code. So it seems to me that > haskell is very nice > and beautiful until your are solving real algorithmic problems when you want > to go back to some > imperative language. > > How would experienced haskellers solve this problem? > > Thanks > -- > View this message in context: http://www.nabble.com/memoization-tp25306687p25306687.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > From gue.schmidt at web.de Sun Sep 6 07:06:24 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Sep 6 06:45:35 2009 Subject: [Haskell-cafe] Trying to reduce memory costs of String duplicates - Oh my god it works In-Reply-To: References: <7ca3f0160909051038o3e57df4ft1c61112f91ac2066@mail.gmail.com> Message-ID: Hi Luke, Brian, oh my god it works! I'm just saying it because that's a first! Late last night I had already suspected that laziness might be one of the reasons why the memoization technique showed no effect on memory consumption and after Brian's email that's exactly where I tried again, using Bang Patterns. IT WORKED! The memory consumption is now down by 20 fold! Thank you guys very very much! G?nther Am 06.09.2009, 03:24 Uhr, schrieb Brian Sniffen : > Remember that each string will still be read, so you may still > allocate a great deal of memory and generate a great deal of garbage. > You will just release it before long, rather than hold it for the life > of your program. Remember also that the memoization itself is lazy: > it does no good if you read all the file in, then force the > memoizations along with the computation of interest. > > -Brian > > 2009/9/5 G?nther Schmidt : >> Hi Luke, >> >> thanks, this is some very good advice as I find many duplicates in the >> data >> I have to iterate over. >> >> However so far I'm unable to tell wether this actually works or not, I >> tried >> it a couple of times under different settings but it showed to >> difference in >> memory consumption. The same mem peeks as before. >> >> Do you have some code that where you could see a before and after? >> >> G?nther >> >> >> Am 05.09.2009, 19:38 Uhr, schrieb Luke Palmer : >> >>> 2009/9/5 G?nther Schmidt : >>>> >>>> Hi all, >>>> >>>> I'm reading in a data of 216k records into a map of Key, Values Pairs, >>>> the >>>> values being strings. >>>> >>>> As it happens out of 216k String values there really are only about >>>> 6.6k >>>> distinct string values, so I could save a lot of RAM if I was able to >>>> "insert" only actually *new* string values into the map and use >>>> references >>>> to (string) values that already are in memory instead. >>>> >>>> Is there a container that would, if I wanted to insert an element, >>>> return >>>> a >>>> pair of either the previously inserted, equal value and the container >>>> unchanged, or the new, previously unknown value and the new container >>>> amended by that element? >>> >>> I believe a memoization of the identity function will do what you want: >>> >>> import qualified Data.MemoCombinators as Memo >>> >>> share = Memo.list Memo.char id >>> >>> Then pass any string through share to make/get a cached version. >>> >>> You might want to limit the scope of share -- eg. put it in a where >>> clause for the function where you're using it -- so that it doesn't >>> eat memory for the lifetime of your program, only for when you need >>> it. >>> >>> Luke >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > From jwlato at gmail.com Sun Sep 6 07:36:57 2009 From: jwlato at gmail.com (John Lato) Date: Sun Sep 6 07:16:07 2009 Subject: [Haskell-cafe] Re: memoization Message-ID: <9979e72e0909060436y29e4d5ddi208ddd0180ad1a74@mail.gmail.com> I just discovered that changing DiffArray to a plain Array improves performance of my code by almost a factor of 10. Bitten by DiffArray yet again! John -- this is no good, just change DiffArray to Array. > update :: (Char -> [Int]) -> DiffArray Int ModP -> Char -> DiffArray Int ModP > update lookup arr c = arr // (map calc . lookup $ c) > ?where > ? ?calc i = (i, (arr ! i) + (arr ! (i-1))) From nonowarn at gmail.com Sun Sep 6 08:05:51 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Sep 6 07:45:00 2009 Subject: [Haskell-cafe] Averting QuickCheck Madness In-Reply-To: References: Message-ID: I think using the runTests hook and the test flag make sense, described at http://www.haskell.org/pipermail/haskell-cafe/2008-September/047223.html. I released some libraries in this way, AFAIK it works well. On Sun, Sep 6, 2009 at 4:57 PM, Christopher Lane Hinson wrote: > > There are some libraries that depend on QuickCheck 2, and others that depend > on QuickCheck 1. ?This can be a problem. ?AIUI, the Haskell Platform current > depends on QC1, but intends to move to QC2 soon. ?I also know that the cabal > mailing list has talked about some kind of private-depends capability to > mitigate this kind of thing in the future. > > However, I don't see how it can possibly be a best practice to depend on > QuickCheck from a shipping library. ?End users never use this, and for users > of upstream packages who may compile from source and contribute the > occasional (but valuable!) patch, this is nothing but a compile-time problem > waiting to happen. > > (Note that a user who contributes to a library should be encouraged to run > test suites, but I'm talking about users of upstream packages.) > > There are some good ideas discussed on this list last year*, but none of > them seem to have been blessed by the community. > > * http://www.haskell.org/pipermail/haskell-cafe/2008-September/047216.html > > Friendly, > --Lane > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Sun Sep 6 08:50:32 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Sep 6 08:29:42 2009 Subject: [Haskell-cafe] Record update fusion (or how should I call it?) Message-ID: I've seen a couple of package being announced that provide first class labels, and other packages already existed for this (Grapefruit Record, HList, Accessor, ...) Regarding this, I have a question about the performance of multiple composed field updates. Maybe an example. Suppose I have a large record - say WindowDescription - which contains a lot of fields. Suppose I have a couple of default window description values, e.g. defaultWindowDesc, dialogBoxDesc, etc Using accessors it is easy to take such a default value, and "modify" a couple of fields, like: let myWindowDesc = set title "Haskell" . set size (640,480) . set background Blue . set fontFamily Arial $ defaultWindowDesc However, I guess this would make a lot of intermediate WindowDescription copies no (whether the fields are strict or not)? So ideally for performance, all these "updates" should be fused, maybe running inside an ST monad? I'm not sure if any of this is valid, but I would like to understand more about this, so any links and hints are welcome :-) Peter Verswyvelen From mf-hcafe-15c311f0c at etc-network.de Sun Sep 6 09:35:16 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sun Sep 6 09:14:39 2009 Subject: [Haskell-cafe] ForeignFunPtr In-Reply-To: References: Message-ID: <20090906133516.GD3384@yoyo> the purpose of ForeignPtr is to attach a finalization procedure to the object behind the pointer. for example, you can have close called aimplicitly whenever the garbage collector finds you don't need a file handle any more. function pointers do not need finalization. cheers, matthias On Sat, Sep 05, 2009 at 07:51:59PM -0300, Maur??cio CA wrote: > To: haskell-cafe@haskell.org > From: Maur??cio CA > Date: Sat, 05 Sep 2009 19:51:59 -0300 > Subject: [Haskell-cafe] ForeignFunPtr > > Hi, > > We have ForeignPtr. Why isn't there a > corresponding ForeignFunPtr? > > > Thanks, > Maur?cio > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** CLASSIFY > succeeds; success probability: 0.9999 pR: 4.1765 > Best match to file #0 (nonspam.css) prob: 0.9999 pR: 4.1765 Total > features in input file: 2256 > #0 (nonspam.css): features: 758386, hits: 2818973, prob: 1.00e+00, pR: > 4.18 #1 (spam.css): features: 1686574, hits: 3077879, prob: 6.66e-05, pR: > -4.18 > From daniel.is.fischer at web.de Sun Sep 6 11:30:42 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Sep 6 11:10:57 2009 Subject: [Haskell-cafe] Re: memoization In-Reply-To: <9979e72e0909060436y29e4d5ddi208ddd0180ad1a74@mail.gmail.com> References: <9979e72e0909060436y29e4d5ddi208ddd0180ad1a74@mail.gmail.com> Message-ID: <200909061730.43031.daniel.is.fischer@web.de> Am Sonntag 06 September 2009 13:36:57 schrieb John Lato: > I just discovered that changing DiffArray to a plain Array improves > performance of my code by almost a factor of 10. Bitten by DiffArray > yet again! That's strange. Compiled without optimisations, using plain Array instead of DiffArray gives a speedup factor of about 38 here, with optimisations it's a factor of 100 (thus it's about on par with the list-only version of the same algorithm). > > John From will.donnelly at gmail.com Sun Sep 6 11:37:05 2009 From: will.donnelly at gmail.com (Will Donnelly) Date: Sun Sep 6 11:16:14 2009 Subject: [Haskell-cafe] Re: How to customize dyre recompile? Message-ID: <6f4294c0909060837p50db7e23x918413c963277061@mail.gmail.com> Hi Andy, I feel that I should offer a disclaimer here: You are misusing Dyre somewhat by attempting to make it handle whole-program recompilation. It is designed to recompile a single configuration file, generally against an installed library form of the application. Some of its code, specifically the part that decides when to recompile, is based almost entirely on this assumption. That aside, you should be able to accomplish your goals like this: 1. Set the 'forceRecomp' parameter (just added in Dyre 0.7.3) to 'False'. This will remove the '-fforce-recomp' flag from GHC's options. 2. Run your executable with the '--force-reconf' flag, which will cause Dyre to always enter the recompilation code. In a test project I just created, this seems to do what you desire. Hope this helps clear things up - Will Donnelly On?Sun, Sep 6 2009 at 1:41 PM,?Andy Stewart wrote: > > Hi all, > > I use below params for configure dyre: > > rebootParams :: Params Config > rebootParams = defaultParams > ? ?{projectName = "Main" > ? ?,realMain ? ?= manatee > ? ?,showError ? = rebootShowError > ? ?,cacheDir ? ?= Just $ return "/test/Download/cache/" > ? ?,configDir ? = Just getCurrentDirectory > ? ?} > > There have two version of function `reboot` to reboot Master binary: > > reboot :: IORefObject -> IO () > reboot ioRefObject = do > ?rs <- rebootGetState ioRefObject > ?relaunchWithBinaryState rs Nothing > > reboot :: IORefObject -> IO () > reboot ioRefObject = do > ?output <- customCompile rebootParams > ?case output of > ? ?Just o -> putStrLn o ? -- output recompile error > ? ?Nothing -> do ? ? ? ? ?-- otherwise relaunch > ? ? ?rs <- rebootGetState ioRefObject > ? ? ?relaunchWithBinaryState rs Nothing > > Becuase i setup `projectName` with `Main`, so i want `dyre` recompile > NECESSARY module when i change any module in my project. > > In first version of function `reboot`, i just use > `relauncheWithBinaryState`, i found `dyre` just recompile all project when i > modified Main.hs, if i modified any others module in project, `dyre` > won't recompile those modified modules. > > In second version, i use `customCompile` for recompile, but this have > another problem, `customComiple` use `-fforce-recomp` flags to remove > all object files, so function `customComiple` will recompile all modules > in project, and not just recompile NECESSARY modules. > > So how to make `dyre` just recompile NECCESSARY modules whatever i > change any modules in project? > > Maybe add new option "--dyre-reconf-necessary" in `dyre`? > > Thanks! > > ?-- Andy From jwlato at gmail.com Sun Sep 6 12:00:49 2009 From: jwlato at gmail.com (John Lato) Date: Sun Sep 6 11:40:00 2009 Subject: [Haskell-cafe] Re: memoization In-Reply-To: <200909061730.43031.daniel.is.fischer@web.de> References: <9979e72e0909060436y29e4d5ddi208ddd0180ad1a74@mail.gmail.com> <200909061730.43031.daniel.is.fischer@web.de> Message-ID: <9979e72e0909060900k5675598bs16ed8d856fb92a00@mail.gmail.com> On Sun, Sep 6, 2009 at 4:30 PM, Daniel Fischer wrote: > Am Sonntag 06 September 2009 13:36:57 schrieb John Lato: >> I just discovered that changing DiffArray to a plain Array improves >> performance of my code by almost a factor of 10. ?Bitten by DiffArray >> yet again! > > That's strange. Compiled without optimisations, using plain Array instead of DiffArray > gives a speedup factor of about 38 here, with optimisations it's a factor of 100 (thus > it's about on par with the list-only version of the same algorithm). > My mistake; I misread the time output. My results are the same as yours. From johanj at cs.uu.nl Sun Sep 6 12:54:48 2009 From: johanj at cs.uu.nl (Johan Jeuring) Date: Sun Sep 6 12:33:58 2009 Subject: [Haskell-cafe] ANNOUNCE: Palindromes 0.1 Message-ID: Palindromes ============================================== Palindromes is a package for finding palindromes in files. Visit the homepage http://www.jeuring.net/Palindromes/ Features -------- The primary features of Palindromes include: * Linear-time algorithm for finding exact palindromes * Linear-time algorithm for finding text palindromes, ignoring spaces, case of characters, and punctuation symbols. Requirements ------------ Palindromes has the following requirements: * GHC version 6.8.1 or later - It has been tested with version 6.10.1. * Cabal library version 1.2.1 or later - It has been tested with version 1.6.0.1. Download & Installation ----------------------- * Use cabal-install cabal install palindromes * If you don't have cabal-install, you must download the Palindromes package from HackageDB and install it manually. Get the `tar.gz` file and decompress it. http://hackage.haskell.org/package/palindromes Once downloaded, use the following commands for configuring, building, and installing the library. runghc Setup.lhs configure runghc Setup.lhs build runghc Setup.lhs install * Get the source: svn checkout https://subversion.cs.uu.nl/repos/staff.johanj.palindromes/ Documentation ------------- The API is documented using Haddock and available on the Palindromes package site. Examples -------- You can find example palindromes, on which Palindromes has been tested, in the `examples` directory of the source distribution. https://subversion.cs.uu.nl/repos/staff.johanj.palindromes/trunk/examples/palindromes Bugs & Support -------------- To report bugs, use the Google Code project page for Palindromes. http://code.google.com/p/palindromes/ For general concerns and questions, email the author: johan at jeuring.net Licensing --------- Palindromes is licensed under the so-called BSD3 license. See the included `LICENSE` file. Credits ------- Palindromes is based on the functional program developed by Johan Jeuring in his PhD thesis. The current author and maintainer of Palindromes is Johan Jeuring. http://www.jeuring.net/ From mauricio.antunes at gmail.com Sun Sep 6 13:53:52 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Sun Sep 6 13:33:28 2009 Subject: [Haskell-cafe] Re: ForeignFunPtr In-Reply-To: <20090906133516.GD3384@yoyo> References: <20090906133516.GD3384@yoyo> Message-ID: Isn't freeHaskellFunPtr a required finalization procedure? Maur?cio > the purpose of ForeignPtr is to attach a finalization procedure to the > object behind the pointer. for example, you can have close called > aimplicitly whenever the garbage collector finds you don't need a file > handle any more. function pointers do not need finalization. > >> >> We have ForeignPtr. Why isn't there a >> corresponding ForeignFunPtr? >> From lazycat.manatee at gmail.com Sun Sep 6 13:17:57 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Sun Sep 6 13:47:29 2009 Subject: [Haskell-cafe] Re: How to customize dyre recompile? References: <6f4294c0909060837p50db7e23x918413c963277061@mail.gmail.com> Message-ID: <871vmk6lh6.fsf@ubuntu.domain> Will Donnelly writes: Hi Will, > Hi Andy, > > I feel that I should offer a disclaimer here: You are misusing Dyre > somewhat by attempting to make it handle whole-program recompilation. > It is designed to recompile a single configuration file, generally > against an installed library form of the application. Some of its > code, specifically the part that decides when to recompile, is based > almost entirely on this assumption. I use dyre for develop dynamic gtk application, so i hope dyre do whole-program recompilaton and just recompile necessary files. Just recompile single file or force recompile all modules is not my desire. It's better if dyre's support single file recompliation and whole-program recompilation, isn't? :) > > That aside, you should be able to accomplish your goals like this: > > 1. Set the 'forceRecomp' parameter (just added in Dyre 0.7.3) to > 'False'. This will remove the '-fforce-recomp' flag from GHC's > options. > 2. Run your executable with the '--force-reconf' flag, which will > cause Dyre to always enter the recompilation code. Now i use below code finish work: ------------------------------> code start <------------------------------ rebootParams :: Params Config rebootParams = defaultParams {projectName = "Main" ,realMain = manatee ,showError = rebootShowError ,cacheDir = Just $ return "/test/Download/cache/" ,configDir = Just getCurrentDirectory ,forceRecomp = False -- don't recompile all modules, steup for recompile whole-program } rebootOptions :: Maybe [String] rebootOptions = Just ["--force-reconf"] rebootShowError :: Config -> String -> Config rebootShowError cfg msg = cfg {errorMsg = Just msg} reboot :: IORefObject -> IO () reboot ioRefObject = do rs <- rebootGetState ioRefObject relaunchWithBinaryState rs rebootOptions ------------------------------> code end <------------------------------ BTW, looks dyre don't recommand user use function `customCompile`, when it will call in function `wrapMain' always. If i just use relaunch function, i just got simple error information: "Error occurred while loading configuration file." when recompile failed. How to display detail information when recompile failed? I missing something? Thanks! -- Andy > > In a test project I just created, this seems to do what you desire. > > Hope this helps clear things up > - Will Donnelly > > On?Sun, Sep 6 2009 at 1:41 PM,?Andy Stewart wrote: >> >> Hi all, >> >> I use below params for configure dyre: >> >> rebootParams :: Params Config >> rebootParams = defaultParams >> ? ?{projectName = "Main" >> ? ?,realMain ? ?= manatee >> ? ?,showError ? = rebootShowError >> ? ?,cacheDir ? ?= Just $ return "/test/Download/cache/" >> ? ?,configDir ? = Just getCurrentDirectory >> ? ?} >> >> There have two version of function `reboot` to reboot Master binary: >> >> reboot :: IORefObject -> IO () >> reboot ioRefObject = do >> ?rs <- rebootGetState ioRefObject >> ?relaunchWithBinaryState rs Nothing >> >> reboot :: IORefObject -> IO () >> reboot ioRefObject = do >> ?output <- customCompile rebootParams >> ?case output of >> ? ?Just o -> putStrLn o ? -- output recompile error >> ? ?Nothing -> do ? ? ? ? ?-- otherwise relaunch >> ? ? ?rs <- rebootGetState ioRefObject >> ? ? ?relaunchWithBinaryState rs Nothing >> >> Becuase i setup `projectName` with `Main`, so i want `dyre` recompile >> NECESSARY module when i change any module in my project. >> >> In first version of function `reboot`, i just use >> `relauncheWithBinaryState`, i found `dyre` just recompile all project when i >> modified Main.hs, if i modified any others module in project, `dyre` >> won't recompile those modified modules. >> >> In second version, i use `customCompile` for recompile, but this have >> another problem, `customComiple` use `-fforce-recomp` flags to remove >> all object files, so function `customComiple` will recompile all modules >> in project, and not just recompile NECESSARY modules. >> >> So how to make `dyre` just recompile NECCESSARY modules whatever i >> change any modules in project? >> >> Maybe add new option "--dyre-reconf-necessary" in `dyre`? >> >> Thanks! >> >> ?-- Andy From derek.a.elkins at gmail.com Sun Sep 6 15:04:08 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sun Sep 6 14:43:16 2009 Subject: [Haskell-cafe] Record update fusion (or how should I call it?) In-Reply-To: References: Message-ID: <61f84eff0909061204i27a83506le9c4a3a7afda683c@mail.gmail.com> The first thing I would do i is verify that the compiler is not already doing this. On Sun, Sep 6, 2009 at 7:50 AM, Peter Verswyvelen wrote: > I've seen a couple of package being announced that provide first class > labels, and other packages already existed for this (Grapefruit > Record, HList, Accessor, ...) > > Regarding this, I have a question about the performance of multiple > composed field updates. Maybe an example. > > Suppose I have a large record - say WindowDescription - which contains > a lot of fields. > > Suppose I have a couple of default window description values, e.g. > defaultWindowDesc, dialogBoxDesc, etc > > Using accessors it is easy to take such a default value, and "modify" > a couple of fields, like: > > let myWindowDesc = set title "Haskell" . set size (640,480) . set > background Blue . set fontFamily Arial $ defaultWindowDesc > > However, I guess this would make a lot of intermediate > WindowDescription copies no (whether the fields are strict or not)? So > ideally for performance, all these "updates" should be fused, maybe > running inside an ST monad? > > I'm not sure if any of this is valid, but I would like to understand > more about this, so any links and hints are welcome :-) > > Peter Verswyvelen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From agocorona at gmail.com Sun Sep 6 15:19:01 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Sun Sep 6 14:58:08 2009 Subject: [Haskell-cafe] Record update fusion (or how should I call it?) In-Reply-To: <61f84eff0909061204i27a83506le9c4a3a7afda683c@mail.gmail.com> References: <61f84eff0909061204i27a83506le9c4a3a7afda683c@mail.gmail.com> Message-ID: Use Haskell records: defaultWindowDescription= WindowDescription {title="", size=(0,0) ......} Many modifications can be fused in a single statement. for example: newWindowDescription= defaultWindowDescription{itle= "Haskell" ; size= (640,480),background= Blue} 2009/9/6 Derek Elkins : > The first thing I would do i is verify that the compiler is not > already doing this. > > On Sun, Sep 6, 2009 at 7:50 AM, Peter Verswyvelen wrote: >> I've seen a couple of package being announced that provide first class >> labels, and other packages already existed for this (Grapefruit >> Record, HList, Accessor, ...) >> >> Regarding this, I have a question about the performance of multiple >> composed field updates. Maybe an example. >> >> Suppose I have a large record - say WindowDescription - which contains >> a lot of fields. >> >> Suppose I have a couple of default window description values, e.g. >> defaultWindowDesc, dialogBoxDesc, etc >> >> Using accessors it is easy to take such a default value, and "modify" >> a couple of fields, like: >> >> let myWindowDesc = set title "Haskell" . set size (640,480) . set >> background Blue . set fontFamily Arial $ defaultWindowDesc >> >> However, I guess this would make a lot of intermediate >> WindowDescription copies no (whether the fields are strict or not)? So >> ideally for performance, all these "updates" should be fused, maybe >> running inside an ST monad? >> >> I'm not sure if any of this is valid, but I would like to understand >> more about this, so any links and hints are welcome :-) >> >> Peter Verswyvelen >> _______________________________________________ >> 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 > From bugfact at gmail.com Sun Sep 6 15:41:18 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Sep 6 15:20:26 2009 Subject: [Haskell-cafe] Record update fusion (or how should I call it?) In-Reply-To: References: <61f84eff0909061204i27a83506le9c4a3a7afda683c@mail.gmail.com> Message-ID: Yes of course Haskell records do this, but these updates are not first class. But this kind of fusion seems rather general. I haven't checked if the compiler already does it. On Sun, Sep 6, 2009 at 9:19 PM, Alberto G. Corona wrote: > Use Haskell records: > > defaultWindowDescription= WindowDescription {title="", size=(0,0) ......} > > Many modifications can be fused in a single statement. for example: > > newWindowDescription= defaultWindowDescription{itle= "Haskell" ; size= > (640,480),background= Blue} > > > > 2009/9/6 Derek Elkins : >> The first thing I would do i is verify that the compiler is not >> already doing this. >> >> On Sun, Sep 6, 2009 at 7:50 AM, Peter Verswyvelen wrote: >>> I've seen a couple of package being announced that provide first class >>> labels, and other packages already existed for this (Grapefruit >>> Record, HList, Accessor, ...) >>> >>> Regarding this, I have a question about the performance of multiple >>> composed field updates. Maybe an example. >>> >>> Suppose I have a large record - say WindowDescription - which contains >>> a lot of fields. >>> >>> Suppose I have a couple of default window description values, e.g. >>> defaultWindowDesc, dialogBoxDesc, etc >>> >>> Using accessors it is easy to take such a default value, and "modify" >>> a couple of fields, like: >>> >>> let myWindowDesc = set title "Haskell" . set size (640,480) . set >>> background Blue . set fontFamily Arial $ defaultWindowDesc >>> >>> However, I guess this would make a lot of intermediate >>> WindowDescription copies no (whether the fields are strict or not)? So >>> ideally for performance, all these "updates" should be fused, maybe >>> running inside an ST monad? >>> >>> I'm not sure if any of this is valid, but I would like to understand >>> more about this, so any links and hints are welcome :-) >>> >>> Peter Verswyvelen >>> _______________________________________________ >>> 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 > From gue.schmidt at web.de Sun Sep 6 19:40:05 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Sep 6 19:19:34 2009 Subject: [Haskell-cafe] HList and Type signatures / synonyms Message-ID: Hi, I keep accumulating values and right now use plain tuples for that. I end up with a 12 element tuple and things are a bit messy. I'd like to use extensible Records from HList instead, thing is I'd like to keep putting type signatures in my code. As it turns out that seems to be where it gets messy with HList. Is there a simple way to do this? G?nther PS: Does anyone know why there are Label-n modules in HList, and which one to use? From ezyang at MIT.EDU Sun Sep 6 20:44:52 2009 From: ezyang at MIT.EDU (Edward Z. Yang) Date: Sun Sep 6 20:24:00 2009 Subject: [Haskell-cafe] HList and Type signatures / synonyms In-Reply-To: References: Message-ID: <1252284227-sup-8018@javelin> Excerpts from G?nther Schmidt's message of Sun Sep 06 19:40:05 -0400 2009: > I keep accumulating values and right now use plain tuples for that. I end > up with a 12 element tuple and things are a bit messy. Hi, you may want to consider using the Writer monad. [1] > I'd like to use extensible Records from HList instead, thing is I'd like > to keep putting type signatures in my code. As it turns out that seems to > be where it gets messy with HList. Perhaps more precisely explaining your problem domain would be useful. Cheers, Edward [1] http://www.haskell.org/all_about_monads/html/writermonad.html From gue.schmidt at web.de Sun Sep 6 21:38:28 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Sep 6 21:18:00 2009 Subject: [Haskell-cafe] Re: HList and Type signatures / synonyms References: <1252284227-sup-8018@javelin> Message-ID: Hi Edward, I suppose you're right, I could have made this a little more detailed. I keep reading in and processing data in an accumulating way, ie. lets say I have a DB table (don't take this literally please, just an example), into in-memory records of type data MyRecord = MyRecord { name :: String, birthDate :: LocalDate} in a second step I read in Gender information so now I'd need an extended Record data MyRecord = MyRecord { name :: String, birthDate :: LocalDate, gender :: Gender } and so on for another 12 times. In other words I need to extend the record. I had been using tuples, ie: (String, LocalDate) -> Gender -> (String, LocalDate, Gender) but after 6 or so *extensions* things get a tad messy. Anyway this is where HList really shines, but it is a bit akward when you want to state the type of an HList record, ie. type Entg = Record (HCons (LVPair (Label HZero) DRG) (HCons (LVPair (Label (HSucc HZero)) BelegungsTyp) (HCons (LVPair (Label (HSucc (HSucc HZero))) EntgeltBetrag) (HCons (LVPair (Label (HSucc (HSucc (HSucc HZero)))) Zuschl?ge) (HCons (LVPair (Label (HSucc (HSucc (HSucc (HSucc HZero))))) Abschl?ge) HNil))))) which happens to be my actual stage 1 data type (Entg), one that has 5 "fields" initial and in several distinct steps 8 more are *added*. So I wonder if there is a more simple way to do this, ie to *extend* the *type* signatures of extend records without such a lot of typing. G?nther Am 07.09.2009, 02:44 Uhr, schrieb Edward Z. Yang : > Excerpts from G?nther Schmidt's message of Sun Sep 06 19:40:05 -0400 > 2009: >> I keep accumulating values and right now use plain tuples for that. I >> end >> up with a 12 element tuple and things are a bit messy. > > Hi, you may want to consider using the Writer monad. [1] > >> I'd like to use extensible Records from HList instead, thing is I'd like >> to keep putting type signatures in my code. As it turns out that seems >> to >> be where it gets messy with HList. > > Perhaps more precisely explaining your problem domain would be useful. > > Cheers, > Edward > > [1] http://www.haskell.org/all_about_monads/html/writermonad.html From alexander.dunlap at gmail.com Sun Sep 6 23:45:23 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Sun Sep 6 23:24:49 2009 Subject: [Haskell-cafe] Re: HList and Type signatures / synonyms In-Reply-To: References: <1252284227-sup-8018@javelin> Message-ID: <57526e770909062045g12047871i9913e6e14cac810b@mail.gmail.com> 2009/9/6 G?nther Schmidt : > Hi Edward, > > I suppose you're right, I could have made this a little more detailed. > > I keep reading in and processing data in an accumulating way, ie. lets say I > have a DB table (don't take this literally please, just an example), into > in-memory records of type > > data MyRecord = MyRecord { > ? ? ? ?name :: String, > ? ? ? ?birthDate :: LocalDate} > > in a second step I read in Gender information so now I'd need an extended > Record > > data MyRecord = MyRecord { > ? ? ? ?name :: String, > ? ? ? ?birthDate :: LocalDate, > ? ? ? ?gender :: Gender } > > and so on for another 12 times. > > In other words I need to extend the record. > > I had been using tuples, ie: > > ? ? ? ?(String, LocalDate) -> Gender -> (String, LocalDate, Gender) > > > but after 6 or so *extensions* things get a tad messy. > > Anyway this is where HList really shines, but it is a bit akward when you > want to state the type of an HList record, ie. > > > type Entg = > ? ?Record > ? ?(HCons > ? ? (LVPair (Label HZero) DRG) > ? ? (HCons > ? ? ?(LVPair (Label (HSucc HZero)) BelegungsTyp) > ? ? ?(HCons > ? ? ? (LVPair (Label (HSucc (HSucc HZero))) EntgeltBetrag) > ? ? ? (HCons > ? ? ? ?(LVPair (Label (HSucc (HSucc (HSucc HZero)))) Zuschl?ge) > ? ? ? ?(HCons > ? ? ? ? (LVPair (Label (HSucc (HSucc (HSucc (HSucc HZero))))) Abschl?ge) > ? ? ? ? HNil))))) > > which happens to be my actual stage 1 data type (Entg), one that has 5 > "fields" initial and in several distinct steps 8 more are *added*. > > > > So I wonder if there is a more simple way to do this, ie to *extend* the > *type* signatures of extend records without such a lot of typing. > > G?nther > > > Am 07.09.2009, 02:44 Uhr, schrieb Edward Z. Yang : > >> Excerpts from G?nther Schmidt's message of Sun Sep 06 19:40:05 -0400 2009: >>> >>> I keep accumulating values and right now use plain tuples for that. I end >>> up with a 12 element tuple and things are a bit messy. >> >> Hi, you may want to consider using the Writer monad. [1] >> >>> I'd like to use extensible Records from HList instead, thing is I'd like >>> to keep putting type signatures in my code. As it turns out that seems to >>> be where it gets messy with HList. >> >> Perhaps more precisely explaining your problem domain would be useful. >> >> Cheers, >> Edward >> >> [1] http://www.haskell.org/all_about_monads/html/writermonad.html > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Why don't you define your record to be the final set of all the information that you will collect, and just leave some of the fields undefined until you collect all the data? That would work well if you are going to be collecting all of the data pretty much all at once. You could also have a record of Maybe values that started out as all Nothing and became Justs as the data was collected. Maybe I'm misunderstanding your problem, but that's how I would do it. Alex From akshay.v.dave at hotmail.com Mon Sep 7 01:22:35 2009 From: akshay.v.dave at hotmail.com (Akshay Dave) Date: Mon Sep 7 01:01:45 2009 Subject: [Haskell-cafe] How to Create Data Type of memory Message-ID: Hi All, I am stuck in converting the transition semantics in Haskell. Please let me know how to define memory data types in Haskell( like we define pointer in C). Prompt help would be greatly appreciated. Sincerely, Akshay _________________________________________________________________ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/b994ab5a/attachment.html From akshay.v.dave at hotmail.com Mon Sep 7 01:23:29 2009 From: akshay.v.dave at hotmail.com (Akshay Dave) Date: Mon Sep 7 01:02:37 2009 Subject: [Haskell-cafe] How to Create Data Type of memory Message-ID: Hi All, I am stuck in converting the transition semantics in Haskell. Please let me know how to define memory data types in Haskell( like we define pointer in C). Prompt help would be greatly appreciated. Sincerely, Akshay _________________________________________________________________ Hotmail? is up to 70% faster. Now good news travels really fast. http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_faster:082009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/988a0d63/attachment.html From lrpalmer at gmail.com Mon Sep 7 01:29:27 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Sep 7 01:08:35 2009 Subject: [Haskell-cafe] How to Create Data Type of memory In-Reply-To: References: Message-ID: <7ca3f0160909062229t2529b570r8ebeb440c046e488@mail.gmail.com> On Sun, Sep 6, 2009 at 11:22 PM, Akshay Dave wrote: > Hi All, > ?? I am stuck in converting the transition semantics in Haskell. Please let > me know how to define memory data types in Haskell( like we define pointer > in C). Prompt help would be greatly appreciated. I'm sorry, but I can't understand your question. Do you want to interface with C or another language using the FFI interface? Or are you asking about a feature of pure Haskell code? If you're asking about pure Haskell, I'm going to guess the answer is "you can't", or use eg. IORef, MArray, for impure types. (But I discourage their use) If you give us more information about what problem you are trying to solve, we can be of more help. Luke From akshay.v.dave at hotmail.com Mon Sep 7 01:45:33 2009 From: akshay.v.dave at hotmail.com (Akshay Dave) Date: Mon Sep 7 01:24:40 2009 Subject: [Haskell-cafe] How to Create Data Type of memory In-Reply-To: <7ca3f0160909062229t2529b570r8ebeb440c046e488@mail.gmail.com> References: <7ca3f0160909062229t2529b570r8ebeb440c046e488@mail.gmail.com> Message-ID: Hi, Thanks for your prompt reply. Actually I am trying to convert the following transitive semantics to Haskell: (Memory maps I to Z) lookup m i = ( meaning lookup for I in memory m)  evB b m = true/(while b do c od;m) -> (c; while b do c od;m) I have written the boolean expression and statement part but I am not able to write the memory representation in Haskell. Hope above explanation helps. Cheers! Akshay > Date: Sun, 6 Sep 2009 23:29:27 -0600 > Subject: Re: [Haskell-cafe] How to Create Data Type of memory > From: lrpalmer@gmail.com > To: akshay.v.dave@hotmail.com > CC: haskell-cafe@haskell.org > > On Sun, Sep 6, 2009 at 11:22 PM, Akshay Dave wrote: > > Hi All, > > I am stuck in converting the transition semantics in Haskell. Please let > > me know how to define memory data types in Haskell( like we define pointer > > in C). Prompt help would be greatly appreciated. > > I'm sorry, but I can't understand your question. Do you want to > interface with C or another language using the FFI interface? Or are > you asking about a feature of pure Haskell code? If you're asking > about pure Haskell, I'm going to guess the answer is "you can't", or > use eg. IORef, MArray, for impure types. (But I discourage their use) > > If you give us more information about what problem you are trying to > solve, we can be of more help. > > Luke _________________________________________________________________ Get back to school stuff for them and cashback for you. http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/8a01a90c/attachment.html From vigalchin at gmail.com Mon Sep 7 02:10:14 2009 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Mon Sep 7 01:49:21 2009 Subject: [Haskell-cafe] "Conceptual Mathematics" Message-ID: <5ae4f2ba0909062310qb960949wb6d997a0615cece1@mail.gmail.com> Hello, "Conceptual Mathematics" has been advertised as accessible to high school students. I would like to collect where this book is being taught to high school students and how it is taught(heuristics). I am interested in teaching it to students locally but I realize that these students to be very gifted. Any advice and especially real world experience would be appreciated. Thank you, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/e3ba9f10/attachment.html From lrpalmer at gmail.com Mon Sep 7 02:12:14 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Sep 7 01:51:20 2009 Subject: [Haskell-cafe] How to Create Data Type of memory In-Reply-To: References: <7ca3f0160909062229t2529b570r8ebeb440c046e488@mail.gmail.com> Message-ID: <7ca3f0160909062312k6da5c66dua5d09eb86d68cd4b@mail.gmail.com> On Sun, Sep 6, 2009 at 11:45 PM, Akshay Dave wrote: > Hi, > ?? Thanks for your prompt reply. Actually I am trying to convert the > following transitive semantics to Haskell: > > (Memory maps I to Z) > lookup m i = ? ( meaning lookup for I in memory m) > > evB b m = true/(while b do c od;m) -> (c; while b do c od;m) > > I have written the boolean expression and statement part but I am not able > to write the memory representation in Haskell. Ah, if you're trying to implement a semantics (emphasis on understandability and correctness), I suggest Data.Map. import qualified Data.Map as Map Map.lookup 2 (Map.insert 1 "x" (Map.insert 2 "y" Map.empty)) -- "y" Luke From akshay.v.dave at hotmail.com Mon Sep 7 02:41:58 2009 From: akshay.v.dave at hotmail.com (Akshay Dave) Date: Mon Sep 7 02:21:08 2009 Subject: [Haskell-cafe] How to Create Data Type of memory In-Reply-To: <7ca3f0160909062312k6da5c66dua5d09eb86d68cd4b@mail.gmail.com> References: <7ca3f0160909062229t2529b570r8ebeb440c046e488@mail.gmail.com> <7ca3f0160909062312k6da5c66dua5d09eb86d68cd4b@mail.gmail.com> Message-ID: Hi Luke, Thanks for your prompt response. I'll try to implement the same for my semantics! Cheers! Akshay > Date: Mon, 7 Sep 2009 00:12:14 -0600 > Subject: Re: [Haskell-cafe] How to Create Data Type of memory > From: lrpalmer@gmail.com > To: akshay.v.dave@hotmail.com > CC: haskell-cafe@haskell.org > > On Sun, Sep 6, 2009 at 11:45 PM, Akshay Dave wrote: > > Hi, > > Thanks for your prompt reply. Actually I am trying to convert the > > following transitive semantics to Haskell: > > > > (Memory maps I to Z) > > lookup m i = ( meaning lookup for I in memory m) > > > > evB b m = true/(while b do c od;m) -> (c; while b do c od;m) > > > > I have written the boolean expression and statement part but I am not able > > to write the memory representation in Haskell. > > Ah, if you're trying to implement a semantics (emphasis on > understandability and correctness), I suggest Data.Map. > > import qualified Data.Map as Map > Map.lookup 2 (Map.insert 1 "x" (Map.insert 2 "y" Map.empty)) -- "y" > > Luke _________________________________________________________________ Hotmail? is up to 70% faster. Now good news travels really fast. http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_faster:082009 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/4cf3743d/attachment.html From magicloud.magiclouds at gmail.com Mon Sep 7 04:45:09 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Sep 7 04:24:18 2009 Subject: [Haskell-cafe] How to generate the .chi file for c2hs? Message-ID: <3bd412d40909070145s78e3a65cl5e336e3ac4fae6e9@mail.gmail.com> Hi, I want to make a binding of a gtk function, which returns a X11 type. gtk2hs is made by c2hs, which is OK to give me the .chi file. Well, X11 is not. So if I make my binding c2hs style, I have to make a .chi file for X11 myself. How to do it? -- ??????? ??????? From magicloud.magiclouds at gmail.com Mon Sep 7 04:45:36 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Sep 7 04:24:43 2009 Subject: [Haskell-cafe] Problem on existential type. In-Reply-To: <2f9b2d30909051153h30714274pc8579134ff42b6@mail.gmail.com> References: <3bd412d40909032305i58748476y3259410d579b7db1@mail.gmail.com> <2f9b2d30909051153h30714274pc8579134ff42b6@mail.gmail.com> Message-ID: <3bd412d40909070145i78e3cde7s6a621729aa4948c5@mail.gmail.com> Thank you all guys. This explained so much. On Sun, Sep 6, 2009 at 2:53 AM, Ryan Ingram wrote: > On Thu, Sep 3, 2009 at 11:05 PM, Magicloud > Magiclouds wrote: >> data GridWidget = forall widget. (WidgetClass widget) => GridWidget widget >> >> liftGW :: (GridWidget widget) -> (widget -> t) -> t >> liftGW (GridWidget label) f = f label >> liftGW (GridWidget textView) f = f textView > > The type signature on liftGW is wrong. ?Also, as mentioned elsewhere, > the two matches overlap; the second case never gets called. > > The correct type signature for "liftGW" is: > > liftGW :: GridWidget -> (forall widget. WidgetClass widget => widget -> t) -> t > > Note that the "f" passed in has to accept *any* widget type, so it's > possible that existential types aren't what you want. > > ?-- ryan > -- ??????? ??????? From duncan.coutts at worc.ox.ac.uk Mon Sep 7 07:52:34 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Sep 7 09:46:15 2009 Subject: [Haskell-cafe] Cabal install specific version of a package In-Reply-To: <14591251911539@webmail114.yandex.ru> References: <14591251911539@webmail114.yandex.ru> Message-ID: <1252324354.5266.1178.camel@localhost> On Wed, 2009-09-02 at 21:12 +0400, Grigory Sarnitskiy wrote: > How to install specific version of a package (derive 0.1.4)? For other examples see the --help output: $ cabal install --help [..snip..] Examples: cabal install Package in the current directory cabal install foo Package from the hackage server cabal install foo-1.0 Specific version of a package cabal install 'foo < 2' Constrained package version From nomeata at debian.org Mon Sep 7 14:04:59 2009 From: nomeata at debian.org (Joachim Breitner) Date: Mon Sep 7 13:44:15 2009 Subject: [Haskell-cafe] haskelldb and Debian Message-ID: <1252346699.6234.31.camel@localhost> Hi Haskell-DB-interested people, we are still on our way to get the Haskell coverage on Debian back in a good shape. One of the open issues is haskelldb, haskelldb-dynamic and haskelldb-hsql-*. All of these are on 0.10 [1] and do not build with ghc-6.10. It seems that at least haskelldb itself has a 0.12 which does build, but the others do not. Thus, some questions: * Are the haskelldb-hsql-* and haskelldb-dynamic packages still maintained? If so, is there a release expected soon? If not, we will have to remove these from Debian. * Without the hsql-* packages, the haskelldb package itself is useless, correct? So we need to package the hdbc series. Are these maintained actively? * Anything else to consider? Greetings, Joachim [1] http://packages.debian.org/search?suite=sid&arch=any&searchon=sourcenames&keywords=haskelldb -- Joachim "nomeata" Breitner Debian Developer nomeata@debian.org | ICQ# 74513189 | GPG-Keyid: 4743206C JID: nomeata@joachim-breitner.de | http://people.debian.org/~nomeata -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/d136a36d/attachment-0001.bin From almeidaraf at gmail.com Mon Sep 7 15:21:08 2009 From: almeidaraf at gmail.com (Rafael Cunha de Almeida) Date: Mon Sep 7 15:01:38 2009 Subject: [Haskell-cafe] ANNOUNCE: Palindromes 0.1 In-Reply-To: References: Message-ID: <4AA55D24.1090205@gmail.com> Johan Jeuring wrote: > Palindromes > ============================================== > > Palindromes is a package for finding palindromes in files. > > Visit the homepage > > http://www.jeuring.net/Palindromes/ > A few options are not working well: $ ./palindromes --h ********************* * Palindrome Finder * ********************* palindromes: --h: openFile: does not exist (No such file or directory) $ cat f socorram-me subi no onibus em marrocos $ ./palindromes -tl f ********************* * Palindrome Finder * ********************* Usage: palindrome [command-line-options] input-file The following options are available: --h: This message -p : Print the longest palindrome (default) -ps: Print the longest palindrome around each position in the input -l : Print the length of the longest palindrome -ls: Print the length of the longest palindrome around each position in the input -t : Print the longest palindrome ignoring case, spacing and punctuation -tl: Print the length of the longest text palindrome $ From dave at zednenem.com Mon Sep 7 15:38:37 2009 From: dave at zednenem.com (David Menendez) Date: Mon Sep 7 15:17:42 2009 Subject: [Haskell-cafe] Re: HList and Type signatures / synonyms In-Reply-To: References: <1252284227-sup-8018@javelin> Message-ID: <49a77b7a0909071238n4e362acdu449e6a8d3f5484ec@mail.gmail.com> 2009/9/6 G?nther Schmidt : > > I keep reading in and processing data in an accumulating way, ie. lets say I > have a DB table (don't take this literally please, just an example), into > in-memory records of type > > data MyRecord = MyRecord { > ? ? ? ?name :: String, > ? ? ? ?birthDate :: LocalDate} > > in a second step I read in Gender information so now I'd need an extended > Record > > data MyRecord = MyRecord { > ? ? ? ?name :: String, > ? ? ? ?birthDate :: LocalDate, > ? ? ? ?gender :: Gender } > > and so on for another 12 times. > > In other words I need to extend the record. > > I had been using tuples, ie: > > ? ? ? ?(String, LocalDate) -> Gender -> (String, LocalDate, Gender) > > > but after 6 or so *extensions* things get a tad messy. > So I wonder if there is a more simple way to do this, ie to *extend* the > *type* signatures of extend records without such a lot of typing. Do you actually need the intermediate data? More specifically, do you need the data to be partial records? One simple way to represent a partial record is a function which takes the missing fields as arguments and returns the complete record, i.e., a constructor like MyRecord :: String -> LocalDate -> Gender -> MyRecord. So a partial result with the name filled in would have type LocalDate -> Gender -> MyRecord. More specifically, if the computations which produce the fields are described using a monad or applicative functor, e.g., getName :: Process String, you can just use <$> and <*> to glue them together. MyRecord <$> getName <*> getDate <*> getGender Or, if your process abstraction is a monad, you can do more complex operations. do name <- getName date <- getDate gender <- getGender name date return $ MyRecord name date gender Instead of constructing intermediate records, all the data is kept in variables until the record is complete. -- Dave Menendez From jgbailey at gmail.com Mon Sep 7 15:51:15 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Mon Sep 7 15:30:40 2009 Subject: [Haskell-cafe] haskelldb and Debian In-Reply-To: <1252346699.6234.31.camel@localhost> References: <1252346699.6234.31.camel@localhost> Message-ID: Joachim, I am maintaing the haskelldb package and it is definitely alive and well. I don't have a Debian install to test on, but I am glad to help get things compiling. See my detailed answers below: On Mon, Sep 7, 2009 at 11:04 AM, Joachim Breitner wrote: > > * Are the haskelldb-hsql-* and haskelldb-dynamic packages still > maintained? If so, is there a release expected soon? If not, we will > have to remove these from Debian. > These are not maintained any more. > * Without the hsql-* packages, the haskelldb package itself is useless, > correct? So we need to package the hdbc series. Are these maintained > actively? > Yes, the haskelldb-hdbc is still maintained and will continue to be as much as I am able. I belive I updated at least haskelldb-hdbc and haskelldb-hdbc-postgres to work with the 2.0 release of HDBC. Like I said, I don't have a Debian install readily accessible to build these but I am glad to help. If need be, I am sure I can get a VM image and build myself but finding the time coudl be hard. > * Anything else to consider? > > I guess just making sure haskelldb-hdbc and haskelldb-hdbc-postgres builds against the latest haskell platform release. Justin p.s. Please send replies only to haskelldb-users. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/2f450e4e/attachment.html From johanj at cs.uu.nl Mon Sep 7 16:11:34 2009 From: johanj at cs.uu.nl (Johan Jeuring) Date: Mon Sep 7 15:50:41 2009 Subject: [Haskell-cafe] ANNOUNCE: Palindromes 0.1 In-Reply-To: <79DF089F-2308-4DB7-A1BA-03E8BAA2DD8D@cs.uu.nl> References: <4AA55D24.1090205@gmail.com> <79DF089F-2308-4DB7-A1BA-03E8BAA2DD8D@cs.uu.nl> Message-ID: <37F22585-7FE2-4F75-973B-695F8A65C769@cs.uu.nl> On 07 Sep 2009, at 21:21, Rafael Cunha de Almeida wrote: > Johan Jeuring wrote: >> Palindromes >> ============================================== >> >> Palindromes is a package for finding palindromes in files. >> >> Visit the homepage >> >> http://www.jeuring.net/Palindromes/ >> > > A few options are not working well: Thanks. Both errors have been corrected in version 0.1.1. And I moved it from category Algorithm to category Algorithms. -- Johan > $ ./palindromes --h > ********************* > * Palindrome Finder * > ********************* > palindromes: --h: openFile: does not exist (No such file or directory) > $ cat f > socorram-me subi no onibus em marrocos > $ ./palindromes -tl f > ********************* > * Palindrome Finder * > ********************* > Usage: > > palindrome [command-line-options] input-file > > The following options are available: > --h: This message > -p : Print the longest palindrome (default) > -ps: Print the longest palindrome around each position in the input > -l : Print the length of the longest palindrome > -ls: Print the length of the longest palindrome around each position > in the input > -t : Print the longest palindrome ignoring case, spacing and > punctuation > -tl: Print the length of the longest text palindrome > $ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From magicloud.magiclouds at gmail.com Mon Sep 7 21:51:51 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon Sep 7 21:30:58 2009 Subject: [Haskell-cafe] Re: How to generate the .chi file for c2hs? In-Reply-To: <3bd412d40909070145s78e3a65cl5e336e3ac4fae6e9@mail.gmail.com> References: <3bd412d40909070145s78e3a65cl5e336e3ac4fae6e9@mail.gmail.com> Message-ID: <3bd412d40909071851v1c07ef3bxe6b4466775728339@mail.gmail.com> Hum, seems like the c2hs in gtk2hs is a non-standard version, and the chi it gives could not be used by c2hs (nor can standard c2hs used in gtk2hs's compiling).... On Mon, Sep 7, 2009 at 4:45 PM, Magicloud Magiclouds wrote: > Hi, > ?I want to make a binding of a gtk function, which returns a X11 type. > ?gtk2hs is made by c2hs, which is OK to give me the .chi file. Well, > X11 is not. So if I make my binding c2hs style, I have to make a .chi > file for X11 myself. > ?How to do it? > > -- > ??????? > ??????? > -- ??????? ??????? From midfield at gmail.com Mon Sep 7 22:06:09 2009 From: midfield at gmail.com (Ben) Date: Mon Sep 7 21:45:13 2009 Subject: [Haskell-cafe] hmatrix on os x Message-ID: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> hello -- i've been having a heck of a time installing hmatrix on mac os x. i've seen the help pages including http://mit.edu/harold/Public/easyVisionNotes.html but they haven't helped me. my setup is haskell platform 2009.2.0.2 (ghc 6.10.4) os x 10.5 macports -- i've tried installing gsl and gsl-devel to no avail. i've tried cabal install with various options, to no avail. has anyone else have luck with this? best, ben From lazycat.manatee at gmail.com Mon Sep 7 22:03:04 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Mon Sep 7 21:47:30 2009 Subject: [Haskell-cafe] How to use Template Haskell build Map? Message-ID: <87ws4auraf.fsf@ubuntu.domain> Hi all, I have below instances: instance PageViewState DiredViewState where instance PageViewState StringViewState where I can use Language.Haskell.Exts.Parser scan above instances got list: typeList :: [Type] typeList = [TyCon (UnQual (Ident "DiredViewState")),TyCon (UnQual (Ident "DiredViewState"))] So question is how to use Template Haskell and above `typeList` build below `Map` at compile-time? tagmap = M.fromList [(typeIdOf StringViewState, Exists (Dict :: PageViewStateDict StringViewState)) ,(typeIdOf DiredViewState, Exists (Dict :: PageViewStateDict DiredViewState))] Thanks! -- Andy From wasserman.louis at gmail.com Mon Sep 7 22:08:34 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Mon Sep 7 21:47:58 2009 Subject: [Haskell-cafe] Deconstructing types Message-ID: Yo, I don't know a thing about SYB, Data.Data, or Data.Typeable, mostly because I'm an efficiency fanatic. Nevertheless, I'd like to know whether or not there's a way to deconstruct a (mostly) arbitrary type, into tuples, unions, etc. using this framework. Any thoughts? Louis Wasserman wasserman.louis@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090907/8159497f/attachment.html From maydwell at gmail.com Mon Sep 7 23:34:22 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Mon Sep 7 23:13:26 2009 Subject: Fwd: [Haskell-cafe] Native windowing for glut applications on OS X. In-Reply-To: References: <6BD93A0B-7DEF-4C91-948F-34C645C89DD1@ece.cmu.edu> Message-ID: I just realized that I only replied to Brandon. Sorry about that :) ---------- Forwarded message ---------- From: Lyndon Maydwell Date: Sat, Sep 5, 2009 at 4:22 PM Subject: Re: [Haskell-cafe] Native windowing for glut applications on OS X. To: "Brandon S. Allbery KF8NH" I installed opengl via macports. Can I adjust my path somehow so that it prefers the native libraries? On Sat, Sep 5, 2009 at 8:57 AM, Brandon S. Allbery KF8NH wrote: > On Sep 4, 2009, at 03:13 , Lyndon Maydwell wrote: >> >> I recently updated glut through cabal to version GLUT-2.2.1.0, and >> where once I had native windowing, now I can only seem to use X11. >> >> Does anyone know how to use native windowing? > > > Do you use Fink or MacPorts? ?Check for OpenGL libraries installed via > those; they're probably shadowing the native libraries. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university ? ?KF8NH > > > From drcygnus at gmail.com Tue Sep 8 01:22:18 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Tue Sep 8 01:01:23 2009 Subject: [Haskell-cafe] ANNOUNCE: dbmigrations 0.1 Message-ID: dbmigrations is: A library and program for the creation, management, and installation of schema updates (called migrations) for a relational database. In particular, this package lets the migration author express explicit dependencies between migrations and the management tool automatically installs or reverts migrations accordingly, using transactions for safety. This package is written to support any HDBC-supported database, although at present only PostgreSQL is fully supported. To get started, see the included README and MOO.TXT files and the usage output for the "moo" command. Get it from Hackage: http://hackage.haskell.org/package/dbmigrations Or get the source with darcs: http://repos.codevine.org/dbmigrations/ This package is motivated by the need for a framework-independent, solid tool to manage database schema changes in a clean way without assuming a linear sequence of changes assumed by existing tools. dbmigrations lets you manage a forest of schema changes. Future work will include an hscurses-based tool to visualize and manipulate available migrations and their dependencies and support for other database engines. Please don't hesitate to send patches, feedback, and criticism directly to me at drcygnus AT gmail DOT com. I'd like to say thanks to Josh Hoyt and Jason Dagit for suggesting improvements, providing support, and showing me how beautiful Haskell is. Thanks! Enjoy! -- Jonathan Daugherty From leather at cs.uu.nl Tue Sep 8 02:34:27 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Sep 8 02:13:51 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: References: Message-ID: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> > I don't know a thing about SYB, Data.Data, or Data.Typeable, mostly because > I'm an efficiency fanatic. Nevertheless, I'd like to know whether or not > there's a way to deconstruct a (mostly) arbitrary type, into tuples, unions, > etc. using this framework. Any thoughts? > You can use the Template Haskell deriving in EMGM to get that structure pretty efficiently. http://www.cs.uu.nl/wiki/GenericProgramming/EMGM http://hackage.haskell.org/package/emgm The obligatory question is: why do you want it? Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/1202abc8/attachment.html From apfelmus at quantentunnel.de Tue Sep 8 04:27:49 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Sep 8 04:07:20 2009 Subject: [Haskell-cafe] Re: hmatrix on os x In-Reply-To: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> References: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> Message-ID: Ben wrote: > i've been having a heck of a time installing hmatrix on mac os x. > i've seen the help pages including > > http://mit.edu/harold/Public/easyVisionNotes.html > > but they haven't helped me. my setup is > > haskell platform 2009.2.0.2 (ghc 6.10.4) > os x 10.5 > macports -- i've tried installing gsl and gsl-devel to no avail. > > i've tried cabal install with various options, to no avail. has > anyone else have luck with this? Lapack and Gsl (or something combination thereof, I don't remember) is installed on MacOS X by default, but it's a framework called vecLib . You have to add ld-options: -framework vecLib to the hmatrix.cabal file and possibly remove the other library flags. I suggest nagging the maintainer about this. (Also, I had to remove and Intel specific opcode when compiling on PowerPC.) Regards, apfelmus -- http://apfelmus.nfshost.com From jwlato at gmail.com Tue Sep 8 04:46:44 2009 From: jwlato at gmail.com (John Lato) Date: Tue Sep 8 04:25:49 2009 Subject: [Haskell-cafe] Re: Looking for a new HWN editor Message-ID: <9979e72e0909080146k24a9decdn1f8c7e0efc969709@mail.gmail.com> I'd just like to say a big "Thank you" to Brent for his service as the HWN editor. I appreciate it very much and always look forward to HWN. Thanks for all your work, Brent. Cheers, John > > Message: 11 > Date: Sat, 5 Sep 2009 17:26:08 -0400 > From: Brent Yorgey > Subject: [Haskell-cafe] Looking for a new HWN editor > > Hi all, > > As you probably know, I've been the editor of the Haskell Weekly News > for a little over a year now, and I've decided that it's time for me > to move on to other things. ?So, I'm looking for someone to volunteer > to take over as HWN editor. > > -Brent From mle+hs at mega-nerd.com Tue Sep 8 05:12:51 2009 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Tue Sep 8 04:52:09 2009 Subject: [Haskell-cafe] Failure to build curl bindings on alpha Message-ID: <20090908191251.db10e6fe.mle+hs@mega-nerd.com> Hi all, I am the Debian Maintainer of the haskell curl bindings which is failing to build on the alpha CPU with the following error: [7 of 8] Compiling Network.Curl.Easy ( Network/Curl/Easy.hs, dist/build/Network/Curl/Easy.o ) Network/Curl/Easy.hs:218:0: On Alpha, I can only handle 32 bytes of non-floating-point arguments to foreign export dynamic When checking declaration: foreign import ccall safe "wrapper" mkProgress :: ProgressFunction -> IO (FunPtr ProgressFunction) Network/Curl/Easy.hs:221:0: On Alpha, I can only handle 32 bytes of non-floating-point arguments to foreign export dynamic When checking declaration: foreign import ccall safe "wrapper" mkDebugFun :: DebugFunctionPrim -> IO (FunPtr DebugFunctionPrim) The GHC version is 6.10.4 and the full Debian build log is here: https://buildd.debian.org/fetch.cgi?&pkg=haskell-curl&ver=1.3.5-2&arch=alpha&stamp=1249232593&file=log I am correct to suspect that this is a bug in ghc rather than in haskell-curl? Any other useful clues or information? Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From thaldyron at gmail.com Tue Sep 8 05:57:10 2009 From: thaldyron at gmail.com (Peter Robinson) Date: Tue Sep 8 05:36:35 2009 Subject: [Haskell-cafe] High memory consumption of "print" Message-ID: The following toy program consumes either 25MB or 70MB, depending on whether the line print "done" is a comment or code. (Using only 1 OS thread increases memory consumption to 130MB when the print is active vs 25MB when inactive.) What am I doing wrong? --------------------- module Main where import Control.Concurrent import Control.Concurrent.STM import Control.Concurrent.STM.TChan import System.Environment import Control.Applicative main = do n <- read . head <$> getArgs tvar <- newTVarIO 0 tchan <- newTChanIO tids <- sequence [ forkIO (test tchan tvar i) | i <- [1..10^n] ] waitForAll tchan $! length tids where waitForAll _ 0 = return () waitForAll tchan len = do atomically $ readTChan tchan waitForAll tchan (len-1) test :: TChan () -> TVar Int -> Int -> IO () test tchan tvar i = do atomically $ do val <- readTVar tvar if val+1 == i then do writeTVar tvar i writeTChan tchan () else retry print "done" --------------------- ghc --make -O2 teststm.hs -threaded && ./teststm 4 +RTS -sstderr From DekuDekuplex at Yahoo.com Tue Sep 8 07:16:27 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Sep 8 06:55:54 2009 Subject: [Haskell-cafe] Re: [Haskell] Looking for a new HWN editor References: <20090905212608.GA379@seas.upenn.edu> <20090905233424.GA29650@seas.upenn.edu> Message-ID: On Sat, 5 Sep 2009 19:34:24 -0400, Brent Yorgey wrote: >On Sat, Sep 05, 2009 at 05:26:08PM -0400, Brent Yorgey wrote: >> Executive summary: >> >> * I'm looking for someone to take over as HWN editor >> * It is highly automated and doesn't take as much time as you might >> think (about 3-4 hours/week on average) >> * You DON'T need to be a Haskell guru >> * It is far from a thankless job and is a fun way to provide an >> appreciated service to the community! > >The position has been filled! More details to come. Wow! That was a quick decision! Most Haskell users probably didn't even have time to read the announcement before the position was filled; I certainly did not. Well, since this position has already been filled, there's probably not much that can be done (other than ask the new editor and hope that he/she is understanding), but just to give a fair opportunity to all Haskell users, if the editor changes again, it may be helpful at least to give everybody an opportunity to read the announcement and apply for the position. Just my two cents.... -- Benjamin L. Russell -- 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^ From bugfact at gmail.com Tue Sep 8 09:31:13 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 8 09:10:16 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 Message-ID: I tried the "cabal install" command on Windows 7, and I had to run it with administrative privileges, otherwise I got access denied (it failed to create the Haskell folder in C:\Program Files) Not sure if this is also the case on Vista. Is this the intended behavior? From vanenkj at gmail.com Tue Sep 8 09:45:56 2009 From: vanenkj at gmail.com (John Van Enk) Date: Tue Sep 8 09:25:00 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: Message-ID: Might it make sense to try and get the concept of "global" and "user" working in Windows? (It may already, but I noticed that the default seems to be global.") I don't know what technical challenges there are, but the ApplicationData directory (or AppData, or whatever) seems like a good place to stick user cabal packages. /jve On Tue, Sep 8, 2009 at 9:31 AM, Peter Verswyvelen wrote: > I tried the "cabal install" command on Windows 7, and I had to run it > with administrative privileges, otherwise I got access denied (it > failed to create the Haskell folder in C:\Program Files) > > Not sure if this is also the case on Vista. > > Is this the intended behavior? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/2efde0c4/attachment.html From gour at gour-nitai.com Tue Sep 8 10:11:57 2009 From: gour at gour-nitai.com (Gour) Date: Tue Sep 8 09:47:01 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: dbmigrations 0.1 References: Message-ID: <877hw9zfte.fsf@gaura-nitai.no-ip.org> >>>>> "Jonathan" == Jonathan Daugherty writes: Jonathan> This package is motivated by the need for a Jonathan> framework-independent, solid tool to manage database schema Jonathan> changes in a clean way without assuming a linear sequence of Jonathan> changes assumed by existing tools. dbmigrations lets you Jonathan> manage a forest of schema changes. Thank you for this package! It is something which Haskell community was really missing. Looking forward to make use of it. Sincerely, Gour -- Gour | Hlapi?ina, Croatia | GPG key: F96FF5F6 --------------------------------------------------------------------------- -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/c8a60dbc/attachment.bin From bugfact at gmail.com Tue Sep 8 10:17:20 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 8 09:56:24 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: Message-ID: Ouch, right, I forgot the default is global. It works fine with cabal install --user. And of course I could have edited the default config file, setting user-install: True Well, maybe for newbies this might be a bit confusing. Typically, under Windows Vista or 7 when you try to install something that requires admin rights, you get a popup window asking if it's okay to do so. Would be great to have this support built into Cabal? On Tue, Sep 8, 2009 at 3:45 PM, John Van Enk wrote: > Might it make sense to try and get the concept of "global" and "user" > working in Windows? (It may already, but I noticed that the default seems to > be global.") > > I don't know what technical challenges there are, but the ApplicationData > directory (or AppData, or whatever) seems like a good place to stick user > cabal packages. > > /jve > > On Tue, Sep 8, 2009 at 9:31 AM, Peter Verswyvelen wrote: >> >> I tried the "cabal install" command on Windows 7, and I had to run it >> with administrative privileges, otherwise I got access denied (it >> failed to create the Haskell folder in C:\Program Files) >> >> Not sure if this is also the case on Vista. >> >> Is this the intended behavior? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jeff at nokrev.com Tue Sep 8 10:58:01 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Tue Sep 8 10:37:24 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: Message-ID: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> On Tue, Sep 8, 2009 at 9:17 AM, Peter Verswyvelen wrote: > Ouch, right, I forgot the default is global. It works fine with cabal > install --user. And of course I could have edited the default config > file, setting user-install: True > > Well, maybe for newbies this might be a bit confusing. Yep, I agree. I'm not sure why Cabal defaults to --global on Windows, but I found it quite counter-intuitive having come from a Linux environment. I forgot about the different default for some time. Jeff Wheeler From doaitse at swierstra.net Tue Sep 8 11:33:28 2009 From: doaitse at swierstra.net (S. Doaitse Swierstra) Date: Tue Sep 8 11:12:31 2009 Subject: [Haskell-cafe] Ph.D position, Utrecht University, the Netherlands Message-ID: <12A039B4-7FE8-40A2-A09B-4E74FDA13123@swierstra.net> Subject: Ph.D position, Utrecht University, the Netherlands =================================================== Vacancy PhD student on Realizing Optimal Sharing in the Functional Language Implementations Utrecht University, The Netherlands. =================================================== Within the Software Technology group of the Information and Computing Sciences department of Utrecht University there is a vacancy for a PhD student to work on the efficient implementation of functional languages. The position is funded by NWO, the Netherlands Organization for Scientific Research. ----------------------------------------------------------------------------------------- Project summary: Lambda-calculus and term rewriting are models of computation lying at the basis of functional programming languages. Both possess syntactic meta-theories based on analyzing rewrite steps. Unfortunately, naive implementations are inefficient, since subterms are frequently copied. To overcome this problem in both theoretical systems and actual implementations, duplicate work is avoided by using graph-based term representations, in which identical subterms can be (but not always are) shared. The question arises whether graph-representations and their reductions that are optimal in a theoretical sense can also be practical from an implementer's point of view. However, so far it is unclear whether nice theoretical ideas combine well with existing implementation methods. The overall-goal of this project is to answer this question in a back-and-forth communication between theoretical concepts and practical realizations. Starting points are the recent work on the optimal Lambdascope implementation based on context sharing, and the Haskell implementation developed at Utrecht University. One of the open problems is whether the Lambdascope framework can be extended to efficiently represent sets of mutually recursive definitions. Another, whether global program analysis can discover where Lambdascope-based approaches solve problems due to insufficient sharing. If both questions can be solved, we want to combine Lambdascope-based implementations with conventional frameworks, and investigate how efficient the resulting implementations become. The unique combination of the theoretical depth from the Logic department and the implementation skills and compiler infrastructure from the Computer Science department make Utrecht University the optimal surroundings for such a project. ----------------------------------------------------------------------------------------- Project leaders are Prof.dr. Doaitse Swierstra and dr. Vincent van Oostrom (principal investigator). The project will be executed in close cooperation between * the Software Technology group (http://www.cs.uu.nl/wiki/Center) of the Information and Computing Sciences department (http://www.cs.uu.nl/ ) * and the Theoretical Philosophy group (http://www.uu.nl/EN/faculties/Humanities/research/researchinstitutes/zeno/research/theoreticalphilosophy/Pages/default.aspx ) of the Philosophy department (http://www.phil.uu.nl/), and between * the more practically oriented PhD student and * the more theory oriented postdoc. ----------------------------------------------------------------------------------------- Requirements: Master degree in Computer Science, Logic, or equivalent. Good knowledge of functional programming, and several advanced computer science techniques. Knowledge of lambda-calculus implementations, Haskell, and compiler construction will be useful. Both theory and software development based on this should appeal to you. Terms of employment: the PhD student should start as soon as possible, but no later than January 1, 2010. The position is for four years (after one year there will be an evaluation), full-time. Gross salary starts with ? 2042,-- per month in the first year and increases to ? 2612,-- in the fourth year of employment. The salary is supplemented with a holiday bonus of 8% and an end-of-year bonus of 3%. In addition we offer: a pension scheme, partially paid parental leave, facilities for child care, flexible employment conditions in which you may trade salary for vacation days or vice versa. Conditions are based on the Collective Employment Agreement of the Dutch Universities: http://www.vsnu.nl/Workstudy/Universities-as-employers-/Collective-Labour-Agreement.htm More information: * about the project can be found on http://www.cs.uu.nl/wiki/bin/view/Center/OptimalSharing * about the Software Technology group on http://www.cs.uu.nl/wiki/Center * about the Information and Computing Sciences department on http://www.cs.uu.nl/ * about this vacancy can be obtained from Doaitse Swierstra (doaitse@cs.uu.nl , +31 6 4613 6929). Send your application in pdf (or another non-proprietary format) to mailto:SciencePenO@uu.nl with a cc to mailto:doaitse@cs.uu.nl. on or before Sept 31, 2009. Mention vacancy nr 62910. _______________________________________________ St-staff mailing list St-staff@cs.uu.nl http://mail.cs.uu.nl/mailman/listinfo/st-staff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/838e7ccd/attachment.html From almeidaraf at gmail.com Tue Sep 8 12:01:23 2009 From: almeidaraf at gmail.com (Rafael Almeida) Date: Tue Sep 8 11:40:26 2009 Subject: [Haskell-cafe] Re: [Haskell] Looking for a new HWN editor In-Reply-To: References: <20090905212608.GA379@seas.upenn.edu> <20090905233424.GA29650@seas.upenn.edu> Message-ID: <6de6b1650909080901x565aa71di9c98aeecd1afe979@mail.gmail.com> On Tue, Sep 8, 2009 at 8:16 AM, Benjamin L.Russell wrote: > On Sat, 5 Sep 2009 19:34:24 -0400, Brent Yorgey > wrote: > >>On Sat, Sep 05, 2009 at 05:26:08PM -0400, Brent Yorgey wrote: >>> Executive summary: >>> >>> ? * I'm looking for someone to take over as HWN editor >>> ? * It is highly automated and doesn't take as much time as you might >>> ? ? think (about 3-4 hours/week on average) >>> ? * You DON'T need to be a Haskell guru >>> ? * It is far from a thankless job and is a fun way to provide an >>> ? ? appreciated service to the community! >> >>The position has been filled! ?More details to come. > > Wow! ?That was a quick decision! ?Most Haskell users probably didn't > even have time to read the announcement before the position was > filled; I certainly did not. > > Well, since this position has already been filled, there's probably > not much that can be done (other than ask the new editor and hope that > he/she is understanding), but just to give a fair opportunity to all > Haskell users, if the editor changes again, it may be helpful at least > to give everybody an opportunity to read the announcement and apply > for the position. > > Just my two cents.... > I don't think that's really necessary. I suppose there's no reason for more people to be editors if the demand is high. It could even eventually have its own articles and perhaps and bigger summaries about the threads. From wasserman.louis at gmail.com Tue Sep 8 13:06:02 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Tue Sep 8 12:45:25 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> Message-ID: Sean, The answer is, I'm working on a recently semi-released package called TrieMap. The objective of this package, building off of the work in this paper, is to automatically derive the type of a generalized trie for any algebraic type based on its algebraic representation. (I am working on writing up my methods for publication.) Of course, if I could get automatic access to the mechanisms of a type's constructors, I wouldn't even require users to describe the algebraic representation of their type... Louis Wasserman wasserman.louis@gmail.com On Tue, Sep 8, 2009 at 2:34 AM, Sean Leather wrote: > > >> I don't know a thing about SYB, Data.Data, or Data.Typeable, mostly >> because I'm an efficiency fanatic. Nevertheless, I'd like to know whether >> or not there's a way to deconstruct a (mostly) arbitrary type, into tuples, >> unions, etc. using this framework. Any thoughts? >> > > You can use the Template Haskell deriving in EMGM to get that structure > pretty efficiently. > > http://www.cs.uu.nl/wiki/GenericProgramming/EMGM > http://hackage.haskell.org/package/emgm > > The obligatory question is: why do you want it? > > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/681443b9/attachment.html From mf-hcafe-15c311f0c at etc-network.de Tue Sep 8 13:28:06 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Tue Sep 8 13:08:38 2009 Subject: [Haskell-cafe] Re: ForeignFunPtr In-Reply-To: References: <20090906133516.GD3384@yoyo> Message-ID: <20090908172806.GE3248@yoyo> You are right, I forgot about callbacks. freeHaskellFunPtr is only for Haskell functions packaged for usage by the foreign code. Example from the FFI specification, Section 5.4.2: type Compare = Int -> Int -> Bool foreign import ccall "wrapper" mkCompare :: Compare -> IO (FunPtr Compare) If you, say, x = mkCompare (<) and at some point decide x is not needed in your foreign code any more, it has to be freed by hand. This is the only case in which you are allowed to use freeHaskellFunPtr. The (much less interesting) case that I was thinking about, where FunPtr is used for foreign C functions, usually requires no finalization. ForeignPtr is used for foreign objects used by Haskell. The garbage collector (gc) can decide whether the object is still in use and, if it's not, finalize it. A Haskell function wrapped in a FunPtr is used in the foreign world. Haskell gc cannot be made responsible for finalizing it. In fact, (unless the foreign world has some gc of its own) there is no way for any compiler of deciding when to finalize at all. The programmer needs to decide this by calling freeHaskellFunPtr, just like she needs to decide when to free mallocked memory in C. Does that make more sense? Please kick me again if you are still not buying it. :-) cheers, matthias On Sun, Sep 06, 2009 at 02:53:52PM -0300, Maur??cio CA wrote: > To: haskell-cafe@haskell.org > From: Maur??cio CA > Date: Sun, 06 Sep 2009 14:53:52 -0300 > Subject: [Haskell-cafe] Re: ForeignFunPtr > > Isn't freeHaskellFunPtr a required finalization procedure? > > Maur?cio > >> the purpose of ForeignPtr is to attach a finalization procedure to the >> object behind the pointer. for example, you can have close called >> aimplicitly whenever the garbage collector finds you don't need a file >> handle any more. function pointers do not need finalization. >> >>> >>> We have ForeignPtr. Why isn't there a >>> corresponding ForeignFunPtr? >>> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** CLASSIFY > succeeds; success probability: 1.0000 pR: 5.6531 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 5.6531 Total > features in input file: 2752 > #0 (nonspam.css): features: 758386, hits: 2838587, prob: 1.00e+00, pR: > 5.65 #1 (spam.css): features: 1686574, hits: 3088399, prob: 2.22e-06, pR: > -5.65 > From leather at cs.uu.nl Tue Sep 8 13:54:19 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Sep 8 13:33:42 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> Message-ID: <3c6288ab0909081054i3eabf90w403b620e16002d5a@mail.gmail.com> > The answer is, I'm working on a recently semi-released package called > TrieMap. > > The objective of this package, building off of the work in this paper, > is to automatically derive the type of a generalized trie for any algebraic > type based on its algebraic representation. (I am working on writing up my > methods for publication.) > > Of course, if I could get automatic access to the mechanisms of a type's > constructors, I wouldn't even require users to describe the algebraic > representation of their type... Well, it's relatively easy to use Template Haskell to determine the structure of a datatype. Look in the "Generics" category on Hackage for a number of examples (e.g. emgm, regular, multirec) or see if the Derive package will do it for you. According to Neil Mitchell, you just need one example: http://www.cogsys.wiai.uni-bamberg.de/aaip09/aaip09_submissions/talk_mitchell.pdf I don't know if it's easy or even possible to capture a sum-of-products view from SYB. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/d6e4e2c2/attachment.html From wasserman.louis at gmail.com Tue Sep 8 14:01:59 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Tue Sep 8 13:41:21 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> Message-ID: Oh, geezzzzz. Wrong link. I meant http://portal.acm.org/citation.cfm?id=967471 . Louis Wasserman wasserman.louis@gmail.com On Tue, Sep 8, 2009 at 1:06 PM, Louis Wasserman wrote: > Sean, > > The answer is, I'm working on a recently semi-released package called > TrieMap. > > The objective of this package, building off of the work in this paper, > is to automatically derive the type of a generalized trie for any algebraic > type based on its algebraic representation. (I am working on writing up my > methods for publication.) > > Of course, if I could get automatic access to the mechanisms of a type's > constructors, I wouldn't even require users to describe the algebraic > representation of their type... > > Louis Wasserman > wasserman.louis@gmail.com > > > On Tue, Sep 8, 2009 at 2:34 AM, Sean Leather wrote: > >> >> >>> I don't know a thing about SYB, Data.Data, or Data.Typeable, mostly >>> because I'm an efficiency fanatic. Nevertheless, I'd like to know whether >>> or not there's a way to deconstruct a (mostly) arbitrary type, into tuples, >>> unions, etc. using this framework. Any thoughts? >>> >> >> You can use the Template Haskell deriving in EMGM to get that structure >> pretty efficiently. >> >> http://www.cs.uu.nl/wiki/GenericProgramming/EMGM >> http://hackage.haskell.org/package/emgm >> >> The obligatory question is: why do you want it? >> >> Sean >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090908/e2e7aab7/attachment.html From dan.doel at gmail.com Tue Sep 8 15:41:02 2009 From: dan.doel at gmail.com (Dan Doel) Date: Tue Sep 8 15:20:13 2009 Subject: [Haskell-cafe] ANNOUNCE: uvector-algorithms 0.2 Message-ID: <200909081541.03112.dan.doel@gmail.com> Greetings, It is my pleasure to announce version 0.2 of the uvector-algorithms package. The package so far has implementations of several sorting and selection algorithms for use on the mutable arrays from the uvector library, as well as combinators for applying them to immutable arrays. New developments in this version include: - A simple benchmarking program for testing the performance of the algorithms (it's what I use to measure them, but I only have one computer to run it on, so perhaps other folks might want to see how it works on their machine) - A testing program, written with quick check to verify properties of the algorithms - Several bugs found and fixed due to the above tests and using HPC to verify good program coverage - Combinators for Schwartzian transform - Reworking radix sort to be more amenable to optimization. It's now around twice as fast. - A Radix instance for strict pairs, and a radix sortBy - Merge sort is now slightly faster due to memcpy in uvector :) The library can be found at hackage: http://hackage.haskell.org/package/uvector-algorithms or in its darcs repository: http://code.haskell.org/~dolio/uvector-algorithms/ As always, I can be notified of any issues. Enjoy. -- Dan From daniil.elovkov at googlemail.com Tue Sep 8 15:44:40 2009 From: daniil.elovkov at googlemail.com (Daniil Elovkov) Date: Tue Sep 8 15:24:00 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> Message-ID: <4AA6B428.6020301@gmail.com> Eugene Kirpichov wrote: > > P.S. I tried to write up the difference between datatype and function > declarations in this respect, but my explanations turned into a mess, > so I erased them in the hope that someone will explain it better than > me. > Hello Eugene, I'll give it a try. In a non-constructive way: there seems to be nothing in common between those. In a constructive way: Datatype forall is called existential quantification, forall in function signature is called first-class polymorphism, if I'm not mistaken. Existential is a perfect word, because it really is data S = exists a. Show a => S [a]. The meaning is that within a given instance of S there lies some value of some particular type (a type exists). It's not any, it's some particular type. It can be either [Int], or forall a. Show a => [a], for example [], or some other type, but it exists. With first-class polymorphism there's nothing that lies somewhere. Nothing of some particular type. The function whose type is forall ... is applicable to any type within the given bounds. And even this function itself doesn't lie anywhere, since it's a parameter. I think it can be considered just a way to impact the scope of type parameters within the signature, roughly speaking. Not sure it this is useful, but data S = ?x. S x f :: ?x. x -> (?y. y -> t) -> t and just in case, the data constructor S doesn't use first-class polymorphism since its type is just S :: ?x. x -> S I know that you perfectly understand it, I just tried to word it :) -- Daniil Elovkov From gue.schmidt at web.de Tue Sep 8 16:48:15 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Tue Sep 8 16:27:32 2009 Subject: [Haskell-cafe] Takusen: *** Exception: readUTF8Char: illegal UTF-8 character 252 Message-ID: Hi all, I'm trying to use Takusen ODBC on Windows. I'm using a German WinXP Pro and try to connect to an MS Access database. As soon as I try to do some inserts the above mentioned exception shows up. Does anyone know a work around for this? G?nther From lemming at henning-thielemann.de Tue Sep 8 17:54:30 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Sep 8 17:33:45 2009 Subject: [Haskell-cafe] ANN: fclabels-0.4.0 - First class accessor labels. In-Reply-To: References: Message-ID: On Fri, 4 Sep 2009, Sebastiaan Visser wrote: > Hello all, > > There are more package around that serve the same purpose (like the Lenses > package which was uploaded a few days ago), but I'm convinced the simplicity > and elegance of fclabels will strike you all. ;-) How does it compare to data-accessor and data-accessor-template? From ryani.spam at gmail.com Tue Sep 8 19:27:13 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Sep 8 19:06:15 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <4AA6B428.6020301@gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> <4AA6B428.6020301@gmail.com> Message-ID: <2f9b2d30909081627h5ed7113eq4a35db6512b70c55@mail.gmail.com> On Tue, Sep 8, 2009 at 12:44 PM, Daniil Elovkov wrote: > Existential is a perfect word, because it really is > data S = exists a. Show a => S [a]. If you were going to make "exists" a keyword, I think you would write it like this: > data S = ConsS (exists a. Show a => [a]) To contrast: > data GhcS = forall a. Show a => ConsGhcS [a] > data T = ConsT (forall a. Show a => [a]) This gives these constructors: > ConsS :: forall a. (Show a => [a] -> S) > ConsGhcS :: forall a. (Show a => [a] -> S) -- same > ConsT :: (forall a. Show a => [a]) -> T -- higher-rank type! T isn't very useful, it has to be able to provide a list of *any* instance of Show, so probably [] is all you get. But you can do something similar: > data N = ConsN (forall a. Num a => [a]) Now you get > ConsN :: (forall a. Num a => [a]) -> N and you can legally do > n = ConsN [1,2,3] since [1,2,3] == [fromInteger 1, fromInteger 2, fromInteger 3] :: forall a. Num a => [a] Conceptually, an "S" holds *some* instance of Show, so the user of a constructed S can only use methods of Show; they don't have any further knowledge about what is inside. But a N holds *any* instance of Num, so the user of the data can pick which one they want to use; Integer, Rational, Double, some (Expr Int) instance made by an embedded DSL programmer, etc. Of course, there are some ways to recover information about what types are inside the existential using GADTs or Data.Dynamic. But those need to be held in the structure itself. For example: > data Typ a where > TBool :: Typ Bool > TInt :: Typ Int > TFunc :: Typ a -> Typ b -> Typ (a -> b) > TList :: Typ a -> Typ [a] > TPair :: Typ a -> Typ b -> Typ (a,b) Now you can create an existential type like this: > data Something = forall a. Something (Typ a) a and you can extract the value if the type matches: > data TEq a b where Refl :: TEq a a > extract :: forall a. Typ a -> Something -> Maybe a > extract ta (Something tb vb) = do > Refl <- eqTyp ta tb > return vb This desugars into ] extract ta (Something tb vb) = ] eqTyp ta tb >>= \x -> ] case x of ] Refl -> return vb ] _ -> fail "pattern match failure" which, since Refl is the only constructor for TEq, simplifies to ] extract ta (Something tb vb) = eqTyp ta tb >>= \Refl -> Just vb The trick is that the pattern match on Refl proves on the right-hand side that "a" is the same type as that held in the existential, so we have successfully extracted information from the existential and can return it to the caller without breaking encapsulation. Here's the helper function eqTyp; it's pretty mechanical: > eqTyp :: Typ a -> Typ b -> Maybe (TEq a b) > eqTyp TBool TBool = return Refl > eqTyp TInt TInt = return Refl > eqTyp (TFunc a1 b1) (TFunc a2 b2) = do > Refl <- eqTyp a1 a2 > Refl <- eqTyp b1 b2 > return Refl > eqTyp (TList a1) (TList a2) = do > Refl <- eqTyp a1 a2 > return Refl > eqTyp (TPair a1 b1) (TPair a2 b2) = do > Refl <- eqTyp a1 a2 > Refl <- eqTyp b1 b2 > return Refl > eqTyp _ _ = Nothing Here's a simple test: > test = Something (TFun TInt TBool) (\x -> x == 3) > runTest = fromJust (extract (TFun TInt TBool) test) 5 runTest == False, of course. -- ryan From velman at cox.net Tue Sep 8 19:57:53 2009 From: velman at cox.net (John Velman) Date: Tue Sep 8 19:36:56 2009 Subject: [Haskell-cafe] problems with HOC install from svn Message-ID: <20090908235753.GA244@cox.net> I'm unable to build HOC from the svn read-only checkout. Here are some details of what I'm doing. I'm running OS X 10.5.8 on an intel iMac with Xcode is 3.1.3. Haskel and Cabal are from the Haskel platform, haskell-platform-2009.2.0.2-i386.dmg I got Parsec 3.0 from Hackage. I checked out HOC using the svn command at http://code.google.com/p/hoc/source/checkout and checked out revision 411. Configure goes OK except for the complaint: ---- Setup.hs:1:0: Warning: In the use of `defaultUserHooks' (imported from Distribution.Simple): Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless you need Cabal-1.2 compatibility in which case you must stick with defaultUserHooks" ---- But when I try to build, I get, after a bunch of apparently successful things: ----------- Loading package binary-0.5.0.1 ... : can't load .so/.DLL for: HSbinary-0.5.0.1 (dlopen(libHSbinary-0.5.0.1.dylib, 9): image not found) ----------- I certainly can't find libHSbinary... of any version on my computer, dylib or not. Tried looking in the /Library/Frameworks/GHC.Framework stuff, also did a find . -iname "*libHS* and found libHSGLFW..., libHSparsec-3.0.0. (also tried this in my home directory). What is this, and how do I get it? Best, John Velman From rmm-haskell at z.odi.ac Tue Sep 8 20:35:54 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Sep 8 20:15:00 2009 Subject: [Haskell-cafe] problems with HOC install from svn In-Reply-To: <20090908235753.GA244@cox.net> References: <20090908235753.GA244@cox.net> Message-ID: It sounds like it's looking for the binary package -- you should install it using cabal, e.g. private (per-user) install: cabal update cabal install binary global (system-wide) install: sudo cabal update sudo cabal install --global binary -Ross On Sep 8, 2009, at 7:57 PM, John Velman wrote: > I'm unable to build HOC from the svn read-only checkout. Here are > some > details of what I'm doing. > > I'm running OS X 10.5.8 on an intel iMac with Xcode is 3.1.3. > > Haskel and Cabal are from the Haskel platform, > haskell-platform-2009.2.0.2-i386.dmg > > I got Parsec 3.0 from Hackage. > > I checked out HOC using the svn command at > http://code.google.com/p/hoc/source/checkout > > and checked out revision 411. > > Configure goes OK except for the complaint: > ---- > Setup.hs:1:0: > Warning: In the use of `defaultUserHooks' > (imported from Distribution.Simple): > Deprecated: "Use simpleUserHooks or autoconfUserHooks, > unless you need Cabal-1.2 > compatibility in which case you must stick with > defaultUserHooks" > ---- > > But when I try to build, I get, after a bunch of apparently successful > things: > ----------- > Loading package binary-0.5.0.1 ... : can't > load .so/.DLL for: HSbinary-0.5.0.1 (dlopen > (libHSbinary-0.5.0.1.dylib, 9): image not found) > ----------- > > I certainly can't find libHSbinary... of any version on my computer, > dylib > or not. Tried looking in the /Library/Frameworks/GHC.Framework > stuff, also > did a find . -iname "*libHS* and found libHSGLFW..., > libHSparsec-3.0.0. > > (also tried this in my home directory). > > What is this, and how do I get it? > > Best, > > John Velman > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From velman at cox.net Tue Sep 8 22:54:08 2009 From: velman at cox.net (John Velman) Date: Tue Sep 8 22:33:11 2009 Subject: [Haskell-cafe] problems with HOC install from svn In-Reply-To: References: <20090908235753.GA244@cox.net> Message-ID: <20090909025408.GB244@cox.net> Thanks. Now I do have libHSbinary-0.5.0.1.a in /usr/local/lib, but apparently not the dylib version. Tomorrow I'll look further. Perhaps there are some options to produce dylib libraries. I've used Haskell on Linux some time ago (but not Cabal), and have been Xcoding with Objective C for a year or so now, but never tried this before. I am interested in HOC, but I've obviously got a lot to learn. Thanks again, John Velman On Tue, Sep 08, 2009 at 08:35:54PM -0400, Ross Mellgren wrote: > It sounds like it's looking for the binary package -- you should install it > using cabal, e.g. > > private (per-user) install: > cabal update > cabal install binary > > global (system-wide) install: > sudo cabal update > sudo cabal install --global binary > > -Ross > > On Sep 8, 2009, at 7:57 PM, John Velman wrote: > >> I'm unable to build HOC from the svn read-only checkout. Here are some >> details of what I'm doing. >> >> I'm running OS X 10.5.8 on an intel iMac with Xcode is 3.1.3. >> >> Haskel and Cabal are from the Haskel platform, >> haskell-platform-2009.2.0.2-i386.dmg >> >> I got Parsec 3.0 from Hackage. >> >> I checked out HOC using the svn command at >> http://code.google.com/p/hoc/source/checkout >> >> and checked out revision 411. >> >> Configure goes OK except for the complaint: >> ---- >> Setup.hs:1:0: >> Warning: In the use of `defaultUserHooks' >> (imported from Distribution.Simple): >> Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless >> you need Cabal-1.2 >> compatibility in which case you must stick with >> defaultUserHooks" >> ---- >> >> But when I try to build, I get, after a bunch of apparently successful >> things: >> ----------- >> Loading package binary-0.5.0.1 ... : can't load .so/.DLL >> for: HSbinary-0.5.0.1 (dlopen(libHSbinary-0.5.0.1.dylib, 9): image not >> found) >> ----------- >> >> I certainly can't find libHSbinary... of any version on my computer, dylib >> or not. Tried looking in the /Library/Frameworks/GHC.Framework stuff, >> also >> did a find . -iname "*libHS* and found libHSGLFW..., libHSparsec-3.0.0. >> >> (also tried this in my home directory). >> >> What is this, and how do I get it? >> >> Best, >> >> John Velman >> >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe From rmm-haskell at z.odi.ac Tue Sep 8 23:44:36 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Sep 8 23:23:40 2009 Subject: [Haskell-cafe] problems with HOC install from svn In-Reply-To: <20090909025408.GB244@cox.net> References: <20090908235753.GA244@cox.net> <20090909025408.GB244@cox.net> Message-ID: <645FB161-6AE2-48C4-968D-A302C0EE69B4@z.odi.ac> I have binary-0.5 not binary-0.5.0.1, but it doesn't have any dylibs. Moreover, I was under the impression that GHC does not yet support shared libraries like those, so I'm not sure why it would be looking for one. I can't really speculate, maybe more of the build output might help? -Ross On Sep 8, 2009, at 10:54 PM, John Velman wrote: > > Thanks. Now I do have libHSbinary-0.5.0.1.a in /usr/local/lib, > but apparently not the dylib version. Tomorrow I'll look further. > Perhaps there are some options to produce dylib libraries. I've used > Haskell on Linux some time ago (but not Cabal), and have been > Xcoding with > Objective C for a year or so now, but never tried this before. I am > interested in HOC, but I've obviously got a lot to learn. > > Thanks again, > > John Velman > > > > On Tue, Sep 08, 2009 at 08:35:54PM -0400, Ross Mellgren wrote: >> It sounds like it's looking for the binary package -- you should >> install it >> using cabal, e.g. >> >> private (per-user) install: >> cabal update >> cabal install binary >> >> global (system-wide) install: >> sudo cabal update >> sudo cabal install --global binary >> >> -Ross >> >> On Sep 8, 2009, at 7:57 PM, John Velman wrote: >> >>> I'm unable to build HOC from the svn read-only checkout. Here are >>> some >>> details of what I'm doing. >>> >>> I'm running OS X 10.5.8 on an intel iMac with Xcode is 3.1.3. >>> >>> Haskel and Cabal are from the Haskel platform, >>> haskell-platform-2009.2.0.2-i386.dmg >>> >>> I got Parsec 3.0 from Hackage. >>> >>> I checked out HOC using the svn command at >>> http://code.google.com/p/hoc/source/checkout >>> >>> and checked out revision 411. >>> >>> Configure goes OK except for the complaint: >>> ---- >>> Setup.hs:1:0: >>> Warning: In the use of `defaultUserHooks' >>> (imported from Distribution.Simple): >>> Deprecated: "Use simpleUserHooks or autoconfUserHooks, >>> unless >>> you need Cabal-1.2 >>> compatibility in which case you must stick with >>> defaultUserHooks" >>> ---- >>> >>> But when I try to build, I get, after a bunch of apparently >>> successful >>> things: >>> ----------- >>> Loading package binary-0.5.0.1 ... : can't >>> load .so/.DLL >>> for: HSbinary-0.5.0.1 (dlopen(libHSbinary-0.5.0.1.dylib, 9): image >>> not >>> found) >>> ----------- >>> >>> I certainly can't find libHSbinary... of any version on my >>> computer, dylib >>> or not. Tried looking in the /Library/Frameworks/GHC.Framework >>> stuff, >>> also >>> did a find . -iname "*libHS* and found libHSGLFW..., >>> libHSparsec-3.0.0. >>> >>> (also tried this in my home directory). >>> >>> What is this, and how do I get it? >>> >>> Best, >>> >>> John Velman >>> >>> >>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe From jgbailey at gmail.com Wed Sep 9 00:19:02 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Tue Sep 8 23:58:22 2009 Subject: [Haskell-cafe] HList and Type signatures / synonyms In-Reply-To: References: Message-ID: Gunther, I've got a little experience with HList - read below. 2009/9/6 G?nther Schmidt : > Hi, > > I keep accumulating values and right now use plain tuples for that. I end up > with a 12 element tuple and things are a bit messy. > > I'd like to use extensible Records from HList instead, thing is I'd like to > keep putting type signatures in my code. As it turns out that seems to be > where it gets messy with HList. > There is a template haskell function called "makeLabel" that can generate the boilerplate for you. If you are comfortable not seeing all the type definitions, it might do the trick. > PS: Does anyone know why there are Label-n modules in HList, and which one > to use? > I don't but Label4 works for me. Justin From alistair at abayley.org Wed Sep 9 01:06:24 2009 From: alistair at abayley.org (Alistair Bayley) Date: Wed Sep 9 00:45:25 2009 Subject: [Haskell-cafe] Takusen: *** Exception: readUTF8Char: illegal UTF-8 character 252 In-Reply-To: References: Message-ID: <79d7c4980909082206p272fac4bu5e4200acde59982e@mail.gmail.com> Hello G?nther, It looks like Access is not using UTF8 as its text encoding. I have Access at work, so I can look into this at some point. The ODBC code assumes the encoding is always UTF8. For some drivers (e.g. PostgreSQL) you must configure the ODBC driver correctly to provide UTF8. Does Takusen work with Access for US7ASCII text? If not, this would suggest that Access is using UTF16 (which is common on Windows). Alistair 2009/9/8 G?nther Schmidt : > Hi all, > > I'm trying to use Takusen ODBC on Windows. > > I'm using a German WinXP Pro and try to connect to an MS Access database. As > soon as I try to do some inserts the above mentioned exception shows up. > > Does anyone know a work around for this? > > G?nther > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From jpm at cs.uu.nl Wed Sep 9 03:23:38 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Wed Sep 9 03:03:01 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> Message-ID: <52f14b210909090023x3b80d0eeg542642324449f0ac@mail.gmail.com> Hello Louis, On Tue, Sep 8, 2009 at 19:06, Louis Wasserman wrote: > Sean, > > The answer is, I'm working on a recently semi-released package called > TrieMap. > Is that similar to what is done in [1]? A draft paper [2] also refers that implementation. Cheers, Pedro [1] http://www.haskell.org/haskellwiki/GHC/Indexed_types#An_associated_data_type_example [2] http://www.cse.unsw.edu.au/~chak/project/generics/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/6c4e7fcb/attachment.html From Christian.Maeder at dfki.de Wed Sep 9 03:49:12 2009 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Wed Sep 9 03:28:17 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: <4AA1340F.7030109@dfki.de> References: <4AA11B5A.50308@dfki.de> <4AA1340F.7030109@dfki.de> Message-ID: <4AA75DF8.10805@dfki.de> If compiling template haskell of Pandoc still does not work, please make a ticket as Simon wrote in: http://hackage.haskell.org/trac/ghc/ticket/2965#comment:24 Cheers Christian Christian Maeder wrote: > Maybe runhaskell is used for template haskell? > > HTH Christian > > Brian Sniffen wrote: >> No, my ghci is now "exec >> /Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4 >> -optc-m32 -opta-m32 -optl-m32 --interactive ${1+"$@"}" and I still see >> the same result. Also, I have switched to "--ld-options" instead of >> "--ld-option," which appears to have been a typo---cabal and setup >> never parsed it. >> >> -Brian >> >> On Fri, Sep 4, 2009 at 9:51 AM, Christian Maeder >> wrote: >>> Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci >>> as well not help? (as I've posted before) >>> >>> Cheers Christian >>> >>> Brian Sniffen wrote: >>>> Having edited the Haskell Platform's /usr/bin/ghc in place, most >>>> packages install fine. I'm still having trouble with Pandoc, even >>>> given the advice: >>>> >>>>> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >>>>> may be used. These options may also be passed to "./Setup configure" >>>> The problem appears to come when linking an incompatible zlib version: >>>> >>>> src/Text/Pandoc/ODT.hs:49:26: >>>> Exception when trying to run compile-time code: >>>> user error (Codec.Compression.Zlib: incompatible zlib version) >>>> Code: ($) makeZip "data" "odt-styles" >>>> In the first argument of `read', namely >>>> `$(makeZip $ "data" "odt-styles")' >>>> In the expression: read ($(makeZip $ "data" "odt-styles")) >>>> In the definition of `refArchive': >>>> refArchive = read ($(makeZip $ "data" "odt-styles")) >>>> >>>> The same problem occurs when making any call to Codec.Archive.Zip or >>>> Codec.Compression.Zlib. >>>> >>>> I do have a universal zlib installed by MacPorts, as well as the >>>> universal zlib that shipped with Snow Leopard and the universal zlib >>>> that came with Cabal. I'm not sure whether this message indicates >>>> that TH code is searching a different library path than non-TH code or >>>> what. Advice is most welcome. I'm particularly interested in finding >>>> out which zlib versions are being found at the construction of >>>> Codec.Compression.Zlib and at runtime (Pandoc compile time). >>>> >>>> >>>> >>>> >> >> From daniil.elovkov at googlemail.com Wed Sep 9 04:08:34 2009 From: daniil.elovkov at googlemail.com (Daniil Elovkov) Date: Wed Sep 9 03:46:58 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <2f9b2d30909081627h5ed7113eq4a35db6512b70c55@mail.gmail.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> <5e0214850909012257o6c1dd7fap3fd3597d745710fe@mail.gmail.com> <4AA6B428.6020301@gmail.com> <2f9b2d30909081627h5ed7113eq4a35db6512b70c55@mail.gmail.com> Message-ID: <4AA76282.3010908@googlemail.com> Ryan Ingram wrote: > On Tue, Sep 8, 2009 at 12:44 PM, Daniil > Elovkov wrote: >> Existential is a perfect word, because it really is >> data S = exists a. Show a => S [a]. > > If you were going to make "exists" a keyword, I think you would write > it like this: > >> data S = ConsS (exists a. Show a => [a]) > > To contrast: > >> data GhcS = forall a. Show a => ConsGhcS [a] >> data T = ConsT (forall a. Show a => [a]) > > This gives these constructors: > >> ConsS :: forall a. (Show a => [a] -> S) >> ConsGhcS :: forall a. (Show a => [a] -> S) -- same >> ConsT :: (forall a. Show a => [a]) -> T -- higher-rank type! Yes, this last one can confuse somebody who tries to understand the difference between existential quantification and first-class polymorphism. Because it looks like the former, but really is the latter. > T isn't very useful, it has to be able to provide a list of *any* > instance of Show, so probably [] is all you get. But you can do > something similar: > >> data N = ConsN (forall a. Num a => [a]) > > Now you get > >> ConsN :: (forall a. Num a => [a]) -> N > > and you can legally do > >> n = ConsN [1,2,3] > > since [1,2,3] == [fromInteger 1, fromInteger 2, fromInteger 3] :: > forall a. Num a => [a] > > Conceptually, an "S" holds *some* instance of Show, so the user of a > constructed S can only use methods of Show; they don't have any > further knowledge about what is inside. But a N holds *any* instance > of Num, so the user of the data can pick which one they want to use; > Integer, Rational, Double, some (Expr Int) instance made by an > embedded DSL programmer, etc. Well, that seems to be exactly how I worded it, but with the examples of data constructor vs function signature, rather than 2 data constructors. > Of course, there are some ways to recover information about what types > are inside the existential using GADTs or Data.Dynamic. But those > need to be held in the structure itself. For example: This is quite amazing. What follows is almost a literal copy of my code, which isn't open :) Even the names are very close! In my version eqTyp is unify :) Hmm, sometimes I think that Haskell allows expressing an intension in so many ways (and I'm sure it's true), but this... >> data Typ a where >> TBool :: Typ Bool >> TInt :: Typ Int >> TFunc :: Typ a -> Typ b -> Typ (a -> b) >> TList :: Typ a -> Typ [a] >> TPair :: Typ a -> Typ b -> Typ (a,b) > > Now you can create an existential type like this: > >> data Something = forall a. Something (Typ a) a > > and you can extract the value if the type matches: > >> data TEq a b where Refl :: TEq a a >> extract :: forall a. Typ a -> Something -> Maybe a >> extract ta (Something tb vb) = do >> Refl <- eqTyp ta tb >> return vb > > This desugars into > > ] extract ta (Something tb vb) = > ] eqTyp ta tb >>= \x -> > ] case x of > ] Refl -> return vb > ] _ -> fail "pattern match failure" > > which, since Refl is the only constructor for TEq, simplifies to > > ] extract ta (Something tb vb) = eqTyp ta tb >>= \Refl -> Just vb > > The trick is that the pattern match on Refl proves on the right-hand > side that "a" is the same type as that held in the existential, so we > have successfully extracted information from the existential and can > return it to the caller without breaking encapsulation. Here's the > helper function eqTyp; it's pretty mechanical: > >> eqTyp :: Typ a -> Typ b -> Maybe (TEq a b) >> eqTyp TBool TBool = return Refl >> eqTyp TInt TInt = return Refl >> eqTyp (TFunc a1 b1) (TFunc a2 b2) = do >> Refl <- eqTyp a1 a2 >> Refl <- eqTyp b1 b2 >> return Refl >> eqTyp (TList a1) (TList a2) = do >> Refl <- eqTyp a1 a2 >> return Refl >> eqTyp (TPair a1 b1) (TPair a2 b2) = do >> Refl <- eqTyp a1 a2 >> Refl <- eqTyp b1 b2 >> return Refl >> eqTyp _ _ = Nothing > > Here's a simple test: > >> test = Something (TFun TInt TBool) (\x -> x == 3) >> runTest = fromJust (extract (TFun TInt TBool) test) 5 > > runTest == False, of course. > > -- ryan From ivan.miljenovic at gmail.com Wed Sep 9 05:59:07 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Wed Sep 9 05:38:13 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.5.0.0 Message-ID: <87r5ugmob8.fsf@gmail.com> I am pleased to announce version 2999.5.0.0 [1] of the graphviz [2] package for Haskell. This is what I like to think of as the "Hey, this is almost getting to be a decent library!" version :p [1] http://hackage.haskell.org/packages/archive/graphviz/2999.5.0.0/graphviz-2999.5.0.0.tar.gz [2] http://hackage.haskell.org/package/graphviz The graphviz package provides bindings to the GraphViz [3] suite of programs by providing the ability to generate and parse GraphViz's Dot [4] language as well as wrappers around the tools themselves. [3] http://www.graphviz.org/ [4] http://www.graphviz.org/doc/info/lang.html This is an almost complete re-write of the previously released version (2999.1.0.2): I do not mean that this version was re-written from scratch, but substantial portions of the library have been improved or replaced. As such, current users of this library will unfortunately have to update their code that uses it. The major changes (becuase there's probably heaps of smaller changes I've forgotten about) are: * Parsing and printing of Dot code was re-written to use the new ParseDot and PrintDot classes rather than the old Parseable class and the Show class. What this means for the end-user is that quotation problems should finally all be resolved (I hope...). In particular, proper quotation of String values is now done automagically: if it is found that the String to be printed requires quoting (because it does not match the format required for non-quoted String values), then quotes within the String are escaped and the entire String is quoted. As part of this, the Data.GraphViz.ParserCombinators module has been moved to Data.GraphViz.Types.Parsing. * Re-write the various Dot* datatypes in Data.GraphViz.Types. Sub-graphs/clusters are now their own entity rather than being part of DotNode and the Node ID type is now a type parameter rather than being just Int. Sub-graphs/clusters can now also be parsed. DotGraph and DotSubGraph now both contain a "DotStatements" value, which in turn contains global attributes, subgraphs, nodes and edges. * The various conversion functions in Data.GraphViz now come in two flavours: the unprimed versions take in a Bool indicating if the graph is directed or not; the primed versions attempt to automatically detect this. Also add cluster support for the graph -> dot -> graph conversion-style functions, as requested by Nikolas Mayr. * Allow custom arrow types as supported by GraphViz; as requested by Han Joosten. * Fixed a bug in HSV-style Color values where Int was used instead of Double; spotted by Michael deLorimier. * Properly resolved the situation initially spotted by Neil Brown: Matthew Sackman was following Dot terminology for an edge `a -> b' when using "head" for `b' and "tail" for `a' (this is presumably because the head/tail of the arrow are at those nodes). DotEdge now uses "from" and "to" avoid ambiguity; the various Attribute values still follow upstream usage. This should hopefully be the last update that is such an intrusive change. The next release will most likely contain updates on how to specify a particular output to use (including variants), with most of the rest remain as-is. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From sfvisser at cs.uu.nl Wed Sep 9 06:21:15 2009 From: sfvisser at cs.uu.nl (Sebastiaan Visser) Date: Wed Sep 9 06:00:26 2009 Subject: [Haskell-cafe] ANN: fclabels-0.4.0 - First class accessor labels. In-Reply-To: References: Message-ID: <3CE585C0-245E-4053-943C-F81CC9E3E699@cs.uu.nl> On Sep 8, 2009, at 11:54 PM, Henning Thielemann wrote: On Fri, 4 Sep 2009, Sebastiaan Visser wrote: > >> Hello all, >> >> There are more package around that serve the same purpose (like the >> Lenses package which was uploaded a few days ago), but I'm >> convinced the simplicity and elegance of fclabels will strike you >> all. ;-) > > How does it compare to data-accessor and data-accessor-template? Please see this reddit thread for more info on this subject: http://www.reddit.com/r/haskell/comments/9hors/fclabels_first_class_labels_that_act_as/ -- Sebastiaan Visser From emax at chalmers.se Wed Sep 9 07:03:46 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Sep 9 06:43:24 2009 Subject: [Haskell-cafe] Strange type error (tfp package + GADTs) Message-ID: <4AA78B92.1070808@chalmers.se> Hi Caf?, Can anyone explain why `add1` is rejected in the code below (which uses the tfp package): import Types.Data.Num data A n where A :: NaturalT n => Int -> A n getA :: A n -> Int getA (A n) = n add1 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) add1 (A a) (A b) = A (a+b) add2 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) add2 a b = A (getA a + getA b) add3 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) add3 (A a) _ = A a `add2` and `add3` are accepted. As far as I can see, `add2` is equivalent to `add1` except that it delegates the pattern matching to the function `getA`. If I only pattern match on one of the arguments, as in `add3`, things are also fine. Thanks! / Emil From duncan.coutts at worc.ox.ac.uk Wed Sep 9 08:28:47 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 9 09:03:59 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> Message-ID: <1252499327.5266.5117.camel@localhost> On Tue, 2009-09-08 at 09:58 -0500, Jeff Wheeler wrote: > On Tue, Sep 8, 2009 at 9:17 AM, Peter Verswyvelen wrote: > > > Ouch, right, I forgot the default is global. It works fine with cabal > > install --user. And of course I could have edited the default config > > file, setting user-install: True > > > > Well, maybe for newbies this might be a bit confusing. > > Yep, I agree. I'm not sure why Cabal defaults to --global on Windows, > but I found it quite counter-intuitive having come from a Linux > environment. I forgot about the different default for some time. It was because last time we discussed this, the Windows users seemed to be of the opinion that things were simpler with global installs since the %PATH% would be right by default and "everyone runs as Administrator anyway". That may well be different now. If the Windows users can come to a consensus on whether the default should be global or user, then we can easily switch it. The same applies for the default global or user installation paths. If there are any Windows users who understand the Windows permissions system then the Cabal hackers would appreciate some help. As it is the Cabal hackers have no access to Vista or Win7 and cannot test what is actually going on with Windows permissions or pop-up windows prompting whether it's ok to do this or that. Duncan From akborder at gmail.com Wed Sep 9 09:35:32 2009 From: akborder at gmail.com (Anakim Border) Date: Wed Sep 9 09:14:33 2009 Subject: [Haskell-cafe] Parallel parsing & multicore Message-ID: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> Hi, I've put together a parser that works like this: - the full input is read into a strict ByteString; - such string is split into a number of lines; - each line is fed (independently) to a parser based on Parsec (version 3). Running the serial version of the parser (compiled with -O2 optimizations) on a rather large file, I get the following: $ ./Parser +RTS -s 2,175,464,100 bytes allocated in the heap 49,293,632 bytes copied during GC 5,297,560 bytes maximum residency (6 sample(s)) 1,406,800 bytes maximum slop 16 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 4140 collections, 0 parallel, 0.39s, 0.42s elapsed Generation 1: 6 collections, 0 parallel, 0.05s, 0.07s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 1.93s ( 1.99s elapsed) GC time 0.44s ( 0.48s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 2.37s ( 2.47s elapsed) %GC time 18.7% (19.5% elapsed) Alloc rate 1,127,336,508 bytes per MUT second Productivity 81.2% of total user, 78.1% of total elapsed The profile report: COST CENTRE MODULE %time %alloc >>=_a6OH Text.Parsec.Prim 20.6 13.0 tokenPrimEx Text.Parsec.Prim 16.5 20.8 fmap_a6Qj Text.Parsec.Prim 15.5 3.6 parserBind Text.Parsec.Prim 12.4 9.3 mplus_a6KS Text.Parsec.Prim 10.3 10.6 notFollowedBy Text.Parsec.Combinator 3.1 4.4 [...] shows that the biggest part of the execution time is spent in the parser (not in the read & line split operations, as expected). Given that each line is parsed independently, I used the following code: map parse lines `using` parListChunk 250 rnf to spark a separate computation for each group of 250 lines. I made the datatype used by the parser an instance of NFData, so that the "rnf" strategy should force a complete evaluation. The threaded version running on 2 cores is moderately faster than the serial one: $ ./Parser +RTS -s -N2 2,377,165,256 bytes allocated in the heap 36,320,944 bytes copied during GC 6,020,720 bytes maximum residency (6 sample(s)) 6,933,928 bytes maximum slop 21 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 2410 collections, 0 parallel, 0.33s, 0.34s elapsed Generation 1: 6 collections, 4 parallel, 0.06s, 0.05s elapsed Parallel GC work balance: 1.83 (2314641 / 1265968, ideal 2) Task 0 (worker) : MUT time: 2.43s ( 1.19s elapsed) GC time: 0.02s ( 0.02s elapsed) Task 1 (worker) : MUT time: 2.15s ( 1.19s elapsed) GC time: 0.29s ( 0.30s elapsed) Task 2 (worker) : MUT time: 2.37s ( 1.19s elapsed) GC time: 0.07s ( 0.08s elapsed) Task 3 (worker) : MUT time: 2.45s ( 1.19s elapsed) GC time: 0.00s ( 0.00s elapsed) INIT time 0.00s ( 0.00s elapsed) MUT time 2.06s ( 1.19s elapsed) GC time 0.39s ( 0.39s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 2.45s ( 1.58s elapsed) %GC time 15.7% (24.9% elapsed) Alloc rate 1,151,990,234 bytes per MUT second Productivity 84.2% of total user, 130.2% of total elapsed The speedup is smaller than what I was expecting given that each unit of work (250 input lines) is completely independent from the others. Changing the size of each work unit did not help; garbage collection times are small enough that increasing the minimum heap size did not produce any speedup either. Is there anything else I can do to understand why the parallel map does not provide a significant speedup? Thanks, AB From stefan at cs.uu.nl Wed Sep 9 09:37:55 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Wed Sep 9 09:16:56 2009 Subject: [Haskell-cafe] Resolving overloading loops for circular constraint graph Message-ID: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> Manuel, Simon, I've spotted a hopefully small but for us quite annoying bug in GHC's type checker: it loops when overloading resolving involves a circular constraint graph containing type-family applications. The following program (also attached) demonstrates the problem: {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} type family F a :: * type instance F Int = (Int, ()) class C a instance C () instance (C (F a), C b) => C (a, b) f :: C (F a) => a -> Int f _ = 2 main :: IO () main = print (f (3 :: Int)) My guess is that the loop is caused by the constraint C (F Int) that arises from the use of f in main: C (F Int) = C (Int, ()) <= C (F Int) Indeed, overloading can be resolved successfully by "black-holing" the initial constraint, but it seems like the type checker refuses to do so. Can you confirm my findings? I'm not sure whether this is a known defect. If it isn't, I'd be more than happy to issue a report. Since this problem arises in a piece of very mission-critical code, I would be pleased to learn about any workarounds. Thanks in advance, Stefan From dons at galois.com Wed Sep 9 09:40:56 2009 From: dons at galois.com (Don Stewart) Date: Wed Sep 9 09:22:06 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> Message-ID: <20090909134056.GE3390@whirlpool.galois.com> akborder: > > The threaded version running on 2 cores is moderately faster than the > serial one: > > $ ./Parser +RTS -s -N2 > 2,377,165,256 bytes allocated in the heap > 36,320,944 bytes copied during GC > 6,020,720 bytes maximum residency (6 sample(s)) > 6,933,928 bytes maximum slop > 21 MB total memory in use (0 MB lost due to fragmentation) > > Generation 0: 2410 collections, 0 parallel, 0.33s, 0.34s elapsed > Generation 1: 6 collections, 4 parallel, 0.06s, 0.05s elapsed > > Parallel GC work balance: 1.83 (2314641 / 1265968, ideal 2) > > Task 0 (worker) : MUT time: 2.43s ( 1.19s elapsed) > GC time: 0.02s ( 0.02s elapsed) > > Task 1 (worker) : MUT time: 2.15s ( 1.19s elapsed) > GC time: 0.29s ( 0.30s elapsed) > > Task 2 (worker) : MUT time: 2.37s ( 1.19s elapsed) > GC time: 0.07s ( 0.08s elapsed) > > Task 3 (worker) : MUT time: 2.45s ( 1.19s elapsed) > GC time: 0.00s ( 0.00s elapsed) > > INIT time 0.00s ( 0.00s elapsed) > MUT time 2.06s ( 1.19s elapsed) > GC time 0.39s ( 0.39s elapsed) > EXIT time 0.00s ( 0.00s elapsed) > Total time 2.45s ( 1.58s elapsed) > > %GC time 15.7% (24.9% elapsed) > > Alloc rate 1,151,990,234 bytes per MUT second > > Productivity 84.2% of total user, 130.2% of total elapsed > > > The speedup is smaller than what I was expecting given that each unit > of work (250 input lines) is completely independent from the others. > Changing the size of each work unit did not help; garbage collection > times are small enough that increasing the minimum heap size did not > produce any speedup either. > > Is there anything else I can do to understand why the parallel map > does not provide a significant speedup? Very interesting idea! I think the big thing would be to measure it with GHC HEAD so you can see how effectively the sparks are being converted into threads. Is there a package and test case somewhere we can try out? -- Don From bulat.ziganshin at gmail.com Wed Sep 9 09:49:56 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 9 09:29:06 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> Message-ID: <1945130250.20090909174956@gmail.com> Hello Anakim, Wednesday, September 9, 2009, 5:35:32 PM, you wrote: > MUT time 1.93s ( 1.99s elapsed) > MUT time 2.06s ( 1.19s elapsed) the speedup is very good. usually you don't get 2x faster execution because cores compete for the access to memory ps: are you sure that you correctly interpret the results? wall times was reduced from 1.99s to 1.19s -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From emax at chalmers.se Wed Sep 9 09:53:14 2009 From: emax at chalmers.se (Emil Axelsson) Date: Wed Sep 9 09:32:50 2009 Subject: [Haskell-cafe] Strange type error (tfp package + GADTs) In-Reply-To: <4AA78B92.1070808@chalmers.se> References: <4AA78B92.1070808@chalmers.se> Message-ID: <4AA7B34A.6090104@chalmers.se> I forgot to say that I'm using GHC 6.10.1. Also, the code requires {-# LANGUAGE FlexibleContexts, GADTs, TypeOperators #-} / Emil Emil Axelsson skrev: > Hi Caf?, > > Can anyone explain why `add1` is rejected in the code below (which uses > the tfp package): > > > > import Types.Data.Num > > data A n > where > A :: NaturalT n => Int -> A n > > getA :: A n -> Int > getA (A n) = n > > add1 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) > add1 (A a) (A b) = A (a+b) > > add2 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) > add2 a b = A (getA a + getA b) > > add3 :: NaturalT (m:+:n) => A m -> A n -> A (m:+:n) > add3 (A a) _ = A a > > > > `add2` and `add3` are accepted. As far as I can see, `add2` is > equivalent to `add1` except that it delegates the pattern matching to > the function `getA`. If I only pattern match on one of the arguments, as > in `add3`, things are also fine. > > Thanks! > > / Emil > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From wasserman.louis at gmail.com Wed Sep 9 10:19:36 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Wed Sep 9 09:58:57 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: <52f14b210909090023x3b80d0eeg542642324449f0ac@mail.gmail.com> References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> <52f14b210909090023x3b80d0eeg542642324449f0ac@mail.gmail.com> Message-ID: The goal is similar, but I'm attempting to automatically infer the appropriate map type for any algebraic datatype -- and while I'm at it, the TrieMap package aims to include all the methods Data.Map offers. Louis Wasserman wasserman.louis@gmail.com 2009/9/9 Jos? Pedro Magalh?es > Hello Louis, > > On Tue, Sep 8, 2009 at 19:06, Louis Wasserman wrote: > >> Sean, >> >> The answer is, I'm working on a recently semi-released package called >> TrieMap. >> > > Is that similar to what is done in [1]? A draft paper [2] also refers that > implementation. > > > Cheers, > Pedro > > [1] > http://www.haskell.org/haskellwiki/GHC/Indexed_types#An_associated_data_type_example > [2] http://www.cse.unsw.edu.au/~chak/project/generics/ > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/1a31d65f/attachment.html From leather at cs.uu.nl Wed Sep 9 10:24:59 2009 From: leather at cs.uu.nl (Sean Leather) Date: Wed Sep 9 10:04:20 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> <52f14b210909090023x3b80d0eeg542642324449f0ac@mail.gmail.com> Message-ID: <3c6288ab0909090724k48349b93x40cdcad4e5cb0e26@mail.gmail.com> > The goal is similar, but I'm attempting to automatically infer the > appropriate map type for any algebraic datatype -- and while I'm at it, the > TrieMap package aims to include all the methods Data.Map offers. > Perhaps you want to read about the type-indexed tries in "Generic Haskell: Applications": http://www.cs.uu.nl/~johanj/publications/ghpractice.pdf Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/784dc290/attachment.html From wasserman.louis at gmail.com Wed Sep 9 10:30:25 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Wed Sep 9 10:09:45 2009 Subject: [Haskell-cafe] Deconstructing types In-Reply-To: <3c6288ab0909090724k48349b93x40cdcad4e5cb0e26@mail.gmail.com> References: <3c6288ab0909072334s64793255n7876d4279337ee46@mail.gmail.com> <52f14b210909090023x3b80d0eeg542642324449f0ac@mail.gmail.com> <3c6288ab0909090724k48349b93x40cdcad4e5cb0e26@mail.gmail.com> Message-ID: This is about the same as the other paper I linked to, I think, but I'm interested in actually connecting the fully general trie construction to Template Haskell and other facilities to reduce the coder's overhead of using these tries in practice to a minimum. Louis Wasserman wasserman.louis@gmail.com On Wed, Sep 9, 2009 at 10:24 AM, Sean Leather wrote: > > The goal is similar, but I'm attempting to automatically infer the >> appropriate map type for any algebraic datatype -- and while I'm at it, the >> TrieMap package aims to include all the methods Data.Map offers. >> > > Perhaps you want to read about the type-indexed tries in "Generic Haskell: > Applications": http://www.cs.uu.nl/~johanj/publications/ghpractice.pdf > > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/9ed7a6be/attachment.html From akborder at gmail.com Wed Sep 9 10:42:55 2009 From: akborder at gmail.com (Anakim Border) Date: Wed Sep 9 10:27:37 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <20090909134056.GE3390@whirlpool.galois.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> Message-ID: <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> > Very interesting idea! > > I think the big thing would be to measure it with GHC HEAD so you can > see how effectively the sparks are being converted into threads. > > Is there a package and test case somewhere we can try out? At this point the parser is just a proof of concept. For those brave enough, however, I've put the code on github: http://github.com/akborder/HsMakefileParser/ The "test.mk" file provides some test cases. To get an input big enough to measure multiple thread performances, you can concatenate that file a few thousand times: the timings in my previous message were obtained parsing a 3000x concatenation (final size: 1.1 MB). From bugfact at gmail.com Wed Sep 9 10:59:55 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Sep 9 10:38:56 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <1252499327.5266.5117.camel@localhost> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> Message-ID: Yes, it's true that most people tended to be administrators on their own Windows desktops, but since Vista, this has changed. Now in Vista, some people still forced admin rights, to get rid of the many annoying dialog boxes that popped up for every tiny task that might be a security breach. But it seems that under Windows 7 this is less intrusive, so we might consider having the Haskell Platform work well by default without assuming admin rights? Or at least the installer should clearly tell you about it, or provide an option. On Wed, Sep 9, 2009 at 2:28 PM, Duncan Coutts wrote: > On Tue, 2009-09-08 at 09:58 -0500, Jeff Wheeler wrote: >> On Tue, Sep 8, 2009 at 9:17 AM, Peter Verswyvelen wrote: >> >> > Ouch, right, I forgot the default is global. It works fine with cabal >> > install --user. And of course I could have edited the default config >> > file, setting user-install: True >> > >> > Well, maybe for newbies this might be a bit confusing. >> >> Yep, I agree. I'm not sure why Cabal defaults to --global on Windows, >> but I found it quite counter-intuitive having come from a Linux >> environment. I forgot about the different default for some time. > > It was because last time we discussed this, the Windows users seemed to > be of the opinion that things were simpler with global installs since > the %PATH% would be right by default and "everyone runs as Administrator > anyway". That may well be different now. > > If the Windows users can come to a consensus on whether the default > should be global or user, then we can easily switch it. The same applies > for the default global or user installation paths. > > If there are any Windows users who understand the Windows permissions > system then the Cabal hackers would appreciate some help. As it is the > Cabal hackers have no access to Vista or Win7 and cannot test what is > actually going on with Windows permissions or pop-up windows prompting > whether it's ok to do this or that. > > Duncan > > From ninegua at gmail.com Wed Sep 9 11:47:53 2009 From: ninegua at gmail.com (Paul L) Date: Wed Sep 9 11:26:52 2009 Subject: [Haskell-cafe] ANNOUNCE: CCA-0.1 Message-ID: <856033f20909090847m196907eclaa4a069dfe89fcbb@mail.gmail.com> I'm pleased to annouce that a library for Causal Commutative Arrows (CCA) has been uploaded to Hackage DB. It implements CCA normalization using Template Haskell and a modified arrow pre-processor (based on arrowp) to generate outout that Template Haskell can parse. It's highly experimental since we are still fiddling with several design choices, and by no means we imply Template Haskell is the best choice to implement CCA. Any suggestion or comment is welcome! -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From bugfact at gmail.com Wed Sep 9 11:50:22 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Sep 9 11:29:23 2009 Subject: [Haskell-cafe] ANNOUNCE: CCA-0.1 In-Reply-To: <856033f20909090847m196907eclaa4a069dfe89fcbb@mail.gmail.com> References: <856033f20909090847m196907eclaa4a069dfe89fcbb@mail.gmail.com> Message-ID: Congratulations! On Wed, Sep 9, 2009 at 5:47 PM, Paul L wrote: > I'm pleased to annouce that a library for Causal Commutative Arrows > (CCA) has been uploaded to Hackage DB. It implements CCA normalization > using Template Haskell and a modified arrow pre-processor (based on > arrowp) to generate outout that Template Haskell can parse. It's > highly experimental since we are still fiddling with several design > choices, and by no means we imply Template Haskell is the best choice > to implement CCA. > > Any suggestion or comment is welcome! > > -- > Regards, > Paul Liu > > Yale Haskell Group > http://www.haskell.org/yale > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From ekmett at gmail.com Wed Sep 9 12:14:23 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Sep 9 11:53:22 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> Message-ID: <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> Hi Anakim, Nice to see someone else working in this space. I have also been working on a set of parallel parsing techniques, which can use small Parsec parsers for local context sensitivity. See the second set of slides in http://comonad.com/reader/2009/iteratees-parsec-and-monoid/ for an overview of how I'm doing something similar to feed Parsec independent chunks. Note that this approach bypasses the need for a separate sequential scan, which otherwise floods your cache, and lets you get closer to the performance limit imposed by Amdahl's law. The code in the second set of slides can be adapted to your case: load everything into a lazy bytestring or fingertree of strict bytestrings, then for each strict bytestring chunk in parallel, scan it for the first newline, and then start an iteratee based parsec parser from that point. I use the iteratee based parsec parsers so that when I glue the partial parses together I can feed the unparsed data on the left side of the first newline in each chunk to the parser I'm joining on the left. I provide a monoid for the purpose of gluing together these partial parses, which encapsulates this behavior. The fingertree case is particularly nice, because it can be used to do cheap incremental reparsing using the same machinery based on out of band updates to the input. This approach is sufficient to parse a lot of interesting languages. As you have noted with Makefiles it can handle indentation based control structures, and with a variation on a Dyck language monoid it can be extended to Haskell-style layout or parenthesis matching/lisp parsing by applying the same techniques at a higher level. -Edward Kmett On Wed, Sep 9, 2009 at 10:42 AM, Anakim Border wrote: > > Very interesting idea! > > > > I think the big thing would be to measure it with GHC HEAD so you can > > see how effectively the sparks are being converted into threads. > > > > Is there a package and test case somewhere we can try out? > > > At this point the parser is just a proof of concept. For those brave > enough, however, I've put the code on github: > > http://github.com/akborder/HsMakefileParser/ > > The "test.mk" file provides some test cases. To get an input big > enough to measure multiple thread performances, you can concatenate > that file a few thousand times: the timings in my previous message > were obtained parsing a 3000x concatenation (final size: 1.1 MB). > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/ebc8c2ad/attachment.html From dons at galois.com Wed Sep 9 12:16:09 2009 From: dons at galois.com (Don Stewart) Date: Wed Sep 9 11:57:18 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> Message-ID: <20090909161609.GF3390@whirlpool.galois.com> ekmett: > Hi Anakim, > ? > Nice to see someone else working in this space. > ? > I have also been working on a set of parallel parsing techniques, which can use > small Parsec parsers for local context sensitivity. > ? > See the second set of slides in http://comonad.com/reader/2009/ > iteratees-parsec-and-monoid/?for an overview of how I'm doing something similar > to feed Parsec independent chunks. Note that?this approach bypasses the need > for a separate sequential scan, which otherwise floods?your cache, and lets you > get closer to the performance limit imposed by Amdahl's law. > ? > The code in the second set of slides can be adapted to your case: load > everything?into a lazy bytestring or fingertree of strict bytestrings, then for > each strict bytestring chunk in parallel, scan it for the first newline, and > then start an iteratee based parsec parser from that point. I use the iteratee > based parsec parsers so that when I glue the partial parses together I can feed > the unparsed data on the left side of the first newline in each chunk to the > parser?I'm joining on?the left. I provide a monoid for the purpose of gluing > together these partial parses, which?encapsulates this behavior.? You can get quite a long way by using bytestring-mmap and strict bytestrings. The first ensures your IO overhead will be low, and the second ensures you don't migrate work needlessly. From batterseapower at hotmail.com Wed Sep 9 12:23:14 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Wed Sep 9 12:02:14 2009 Subject: [Haskell-cafe] ANNOUNCE: CCA-0.1 In-Reply-To: <856033f20909090847m196907eclaa4a069dfe89fcbb@mail.gmail.com> References: <856033f20909090847m196907eclaa4a069dfe89fcbb@mail.gmail.com> Message-ID: <9d4d38820909090923l577aeb43t97220398a7dfede@mail.gmail.com> Great stuff Paul! It looks like you missed it out, so for others it might be helpful to know taht the link is: http://hackage.haskell.org/package/CCA I'm very happy you released this, as it was just today that I found out that I really needed a version of arrowp that could produce Template Haskell. ??, Max 2009/9/9 Paul L : > I'm pleased to annouce that a library for Causal Commutative Arrows > (CCA) has been uploaded to Hackage DB. It implements CCA normalization > using Template Haskell and a modified arrow pre-processor (based on > arrowp) to generate outout that Template Haskell can parse. It's > highly experimental since we are still fiddling with several design > choices, and by no means we imply Template Haskell is the best choice > to implement CCA. > > Any suggestion or comment is welcome! > > -- > Regards, > Paul Liu > > Yale Haskell Group > http://www.haskell.org/yale > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From ekmett at gmail.com Wed Sep 9 12:34:02 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Sep 9 12:13:02 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <20090909161609.GF3390@whirlpool.galois.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> <20090909161609.GF3390@whirlpool.galois.com> Message-ID: <7fb8f82f0909090934u737f3f7ahb99423c69a45ef0d@mail.gmail.com> On Wed, Sep 9, 2009 at 12:16 PM, Don Stewart wrote: > ekmett: > > Hi Anakim, > > > > Nice to see someone else working in this space. > > > > I have also been working on a set of parallel parsing techniques, which > can use > > small Parsec parsers for local context sensitivity. > > > > See the second set of slides in http://comonad.com/reader/2009/ > > iteratees-parsec-and-monoid/ for an overview of how I'm doing something > similar > > to feed Parsec independent chunks. Note that this approach bypasses the > need > > for a separate sequential scan, which otherwise floods your cache, and > lets you > > get closer to the performance limit imposed by Amdahl's law. > > > > The code in the second set of slides can be adapted to your case: load > > everything into a lazy bytestring or fingertree of strict bytestrings, > then for > > each strict bytestring chunk in parallel, scan it for the first newline, > and > > then start an iteratee based parsec parser from that point. I use the > iteratee > > based parsec parsers so that when I glue the partial parses together I > can feed > > the unparsed data on the left side of the first newline in each chunk to > the > > parser I'm joining on the left. I provide a monoid for the purpose of > gluing > > together these partial parses, which encapsulates this behavior. > > You can get quite a long way by using bytestring-mmap and strict > bytestrings. The first ensures your IO overhead will be low, and the > second ensures you don't migrate work needlessly. I'm actually using bytestring-mmap in a toy compiler which uses these techniques, though at present I'm using System.IO.Posix.MMap.Lazy rather than the strict version. As for migrating work, maybe I'm not understanding your point, but my whole goal was to migrate the chunking and parsing out to other cores, so the behavior of parMap rwhnf'ing the monoidal reduction over the chunks seems to be exactly what I want. I could perhaps get better results by trying to assign the same thread contiguous ranges of the input though, and controlling the choice of core used to merge chunks more intelligently by maybe doing something like mixing up pseq and par to group runs onto the same core where possible. Could you elaborate? -Edward -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/b236173e/attachment.html From dons at galois.com Wed Sep 9 12:33:15 2009 From: dons at galois.com (Don Stewart) Date: Wed Sep 9 12:14:28 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <7fb8f82f0909090934u737f3f7ahb99423c69a45ef0d@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> <20090909161609.GF3390@whirlpool.galois.com> <7fb8f82f0909090934u737f3f7ahb99423c69a45ef0d@mail.gmail.com> Message-ID: <20090909163315.GL3390@whirlpool.galois.com> ekmett: > > > On Wed, Sep 9, 2009 at 12:16 PM, Don Stewart wrote: > > ekmett: > > Hi Anakim, > > ? > > Nice to see someone else working in this space. > > ? > > I have also been working on a set of parallel parsing techniques, which > can use > > small Parsec parsers for local context sensitivity. > > ? > > See the second set of slides in http://comonad.com/reader/2009/ > > iteratees-parsec-and-monoid/?for an overview of how I'm doing something > similar > > to feed Parsec independent chunks. Note that?this approach bypasses the > need > > for a separate sequential scan, which otherwise floods?your cache, and > lets you > > get closer to the performance limit imposed by Amdahl's law. > > ? > > The code in the second set of slides can be adapted to your case: load > > everything?into a lazy bytestring or fingertree of strict bytestrings, > then for > > each strict bytestring chunk in parallel, scan it for the first newline, > and > > then start an iteratee based parsec parser from that point. I use the > iteratee > > based parsec parsers so that when I glue the partial parses together I > can feed > > the unparsed data on the left side of the first newline in each chunk to > the > > parser?I'm joining on?the left. I provide a monoid for the purpose of > gluing > > together these partial parses, which?encapsulates this behavior.? > > You can get quite a long way by using bytestring-mmap and strict > bytestrings. The first ensures your IO overhead will be low, and the > second ensures you don't migrate work needlessly. > > ? > I'm actually using bytestring-mmap in?a toy compiler which uses these > techniques, though at present I'm using System.IO.Posix.MMap.Lazy rather than > the strict version. > ? > As for migrating work, maybe I'm not understanding your point, but my whole > goal was to migrate the chunking and parsing out to other cores, so the > behavior of parMap rwhnf'ing the monoidal reduction?over the?chunks?seems to be > exactly what I want. I could perhaps get better results by trying to assign the > same thread contiguous ranges of the input though, and controlling the choice > of core used to?merge chunks?more intelligently by maybe doing something like > mixing up pseq and par to group runs onto the same core where possible. > ? Oh, I just find strict structures easier when determining in which thread work is happening. Appropriate use of rnf and friends is also fine. -- Don From velman at cox.net Wed Sep 9 13:02:45 2009 From: velman at cox.net (John Velman) Date: Wed Sep 9 12:41:45 2009 Subject: [Haskell-cafe] problems with HOC install from svn In-Reply-To: <645FB161-6AE2-48C4-968D-A302C0EE69B4@z.odi.ac> References: <20090908235753.GA244@cox.net> <20090909025408.GB244@cox.net> <645FB161-6AE2-48C4-968D-A302C0EE69B4@z.odi.ac> Message-ID: <20090909170245.GB266@cox.net> I'm guessing the problem was with cabal's use of dlopen (see my inclusion of error message below). From some googling, the OS-X dlopen was redone by apple at some time and from results I obtained, seems to require dylib libraries unless (some things I don't understand). It seems that some earlier versions of GHC could use dylibs, but not 6.10. >From some similar sounding issues I found in the issues part of the HOC site on code.google, I made a wild guess that using sudo runhaskell Setup.hs [options] might work. It did. I went all the way through the installation instructions using this procedure wherever the README file said "cabal". Everything compiled, linked, and installed in global locations. Also compiled and linked one of the examples this way, and it seems to work. I'll submit an issue to the HOC site (if it will let me -- don't know about permissions for issues on this site). Thanks for your interest and help. John Velman On Tue, Sep 08, 2009 at 11:44:36PM -0400, Ross Mellgren wrote: > I have binary-0.5 not binary-0.5.0.1, but it doesn't have any dylibs. > Moreover, I was under the impression that GHC does not yet support shared > libraries like those, so I'm not sure why it would be looking for one. I > can't really speculate, maybe more of the build output might help? > > -Ross > > On Sep 8, 2009, at 10:54 PM, John Velman wrote: > >> >> Thanks. Now I do have libHSbinary-0.5.0.1.a in /usr/local/lib, >> but apparently not the dylib version. Tomorrow I'll look further. >> Perhaps there are some options to produce dylib libraries. I've used >> Haskell on Linux some time ago (but not Cabal), and have been Xcoding with >> Objective C for a year or so now, but never tried this before. I am >> interested in HOC, but I've obviously got a lot to learn. >> >> Thanks again, >> >> John Velman >> >> >> >> On Tue, Sep 08, 2009 at 08:35:54PM -0400, Ross Mellgren wrote: >>> It sounds like it's looking for the binary package -- you should install >>> it >>> using cabal, e.g. >>> >>> private (per-user) install: >>> cabal update >>> cabal install binary >>> >>> global (system-wide) install: >>> sudo cabal update >>> sudo cabal install --global binary >>> >>> -Ross >>> >>> On Sep 8, 2009, at 7:57 PM, John Velman wrote: >>> >>>> I'm unable to build HOC from the svn read-only checkout. Here are some >>>> details of what I'm doing. >>>> >>>> I'm running OS X 10.5.8 on an intel iMac with Xcode is 3.1.3. >>>> >>>> Haskel and Cabal are from the Haskel platform, >>>> haskell-platform-2009.2.0.2-i386.dmg >>>> >>>> I got Parsec 3.0 from Hackage. >>>> >>>> I checked out HOC using the svn command at >>>> http://code.google.com/p/hoc/source/checkout >>>> >>>> and checked out revision 411. >>>> >>>> Configure goes OK except for the complaint: >>>> ---- >>>> Setup.hs:1:0: >>>> Warning: In the use of `defaultUserHooks' >>>> (imported from Distribution.Simple): >>>> Deprecated: "Use simpleUserHooks or autoconfUserHooks, unless >>>> you need Cabal-1.2 >>>> compatibility in which case you must stick with >>>> defaultUserHooks" >>>> ---- >>>> >>>> But when I try to build, I get, after a bunch of apparently successful >>>> things: >>>> ----------- >>>> Loading package binary-0.5.0.1 ... : can't load .so/.DLL >>>> for: HSbinary-0.5.0.1 (dlopen(libHSbinary-0.5.0.1.dylib, 9): image not >>>> found) >>>> ----------- >>>> >>>> I certainly can't find libHSbinary... of any version on my computer, >>>> dylib >>>> or not. Tried looking in the /Library/Frameworks/GHC.Framework stuff, >>>> also >>>> did a find . -iname "*libHS* and found libHSGLFW..., libHSparsec-3.0.0. >>>> >>>> (also tried this in my home directory). >>>> >>>> What is this, and how do I get it? >>>> >>>> Best, >>>> >>>> John Velman >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe@haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe From martin.sulzmann.haskell at googlemail.com Wed Sep 9 14:57:13 2009 From: martin.sulzmann.haskell at googlemail.com (Martin Sulzmann) Date: Wed Sep 9 14:36:14 2009 Subject: [Haskell-cafe] Resolving overloading loops for circular constraint graph In-Reply-To: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> References: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> Message-ID: <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> Your example must loop because as you show below the instance declaration leads to a cycle. By "black-holing" you probably mean co-induction. That is, if the statement to proven appears again, we assume it must hold. However, type classes are by default inductive, so there's no easy fix to offer to your problem. In any case, this is not a bug, you simply play with fire once type functions show up in the instance context. There are sufficient conditions to guarantee termination, but they are fairly restrictive. -Martin 2009/9/9 Stefan Holdermans > Manuel, Simon, > > I've spotted a hopefully small but for us quite annoying bug in GHC's type > checker: it loops when overloading resolving involves a circular constraint > graph containing type-family applications. > > The following program (also attached) demonstrates the problem: > > {-# LANGUAGE FlexibleContexts #-} > {-# LANGUAGE TypeFamilies #-} > > type family F a :: * > type instance F Int = (Int, ()) > > class C a > instance C () > instance (C (F a), C b) => C (a, b) > > f :: C (F a) => a -> Int > f _ = 2 > > main :: IO () > main = print (f (3 :: Int)) > > My guess is that the loop is caused by the constraint C (F Int) that arises > from the use of f in main: > > C (F Int) = C (Int, ()) <= C (F Int) > > Indeed, overloading can be resolved successfully by "black-holing" the > initial constraint, but it seems like the type checker refuses to do so. > > Can you confirm my findings? > > I'm not sure whether this is a known defect. If it isn't, I'd be more than > happy to issue a report. > > Since this problem arises in a piece of very mission-critical code, I would > be pleased to learn about any workarounds. > > Thanks in advance, > > Stefan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/213e5261/attachment.html From duncan.coutts at worc.ox.ac.uk Wed Sep 9 11:39:00 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 9 14:36:42 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> Message-ID: <1252510740.5266.5315.camel@localhost> On Wed, 2009-09-09 at 16:59 +0200, Peter Verswyvelen wrote: > Yes, it's true that most people tended to be administrators on their > own Windows desktops, but since Vista, this has changed. > > Now in Vista, some people still forced admin rights, to get rid of the > many annoying dialog boxes that popped up for every tiny task that > might be a security breach. > > But it seems that under Windows 7 this is less intrusive, so we might > consider having the Haskell Platform work well by default without > assuming admin rights? Or at least the installer should clearly tell > you about it, or provide an option. It's always been my view that it should work without admin privileges. It's only been very recently that I've had access to a Windows installation where I am admin. What you need to do is to get the Windows users to agree on what the sensible defaults should be. If you conclude that actually it needs something more complicated like interacting with Windows UAC or something then we'll need to find a volunteer Windows hacker who can implement it. The situation we have at the moment is people complaining but nobody taking action. Duncan From sebastian.sylvan at gmail.com Wed Sep 9 15:19:50 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Wed Sep 9 14:58:49 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <1252499327.5266.5117.camel@localhost> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> Message-ID: <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> On Wed, Sep 9, 2009 at 1:28 PM, Duncan Coutts wrote: > On Tue, 2009-09-08 at 09:58 -0500, Jeff Wheeler wrote: > > On Tue, Sep 8, 2009 at 9:17 AM, Peter Verswyvelen > wrote: > > > > > Ouch, right, I forgot the default is global. It works fine with cabal > > > install --user. And of course I could have edited the default config > > > file, setting user-install: True > > > > > > Well, maybe for newbies this might be a bit confusing. > > > > Yep, I agree. I'm not sure why Cabal defaults to --global on Windows, > > but I found it quite counter-intuitive having come from a Linux > > environment. I forgot about the different default for some time. > > It was because last time we discussed this, the Windows users seemed to > be of the opinion that things were simpler with global installs since > the %PATH% would be right by default and "everyone runs as Administrator > anyway". That may well be different now. > > If the Windows users can come to a consensus on whether the default > should be global or user, then we can easily switch it. The same applies > for the default global or user installation paths. > I think it's morally right to run as user by default. Yes, the windows culture has some legacy that may, on occasion, make it slightly harder to use "well behaved" programs, but it's fairly minor these days. -- Sebastian Sylvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/215f9348/attachment.html From stefan at cs.uu.nl Wed Sep 9 15:35:55 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Wed Sep 9 15:15:01 2009 Subject: [Haskell-cafe] Resolving overloading loops for circular constraint graph In-Reply-To: <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> References: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> Message-ID: Dear Martin, > Your example must loop because as you show below > the instance declaration leads to a cycle. > By "black-holing" you probably mean co-induction. That is, > if the statement to proven appears again, we assume it must hold. > However, type classes are by default inductive, so there's no > easy fix to offer to your problem. Yes, I meant coinductive resolving of overloading. By that line of reasoning, the following should loop as well, but doesn't: {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} class C a instance C () instance (C (a, ()), C b) => C (a, b) f :: C (a, ()) => a -> Int f _ = 2 main :: IO () main = print (f (3 :: Int)) Note: here I would accept looping behaviour as this program requires undecidable instances. > In any case, this is not a bug, you simply play with fire > once type functions show up in the instance context. > There are sufficient conditions to guarantee termination, > but they are fairly restrictive. I disagree: it is a bug. I think the original program should require undecidable instances as well: indeed, the presence of the type family makes that the constraint is possibly no smaller than the instance head. However, without the undecidable-instance requirement (i.e., as it is now), I expect type checking to terminate. Cheers, Stefan From stefan at cs.uu.nl Wed Sep 9 15:48:08 2009 From: stefan at cs.uu.nl (Stefan Holdermans) Date: Wed Sep 9 15:27:15 2009 Subject: [Haskell-cafe] Re: Resolving overloading loops for circular constraint graph In-Reply-To: <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> References: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> Message-ID: Dear Martin, > By "black-holing" you probably mean co-induction. That is, > if the statement to proven appears again, we assume it must hold. > However, type classes are by default inductive, so there's no > easy fix to offer to your problem. A propos: are there fundamental objections to coinductive resolving, i.e., constructing recursive dictionaries. I suppose termination is hard to guarantee then: is it enough to require constraints to be productive w.r.t. instance heads? Cheers, Stefan From akborder at gmail.com Wed Sep 9 15:58:58 2009 From: akborder at gmail.com (Anakim Border) Date: Wed Sep 9 15:37:59 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> Message-ID: <525753470909091258o33edb392v6bb3810afbc3a27f@mail.gmail.com> Hi Edward, I read your slides a few weeks ago when they were posted on Reddit and found your approach very interesting. In fact it provided the inspiration for the parser I've written. I did not use the same strategy, however, because parsing makefiles poses its own challenges. The make syntax is actually the union of two different languages, one for defining targets and one for commands. It's easy to identify commands following target definitions (they belong to lines starting with a tab), but if you jump to the middle of a makefile you can't decide, for example, if you are inside a define block (that should be parsed like a command) because the lines in its body are not marked by any specific prefix. Thus the need for a sequential scan. All this may seem rather involved and specific to an unusual format, but one encounters the same problem when parsing here-documents in shell scripts or multi line (triple-quoted) comments in Python. The cache trashing effect you mention is certainly an issue I did not foresee. I guess a possible solution would be to base parMap on different 'par' primitive; one that sparks a number of computations equal to the number of available OS threads and then blocks until at least one of them is done. -- AB From darrelll at amgen.com Wed Sep 9 16:55:54 2009 From: darrelll at amgen.com (Lewis-Sandy, Darrell) Date: Wed Sep 9 16:34:57 2009 Subject: [Haskell-cafe] Darcs 2.3 and NFS Message-ID: I am trying to set up darcs so that I can share patches between the many machines that I use for application development and testing. The machines have various operating systems (Windows XP, Windows 2000, Windows Vista, Ubuntu 9.04 32-bit, Ubuntu 64 bit, etc). I have a windows file share that is accessible to all the machines, and has been permanently mounted as a CIFS share on the Linux machines. I would like to use that drive for a centralized repository. Since all machines have access to that share I assumed that I could use darcs without setting up either http or ssh access. I have built darcs 2.3 on the Ubuntu 9.04 (Jaunty) 32 bit box and am able to execute darcs commands against any local folders, but am consistently getting an error message when I try to push or put to the NFS: darcs: ./_darcs/tentative_pristine-0:rename: already exists (File exists) Likewise when I navigate to the mounted share folder and attempt a get or pull. Has anyone else encountered this problem? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/f60692eb/attachment-0001.html From ganesh at earth.li Wed Sep 9 17:19:35 2009 From: ganesh at earth.li (Ganesh Sittampalam) Date: Wed Sep 9 16:58:34 2009 Subject: [Haskell-cafe] Darcs 2.3 and NFS In-Reply-To: References: Message-ID: On Wed, 9 Sep 2009, Lewis-Sandy, Darrell wrote: > Windows Vista, Ubuntu 9.04 32-bit, Ubuntu 64 bit, etc). I have a > windows file share that is accessible to all the machines, and has been > permanently mounted as a CIFS share on the Linux machines. > > I have built darcs 2.3 on the Ubuntu 9.04 (Jaunty) 32 bit box and am > able to execute darcs commands against any local folders, but am > consistently getting an error message when I try to push or put to the > NFS: > > darcs: ./_darcs/tentative_pristine-0:rename: already exists (File > exists) At a guess, Windows filesystem semantics are causing trouble here and darcs doesn't know to work around them. There's some code in src/Workaround.hs that sets up a custom renameFile function on Windows - try changing that so that it's unconditionally enabled? Following up on darcs-users would be best though you might need to subscribe. Cheers, Ganesh From ekmett at gmail.com Wed Sep 9 19:31:00 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Sep 9 19:09:58 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <525753470909091258o33edb392v6bb3810afbc3a27f@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> <525753470909091258o33edb392v6bb3810afbc3a27f@mail.gmail.com> Message-ID: <7fb8f82f0909091631t5bb02558k79cdff57616733b7@mail.gmail.com> Actually you can still do the same trick, you just need a smarter delimiter -- ironically the same one I use in Kata. ;) Look for non-backslashed newlines rather than newlines in general and start there. You need a little bit of book-keeping in case a backslash and newline straddle the chunk boundary but it bundles up and gets hidden from you by the monoid. As for the triple quoting or mixed mode languages, I have three options that I've explored: 1.) I have a set of parser combinators that I've been working on that parse fully monoidally, which are sufficient for context-free attribute grammars which can tackle that problem head on. But you give up the monadic sugar that makes parsec so syntactically sweet. (Though I need to change its name since another project named parsimony just appeared on hackage!) 2.) You can define a reversible lexer, whereby given a list of tokens you can generate the original input string, but then you spend a lot of time gluing string fragments together when you started with a perfectly good bytestring. 3.) My favorite option, using the iteratee backed parsec parser from the post you can 'slice' the input bytestring between two cursor positions efficiently. When you start parsing in a superposition of states and the only marker flips your mode rather than cleanly starts or starts it, especially when one is boring like a triple quoted string, just mark the location of the start of your lexer, and maintain two token lists, flipping their roles at each transition. All you wind up doing is grabbing a few extra bytestring slices and lexing the body of your string using the general purpose lexer just in case. Nicely if you have edge cases that cannot occur in one sublanguage or the other, then you can use that to collapse out of the superposition of states into a single state. I'm using this approach for parsing CDATA sections in XML monoidally, which has the same issue. -Edward Kmett On Wed, Sep 9, 2009 at 3:58 PM, Anakim Border wrote: > Hi Edward, > > I read your slides a few weeks ago when they were posted on Reddit and > found your approach very interesting. In fact it provided the > inspiration for the parser I've written. > > I did not use the same strategy, however, because parsing makefiles > poses its own challenges. The make syntax is actually the union of two > different languages, one for defining targets and one for commands. > It's easy to identify commands following target definitions (they > belong to lines starting with a tab), but if you jump to the middle of > a makefile you can't decide, for example, if you are inside a define > block (that should be parsed like a command) because the lines in its > body are not marked by any specific prefix. Thus the need for a > sequential scan. All this may seem rather involved and specific to an > unusual format, but one encounters the same problem when parsing > here-documents in shell scripts or multi line (triple-quoted) comments > in Python. > > The cache trashing effect you mention is certainly an issue I did not > foresee. I guess a possible solution would be to base parMap on > different 'par' primitive; one that sparks a number of computations > equal to the number of available OS threads and then blocks until at > least one of them is done. > > -- AB > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/aebd119f/attachment.html From mpm at alumni.caltech.edu Wed Sep 9 21:29:33 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Wed Sep 9 21:08:47 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) Message-ID: <4AA8567D.20206@alumni.caltech.edu> I'm trying to learn qtHaskell. I realize few people on this list know anything about qtHaskell, but I have a question that probably relates to all GUIs as implemented in Haskell. I just need a hint that could help me figure out the next step, which I might be able to infer from the qtHaskell API. I don't think is any tutorial-type or step-by-step type documentation for qtHaskell. I have sent some questions to the author of qtHaskell, David Harley, but he hasn't responded yet, and anyway I don't want to trouble him every time I have a question, so I'm trying to infer as much as I can. The problem relates to state. In Qt, one adds state to a widget by subclassing it and adding new member variables. For example, I want to create a widget that responds to keypresses and remembers what keypresses have taken place. I'm totally stuck on this part, because Haskell doesn't have state. There must be some kind of Haskell call that adds state to a widget, but it is hard to figure out from the qtHaskell examples David provides. Thanks, Mike From mpm at alumni.caltech.edu Wed Sep 9 21:58:23 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Wed Sep 9 21:37:28 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA8567D.20206@alumni.caltech.edu> References: <4AA8567D.20206@alumni.caltech.edu> Message-ID: <4AA85D3F.7060208@alumni.caltech.edu> Been poking around. Maybe IORef has something to do with this? I found a qtHaskell example that seems to make use of IORef in order to accomplish something similar to what I want. Michael P Mossey wrote: > I'm trying to learn qtHaskell. I realize few people on this list know > anything about qtHaskell, but I have a question that probably relates to > all GUIs as implemented in Haskell. I just need a hint that could help > me figure out the next step, which I might be able to infer from the > qtHaskell API. > > I don't think is any tutorial-type or step-by-step type documentation > for qtHaskell. I have sent some questions to the author of qtHaskell, > David Harley, but he hasn't responded yet, and anyway I don't want to > trouble him every time I have a question, so I'm trying to infer as much > as I can. > > The problem relates to state. In Qt, one adds state to a widget by > subclassing it and adding new member variables. For example, I want to > create a widget that responds to keypresses and remembers what > keypresses have taken place. > > I'm totally stuck on this part, because Haskell doesn't have state. > There must be some kind of Haskell call that adds state to a widget, but > it is hard to figure out from the qtHaskell examples David provides. > > Thanks, > Mike > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jeff at nokrev.com Wed Sep 9 22:18:12 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Wed Sep 9 21:57:30 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> Message-ID: <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> On Wed, Sep 9, 2009 at 2:19 PM, Sebastian Sylvan wrote: > I think it's morally right to run as user by default. Yes, the windows > culture has some legacy that may, on occasion, make it slightly harder to > use "well behaved" programs, but it's fairly minor these days. I strongly agree. Presently, on Windows 7, I have to right-click and "Run As Administrator" and then approve the process via UAC to get anything done under the default --global setting, in much the same way I would have to launch a root terminal and provide my password within GNOME (a la gksu) or other *nix environments (Windows doesn't have anything like sudo, as far as I know). Since it works essentially the same as *nix does, as of Windows 7, I see no reason for a different default. Jeff Wheeler From jvranish at gmail.com Wed Sep 9 23:12:35 2009 From: jvranish at gmail.com (Job Vranish) Date: Wed Sep 9 22:51:33 2009 Subject: [Haskell-cafe] Fixed length list type? Message-ID: Does anyone know of a hackage package that has fixed length list type that is an instance of Applicative, Foldable and Traversable? (a list type that somehow encodes its length in the type) I've found lots of fixed length list types, but non that are members of the common typeclasses. I've implement one here: http://github.com/jvranish/FixedList/blob/6c861a12ba5d17481fd22cdb1f90404abff7c0bc/src/Data/FixedList.hs But am I just duplicating work that is already out there? Thanks, - Job -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090909/d94570c6/attachment.html From bulat.ziganshin at gmail.com Thu Sep 10 01:06:40 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 00:51:36 2009 Subject: [Haskell-cafe] Parallel parsing & multicore In-Reply-To: <525753470909091258o33edb392v6bb3810afbc3a27f@mail.gmail.com> References: <525753470909090635gbe20db7xd773cb9aa6df1b32@mail.gmail.com> <20090909134056.GE3390@whirlpool.galois.com> <525753470909090742o1856549ar123f46a3c5ef2888@mail.gmail.com> <7fb8f82f0909090914i4b137d67ta9e7251a1c7ea820@mail.gmail.com> <525753470909091258o33edb392v6bb3810afbc3a27f@mail.gmail.com> Message-ID: <253027155.20090910090640@gmail.com> Hello Anakim, Wednesday, September 9, 2009, 11:58:58 PM, you wrote: > foresee. I guess a possible solution would be to base parMap on > different 'par' primitive; one that sparks a number of computations > equal to the number of available OS threads and then blocks until at > least one of them is done. actually you should ask RTS -N value, that should be available via internal RTS structures. and then user, optionally, may link in a code that sets RTS -N to the number of hardware threads -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Sep 10 01:10:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 00:51:38 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA8567D.20206@alumni.caltech.edu> References: <4AA8567D.20206@alumni.caltech.edu> Message-ID: <1887042328.20090910091052@gmail.com> Hello Michael, Thursday, September 10, 2009, 5:29:33 AM, you wrote: > I'm totally stuck on this part, because Haskell doesn't have state. There must Haskell support states (yes, IORef is equal to C++ reference type - it's a constant pointer to some memory area that you may read/write), but it doesn't support OOP subclassing. this problem solved in different ways in each particular haskell GUI -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From z_axis at 163.com Thu Sep 10 02:20:30 2009 From: z_axis at 163.com (zaxis) Date: Thu Sep 10 01:59:28 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? Message-ID: <25377949.post@talk.nabble.com> myFoldl :: (a -> b -> a) -> a -> [b] -> a myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) I know myFoldl implements foldl using foldr. However i really donot know how it can do it ? Please shed a light one me, thanks! -- View this message in context: http://www.nabble.com/Would-you-mind-explain-such-a-code---tp25377949p25377949.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From briand at aracnet.com Thu Sep 10 02:21:34 2009 From: briand at aracnet.com (brian) Date: Thu Sep 10 02:00:37 2009 Subject: [Haskell-cafe] hmatrix on os x In-Reply-To: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> References: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> Message-ID: yep I had some trouble too, although interestingly less than on linux pc. can you provide some error messages and we can see if your problems are the same one's I saw. I think most of my problem involved the location of the libraries. Also I think that you are really going to want to have fink installed. Brian On Sep 7, 2009, at 7:06 PM, Ben wrote: > hello -- > > i've been having a heck of a time installing hmatrix on mac os x. > i've seen the help pages including > > http://mit.edu/harold/Public/easyVisionNotes.html > > but they haven't helped me. my setup is > > haskell platform 2009.2.0.2 (ghc 6.10.4) > os x 10.5 > macports -- i've tried installing gsl and gsl-devel to no avail. > > i've tried cabal install with various options, to no avail. has > anyone else have luck with this? > > best, ben > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From g.c.stavenga at uu.nl Thu Sep 10 02:55:28 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Thu Sep 10 02:34:25 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: <25377949.post@talk.nabble.com> References: <25377949.post@talk.nabble.com> Message-ID: <25378268.post@talk.nabble.com> zaxis wrote: > > myFoldl :: (a -> b -> a) -> a -> [b] -> a > > myFoldl f z xs = foldr step id xs z > where step x g a = g (f a x) > > I know myFoldl implements foldl using foldr. However i really donot know > how it can do it ? > > Please shed a light one me, thanks! > Hi, Nice example! Well this is indeed an abstract piece of code. But basically foldl f z xs starts with z and keeps applying (`f`x) to it so for example foldl f z [1,2,3] = ((`f`3).(`f`2).(`f`1)) z Because functions are first-class in haskell, we can also perform a foldl where instead of calculating the intermediate values we calculate the total function, i.e. ((`f`3).(`f`2).(`f`1)) and apply it to z. When the list is empty z goes to z, so the start function must be id. So we can write (`f`3).(`f`2).(`f`1) = foldr (\x g -> g . (`f`x)) id xs This is almost in your form. Hope this helps, Gerben -- View this message in context: http://www.nabble.com/Would-you-mind-explain-such-a-code---tp25377949p25378268.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From martijn at van.steenbergen.nl Thu Sep 10 02:57:51 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Sep 10 02:37:00 2009 Subject: [Haskell-cafe] hmatrix on os x In-Reply-To: References: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> Message-ID: <4AA8A36F.8040406@van.steenbergen.nl> brian wrote: > yep I had some trouble too, although interestingly less than on linux pc. > > can you provide some error messages and we can see if your problems are > the same one's I saw. If this helps, here is the error message I got: Configuring hmatrix-0.5.2.2... Checking foreign libraries... FAIL *** Sorry, I can't link GSL. *** Please make sure that the appropriate -dev packages are installed. *** You can also specify the required libraries using *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc. setup: Package hmatrix-0.5.2.2 can't be built on this system. cabal: Error: some packages failed to install: hmatrix-0.5.2.2 failed during the building phase. The exception was: exit: ExitFailure 1 M. From z_axis at 163.com Thu Sep 10 03:51:21 2009 From: z_axis at 163.com (zaxis) Date: Thu Sep 10 03:30:21 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: <25378268.post@talk.nabble.com> References: <25377949.post@talk.nabble.com> <25378268.post@talk.nabble.com> Message-ID: <25378882.post@talk.nabble.com> thanks for your quick answer! As I understand foldr (\x g -> g . (`f`x)) id xs will return a function such as (`f` 3).(`f` 2).(`f` 1) . You have already made it clear ! However, why does the "step" function below has three parameters ? I think foldr will call step using two parameters, the 1st is list element and the 2nd is a funtion whose initial value is id). myFoldl f z xs = foldr step id xs z where step x g a = g (f a x) staafmeister wrote: > > > > zaxis wrote: >> >> myFoldl :: (a -> b -> a) -> a -> [b] -> a >> >> myFoldl f z xs = foldr step id xs z >> where step x g a = g (f a x) >> >> I know myFoldl implements foldl using foldr. However i really donot know >> how it can do it ? >> >> Please shed a light one me, thanks! >> > > Hi, > > Nice example! Well this is indeed an abstract piece of code. But basically > foldl f z xs starts with z and keeps applying (`f`x) to it > so for example foldl f z [1,2,3] = ((`f`3).(`f`2).(`f`1)) z > > Because functions are first-class in haskell, we can also perform a foldl > where instead of calculating the intermediate values we calculate the > total function, i.e. ((`f`3).(`f`2).(`f`1)) and apply it to z. > > When the list is empty z goes to z, so the start function must be id. > So we can write > (`f`3).(`f`2).(`f`1) = foldr (\x g -> g . (`f`x)) id xs > > This is almost in your form. > > Hope this helps, > Gerben > -- View this message in context: http://www.nabble.com/Would-you-mind-explain-such-a-code---tp25377949p25378882.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From oleg at okmij.org Thu Sep 10 03:58:22 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Sep 10 03:40:29 2009 Subject: [Haskell-cafe] Re: Would you mind explain such a code ? Message-ID: <20090910075822.A4AC4176D5@Adric.metnet.navy.mil> > I know myFoldl implements foldl using foldr. However i really donot know how > it can do it ? You will probably like Graham Hutton A Tutorial on the Universality and Expressiveness of Fold JFP, 1999. http://www.cs.nott.ac.uk/~gmh/fold.pdf Section 5.1 (actually, suml in Section 5) of the paper explains how the expression of foldl in terms of foldr can be _calculated_. The result is correct by construction. From simonpj at microsoft.com Thu Sep 10 04:55:29 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Thu Sep 10 04:35:33 2009 Subject: [Haskell-cafe] RE: Resolving overloading loops for circular constraint graph In-Reply-To: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> References: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C363F9B9EBA9@EA-EXMSG-C334.europe.corp.microsoft.com> Stefan You are trying to do something quite delicate here. The whole idea of solving constraints in a co-inductive way (building a recursive group of dictionary definitions) relies on spotting something we've seen before to "tie the knot". To date, the main application I knew for this fairly exotic idea was described in the SYB3 paper [1]. So I'm curious about your application (and that of anyone else) that relies on this recursive-dictionary-solving mechanism. Returning to your problem, this "loop spotting" mechanism is rather syntactic at the moment, whereas your application needs something more refined, involving equality modulo type function reductions. Alas, the constraint solving machinery for type classes and for type functions is not properly integrated. I'm amazed it works as well as it does, actually. We [Manuel, Dimitrios, and I] are (slowly, slowly) working on a complete rewrite of GHC's constraint-solving mechanism. I'm pretty sure that it'll solve this problem among many others. But don't hold your breath. It'll be months not weeks. But not years! sorry not to be able to solve your problem sooner. I'll open a ticket. Simon [1] http://research.microsoft.com/~simonpj/papers/hmap | -----Original Message----- | From: Stefan Holdermans [mailto:stefan@cs.uu.nl] | Sent: 09 September 2009 14:38 | To: Manuel M T Chakravarty; Simon Peyton-Jones | Cc: glasgow-haskell-users; haskell-cafe; Jos? Pedro Magalh?es; Thomas van Noort; | Johan Jeuring | Subject: Resolving overloading loops for circular constraint graph | | Manuel, Simon, | | I've spotted a hopefully small but for us quite annoying bug in GHC's | type checker: it loops when overloading resolving involves a circular | constraint graph containing type-family applications. | | The following program (also attached) demonstrates the problem: | | {-# LANGUAGE FlexibleContexts #-} | {-# LANGUAGE TypeFamilies #-} | | type family F a :: * | type instance F Int = (Int, ()) | | class C a | instance C () | instance (C (F a), C b) => C (a, b) | | f :: C (F a) => a -> Int | f _ = 2 | | main :: IO () | main = print (f (3 :: Int)) | | My guess is that the loop is caused by the constraint C (F Int) that | arises from the use of f in main: | | C (F Int) = C (Int, ()) <= C (F Int) | | Indeed, overloading can be resolved successfully by "black-holing" the | initial constraint, but it seems like the type checker refuses to do so. | | Can you confirm my findings? | | I'm not sure whether this is a known defect. If it isn't, I'd be more | than happy to issue a report. | | Since this problem arises in a piece of very mission-critical code, I | would be pleased to learn about any workarounds. | | Thanks in advance, | | Stefan From bugfact at gmail.com Thu Sep 10 05:21:18 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 10 05:00:16 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> Message-ID: Actually, this UAC was already present in Vista no? On Thu, Sep 10, 2009 at 4:18 AM, Jeff Wheeler wrote: > On Wed, Sep 9, 2009 at 2:19 PM, Sebastian > Sylvan wrote: > >> I think it's morally right to run as user by default. Yes, the windows >> culture has some legacy that may, on occasion, make it slightly harder to >> use "well behaved" programs, but it's fairly minor these days. > > I strongly agree. Presently, on Windows 7, I have to right-click and > "Run As Administrator" and then approve the process via UAC to get > anything done under the default --global setting, in much the same way > I would have to launch a root terminal and provide my password within > GNOME (a la gksu) or other *nix environments (Windows doesn't have > anything like sudo, as far as I know). > > Since it works essentially the same as *nix does, as of Windows 7, I > see no reason for a different default. > > Jeff Wheeler > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From akborder at gmail.com Thu Sep 10 05:24:38 2009 From: akborder at gmail.com (Anakim Border) Date: Thu Sep 10 05:03:36 2009 Subject: [Haskell-cafe] Bounded parMap Message-ID: <525753470909100224x70b8b6fes637e3872e7179cf9@mail.gmail.com> Hi, lately I've been working on a parallel parser whose core is something like this: pMap parse blocks where pMap is a map-like function sparking independent computations over the elements of the "blocks" list. The actual implementation used Control.Parallel.Strategies: map parse blocks `using` parListChunk n rnf In a recent post [1], however, Edward Kmett noted that such code is cache oblivious because the "blocks" list is traversed independently by the map and by the sparks. It may therefore happen that the first spark starts to be evaluated when the map is already at the end of the list. Moreover, all the sparks are generated almost instantaneously even if only a few of them can be evaluated concurrently (I'm assuming here that the length of the list is bigger than the number of available native threads, but that seems reasonable). To solve this issue I imagined an alternative "par" primitive sparking a new computation in parallel when a native thread is free to perform its evaluation and otherwise blocking. It turns out it is possible to implement something like this in a library; have a look at the BoundedParMap module here: http://github.com/akborder/HsMakefileParser/ The code uses unsafe operations, so I'm not sure it can be completely trusted. Given however that the "boundedParMap" function combines deterministically the results of multiple applications of a pure function, it should remain referentially transparent. To measure performances I made two versions of my parser (Makefile.hs), one keeping Control.Parallel.Strategies as before and the other using BoundedParMap. I built them (ghc -O2 -threaded; ghc 6.11.20090907) and run them on a quad-core system (+RTS -N4) over a list generating 48 sparks. Running each implementation 10 times I got the following run times: Control.Parallel.Strategies: 1.328 +- 0.1 BoundedParMap: 1.095 +- 0.12 BoundedParMap seems to be faster, especially considering that the total number of sparks (48) is quite small. Do you think that the difference is actually due to better caching (both in the list traversing and because the runtime system deals with less sparks at any time) or to something else I'm missing? -- AB [1] http://www.haskell.org/pipermail/haskell-cafe/2009-September/066158.html From bugfact at gmail.com Thu Sep 10 05:25:23 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 10 05:04:21 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> Message-ID: Interestingly, a sudo for Windows does seem to exist. It's called the "runas" command. At first sight it existed already since Windows XP Also on Sourceforge an open source sudo command for Windows is hosted: http://sourceforge.net/projects/sudowin On Thu, Sep 10, 2009 at 11:21 AM, Peter Verswyvelen wrote: > Actually, this UAC was already present in Vista no? > > On Thu, Sep 10, 2009 at 4:18 AM, Jeff Wheeler wrote: >> On Wed, Sep 9, 2009 at 2:19 PM, Sebastian >> Sylvan wrote: >> >>> I think it's morally right to run as user by default. Yes, the windows >>> culture has some legacy that may, on occasion, make it slightly harder to >>> use "well behaved" programs, but it's fairly minor these days. >> >> I strongly agree. Presently, on Windows 7, I have to right-click and >> "Run As Administrator" and then approve the process via UAC to get >> anything done under the default --global setting, in much the same way >> I would have to launch a root terminal and provide my password within >> GNOME (a la gksu) or other *nix environments (Windows doesn't have >> anything like sudo, as far as I know). >> >> Since it works essentially the same as *nix does, as of Windows 7, I >> see no reason for a different default. >> >> Jeff Wheeler >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From roma at ro-che.info Thu Sep 10 05:47:05 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Thu Sep 10 05:25:38 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: <25378882.post@talk.nabble.com> References: <25377949.post@talk.nabble.com> <25378268.post@talk.nabble.com> <25378882.post@talk.nabble.com> Message-ID: <20090910094705.GA6209@flit> * zaxis [2009-09-10 00:51:21-0700] > > thanks for your quick answer! > > As I understand foldr (\x g -> g . (`f`x)) id xs will return a function > such as (`f` 3).(`f` 2).(`f` 1) . You have already made it clear ! However, > why does the "step" function below has three parameters ? I think foldr > will call step using two parameters, the 1st is list element and the 2nd is > a funtion whose initial value is id). That's right. step x g a = g (f a x) is, thanks to currying, another way to write step x g = \a -> g (f a x) This is what we want -- function of two arguments, which returns a new value of accumulator (which in this case is a function itself). And g (f a x) can be rewritten as g ((f a) x) = g (a `f` x) = g ((`f` x) a) = (g . (`f` x)) a, thus step x g = \a -> g (f a x) = \a -> (g . (`f` x)) a = g . (`f` x) (the last step is called 'eta-reduction'). Remember that g is a previous value of accumulator and step x g is its new value, so on each step we compose accumulator with (`f` x) to get the new value. So in the end it will look like you wrote above. > myFoldl f z xs = foldr step id xs z > where step x g a = g (f a x) > > > staafmeister wrote: > > > > > > > > zaxis wrote: > >> > >> myFoldl :: (a -> b -> a) -> a -> [b] -> a > >> > >> myFoldl f z xs = foldr step id xs z > >> where step x g a = g (f a x) > >> > >> I know myFoldl implements foldl using foldr. However i really donot know > >> how it can do it ? > >> > >> Please shed a light one me, thanks! > >> > > > > Hi, > > > > Nice example! Well this is indeed an abstract piece of code. But basically > > foldl f z xs starts with z and keeps applying (`f`x) to it > > so for example foldl f z [1,2,3] = ((`f`3).(`f`2).(`f`1)) z > > > > Because functions are first-class in haskell, we can also perform a foldl > > where instead of calculating the intermediate values we calculate the > > total function, i.e. ((`f`3).(`f`2).(`f`1)) and apply it to z. > > > > When the list is empty z goes to z, so the start function must be id. > > So we can write > > (`f`3).(`f`2).(`f`1) = foldr (\x g -> g . (`f`x)) id xs > > > > This is almost in your form. > > > > Hope this helps, > > Gerben > > > > -- > View this message in context: http://www.nabble.com/Would-you-mind-explain-such-a-code---tp25377949p25378882.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From duncan.coutts at worc.ox.ac.uk Thu Sep 10 05:58:21 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 10 05:58:51 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> Message-ID: <1252576701.5266.6434.camel@localhost> On Wed, 2009-09-09 at 20:19 +0100, Sebastian Sylvan wrote: > > > On Wed, Sep 9, 2009 at 1:28 PM, Duncan Coutts > wrote: > > If the Windows users can come to a consensus on whether the > default should be global or user, then we can easily switch > it. The same applies for the default global or user > installation paths. > I think it's morally right to run as user by default. Yes, the windows > culture has some legacy that may, on occasion, make it slightly harder > to use "well behaved" programs, but it's fairly minor these days. So is it just a matter of switching the default, or do the default user paths have to change too? Is there any recommended/sensible place for installing per-user applications on Windows? (I think there wasn't on XP, but perhaps that's changed on Vista/Win7) Have you tried running with user as the default for a while? Does it work ok? Duncan From sebastian.sylvan at gmail.com Thu Sep 10 06:39:23 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Thu Sep 10 06:18:21 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <1252576701.5266.6434.camel@localhost> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> Message-ID: <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> On Thu, Sep 10, 2009 at 10:58 AM, Duncan Coutts wrote: > On Wed, 2009-09-09 at 20:19 +0100, Sebastian Sylvan wrote: > > > > > > On Wed, Sep 9, 2009 at 1:28 PM, Duncan Coutts > > wrote: > > > > > If the Windows users can come to a consensus on whether the > > default should be global or user, then we can easily switch > > it. The same applies for the default global or user > > installation paths. > > > I think it's morally right to run as user by default. Yes, the windows > > culture has some legacy that may, on occasion, make it slightly harder > > to use "well behaved" programs, but it's fairly minor these days. > > So is it just a matter of switching the default, or do the default user > paths have to change too? Is there any recommended/sensible place for > installing per-user applications on Windows? (I think there wasn't on > XP, but perhaps that's changed on Vista/Win7) > > I think it's %LOCALAPPDATA% -- Sebastian Sylvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/f346fa89/attachment.html From duncan.coutts at worc.ox.ac.uk Thu Sep 10 06:53:46 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 10 06:36:04 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <50c1e0910909091918v6710298cud9f54a043d0b3e0@mail.gmail.com> Message-ID: <1252580026.5266.6511.camel@localhost> On Wed, 2009-09-09 at 21:18 -0500, Jeff Wheeler wrote: > On Wed, Sep 9, 2009 at 2:19 PM, Sebastian > Sylvan wrote: > > > I think it's morally right to run as user by default. Yes, the windows > > culture has some legacy that may, on occasion, make it slightly harder to > > use "well behaved" programs, but it's fairly minor these days. > > I strongly agree. Presently, on Windows 7, I have to right-click and > "Run As Administrator" and then approve the process via UAC to get > anything done under the default --global setting And when you switch the default to user installs (by editing the config file) does everything work ok then? I'm trying to work out if we switch the "default default", if it'll just work, or if there are further problems to solve. Duncan From deniz.a.m.dogan at gmail.com Thu Sep 10 07:16:56 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Sep 10 06:55:52 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> Message-ID: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> 2009/9/10 Sebastian Sylvan : > > > On Thu, Sep 10, 2009 at 10:58 AM, Duncan Coutts > wrote: >> >> On Wed, 2009-09-09 at 20:19 +0100, Sebastian Sylvan wrote: >> > >> > >> > On Wed, Sep 9, 2009 at 1:28 PM, Duncan Coutts >> > wrote: >> >> > >> > ? ? ? ? If the Windows users can come to a consensus on whether the >> > ? ? ? ? default should be global or user, then we can easily switch >> > ? ? ? ? it. The same applies for the default global or user >> > ? ? ? ? installation paths. >> >> > I think it's morally right to run as user by default. Yes, the windows >> > culture has some legacy that may, on occasion, make it slightly harder >> > to use "well behaved" programs, but it's fairly minor these days. >> >> So is it just a matter of switching the default, or do the default user >> paths have to change too? Is there any recommended/sensible place for >> installing per-user applications on Windows? (I think there wasn't on >> XP, but perhaps that's changed on Vista/Win7) >> > > I think it's %LOCALAPPDATA% > > > > -- > Sebastian Sylvan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > Is there any %LOCALAPPDATA% on Windows XP? If not, what is the difference between %LOCALAPPDATA% and %APPDATA% in Windows Vista/7? I was thinking if it's not unreasonable to store Cabal stuff in %APPDATA%, one might as well use that and cover XP, Vista and 7 all in one. -- Deniz Dogan From g.c.stavenga at uu.nl Thu Sep 10 07:54:34 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Thu Sep 10 07:33:30 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25306687.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> Message-ID: <25381881.post@talk.nabble.com> Thanks to reactions! What do you think about such a function? This function is still a bit dangerous (I think). I don't know how to make sure the compiler does not lift cache to something global. But on the other hand this use of unsafePerformIO is legit because it doesn't alter the referential transparency of the function. The same as in DiffArray. Greetings Gerben memo f = let cache = unsafePerformIO $ newIORef M.empty cachedFunc x = unsafePerformIO (do m <- readIORef cache case M.lookup x m of Just y -> return y Nothing -> do let res = f x writeIORef cache $ M.insert x res m return res) in cachedFunc memo2 f = curry $ memo $ uncurry f -- View this message in context: http://www.nabble.com/memoization-tp25306687p25381881.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From frank at geoinfo.tuwien.ac.at Thu Sep 10 08:02:27 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Thu Sep 10 07:41:31 2009 Subject: [Haskell-cafe] better error message for "undefined" Message-ID: <200909101402.27945.frank@geoinfo.tuwien.ac.at> the haskell prelude introduces the type undefined and contains a remark to the effect that compilers are expected to intrudocue a meaningful error message. GHC just prints 'Prelude undefined' which is not very informativ. is there a way to have different kinds of undefined? such that i get a message which one was hit. something like writing in the code 'unefined 'my error 123' which prints 'undefined - my error 123' when it is accidentally hit. i searched the web, but found nothing. any suggestions? thanks a lot! andrew From bulat.ziganshin at gmail.com Thu Sep 10 08:07:54 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 07:46:58 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25381881.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> Message-ID: <851558299.20090910160754@gmail.com> Hello staafmeister, Thursday, September 10, 2009, 3:54:34 PM, you wrote: > What do you think about such a function? This function is a bit of refactoring -- "global variable" in haskell way cache = unsafePerformIO $ newIORef M.empty memo f x = unsafePerformIO$ do m <- readIORef cache case M.lookup x m of Just y -> return y Nothing -> do let res = f x writeIORef cache $ M.insert x res m return res memo2 = curry . memo . uncurry -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Thu Sep 10 08:08:44 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 07:47:48 2009 Subject: [Haskell-cafe] better error message for "undefined" In-Reply-To: <200909101402.27945.frank@geoinfo.tuwien.ac.at> References: <200909101402.27945.frank@geoinfo.tuwien.ac.at> Message-ID: <516729548.20090910160844@gmail.com> Hello Andrew, Thursday, September 10, 2009, 4:02:27 PM, you wrote: > is there a way to have different kinds of undefined? such that i get a message > which one was hit. something like writing in the code 'unefined 'my error 123' > which prints 'undefined - my error 123' when it is accidentally hit. error "my error 123" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From martijn at van.steenbergen.nl Thu Sep 10 08:08:48 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Thu Sep 10 07:47:58 2009 Subject: [Haskell-cafe] better error message for "undefined" In-Reply-To: <200909101402.27945.frank@geoinfo.tuwien.ac.at> References: <200909101402.27945.frank@geoinfo.tuwien.ac.at> Message-ID: <4AA8EC50.1010001@van.steenbergen.nl> You can use the error function. It accepts a string that is displayed when the error is evaluated: > GHCi, version 6.10.1: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> error "hi!" > *** Exception: hi! HTH, Martijn. Andrew U. Frank wrote: > is there a way to have different kinds of undefined? such that i get a message > which one was hit. something like writing in the code 'unefined 'my error 123' > which prints 'undefined - my error 123' when it is accidentally hit. From g.c.stavenga at uu.nl Thu Sep 10 08:23:26 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Thu Sep 10 08:02:21 2009 Subject: Re[Haskell-cafe] [2]: memoization In-Reply-To: <851558299.20090910160754@gmail.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> Message-ID: <25382341.post@talk.nabble.com> Hi Bulat, Bulat Ziganshin-2 wrote: > > Hello staafmeister, > > Thursday, September 10, 2009, 3:54:34 PM, you wrote: > >> What do you think about such a function? This function is > > a bit of refactoring > > -- "global variable" in haskell way > cache = unsafePerformIO $ newIORef M.empty > > memo f x = unsafePerformIO$ do > m <- readIORef cache > case M.lookup x m of > Just y -> return y > Nothing -> do let res = f x > writeIORef cache $ M.insert x res m > return res > > memo2 = curry . memo . uncurry > This doesn't work and is exactly what I'm afraid the compiler is going to do. Cache needs to be associated with the function f. Otherwise one would get conflicts Greetings -- View this message in context: http://www.nabble.com/memoization-tp25306687p25382341.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bugfact at gmail.com Thu Sep 10 08:26:38 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 10 08:05:36 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> Message-ID: No Windows XP did not have support for roaming profiles yet I think. But it wouldn't be too difficult to use %LOCALAPPDATA% first, and when it doesn't exist, use %APPDATA%? This article explains a lot about the differences; I didn't have time yet to read it in detail http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx What other software sometimes does (like Autodesk Maya), is just create a folder in the "My Documents" logical folder. I personally don't like this. On Thu, Sep 10, 2009 at 1:16 PM, Deniz Dogan wrote: > 2009/9/10 Sebastian Sylvan : >> >> >> On Thu, Sep 10, 2009 at 10:58 AM, Duncan Coutts >> wrote: >>> >>> On Wed, 2009-09-09 at 20:19 +0100, Sebastian Sylvan wrote: >>> > >>> > >>> > On Wed, Sep 9, 2009 at 1:28 PM, Duncan Coutts >>> > wrote: >>> >>> > >>> > ? ? ? ? If the Windows users can come to a consensus on whether the >>> > ? ? ? ? default should be global or user, then we can easily switch >>> > ? ? ? ? it. The same applies for the default global or user >>> > ? ? ? ? installation paths. >>> >>> > I think it's morally right to run as user by default. Yes, the windows >>> > culture has some legacy that may, on occasion, make it slightly harder >>> > to use "well behaved" programs, but it's fairly minor these days. >>> >>> So is it just a matter of switching the default, or do the default user >>> paths have to change too? Is there any recommended/sensible place for >>> installing per-user applications on Windows? (I think there wasn't on >>> XP, but perhaps that's changed on Vista/Win7) >>> >> >> I think it's %LOCALAPPDATA% >> >> >> >> -- >> Sebastian Sylvan >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > Is there any %LOCALAPPDATA% on Windows XP? If not, what is the > difference between %LOCALAPPDATA% and %APPDATA% in Windows Vista/7? I > was thinking if it's not unreasonable to store Cabal stuff in > %APPDATA%, one might as well use that and cover XP, Vista and 7 all in > one. > > -- > Deniz Dogan > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Thu Sep 10 08:34:38 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 10 08:13:35 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <851558299.20090910160754@gmail.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> Message-ID: You might want to watch out for multithreading issues, although in this case, I don't think it will cause sever problems, besides a couple of redundant cache updates. On Thu, Sep 10, 2009 at 2:07 PM, Bulat Ziganshin wrote: > Hello staafmeister, > > Thursday, September 10, 2009, 3:54:34 PM, you wrote: > >> What do you think about such a function? This function is > > a bit of refactoring > > -- "global variable" in haskell way > cache = unsafePerformIO $ newIORef M.empty > > memo f x = unsafePerformIO$ do > ? ? ? ? ? ? ? ? ? ? ? m <- readIORef cache > ? ? ? ? ? ? ? ? ? ? ? case M.lookup x m of > ? ? ? ? ? ? ? ? ? ? ? ? Just y -> return y > ? ? ? ? ? ? ? ? ? ? ? ? Nothing -> do let res = f x > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? writeIORef cache $ M.insert x res m > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return res > > memo2 = curry . memo . uncurry > > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bugfact at gmail.com Thu Sep 10 08:43:10 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 10 08:22:07 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: <20090910094705.GA6209@flit> References: <25377949.post@talk.nabble.com> <25378268.post@talk.nabble.com> <25378882.post@talk.nabble.com> <20090910094705.GA6209@flit> Message-ID: On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka wrote: > ?step x g a = g (f a x) > > is, thanks to currying, another way to write > > ?step x g = \a -> g (f a x) I thought currying just meant curry f x y = f (x,y) Isn't the reason that f x y z = body is the same as f = \x -> \y -> \z -> body just cause the former is syntactic sugar of the latter? From fmartini at gmail.com Thu Sep 10 08:44:42 2009 From: fmartini at gmail.com (Felix Martini) Date: Thu Sep 10 08:23:39 2009 Subject: [Haskell-cafe] Re: Cabal install on Windows 7 In-Reply-To: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> Message-ID: <4cf86b4f-1c19-477e-bef7-101c3d58e3db@s31g2000yqs.googlegroups.com> > Is there any %LOCALAPPDATA% on Windows XP? If not, what is the > difference between %LOCALAPPDATA% and %APPDATA% in Windows Vista/7? XP does not define the %LOCALAPPDATA% environment variable, but it is equivalent to %USERPROFILE%\Local Settings\Application Data. Data in local application data folders remains on one computer and is not stored on a Windows server in a Windows domain setting. Data in application data folders can be transferred over the local network when a user accesses his data on multiple computers. So for larger user data files the local application data folder is often more suitable. Microsoft uses the folder for things like "click once" applications and Google uses it to store Google Chrome so people do not need administrator permission to install it. I run the Haskell platform on XP with the cabal --user config setting on a limited account and i don't have any issues. I think it is better if the platform itself is installed by an administrator account and shared by all users like on Unix. Ideally in a path without any spaces because that prevents a lot of issues when compiling packages that use C bindings. I myself store most software originating from the Unix world in C:\Applications instead of C:\Program Files and the platform folder should preferably be named HaskellPlatform instead of Haskell Platform. Regards, Felix From bulat.ziganshin at gmail.com Thu Sep 10 08:50:54 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 08:30:06 2009 Subject: Re[Haskell-cafe] [2]: memoization In-Reply-To: <25382341.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <25382341.post@talk.nabble.com> Message-ID: <1601456353.20090910165054@gmail.com> Hello staafmeister, Thursday, September 10, 2009, 4:23:26 PM, you wrote: > This doesn't work and is exactly what I'm afraid the compiler is going to > do. Cache needs to > be associated with the function f. > Otherwise one would get conflicts well, technique i used is well known, we would have something like C global variable. initiating it inside function is a technique i never seen, i *expect* that it would be the same since syntax scoping doesn't change semantics, but it would be better to ask people that know haskell better if you want to disable sharing of cache you need to make function (or some string representing it) an explicit parameter. i see that you try to do it via declaring f at the outer function level and x in the inner function, but this shouldn't work. the following: outer f = inner where inner x = f x*f x and outer f x = f x*f x are exactly the same. in general, consider Haskell as pure math notation with all its features -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From regis.saint-paul at create-net.org Thu Sep 10 09:18:19 2009 From: regis.saint-paul at create-net.org (Regis Saint-Paul) Date: Thu Sep 10 08:57:21 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com><1252499327.5266.5117.camel@localhost><3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com><1252576701.5266.6434.camel@localhost><3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> Message-ID: One way in which cabal can be made UAC aware (and therefore request for elevation privileges instead of just failing) would be to embed a manifest in the cabal.exe. This can be done by changing the default manifest (an XML file) that is embedded at link time by GHC. This is supported by GHC through compilation options. It could be used when building cabal for windows. The manifest itself is simple, it just needs one additional line to say it requires admin privileges. All details are here: http://msdn.microsoft.com/en-us/library/bb756929.aspx However, a problem with this approach is that cabal.exe as a whole would be seen as needing administrator privilege, regardless of whether the setting is global or user. If we want to request admin privileges only when actually needed (i.e., when writing in a protected folder). To address this, there are several options: - have two distinct executables for cabal, cabal-global and cabal-user with different manifest - use windows API for requesting elevation during the process (ugly) - use shellexecute command for running a process performing just the task that needs elevated privileges. Someone mentioned the "runas" command. But unlike su on linux, runas only changes the user, not the privileges attached to it. That is, on VISTA and 7, even admin users are seen as "standard user" unless they explicitly acknowledge they want to elevate a process with admin rights. So if you need admin rights while running as admin, you are only prompted for yes or no, while if you need admin rights as a non-admin user, you are also prompted for admin pass. This was done do address the legacy problem that everyone was using windows as admin in the first place. Also, the AppData folder is for application data, not for the application itself. I'm not sure how far one needs to go in terms of well-behaving for windows when it comes to multi-platform applications. I'd like to point out the "Application Compatibility Toolkit" which allows testing if an application is well behaved for vista and 7 and provides guidelines for that (it's a free download): http://www.microsoft.com/downloads/details.aspx?FamilyID=24da89e9-b581-47b0- b45e-492dd6da2971&DisplayLang=en you may also need to download the application verifier here: http://www.microsoft.com/downloads/details.aspx?FamilyID=c4a25ab9-649d-4a1b- b4a7-c9d8b095df18&DisplayLang=en You can use also on XP to test for vista and 7. I tried running it with cabal install somepackage and it points out a number of privilege errors. Note that if cabal was writing packages in AppData instead of "program files", then the problem would only surface when cabal install moves executable in the bin directory. It seems to me that the cygwin/mingw and, more generally, the GNU way of dealing with windows is to mainly ignore the directory structure of windows and install things in a separate directory chosen by the user (possibly in program files or elsewhere), requesting the user to manually change the path accordingly. That could be a solution to consider too. Hope this helps a bit, Regis From roma at ro-che.info Thu Sep 10 09:22:02 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Thu Sep 10 09:00:29 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: References: <25377949.post@talk.nabble.com> <25378268.post@talk.nabble.com> <25378882.post@talk.nabble.com> <20090910094705.GA6209@flit> Message-ID: <20090910132202.GA30281@flit> * Peter Verswyvelen [2009-09-10 14:43:10+0200] > On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka wrote: > > ?step x g a = g (f a x) > > > > is, thanks to currying, another way to write > > > > ?step x g = \a -> g (f a x) > > I thought currying just meant > > curry f x y = f (x,y) Here you use 'currying' meaning the process of applying the 'curry' operation, i.e. transforming 'uncurried' function to a 'curried' one. (BTW, Wikipedia agrees with you.) > Isn't the reason that > > f x y z = body > > is the same as > > f = \x -> \y -> \z -> body > > just cause the former is syntactic sugar of the latter? Technically, yes. Generally speaking, currying is the idea of interchangeability of the function which takes several arguments and the function which returns another function (i.e. what is used here). -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From v.dijk.bas at gmail.com Thu Sep 10 09:21:40 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Thu Sep 10 09:00:41 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation Message-ID: Dear all, We like to announce the release of a Haskell binding to Manolis Lourakis's C levmar library at: http://www.ics.forth.gr/~lourakis/levmar/ This library implements the Levenberg-Marquardt algorithm which is an iterative technique that finds a local minimum of a function that is expressed as the sum of squares of nonlinear functions. It has become a standard technique for nonlinear least-squares problems and can be thought of as a combination of steepest descent and the Gauss-Newton method. When the current solution is far from the correct one, the algorithm behaves like a steepest descent method: slow, but guaranteed to converge. When the current solution is close to the correct solution, it becomes a Gauss-Newton method. Our binding consists of three packages: * http://hackage.haskell.org/package/bindings-levmar-0.1 A low-level wrapper around the C library. Note that the C library is lightly patched so that the functions can be safely called inside unsafePerformIO. The patched C library is bundled with this package. * http://hackage.haskell.org/package/levmar-0.1 A high-level wrapper around bindings-levmar. It provides a more familiar Haskell interface. For example, instead of passing a 'Ptr r' to the levmar function you can pass a [r]. levmar also provides some higher-level modules that use some type-level programming to add more type safety. * http://hackage.haskell.org/package/levmar-chart-0.1 Finally levmar-chart is a small package for quickly viewing the output of levmar in a chart. Unfortunately the documentation of these libraries is not available from hackage because bindings-levmar won't configure because of a missing dependency (lapack) on the hackage server. Instead I put the documentation at the following places: http://code.haskell.org/bindings-levmar/bindings-levmar-0.1/doc/html/bindings-levmar/index.html http://code.haskell.org/levmar/levmar-0.1/doc/html/levmar/index.html Here follows a quick example: Suppose we have the following model functions: constant :: Num r => Model N1 r r linear :: Num r => Model N2 r r quadratic :: Num r => Model N3 r r cubic :: Num r => Model N4 r r constant a _ = a linear b a x = b * x + constant a x quadratic c b a x = c * x*x + linear b a x cubic d c b a x = d * x*x*x + quadratic c b a x And the jacobians: constantJacob :: Num r => Jacobian N1 r r linearJacob :: Num r => Jacobian N2 r r quadraticJacob :: Num r => Jacobian N3 r r cubicJacob :: Num r => Jacobian N4 r r constantJacob _ _ = 1 ::: Nil linearJacob _ a x = x ::: constantJacob a x quadraticJacob _ b a x = x*x ::: linearJacob b a x cubicJacob _ c b a x = x*x*x ::: quadraticJacob c b a x Now assume we have some sample data. If you call levmar like this: levmar cubic (Just cubicJacob) (-0.05 ::: 0.5 ::: -12 ::: 10 ::: Nil) samples 1000 defaultOpts Nothing Nothing noLinearConstraints Nothing You get the following fit (using levmar-chart): http://code.haskell.org/~roelvandijk/code/levmar-chart/cubicFit.png Note that levmar contains a demo with a lot more examples: http://code.haskell.org/levmar/Demo.hs Happy fitting, Roel and Bas van Dijk From leather at cs.uu.nl Thu Sep 10 09:22:45 2009 From: leather at cs.uu.nl (Sean Leather) Date: Thu Sep 10 09:02:03 2009 Subject: [Haskell-cafe] Would you mind explain such a code ? In-Reply-To: References: <25377949.post@talk.nabble.com> <25378268.post@talk.nabble.com> <25378882.post@talk.nabble.com> <20090910094705.GA6209@flit> Message-ID: <3c6288ab0909100622o47cdfa23o59bc547662f934f6@mail.gmail.com> On Thu, Sep 10, 2009 at 14:43, Peter Verswyvelen wrote: > On Thu, Sep 10, 2009 at 11:47 AM, Roman Cheplyaka wrote: > > step x g a = g (f a x) > > > > is, thanks to currying, another way to write > > > > step x g = \a -> g (f a x) > > I thought currying just meant > > curry f x y = f (x,y) > > > Isn't the reason that > > f x y z = body > > is the same as > > f = \x -> \y -> \z -> body > > just cause the former is syntactic sugar of the latter? > In some functional programming languages, these are not equivalent. For example, Clean does not have currying, so f :: Int Int -> Int f x y = x + y is not the same as f :: Int -> Int -> Int f x = (+) x Notice the difference in types. The first is more like 'f :: (Int, Int) -> Int' in Haskell. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/b9f37c3f/attachment.html From matthijs at stdin.nl Thu Sep 10 09:24:57 2009 From: matthijs at stdin.nl (Matthijs Kooijman) Date: Thu Sep 10 09:03:54 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> Message-ID: <20090910132457.GF8930@katherina.student.utwente.nl> Hi Regis, > - use windows API for requesting elevation during the process (ugly) Why is this ugly? This seems like an elegant solution, to get privileges only when you actually need them? Gr. Matthijs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/d08faca1/attachment.bin From bulat.ziganshin at gmail.com Thu Sep 10 09:36:03 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 09:20:09 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <20090910132457.GF8930@katherina.student.utwente.nl> References: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <20090910132457.GF8930@katherina.student.utwente.nl> Message-ID: <1168366943.20090910173603@gmail.com> Hello Matthijs, Thursday, September 10, 2009, 5:24:57 PM, you wrote: >> - use windows API for requesting elevation during the process (ugly) > Why is this ugly? This seems like an elegant solution, to get privileges only > when you actually need them? afaik you need to run special COM server with elevated privileges. it's much easier just to run external app with proper manifest see page 22 in http://pascalfonteneau.developpez.com/articles/delphi/vista/uac/VistaUACandDelphi.pdf -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From regis.saint-paul at create-net.org Thu Sep 10 09:46:36 2009 From: regis.saint-paul at create-net.org (Regis Saint-Paul) Date: Thu Sep 10 09:25:36 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <20090910132457.GF8930@katherina.student.utwente.nl> References: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <20090910132457.GF8930@katherina.student.utwente.nl> Message-ID: I'm not familiar with cabal source code enough to actually assess how much of a problem it would be but I assumed so because: - one would need to identify the exact location in the cabal code where elevation will be required. That means one would have to check if a folder where cabal wishes to write is or not protected. For users who install outside of program files (under msys for instance), failing to do so would raise unnecessary UAC elevation requests - this would create a less portable code overall (I do not know the extent of windows/linux specific code in cabal code base, but it seems to be very small at this stage). By comparison, the manifest option only requires modifying the build process, leaving the code unaffected. On the other hand, this solution is clearly the best if the objective is to become fully compliant with windows recommendations. To have a nice UAC warning, it would also take to create a signed certificate, etc...(or we just get something like "An unidentified program wants to access your computer" instead of the "windows needs your permission to continue". And probably other side issues to consider. So you are right, "ugly" is not appropriate. It just builds down to more work and more platform specific code. Cheers, Regis > -----Original Message----- > From: Matthijs Kooijman [mailto:matthijs@stdin.nl] > Sent: Thursday, 10 September 2009 3:25 PM > To: Regis Saint-Paul > Cc: haskell-cafe@haskell.org; 'Duncan Coutts' > Subject: Re: [Haskell-cafe] Cabal install on Windows 7 > > Hi Regis, > > > - use windows API for requesting elevation during the process (ugly) > Why is this ugly? This seems like an elegant solution, to get privileges > only > when you actually need them? > > Gr. > > Matthijs From regis.saint-paul at create-net.org Thu Sep 10 10:05:19 2009 From: regis.saint-paul at create-net.org (Regis Saint-Paul) Date: Thu Sep 10 09:44:20 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com><20090910132457.GF8930@katherina.student.utwente.nl> Message-ID: <611B981A94F24533BC360A4A80E7F3C5@createnet.org> One last note as it may be confusing in previous message...I mention to use windows API, but there is no API per-se that can elevate a process already running. It takes to create another process which, at startup time, will popup the elevation dialog. The win32 function to call is therefore just the shellexecute(). --Regis From bulat.ziganshin at gmail.com Thu Sep 10 10:19:07 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 10 09:58:09 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <611B981A94F24533BC360A4A80E7F3C5@createnet.org> References: <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com><20090910132457.GF8930@katherina.student.utwente.nl> <611B981A94F24533BC360A4A80E7F3C5@createnet.org> Message-ID: <1934111007.20090910181907@gmail.com> Hello Regis, Thursday, September 10, 2009, 6:05:19 PM, you wrote: > One last note as it may be confusing in previous message...I mention to use > windows API, but there is no API per-se that can elevate a process already > running. It takes to create another process which, at startup time, will > popup the elevation dialog. to be exact, this process should manifest itself as requiring Admin privileges and Windows itself will popup dialog asking user whether he trust this executable -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From skluft at gmail.com Thu Sep 10 11:25:41 2009 From: skluft at gmail.com (Seb) Date: Thu Sep 10 11:04:38 2009 Subject: [Haskell-cafe] Problem installing OpenGL Message-ID: <79dad943-afcb-4dc3-a35a-0b02e6ad0a98@w36g2000yqm.googlegroups.com> Hi, I'm having trouble installing OpenGL through cabal. It fails when it tries to install OpenGLRaw with this error message: cabal: Missing dependency on a foreign library: * Missing C library: GL I'm running OS X Leopard and have Xcode 3.1.3 installed. Do i have to install something separate or is cabal just not looking in the right places? From mf-hcafe-15c311f0c at etc-network.de Thu Sep 10 11:42:36 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Thu Sep 10 11:21:47 2009 Subject: Re[Haskell-cafe] [2]: memoization In-Reply-To: <25382341.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <25382341.post@talk.nabble.com> Message-ID: <20090910154235.GJ5302@yoyo> On Thu, Sep 10, 2009 at 05:23:26AM -0700, staafmeister wrote: > To: haskell-cafe@haskell.org > From: staafmeister > Date: Thu, 10 Sep 2009 05:23:26 -0700 (PDT) > Subject: Re: Re[Haskell-cafe] [2]: memoization > > > > Hi Bulat, > > > Bulat Ziganshin-2 wrote: > > > > Hello staafmeister, > > > > Thursday, September 10, 2009, 3:54:34 PM, you wrote: > > > >> What do you think about such a function? This function is > > > > a bit of refactoring > > > > -- "global variable" in haskell way > > cache = unsafePerformIO $ newIORef M.empty > > > > memo f x = unsafePerformIO$ do > > m <- readIORef cache > > case M.lookup x m of > > Just y -> return y > > Nothing -> do let res = f x > > writeIORef cache $ M.insert x res m > > return res > > > > memo2 = curry . memo . uncurry > > > > This doesn't work and is exactly what I'm afraid the compiler is going to > do. Cache needs to > be associated with the function f. > > Otherwise one would get conflicts then make the cache object store functions together with values. cache = unsafePerformIO $ newIORef M.empty memo f x = unsafePerformIO$ do m <- readIORef cache case M.lookup (mkKey f, x) m of Just y -> return y Nothing -> do let res = f x writeIORef cache $ M.insert (mkKey f, x) res m return res memo2 = curry . memo . uncurry This leaves mkKey. Since functions are neither Ord nor Show, you'd have to hack something together yourself. Perhaps an explicit argument to memo? memo :: (Ord a) => String -> (a -> b) -> a -> IO b memo fname f x = unsafePerformIO$ do m <- readIORef cache case M.lookup (fname, x) m of Just y -> return y Nothing -> do let res = f x writeIORef cache $ M.insert (fname, x) res m return res there is probably a better and more elegant solution, but this should at least work. right? matthias From tom at lokhorst.eu Thu Sep 10 12:33:52 2009 From: tom at lokhorst.eu (Tom Lokhorst) Date: Thu Sep 10 12:13:10 2009 Subject: [Haskell-cafe] Dutch HUG: meeting tomorrow in Utrecht Message-ID: <317ca7670909100933k3dd8dacbk657f21d28f2ec22f@mail.gmail.com> Hi everyone, I want to remind all functional programmers currently in The Netherlands of the Dutch Haskell User Group [1, 2] meeting tomorrow at 19:00 [3]. The meeting will be in Booth Hall [4] of the Utrecht University Library, where we'll have three talks. There's free car parking [5] at the library, and it's easily accessible by bike and bus [6]. Also, to stay on top of Dutch HUG related news, please subscribe to the mailing list [2]. See you tomorrow! - Tom Lokhorst [1]: http://www.haskell.org/haskellwiki/Dutch_HUG [2]: http://groups.google.com/group/dutch-hug [3]: http://www.mail-archive.com/haskell-cafe@haskell.org/msg64036.html [4]: http://www.uu.nl/EN/library/contact/university_library/zaalverhuur/Pages/default.aspx#booth [5]: http://www.uu.nl/EN/library/contact/university_library/Parkeren/Pages/default.aspx [6]: http://www.uu.nl/EN/library/contact/university_library/plattegrondenrou/Pages/default.aspx From frank at geoinfo.tuwien.ac.at Thu Sep 10 13:01:29 2009 From: frank at geoinfo.tuwien.ac.at (Andrew U. Frank) Date: Thu Sep 10 12:40:31 2009 Subject: [Haskell-cafe] retrieving arguments for functions from a heterogenous list (HList) Message-ID: <200909101901.30225.frank@geoinfo.tuwien.ac.at> I have a number of functions which have some arguments and produce a single result. all the arguments are in a heterogenous list and the results should update the list. this appears somewhat similar to the keyword-argument solution for functions proposed by oleg kiselyov in 2004. i would like to have a method to convert the functions f :: A -> B -> C g:: A -> D -> C -> B (for example) to f' :: argTypes -> H -> H g' :: argTypes -> H -> H where H is a heterogenous list containing A, B, C, D (and others) and argTypes is another heterogenous list containing the types of the arguments, which are used to retrieve the data from the list (with .!!.) - the result has the correct type and is updated in the list with .@@. . naively this could be done by some functins fx (recursing over the list of arguments) storing the last argument in the HList: fx :: (HList l) => op -> HCons e l -> H -> H fx op HNil uod = uod .@@. op fx op (HCons a as) uod = fx (op arg) as uod where arg = uod .!!. a this code does not compile, because HNil and HCons do not match (they are different data types, not a union type). code that compiles looks like class (HList l, HList k , HUpdateAtHNat n e k k, HType2HNat e k n , HLookupByHNat n k e ) => HCall e n f l k | l k -> n where hcall :: f -> l -> k -> k -- not general instance ( HNat n , HUpdateAtHNat n e UoD UoD, HType2HNat e UoD n , HLookupByHNat n UoD e ) => HCall e n e HNil UoD where hcall opv HNil k = hcall0 opv k instance (HCall e n f l UoD , HLookupByHNat n UoD e, HType2HNat e n UoD ) => HCall e n (e -> f) (HCons a l) UoD where hcall op (HCons a l) k = hcall (op arg) l k where arg = hLookupByHNat n k n = hType2HNat (toProxy arg) k :: n hcall0 :: ( HUpdateAtHNat n f UoD UoD, HType2HNat f H n, HCall e n f HNil UoD) => f -> H -> H hcall0 op k = hUpdateAtHNat n (const op undefined) k `asTypeOf` k where n = hType2HNat (toProxy op) k where i factored out the terminating call, which is probably wrong. i would like to use it as: showPop4 :: (HList hNil, HCall Population n (District -> Population) (hConst District hNil) UoD) => (hCons District hNil) -> UoD -> UoD showPop4 arg uod = hcall showPop2 arg uod unfortunately, calls to this function result in 'cannot deduce' compilation error; it seems that some of the intermediate types are not known. i appreciate any help! andrew From agocorona at gmail.com Thu Sep 10 13:14:31 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Sep 10 12:53:30 2009 Subject: Fwd: Re[Haskell-cafe] [2]: memoization In-Reply-To: References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <25382341.post@talk.nabble.com> <20090910154235.GJ5302@yoyo> Message-ID: instead o that you can use a key such is: key :: a -> Int key = unsafePerformIO . hashStableName . makeStableName that is defined for any kind of data then, a unique key for the pair f x could be: key1 f x=(key f , key x) However my experience is that ocassionally gives different hashes for the same object, so maybe a few registers will be duplicated. 2009/9/10 > On Thu, Sep 10, 2009 at 05:23:26AM -0700, staafmeister wrote: > > To: haskell-cafe@haskell.org > > From: staafmeister > > Date: Thu, 10 Sep 2009 05:23:26 -0700 (PDT) > > Subject: Re: Re[Haskell-cafe] [2]: memoization > > > > > > > > Hi Bulat, > > > > > > Bulat Ziganshin-2 wrote: > > > > > > Hello staafmeister, > > > > > > Thursday, September 10, 2009, 3:54:34 PM, you wrote: > > > > > >> What do you think about such a function? This function is > > > > > > a bit of refactoring > > > > > > -- "global variable" in haskell way > > > cache = unsafePerformIO $ newIORef M.empty > > > > > > memo f x = unsafePerformIO$ do > > > m <- readIORef cache > > > case M.lookup x m of > > > Just y -> return y > > > Nothing -> do let res = f x > > > writeIORef cache $ M.insert x > res m > > > return res > > > > > > memo2 = curry . memo . uncurry > > > > > > > This doesn't work and is exactly what I'm afraid the compiler is going to > > do. Cache needs to > > be associated with the function f. > > > > Otherwise one would get conflicts > > then make the cache object store functions together with values. > > > cache = unsafePerformIO $ newIORef M.empty > > memo f x = unsafePerformIO$ do > m <- readIORef cache > case M.lookup (mkKey f, x) m of > Just y -> return y > Nothing -> do let res = f x > writeIORef cache $ M.insert (mkKey > f, x) res m > return res > > memo2 = curry . memo . uncurry > > This leaves mkKey. Since functions are neither Ord nor Show, you'd > have to hack something together yourself. Perhaps an explicit > argument to memo? > > memo :: (Ord a) => String -> (a -> b) -> a -> IO b > memo fname f x = unsafePerformIO$ do > m <- readIORef cache > case M.lookup (fname, x) m of > Just y -> return y > Nothing -> do let res = f x > writeIORef cache $ M.insert (fname, > x) res m > return res > > there is probably a better and more elegant solution, but this should > at least work. right? > > > matthias > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/de859d6c/attachment.html From bts at alum.mit.edu Thu Sep 10 14:08:09 2009 From: bts at alum.mit.edu (Brian Sniffen) Date: Thu Sep 10 13:47:42 2009 Subject: [Haskell-cafe] Re: Snow Leopard breaks GHC In-Reply-To: <4AA75DF8.10805@dfki.de> References: <4AA11B5A.50308@dfki.de> <4AA1340F.7030109@dfki.de> <4AA75DF8.10805@dfki.de> Message-ID: My problems were resolved by removing MacPorts from the system and adding 32-bit flags to runhaskell---apparently its zlib was interfering, as well as the runhaskell/runghc problems. Thank you for the advice, Brian On Wed, Sep 9, 2009 at 3:49 AM, Christian Maeder wrote: > If compiling template haskell of Pandoc still does not work, please make > a ticket as Simon wrote in: > > http://hackage.haskell.org/trac/ghc/ticket/2965#comment:24 > > Cheers Christian > > Christian Maeder wrote: >> Maybe runhaskell is used for template haskell? >> >> HTH Christian >> >> Brian Sniffen wrote: >>> No, my ghci is now "exec >>> /Library/Frameworks/GHC.framework/Versions/610/usr/bin/ghc-6.10.4 >>> -optc-m32 -opta-m32 -optl-m32 --interactive ${1+"$@"}" and I still see >>> the same result. ?Also, I have switched to "--ld-options" instead of >>> "--ld-option," which appears to have been a typo---cabal and setup >>> never parsed it. >>> >>> -Brian >>> >>> On Fri, Sep 4, 2009 at 9:51 AM, Christian Maeder >>> wrote: >>>> Does adding -optc-m32 -opta-m32 -optl-m32 to /usr/bin/ghci >>>> as well not help? (as I've posted before) >>>> >>>> Cheers Christian >>>> >>>> Brian Sniffen wrote: >>>>> Having edited the Haskell Platform's /usr/bin/ghc in place, most >>>>> packages install fine. ?I'm still having trouble with Pandoc, even >>>>> given the advice: >>>>> >>>>>> Once cabal works, options --ld-option=-m32 (and also --gcc-option=-m32) >>>>>> may be used. These options may also be passed to "./Setup configure" >>>>> The problem appears to come when linking an incompatible zlib version: >>>>> >>>>> src/Text/Pandoc/ODT.hs:49:26: >>>>> ? Exception when trying to run compile-time code: >>>>> ? ? user error (Codec.Compression.Zlib: incompatible zlib version) >>>>> ? ? Code: ($) makeZip "data" "odt-styles" >>>>> ? In the first argument of `read', namely >>>>> ? ? ? `$(makeZip $ "data" "odt-styles")' >>>>> ? In the expression: read ($(makeZip $ "data" "odt-styles")) >>>>> ? In the definition of `refArchive': >>>>> ? ? ? refArchive = read ($(makeZip $ "data" "odt-styles")) >>>>> >>>>> The same problem occurs when making any call to Codec.Archive.Zip or >>>>> Codec.Compression.Zlib. >>>>> >>>>> I do have a universal zlib installed by MacPorts, as well as the >>>>> universal zlib that shipped with Snow Leopard and the universal zlib >>>>> that came with Cabal. ?I'm not sure whether this message indicates >>>>> that TH code is searching a different library path than non-TH code or >>>>> what. ?Advice is most welcome. ?I'm particularly interested in finding >>>>> out which zlib versions are being found at the construction of >>>>> Codec.Compression.Zlib and at runtime (Pandoc compile time). >>>>> >>>>> >>>>> >>>>> >>> >>> > -- Brian Sniffen http://evenmere.org/~bts/ From agocorona at gmail.com Thu Sep 10 14:51:09 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Sep 10 14:30:06 2009 Subject: Re[Haskell-cafe] [2]: memoization In-Reply-To: References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <25382341.post@talk.nabble.com> <20090910154235.GJ5302@yoyo> Message-ID: key x= unsafePerformIO $ makeStableName x >>= return . hashStableName sorry 2009/9/10 Alberto G. Corona > instead o that you can use a key such is: > key :: a -> Int > key = unsafePerformIO . hashStableName . makeStableName > > that is defined for any kind of data > > then, a unique key for the pair f x could be: > > key1 f x=(key f , key x) > > > However my experience is that ocassionally gives different hashes for the > same object, so maybe a few registers will be duplicated. > > > > 2009/9/10 > > >> On Thu, Sep 10, 2009 at 05:23:26AM -0700, staafmeister wrote: >> > To: haskell-cafe@haskell.org >> > From: staafmeister >> > Date: Thu, 10 Sep 2009 05:23:26 -0700 (PDT) >> > Subject: Re: Re[Haskell-cafe] [2]: memoization >> > >> > >> > >> > Hi Bulat, >> > >> > >> > Bulat Ziganshin-2 wrote: >> > > >> > > Hello staafmeister, >> > > >> > > Thursday, September 10, 2009, 3:54:34 PM, you wrote: >> > > >> > >> What do you think about such a function? This function is >> > > >> > > a bit of refactoring >> > > >> > > -- "global variable" in haskell way >> > > cache = unsafePerformIO $ newIORef M.empty >> > > >> > > memo f x = unsafePerformIO$ do >> > > m <- readIORef cache >> > > case M.lookup x m of >> > > Just y -> return y >> > > Nothing -> do let res = f x >> > > writeIORef cache $ M.insert x >> res m >> > > return res >> > > >> > > memo2 = curry . memo . uncurry >> > > >> > >> > This doesn't work and is exactly what I'm afraid the compiler is going >> to >> > do. Cache needs to >> > be associated with the function f. >> > >> > Otherwise one would get conflicts >> >> then make the cache object store functions together with values. >> >> >> cache = unsafePerformIO $ newIORef M.empty >> >> memo f x = unsafePerformIO$ do >> m <- readIORef cache >> case M.lookup (mkKey f, x) m of >> Just y -> return y >> Nothing -> do let res = f x >> writeIORef cache $ M.insert (mkKey >> f, x) res m >> return res >> >> memo2 = curry . memo . uncurry >> >> This leaves mkKey. Since functions are neither Ord nor Show, you'd >> have to hack something together yourself. Perhaps an explicit >> argument to memo? >> >> memo :: (Ord a) => String -> (a -> b) -> a -> IO b >> memo fname f x = unsafePerformIO$ do >> m <- readIORef cache >> case M.lookup (fname, x) m of >> Just y -> return y >> Nothing -> do let res = f x >> writeIORef cache $ M.insert (fname, >> x) res m >> return res >> >> there is probably a better and more elegant solution, but this should >> at least work. right? >> >> >> matthias >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/b7467f82/attachment.html From martin.sulzmann.haskell at googlemail.com Thu Sep 10 14:54:50 2009 From: martin.sulzmann.haskell at googlemail.com (Martin Sulzmann) Date: Thu Sep 10 14:33:52 2009 Subject: [Haskell-cafe] Re: Resolving overloading loops for circular constraint graph In-Reply-To: References: <74E497E9-3AF7-43CF-B48E-7052134112D4@cs.uu.nl> <4bb51c60909091157u4efe6e62mdf32af7a449c404@mail.gmail.com> Message-ID: <4bb51c60909101154i57685c64mf0e7f60355951155@mail.gmail.com> 2009/9/9 Stefan Holdermans > Dear Martin, > > By "black-holing" you probably mean co-induction. That is, >> if the statement to proven appears again, we assume it must hold. >> However, type classes are by default inductive, so there's no >> easy fix to offer to your problem. >> > > A propos: are there fundamental objections to coinductive resolving, i.e., > constructing recursive dictionaries. I suppose termination is hard to > guarantee then: is it enough to require constraints to be productive w.r.t. > instance heads? > > Yes, you need instances to be productive, otherwise, you get bogus cyclic proofs like instance Foo a => Foo a dictFooa = dictFooa You could call this a bug, or simply blame the programmer for writing down a 'bogus' instance. Under co-inductive type class solving more (type class) programs will terminate (my guess). Here are some references: Satish R. Thatte: Semantics of Type Classes Revisited. LISP and Functional Programming 1994: 208-219 As far as I know, the first paper which talks about co-induction and type classes. I myself and some co-workers explored this idea further in some unpublished draft: AUTHOR = {M. Sulzmann and J. Wazny and P. J. Stuckey}, TITLE = {Co-induction and Type Improvement in Type Class Proofs}, NOTE = {Manuscript}, YEAR = {2005}, MONTH = {July}, PS = {http://www.cs.mu.oz.au/~sulzmann/manuscript/coind-type-class-proofs.ps } I'm quite fond of co-induction because it's such an elegant and powerful proof technique. However, GHC's co-induction mechanism is fairly limited, see Simon's reply, so I'm also curious to see what's happening in the future. -Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/c259bd76/attachment-0001.html From westondan at imageworks.com Thu Sep 10 14:57:26 2009 From: westondan at imageworks.com (Dan Weston) Date: Thu Sep 10 14:36:29 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA8567D.20206@alumni.caltech.edu> References: <4AA8567D.20206@alumni.caltech.edu> Message-ID: <4AA94C16.8080407@imageworks.com> One simple solution is to leave the state in Qt. As of Qt 4.2, in C++ you can use bool QObject::setProperty(const char * name, const QVariant & value) QVariant QObject::property(const char * name) const to set and get properties on any QObject (hence any QWidget). Since I believe these are (not yet) wrapped in QtHaskell, you can instead just create a widget that contains the state and just don't add it to a layout. Parent it to a widget and it will quietly disappear when its parent dies. If you want it to persist until you say so, don't parent it to anything (but then you might as well use Haskell for your state!) Dan Michael P Mossey wrote: > I'm trying to learn qtHaskell. I realize few people on this list know anything > about qtHaskell, but I have a question that probably relates to all GUIs as > implemented in Haskell. I just need a hint that could help me figure out the > next step, which I might be able to infer from the qtHaskell API. > > I don't think is any tutorial-type or step-by-step type documentation for > qtHaskell. I have sent some questions to the author of qtHaskell, David Harley, > but he hasn't responded yet, and anyway I don't want to trouble him every time I > have a question, so I'm trying to infer as much as I can. > > The problem relates to state. In Qt, one adds state to a widget by subclassing > it and adding new member variables. For example, I want to create a widget that > responds to keypresses and remembers what keypresses have taken place. > > I'm totally stuck on this part, because Haskell doesn't have state. There must > be some kind of Haskell call that adds state to a widget, but it is hard to > figure out from the qtHaskell examples David provides. > > Thanks, > Mike > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lemming at henning-thielemann.de Thu Sep 10 15:16:29 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Sep 10 14:55:26 2009 Subject: [Haskell-cafe] ANNOUNCE: Palindromes 0.1 In-Reply-To: References: Message-ID: On Sun, 6 Sep 2009, Johan Jeuring wrote: > The primary features of Palindromes include: > > * Linear-time algorithm for finding exact palindromes > * Linear-time algorithm for finding text palindromes, > ignoring spaces, case of characters, and punctuation > symbols. You made me curious, whether there are palindromes in my texts. However, I have some difficulties getting sensible results from it. First I found a long palindrome, that was actually a code example for an array definition. So I wondered, whether this palindrome shadows nicer shorter palindromes in the same text. How about an option for showing the n longest palindromes or palindromes with length larger than n? Then I found a palindrome in Functi[on sin is no]t defined How about restricting text palindromes to sequences that are bounded by space and punctuation? The Palindrome welcome message is a bit disturbing when running palindrome on a set of files. I also like to filter out HTML markup (with strip-html from tagchup package), before piping into palindrome. This however would require to run palindrome on standard input. The options are '-x' for a single answer and '-xs' for multiple answers, but for '-ts' this logic does not hold. How about '-lt' or '-tl' ? I would like to have '-ts' to print all text palindromes (or actually, I would like to get all palindromes with at least 5 characters). > Documentation > ------------- > > The API is documented using Haddock and available on the Palindromes package > site. It says, that the executable is FindingPalindromes, but actually it is palindromes, right? Pretty much suggestions, I know. Don't get worried and thank you for the program! From duncan.coutts at worc.ox.ac.uk Thu Sep 10 16:43:54 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 10 16:27:04 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA8567D.20206@alumni.caltech.edu> References: <4AA8567D.20206@alumni.caltech.edu> Message-ID: <1252615434.5266.7115.camel@localhost> On Wed, 2009-09-09 at 18:29 -0700, Michael P Mossey wrote: > I'm trying to learn qtHaskell. I realize few people on this list know anything > about qtHaskell, but I have a question that probably relates to all GUIs as > implemented in Haskell. I just need a hint that could help me figure out the > next step, which I might be able to infer from the qtHaskell API. Ultimately it's done by some kind of mutable state, either an IORef, MVar or a thread. On top of these you can layer nicer stuff like a state monad (with a 'runState' function that saves and restores from an IORef). A personal favourite of mine is having the GUI event handler post data over a channel to a thread. That thread reads from the channel and deals with the events. The state of the GUI app is then held as local parameters in that thread. Doing this of course requires that the GUI lib you're using can cope with normal Haskell (forkIO) threads. This is possible with gtk2hs, I don't know about the others. Duncan From mpm at alumni.caltech.edu Thu Sep 10 17:12:58 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Sep 10 16:52:03 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA94C16.8080407@imageworks.com> References: <4AA8567D.20206@alumni.caltech.edu> <4AA94C16.8080407@imageworks.com> Message-ID: <4AA96BDA.6030600@alumni.caltech.edu> Dan Weston wrote: > One simple solution is to leave the state in Qt. > > As of Qt 4.2, in C++ you can use > > bool QObject::setProperty(const char * name, const QVariant & value) > QVariant QObject::property(const char * name) const > > to set and get properties on any QObject (hence any QWidget). > > Since I believe these are (not yet) wrapped in QtHaskell, you can > instead just create a widget that contains the state and just don't add > it to a layout. Parent it to a widget and it will quietly disappear when > its parent dies. If you want it to persist until you say so, don't > parent it to anything (but then you might as well use Haskell for your > state!) > > Dan Thanks for the reply, Dan. I don't quite follow---you mean create a widget in C++? I can't find setProperty/property in qtHaskell. I would like to keep everything in Haskell, though. From mpm at alumni.caltech.edu Thu Sep 10 17:13:51 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Sep 10 16:52:49 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <1252615434.5266.7115.camel@localhost> References: <4AA8567D.20206@alumni.caltech.edu> <1252615434.5266.7115.camel@localhost> Message-ID: <4AA96C0F.6070302@alumni.caltech.edu> Duncan Coutts wrote: > On Wed, 2009-09-09 at 18:29 -0700, Michael P Mossey wrote: >> I'm trying to learn qtHaskell. I realize few people on this list know anything >> about qtHaskell, but I have a question that probably relates to all GUIs as >> implemented in Haskell. I just need a hint that could help me figure out the >> next step, which I might be able to infer from the qtHaskell API. > > Ultimately it's done by some kind of mutable state, either an IORef, > MVar or a thread. > > On top of these you can layer nicer stuff like a state monad (with a > 'runState' function that saves and restores from an IORef). > > A personal favourite of mine is having the GUI event handler post data > over a channel to a thread. That thread reads from the channel and deals > with the events. The state of the GUI app is then held as local > parameters in that thread. > > Doing this of course requires that the GUI lib you're using can cope > with normal Haskell (forkIO) threads. This is possible with gtk2hs, I > don't know about the others. Hi Duncan, thanks for the reply. Can you point me to some code examples that do these things? -Mike From mauricio.antunes at gmail.com Thu Sep 10 20:28:51 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Sep 10 20:08:11 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: Message-ID: > Our binding consists of three packages: > > * http://hackage.haskell.org/package/bindings-levmar-0.1 Which were the changes you needed to do to the library code? I believe this is going to cause you two problems: maintenance (as you can't always be sure the patched version didn't introduce a bug) and license (as levmar is GPL. You can't distribute it linked to non GPL code). > * http://hackage.haskell.org/package/levmar-0.1 Cool. Don't you think the type level natural numbers deserve their own package? > Unfortunately the documentation of these libraries is not > available from hackage because bindings-levmar won't configure > because of a missing dependency (lapack) on the hackage server. I'll try to write you a patch to solve that after I study better your code. Best, Maur?cio From lrpalmer at gmail.com Thu Sep 10 20:46:06 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Sep 10 20:25:02 2009 Subject: [Haskell-cafe] memoization In-Reply-To: References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> Message-ID: <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> On Thu, Sep 10, 2009 at 6:34 AM, Peter Verswyvelen wrote: > You might want to watch out for multithreading issues, although in > this case, I don't think it will cause sever problems, besides a > couple of redundant cache updates. > > > On Thu, Sep 10, 2009 at 2:07 PM, Bulat Ziganshin > wrote: >> Hello staafmeister, >> >> Thursday, September 10, 2009, 3:54:34 PM, you wrote: >> >>> What do you think about such a function? This function is >> >> a bit of refactoring >> >> -- "global variable" in haskell way >> cache = unsafePerformIO $ newIORef M.empty Watch out! This is not necessarily the same. The cache in the original message was one per function, not one globally, because the let occurred inside a lambda binding. However, because the body of cache didn't depend on f, we can use lambda calculus rules to lift the let outside the lambda. So your transformation is completely valid... And yet, the original code works, and Bulat's equivalent code does not (in fact you can make a segfault using it). I wouldn't dare say the original code is "correct" though, since a valid transformation can break it. Compilers do valid transformations. O unsafePerformIO, how I love thee... Luke >> >> memo f x = unsafePerformIO$ do >> ? ? ? ? ? ? ? ? ? ? ? m <- readIORef cache >> ? ? ? ? ? ? ? ? ? ? ? case M.lookup x m of >> ? ? ? ? ? ? ? ? ? ? ? ? Just y -> return y >> ? ? ? ? ? ? ? ? ? ? ? ? Nothing -> do let res = f x >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? writeIORef cache $ M.insert x res m >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? return res >> >> memo2 = curry . memo . uncurry >> >> >> -- >> Best regards, >> ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@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 > From qdunkan at gmail.com Thu Sep 10 21:03:43 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Sep 10 20:42:38 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? Message-ID: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> Is there any particular reason to not move the instance to the prelude? A module was failing when imported from one place and ok when imported from another, so I spent a frustrating 10 minutes searching for the instance. I couldn't find a way to search haddock for instances (not even grep on the html), nor hoogle, nor anything else. Finally I turned to google and found a couple of haskell-cafe threads with people wondering why other people's code failed for them. This was especially frustrating because I knew I had written my own instance when I originally couldn't find it, then removed my own when I did find it, then forgot where I found it *two times* so I knew it existed, just not where. So this is the third time I've done this search. Now I have a few commented 'import Control.Monad.Error ()' scattered about in a few "low level" modules to try to make sure it's visible everywhere and next time I go hunting I can look in my own modules. If orphan instances are discouraged, shouldn't the instance for Monad Either be declared where Either is? This should probably go for Functor Either too. I notice that Monad Maybe is in Prelude, and it would be a pain if it weren't. If there's no particular reason to not move it, I'll do a libraries proposal... or since it involves the prelude should this be haskell-prime? From ryani.spam at gmail.com Thu Sep 10 21:33:47 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Sep 10 21:12:42 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> Message-ID: <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> On Thu, Sep 10, 2009 at 5:46 PM, Luke Palmer wrote: > However, because the body of cache didn't depend on f, we can use > lambda calculus rules to lift the let outside the lambda. So your > transformation is completely valid... And yet, the original code > works, and Bulat's equivalent code does not (in fact you can make a > segfault using it). > > I wouldn't dare say the original code is "correct" though, since a > valid transformation can break it. Compilers do valid > transformations. > > O unsafePerformIO, how I love thee... Right, which is why you should write it like this: memoIO :: Ord a => (a -> b) -> IO (a -> IO b) memoIO f = do cache <- newIORef M.empty return $ \x -> do m <- readIORef cache case M.lookup x m of Just y -> return y Nothing -> do let res = f x writeIORef cache $ M.insert x res m return res memo :: Ord a => (a -> b) -> (a -> b) memo f = unsafePerformIO $ do fmemo <- memoIO f return (unsafePerformIO . fmemo) I don't think there is any valid transformation that breaks this, since the compiler can't lift anything through unsafePerformIO. Am I mistaken? -- ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090910/68e285f5/attachment.html From vandijk.roel at gmail.com Fri Sep 11 03:33:54 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Fri Sep 11 03:12:49 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: Message-ID: >> * http://hackage.haskell.org/package/bindings-levmar-0.1 > > Which were the changes you needed to do to the library code? I > believe this is going to cause you two problems: maintenance (as > you can't always be sure the patched version didn't introduce a > bug) and license (as levmar is GPL. You can't distribute it linked > to non GPL code). The C library prints error messages to stderr. We can check some things before calling the C functions to ensure that some erroneous conditions do not occur, but we can't prevent all cases. Since the functions already returned a generic error code we disabled all printing to stderr and created an enumeration of error codes. In Haskell we wrap this error code in a nice data type so if something goes wrong you'll know why. We have send a patch with these changes to the author and we are waiting for a reply. The license issue is indeed a problem. Either your (linked + distributed) code must be GPL or you must acquire a different (commercial) license from the author of the C library. The benefits of the library we have chosen for this binding is that it is small, just a few .c files, and it has almost no dependencies. If anyone knows of any other implementations of Levenberg-Marquardt that are also easy to bind then we would certainly like to hear it. If the feature set is not to different we might be able to provide a common interface. >> * http://hackage.haskell.org/package/levmar-0.1 > > Cool. > > Don't you think the type level natural numbers deserve their own > package? Perhaps in the future. For this release we just focused on levmar. We might also use another package for type level programming if it suits our needs. >> Unfortunately the documentation of these libraries is not >> available from hackage because bindings-levmar won't configure >> because of a missing dependency (lapack) on the hackage server. > > I'll try to write you a patch to solve that after I study better > your code. Lapack has to be installed on the hackage server in order for the package to build. Another option is to temporarily remove the dependency on lapack from the cabal file. The package would probably build, you just wouldn't be able to link against it. But the downside is that someone won't be able to cabal install it without first modifying the .cabal file. That is unacceptable in my opinion. Roel From v.dijk.bas at gmail.com Fri Sep 11 03:41:10 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Fri Sep 11 03:20:09 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: Message-ID: 2009/9/11 Maur??cio CA : > Which were the changes you needed to do to the library code? Attached is the patch to the C levmar library. regards, Bas -------------- next part -------------- A non-text attachment was scrubbed... Name: levmar_explicit_error.patch Type: application/octet-stream Size: 43626 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/22825fee/levmar_explicit_error-0001.obj From roma at ro-che.info Fri Sep 11 03:56:28 2009 From: roma at ro-che.info (Roman Cheplyaka) Date: Fri Sep 11 03:35:54 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <1252615434.5266.7115.camel@localhost> References: <4AA8567D.20206@alumni.caltech.edu> <1252615434.5266.7115.camel@localhost> Message-ID: <20090911075628.GA12164@flit> * Duncan Coutts [2009-09-10 20:43:54+0000] > A personal favourite of mine is having the GUI event handler post data > over a channel to a thread. That thread reads from the channel and deals > with the events. The state of the GUI app is then held as local > parameters in that thread. > > Doing this of course requires that the GUI lib you're using can cope > with normal Haskell (forkIO) threads. This is possible with gtk2hs, I > don't know about the others. I also would be happy to see some code. Recently I need to write a small app in gtk2hs which had to deal with state. I used Reader monad with IORef's in it, but got tired of mixing code in different monads. (It would help, btw, if gtk2hs functions were not in IO, but in MonadIO). So I'm curious how 'gtk2hs app done right' looks like. -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain From g.c.stavenga at uu.nl Fri Sep 11 08:57:01 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Fri Sep 11 08:35:55 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25306687.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> Message-ID: <25400506.post@talk.nabble.com> Hi, Investigating memoization inspired by replies from this thread. I encountered something strange in the behavior of ghci. Small chance it's a bug, it probably is a feature, but I certainly don't understand it :) The interpreter session went as follows GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> :load test_bug.hs [1 of 1] Compiling Main ( test_bug.hs, interpreted ) Ok, modules loaded: Main. *Main> let s1 = memo2 solve2 Loading package syb ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package filepath-1.1.0.2 ... linking ... done. Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.2 ... linking ... done. Loading package unix-2.3.2.0 ... linking ... done. Loading package directory-1.0.0.3 ... linking ... done. Loading package process-1.0.1.1 ... linking ... done. Loading package random-1.0.0.1 ... linking ... done. Loading package haskell98 ... linking ... done. *Main> :type s1 s1 :: [()] -> [()] -> ModP *Main> let s2 a b = memo2 solve2 a b *Main> :type s2 s2 :: (Eq t) => [t] -> [t] -> ModP Here memo2 is a function that works like a combinator to obtain a memoized recursive function. However the type of the function depends on how I define it. In point-free style it gets the wrong type, however if I define (s2) with explicit arguments the type is correct? Do you know what happens here? I would expect the types to be the same. Another question is: I use now makeStableName for equality but using this function memoization does not work and it still takes a long (exponential?) time to go through the codejam testcases. The memoization using data.map works flawless. Greetings, Gerben ps. The content of test_bug.hs is import Data.IORef import System.IO.Unsafe import Control.Exception import qualified Data.Map as M import Text.Printf import qualified Data.HashTable as H import System.Mem.StableName import Data.Ratio import Array memo f = unsafePerformIO $ do cache <- H.new (==) (H.hashInt . hashStableName) let cacheFunc = \x -> unsafePerformIO $ do stable <- makeStableName x lup <- H.lookup cache stable case lup of Just y -> return y Nothing -> do let res = f cacheFunc x H.insert cache stable res return res return cacheFunc memo2 f = curry $ memo (\g (x,y) -> f (curry g) x y) newtype ModP = ModP Integer deriving Eq p=10007 instance Show ModP where show (ModP x) = printf "%d" x instance Num ModP where ModP x + ModP y = ModP ((x + y) `mod` p) fromInteger x = ModP (x `mod` p) ModP x * ModP y = ModP ((x * y) `mod` p) abs = undefined signum = undefined solve2 f _ [] = 1::ModP solve2 f [] _ = 0::ModP solve2 f (hs:ts) t@(ht:tt) | hs==ht = f ts tt + f ts t | otherwise = f ts t go (run, line) = "Case #"++show run++": "++show ((memo2 solve2) line "welcome to code jam") main = interact $ unlines . map go . zip [1..] . tail . lines -- View this message in context: http://www.nabble.com/memoization-tp25306687p25400506.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Fri Sep 11 09:06:43 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Sep 11 08:45:45 2009 Subject: [Haskell-cafe] memoization In-Reply-To: <25400506.post@talk.nabble.com> References: <25306687.post@talk.nabble.com> <25400506.post@talk.nabble.com> Message-ID: <978332784.20090911170643@gmail.com> Hello staafmeister, Friday, September 11, 2009, 4:57:01 PM, you wrote: > Here memo2 is a function that works like a combinator to obtain a memoized > recursive function. However the type of the function depends on how I define > it. In point-free style it gets the wrong > type, however if I define (s2) with explicit arguments the type is correct? > Do you know what happens here? I would expect the types to be the same. looks like you need to pass -fno-monomorphism-restriction to ghci. it's a "bug" of haskell definition, expected to be removed in the next language version -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ekmett at gmail.com Fri Sep 11 09:10:01 2009 From: ekmett at gmail.com (Edward Kmett) Date: Fri Sep 11 08:48:56 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> Message-ID: <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> Unfortunately, the instance of Monad for Either a is somewhat misguided in Haskell. There is a spurious restraint that the Left value in your Either be a member of some Error class, which was brought about by the deletion of MonadZero from Haskell 98 (as part of the elimination of failure free patterns, and an attempted simplification of the language). In order to support the arguable misfeature of including 'fail' in Monad, the Either instance for Monad has this extra constraint. That in and of itself is only mildly annoying, but then to use that constraint requires a multi-parameter type class for MonadError, which isn't a Haskell 98 feature. So it isn't in the standard prelude, which tries to limit itself to that which could be plausibly implemented as Haskell 98, but instead sits off in one of the dozen or so monad transformer library variants floating around. In theory, this is good, because you can then define your own monad instance for Either without that constraint -- if you don't care to exploit the Error instance's ability to get fail to work. Or you want a real Either monad for tricks like Oleg's recent post on the constructive law of excluded middle, or to talk about apomorphisms as a generalized anamorphism, parameterized on the either monad so it can be symmetrical to paramorphisms. In practice, you link in someone's code that links in the MTL, and then you're stuck using the MTL instance anyways. -Edward Kmett On Thu, Sep 10, 2009 at 9:03 PM, Evan Laforge wrote: > Is there any particular reason to not move the instance to the > prelude? A module was failing when imported from one place and ok > when imported from another, so I spent a frustrating 10 minutes > searching for the instance. I couldn't find a way to search haddock > for instances (not even grep on the html), nor hoogle, nor anything > else. Finally I turned to google and found a couple of haskell-cafe > threads with people wondering why other people's code failed for them. > This was especially frustrating because I knew I had written my own > instance when I originally couldn't find it, then removed my own when > I did find it, then forgot where I found it *two times* so I knew it > existed, just not where. So this is the third time I've done this > search. Now I have a few commented 'import Control.Monad.Error ()' > scattered about in a few "low level" modules to try to make sure it's > visible everywhere and next time I go hunting I can look in my own > modules. > > If orphan instances are discouraged, shouldn't the instance for Monad > Either be declared where Either is? This should probably go for > Functor Either too. I notice that Monad Maybe is in Prelude, and it > would be a pain if it weren't. > > If there's no particular reason to not move it, I'll do a libraries > proposal... or since it involves the prelude should this be > haskell-prime? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/39fae09e/attachment.html From skluft at gmail.com Fri Sep 11 09:24:21 2009 From: skluft at gmail.com (Seb) Date: Fri Sep 11 09:03:14 2009 Subject: [Haskell-cafe] Re: Problem installing OpenGL In-Reply-To: <79dad943-afcb-4dc3-a35a-0b02e6ad0a98@w36g2000yqm.googlegroups.com> References: <79dad943-afcb-4dc3-a35a-0b02e6ad0a98@w36g2000yqm.googlegroups.com> Message-ID: Think I've found the solution my self. If I download the packages and make a small change in the .cabal-file everything seems to work fine again. All i had to do was replace "extra-libraries: GL" with "frameworks: OpenGL". Not sure if this is the proper fix to make as I'm not any good with cabal packages and how that works, but it worked for me. On Sep 10, 5:25?pm, Seb wrote: > Hi, > > I'm having trouble installing OpenGL through cabal. It fails when it > tries to install OpenGLRaw with this error message: > > cabal: Missing dependency on a foreign library: > * Missing C library: GL > > I'm running OS X Leopard and have Xcode 3.1.3 installed. Do i have to > install something separate or is cabal just not looking in the right > places? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From golubovsky at gmail.com Fri Sep 11 10:29:50 2009 From: golubovsky at gmail.com (Dimitry Golubovsky) Date: Fri Sep 11 10:08:45 2009 Subject: [Haskell-cafe] Externally derive instance of Data? Message-ID: Hi, Given a datatype defined somewhere in a third-party package, without deriving (Data) specified. Is it possible, in my module which is importing that datatype from that package, to auto-derive instance of Data for the said datatype? The goal is not to recompile the package just because an auto-derived instance is needed. Or no way other than to recompile the package? Thanks. -- Dimitry Golubovsky Anywhere on the Web From jpm at cs.uu.nl Fri Sep 11 10:53:03 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Fri Sep 11 10:32:16 2009 Subject: [Haskell-cafe] Externally derive instance of Data? In-Reply-To: References: Message-ID: <52f14b210909110753s603af80dh4015deddf7a3b2a2@mail.gmail.com> Hi Dimitry, I think what you want is stand-alone deriving: http://www.haskell.org/ghc/docs/latest/html/users_guide/deriving.html#stand-alone-deriving Cheers, Pedro On Fri, Sep 11, 2009 at 16:29, Dimitry Golubovsky wrote: > Hi, > > Given a datatype defined somewhere in a third-party package, without > deriving (Data) specified. > > Is it possible, in my module which is importing that datatype from > that package, to auto-derive instance of Data for the said datatype? > The goal is not to recompile the package just because an auto-derived > instance is needed. > > Or no way other than to recompile the package? > > Thanks. > > -- > Dimitry Golubovsky > > Anywhere on the Web > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/0fed1b4d/attachment.html From nccb2 at kent.ac.uk Fri Sep 11 11:26:47 2009 From: nccb2 at kent.ac.uk (Neil Brown) Date: Fri Sep 11 11:05:43 2009 Subject: [Haskell-cafe] Control.Exception base-3/base-4 woes Message-ID: <4AAA6C37.9050203@kent.ac.uk> Hi, In my CHP library I need to do some exception catching. I want the library to work on GHC 6.8 (with base-3 -- this is the current version in Ubuntu Hardy and Jaunty, for example) and GHC 6.10 (which comes with base-4). But base-3 and base-4 need different code for exception catching (whether it's importing Control.OldException or giving a type to the catch method). Here's what I currently do -- my Haskell file contains this: #if __GLASGOW_HASKELL__ >= 609 import qualified Control.OldException as C #else import qualified Control.Exception as C #endif My cabal file contains this (it used to say just "base,..." but Hackage complained at me the other day when I tried to upload that): Build-Depends: base >= 3 && < 5, ... This works on two machines: one is 6.8+base-3, the other is 6.10+base-3&base-4, where cabal seems to use base-4. However, I have had a bug report (now replicated) which stems from a different 6.10+base-3&base-4 machine where cabal picks base-3 instead. The real problem is that the #if is based on GHC version, but really it should be based on which base-* library is being used. I know the code works with base-3 (use Control.Exception) and base-4 (use Control.OldException) but I can't get the build process right to alter the code based on which base-* library is being used. Can anyone tell me how to fix this? I don't think that changing to always use Control.Exception would fix this, because I need to give a different type for catch in base-3 to base-4, so there's still the incompatibility to be dealt with. Thanks, Neil. From dave at zednenem.com Fri Sep 11 11:42:41 2009 From: dave at zednenem.com (David Menendez) Date: Fri Sep 11 11:21:37 2009 Subject: [Haskell-cafe] Control.Exception base-3/base-4 woes In-Reply-To: <4AAA6C37.9050203@kent.ac.uk> References: <4AAA6C37.9050203@kent.ac.uk> Message-ID: <49a77b7a0909110842r753f399fx229901e9d6aba78b@mail.gmail.com> On Fri, Sep 11, 2009 at 11:26 AM, Neil Brown wrote: > > Can anyone tell me how to fix this? ?I don't think that changing to always > use Control.Exception would fix this, because I need to give a different > type for catch in base-3 to base-4, so there's still the incompatibility to > be dealt with. I'd try using a cabal flag to set a CPP flag. E.g., from cabal Flag Base3 Description: Use Version 3 of Base Default: False Library/Executable if flag(Base3) CPP-Options: -D _BASE_3_ Build-Depends: base >= 3 && < 4 else Build-Depends: base >= 4 && < 5 And then do, #if _BASE_3_ import qualified Control.Exception as C #else import qualified Control.OldException as C #endif -- Dave Menendez From ganesh.sittampalam at credit-suisse.com Fri Sep 11 11:52:26 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Fri Sep 11 11:31:34 2009 Subject: [Haskell-cafe] Control.Exception base-3/base-4 woes In-Reply-To: <4AAA6C37.9050203@kent.ac.uk> References: <4AAA6C37.9050203@kent.ac.uk> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9F9E7@ELON17P32001A.csfb.cs-group.com> Neil Brown wrote: > Can anyone tell me how to fix this? I don't think that changing to > always use Control.Exception would fix this, because I need to give a > different type for catch in base-3 to base-4, so there's still the > incompatibility to be dealt with. http://hackage.haskell.org/package/extensible-exceptions ? Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From mauricio.antunes at gmail.com Fri Sep 11 11:55:25 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Fri Sep 11 11:34:43 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: Message-ID: > The C library prints error messages to stderr. (...) > Attached is the patch to the C levmar library. Thanks for the file. > The license issue is indeed a problem. Either your (linked + > distributed) code must be GPL or you must acquire a different > (commercial) license from the author of the C library. I don't think the GPL is itself a problem, I just meant that by packaging levmar with your bindings-levmar you probably have to GPL bindings-levmar itself. Although, since you used BSD, I don't think anyone will waste time bothering you about that. > Lapack has to be installed on the hackage server in order for > the package to build. Another option is to temporarily remove > the dependency on lapack from the cabal file. (...). But the > downside is that someone won't be able to cabal install it > without first modifying the .cabal file. That is unacceptable in > my opinion. Yes, this is difficult to solve... I've even asked that some nice, trusted C libraries could be installed on hackage so that we could bind to them. Maybe this can be accepted in the future if the idea of having many good quality bindings-* packages grow up. In the mean time, we have a two-sided problem: if we release a package with linking options removed we have to edit cabal file, which is unacceptable in my opinion too; and if we do not, all bindings-*, as well as all packages built on them, will be marked with "Build failure" on hackage and lack documentation, which is also unnaceptable... The good thing is that this problem can be isolated on bindings-* packages. If it is solved, it is solved once and for all. So far, my solution has been this: * to leave a 'pkg-config' line in bindings-* cabal file. This way, your package can be used properly as long as your installed library has pkg-config configuration, and this is easy to add (even for your favorite distribution library package) if it doesn't. * to comment that pkg-config line, so that hackage will build your package. Users can just add something like 'pkgconfig-depends: levmar' to their own packages. Though I have no reason to claim this is the best solution. Also: bindings-common has some macros that could easy your job. You could have used, for instance: #bindings_frac LM_INIT_MU #bindings_frac LM_STOP_THRESH #bindings_frac LM_DIFF_DELTA Although this would add a dependency, so I don't know if it's worth. Best, Maur?cio From jeremy.odonoghue at gmail.com Fri Sep 11 11:55:50 2009 From: jeremy.odonoghue at gmail.com (Jeremy O'Donoghue) Date: Fri Sep 11 11:34:50 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AA96C0F.6070302@alumni.caltech.edu> References: <4AA8567D.20206@alumni.caltech.edu> <1252615434.5266.7115.camel@localhost> <4AA96C0F.6070302@alumni.caltech.edu> Message-ID: <4AAA7306.7050301@gmail.com> Michael Mossey wrote: > Duncan Coutts wrote: >> On Wed, 2009-09-09 at 18:29 -0700, Michael P Mossey wrote: >>> I'm trying to learn qtHaskell. I realize few people on this list >>> know anything about qtHaskell, but I have a question that probably >>> relates to all GUIs as implemented in Haskell. I just need a hint >>> that could help me figure out the next step, which I might be able >>> to infer from the qtHaskell API. >> >> Ultimately it's done by some kind of mutable state, either an IORef, >> MVar or a thread. In wxHaskell, the 'simplest' way to code this looks something like the following (literate Haskell) Structure containing 'state' of all of the GUI objects > data UIState = UIState { uiConnect :: Button () > , uiPort :: TextCtrl () > , uiUser :: TextCtrl () > , uiPasswd :: TextCtrl () > , uiSandbox :: TextCtrl () > , uiClients :: ComboBox () > , uiChanges :: SingleListBox () > , uiChangeInfo :: TextCtrl () > , uiOrigin :: TextCtrl () > , uiUpdate :: TextCtrl () > , uiFrame :: Frame () > } > uiState = unsafePerformIO $ newMVar (Nothing :: Maybe UIState) Ensure that we initialize exactly once... > uiInitState bt pt us pw sb cl ci ch or up f = > takeMVar uiState >>= \st -> > case st of > Nothing -> let st' = UIState bt pt us pw sb cl ci ch or up f in > putMVar uiState (Just st') > Just _ -> return () Get the mutable state. Note that in the error case we deliberately do not put the MVar back, as a means to block all threads waiting on the MVar (as this would indicate a general programming/threading issue to be identified). > getMVarState mv txt = > takeMVar mv >>= \may_st -> > case may_st of > Nothing -> error (txt ++ " is not available") > Just st -> putMVar mv may_st >> > return st Fetch the UI state - this will fail fatally if we fetch before state is initialized > uiGetState = getMVarState uiState "UI state" I don't have anything as neat to show you as Duncan's suggetion (I'd also be interested to see a cleaner way to do it - this sort of code always grates a little with me, although all of the major Haskell GUI bindings seem to need a similar programming style. However, at the most basic 'trying it out' level, I suspect that something very like this will work just as well for qtHaskell as it does for wxHaskell. >> On top of these you can layer nicer stuff like a state monad (with a >> 'runState' function that saves and restores from an IORef). >> >> A personal favourite of mine is having the GUI event handler post data >> over a channel to a thread. That thread reads from the channel and deals >> with the events. The state of the GUI app is then held as local >> parameters in that thread. >> >> Doing this of course requires that the GUI lib you're using can cope >> with normal Haskell (forkIO) threads. This is possible with gtk2hs, I >> don't know about the others. Regards Jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/2c02ff93/attachment.html From qdunkan at gmail.com Fri Sep 11 11:55:57 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Sep 11 11:35:00 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> Message-ID: <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> On Fri, Sep 11, 2009 at 6:10 AM, Edward Kmett wrote: > Unfortunately, the instance of Monad for Either a is somewhat misguided in > Haskell. > > There is a spurious restraint that the Left value in your Either be a member > of some Error class, which was brought about by the deletion of MonadZero > from Haskell 98 (as part of the elimination of failure free patterns, and an > attempted simplification of the language). I just tried it, and my own instance for Monad (Either String) (all I'm really interested in anyway) can coexist with the one for Error e => Monad (Either e). But indeed, with the presence of fail, you can't write the general Monad (Either e) which "should" work. And it does require FlexibleInstances. I suppose as long as flexible instances aren't standard then even the String instance can't go in the Prelude. > In theory, this is good, because you can then define your own monad instance > for Either without that constraint --?if you don't care to exploit the Error > instance's ability to get fail to work. Or you want a real Either monad for > tricks like Oleg's recent post on the constructive law of excluded middle, > or to talk about apomorphisms as a generalized anamorphism, parameterized on > the either monad so it can be symmetrical to paramorphisms. In practice, > you?link in?someone's code that links in the MTL, and then you're stuck > using?the MTL instance?anyways. Right. I know there was some argument a while back, but I thought that position that instances are global period was pretty "official". At least it made sense to me. The more libraries you import the less control you have over the extent of what they may import. But I guess it wouldn't be haskell if every third person didn't have an idea for a better way to implement the mtl... I just want an exception with a message though! From darrelll at amgen.com Fri Sep 11 12:20:45 2009 From: darrelll at amgen.com (Lewis-Sandy, Darrell) Date: Fri Sep 11 11:59:40 2009 Subject: [Haskell-cafe] RE: Darcs and NFS Resolution In-Reply-To: <20090910183404.CA4223247BC@www.haskell.org> References: <20090910183404.CA4223247BC@www.haskell.org> Message-ID: Thanks to everyone who pointed me in the right direction on this problem, I have been able to find a work around that allows me to push to an archive on a network file share. After some digging, I discovered the root of the problem. Briefly, Darcs uses the standard library System.Directory to perform file manipulations. This library make use of compiler pragmas to conditionally compile either the Windows or Linux specific functions based on the host operating system. This approach assumes that when your operating system is a Linux variant, all your mounted volumes will natively support POSIX. When you have mounted CIFS volumes, this will result in errors when calling those library functions to create, rename, copy and delete files or folders! Given the flexibility of the Linux operating system, A more versatile implementation for System.Directory might be able to detect the file system of each volume at runtime and choose the appropriate functions to call. But I digress... To workaround the inability to push to a CIFS volume in darcs, I modified the workaround.hs module to shell out to the OS's rename function rather than using the Haskell library's rename function. Specifically: I added the following code after the #else near line 80: renameFile :: FilePath -> FilePath -> IO () renameFile old new = do ecode <- System.Cmd.rawSystem "mv" [old,new] case ecode of ExitSuccess -> return () ExitFailure n -> putStrLn ("renameFile failed with exit code" ++ show n) which ensures that when the operating system is not WIN32, that renaming of files will be performed by the OS shell. I then added the System.Cmd module to the list of imports by inserting the following code near line 21 import qualified System.Cmd(rawSystem) after a recompile I could push to a CIFS volume, for example: sudo darcs push /mnt/cifsvol this is an obvious hack, and does not address the inability to put to a CIFS share (put depends upon copyFile and would need to be hacked to shell-out as well). Archives on the CIFS share have to be created by navigating to that folder and initializing. Shelling out is clearly a poor long term solution; a longer term solution would ideally introduce into the Haskell System.Directory library the ability to apply the correct functions transparently in accordance with the file system of the volume. Cheers -Darrell Lewis-Sandy From bulat.ziganshin at gmail.com Fri Sep 11 12:39:34 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Sep 11 12:18:37 2009 Subject: [Haskell-cafe] Control.Exception base-3/base-4 woes In-Reply-To: <4AAA6C37.9050203@kent.ac.uk> References: <4AAA6C37.9050203@kent.ac.uk> Message-ID: <827057599.20090911203934@gmail.com> Hello Neil, Friday, September 11, 2009, 7:26:47 PM, you wrote: i suggest you to import extensible-exceptions package instead - it's available even for ghc 6.8. alternatively, you may import old-exceptions package (or something like this). trying to develop code compatible with both versions of exceptions should be a nightmare :D > Hi, > In my CHP library I need to do some exception catching. I want the > library to work on GHC 6.8 (with base-3 -- this is the current version > in Ubuntu Hardy and Jaunty, for example) and GHC 6.10 (which comes with > base-4). But base-3 and base-4 need different code for exception > catching (whether it's importing Control.OldException or giving a type > to the catch method). > Here's what I currently do -- my Haskell file contains this: > #if __GLASGOW_HASKELL__ >= 609 > import qualified Control.OldException as C > #else > import qualified Control.Exception as C > #endif > My cabal file contains this (it used to say just "base,..." but Hackage > complained at me the other day when I tried to upload that): > Build-Depends: base >= 3 && < 5, ... > This works on two machines: one is 6.8+base-3, the other is > 6.10+base-3&base-4, where cabal seems to use base-4. However, I have > had a bug report (now replicated) which stems from a different > 6.10+base-3&base-4 machine where cabal picks base-3 instead. The real > problem is that the #if is based on GHC version, but really it should be > based on which base-* library is being used. I know the code works with > base-3 (use Control.Exception) and base-4 (use Control.OldException) but > I can't get the build process right to alter the code based on which > base-* library is being used. > Can anyone tell me how to fix this? I don't think that changing to > always use Control.Exception would fix this, because I need to give a > different type for catch in base-3 to base-4, so there's still the > incompatibility to be dealt with. > Thanks, > Neil. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From aslatter at gmail.com Fri Sep 11 13:14:24 2009 From: aslatter at gmail.com (Antoine Latter) Date: Fri Sep 11 12:53:19 2009 Subject: [Haskell-cafe] Control.Exception base-3/base-4 woes In-Reply-To: <49a77b7a0909110842r753f399fx229901e9d6aba78b@mail.gmail.com> References: <4AAA6C37.9050203@kent.ac.uk> <49a77b7a0909110842r753f399fx229901e9d6aba78b@mail.gmail.com> Message-ID: <694519c50909111014t638795e6m9db015bbd51651e3@mail.gmail.com> On Fri, Sep 11, 2009 at 10:42 AM, David Menendez wrote: > On Fri, Sep 11, 2009 at 11:26 AM, Neil Brown wrote: >> >> Can anyone tell me how to fix this? ?I don't think that changing to always >> use Control.Exception would fix this, because I need to give a different >> type for catch in base-3 to base-4, so there's still the incompatibility to >> be dealt with. > > I'd try using a cabal flag to set a CPP flag. > > E.g., from cabal > > ? ?Flag Base3 > ? ? ? ?Description: Use Version 3 of Base > ? ? ? ?Default: False > > ? ?Library/Executable > ? ? ? ?if flag(Base3) > ? ? ? ? ? ?CPP-Options: -D _BASE_3_ > ? ? ? ? ? ?Build-Depends: base >= 3 && < 4 > > ? ? ? ?else > ? ? ? ? ? ?Build-Depends: base >= 4 && < 5 > > And then do, > > ? ?#if _BASE_3_ > ? ?import qualified Control.Exception as C > ? ?#else > ? ?import qualified Control.OldException as C > ? ?#endif > I've had success with this. See: http://hackage.haskell.org/packages/archive/uuid/1.0.2/uuid.cabal Antoine From a.biurvOir4 at asuhan.com Fri Sep 11 13:19:32 2009 From: a.biurvOir4 at asuhan.com (Kim-Ee Yeoh) Date: Fri Sep 11 12:58:24 2009 Subject: [Haskell-cafe] Essentials about type classes? In-Reply-To: <25393728.post@talk.nabble.com> References: <25393728.post@talk.nabble.com> Message-ID: <25405022.post@talk.nabble.com> Hi Fredrik, Temaran wrote: > > data Dar = Dar String String > deriving (Show, Eq) > > class Bar a where > foo :: a -> Int > > instance Bar Dar where > foo(Dar n c) = length c > > but it keeps generating the same error; > > ERROR "./Bar.hs":16 - Inferred type is not general enough > *** Expression : foo > *** Expected type : a -> Int > *** Inferred type : Dar -> Int > You're missing indentation. Instead of declaring foo as a member of the typeclass, your code says it's a top-level function fully-polymorphic in the first parameter. That's why defining it later as foo (Dar ...) gives the error message it does. -- View this message in context: http://www.nabble.com/Essentials-about-type-classes--tp25393728p25405022.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dagit at codersbase.com Fri Sep 11 13:54:27 2009 From: dagit at codersbase.com (Jason Dagit) Date: Fri Sep 11 13:33:19 2009 Subject: [Haskell-cafe] RE: Darcs and NFS Resolution In-Reply-To: References: <20090910183404.CA4223247BC@www.haskell.org> Message-ID: Hi Darrell, This message definitely also belongs on the darcs-users@darcs.net mailing list. You can find information about how to subscribe here: http://lists.osuosl.org/mailman/listinfo/darcs-users Please join our list! I'm adding the list to the CC list in my reply. On Fri, Sep 11, 2009 at 9:20 AM, Lewis-Sandy, Darrell wrote: > Thanks to everyone who pointed me in the right direction on this problem, I > have been able to find a work around that allows me to push to an archive on > a network file share. > > After some digging, I discovered the root of the problem. Briefly, Darcs > uses the standard library System.Directory to perform file manipulations. > This library make use of compiler pragmas to conditionally compile either > the Windows or Linux specific functions based on the host operating system. > > This approach assumes that when your operating system is a Linux variant, > all your mounted volumes will natively support POSIX. When you have mounted > CIFS volumes, this will result in errors when calling those library > functions to create, rename, copy and delete files or folders! Given the > flexibility of the Linux operating system, A more versatile implementation > for System.Directory might be able to detect the file system of each volume > at runtime and choose the appropriate functions to call. But I digress... > > To workaround the inability to push to a CIFS volume in darcs, I modified > the workaround.hs module to shell out to the OS's rename function rather > than using the Haskell library's rename function. Specifically: > Ah clever way to test this. > > I added the following code after the #else near line 80: > > renameFile :: FilePath -> FilePath -> IO () > renameFile old new = do > ecode <- System.Cmd.rawSystem "mv" [old,new] > case ecode of > ExitSuccess -> return () > ExitFailure n -> putStrLn ("renameFile failed with exit code" ++ > show n) > > which ensures that when the operating system is not WIN32, that renaming of > files will be performed by the OS shell. I then added the System.Cmd module > to the list of imports by inserting the following code near line 21 > > import qualified System.Cmd(rawSystem) > > after a recompile I could push to a CIFS volume, for example: > > sudo darcs push /mnt/cifsvol > > this is an obvious hack, and does not address the inability to put to a > CIFS share (put depends upon copyFile and would need to be hacked to > shell-out as well). Archives on the CIFS share have to be created by > navigating to that folder and initializing. > Interesting. > > Shelling out is clearly a poor long term solution; a longer term solution > would ideally introduce into the Haskell System.Directory library the > ability to apply the correct functions transparently in accordance with the > file system of the volume. > Yes, and in the meantime we can implement something like this in workaround.hs. Thanks! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/275114c4/attachment.html From lists at qseep.net Fri Sep 11 14:46:00 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Sep 11 14:24:54 2009 Subject: [Haskell-cafe] Unable to install Haskell Platform without readline Message-ID: <670e468e0909111146y2921f179x4087617294abc52@mail.gmail.com> Hi folks, I just installed GHC 6.10.4 on Ubuntu 9.04 32-bit, and then tried to install the Haskell Platform from source. It built quite a bit of stuff, with many warnings but no errors, and then finally died with the error below. To install editline, I need cabal, which is of course why I installed the Platform. I read an earlier thread from May that said that editline came with GHC 6.10.2, so the Platform didn't work with 6.10.3, but was soon to be updated. Now the web sitefor the Platform says it comes with 6.10.4, so I assumed it should work with 6.10.4, but apparently it still has this problem of still missing editline. Am I doing something wrong? checking editline/readline.h usability... no checking editline/readline.h presence... no checking for editline/readline.h... no checking editline/editline.h usability... no checking editline/editline.h presence... no checking for editline/editline.h... no checking readline/readline.h usability... yes checking readline/readline.h presence... yes checking for readline/readline.h... yes checking for sign of read_history result on error... negative checking for rl_completion_matches... no checking for completion_matches... no configure: error: editline not found, so this package cannot be built See `config.log' for more details. Error: Configuring the editline-0.2.1.0 package failed make: *** [build.stamp] Error 2 - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/e1dac7ec/attachment.html From lists at qseep.net Fri Sep 11 14:55:32 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Sep 11 14:34:27 2009 Subject: [Haskell-cafe] Re: Unable to install Haskell Platform without editline Message-ID: <670e468e0909111155w404ec4e7ma6db763b35dd2608@mail.gmail.com> I mean editline, not readline. On Fri, Sep 11, 2009 at 11:46 AM, Lyle Kopnicky wrote: > Hi folks, > > I just installed GHC 6.10.4 on Ubuntu 9.04 32-bit, and then tried to > install the Haskell Platform from source. It built quite a bit of stuff, > with many warnings but no errors, and then finally died with the error > below. > > To install editline, I need cabal, which is of course why I installed the > Platform. I read an earlier thread from May that said that editline came > with GHC 6.10.2, so the Platform didn't work with 6.10.3, but was soon to be > updated. Now the web sitefor the Platform says it comes with 6.10.4, so I assumed it should work with > 6.10.4, but apparently it still has this problem of still missing editline. > > Am I doing something wrong? > > checking editline/readline.h usability... no > checking editline/readline.h presence... no > checking for editline/readline.h... no > checking editline/editline.h usability... no > checking editline/editline.h presence... no > checking for editline/editline.h... no > checking readline/readline.h usability... yes > checking readline/readline.h presence... yes > checking for readline/readline.h... yes > checking for sign of read_history result on error... negative > checking for rl_completion_matches... no > checking for completion_matches... no > configure: error: editline not found, so this package cannot be built > See `config.log' for more details. > > Error: > Configuring the editline-0.2.1.0 package failed > make: *** [build.stamp] Error 2 > > - Lyle > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/132908a7/attachment-0001.html From judah.jacobson at gmail.com Fri Sep 11 15:01:11 2009 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Fri Sep 11 14:40:25 2009 Subject: [Haskell-cafe] Unable to install Haskell Platform without readline In-Reply-To: <670e468e0909111146y2921f179x4087617294abc52@mail.gmail.com> References: <670e468e0909111146y2921f179x4087617294abc52@mail.gmail.com> Message-ID: <6d74b0d20909111201s1f5d0c13s55c02096e4b2cc0d@mail.gmail.com> On Fri, Sep 11, 2009 at 11:46 AM, Lyle Kopnicky wrote: > Hi folks, > > I just installed GHC 6.10.4 on Ubuntu 9.04 32-bit, and then tried to install > the Haskell Platform from source. It built quite a bit of stuff, with many > warnings but no errors, and then finally died with the error below. > > To install editline, I need cabal, which is of course why I installed the > Platform. I read an earlier thread from May that said that editline came > with GHC 6.10.2, so the Platform didn't work with 6.10.3, but was soon to be > updated. Now the web site for the Platform says it comes with 6.10.4, so I > assumed it should work with 6.10.4, but apparently it still has this problem > of still missing editline. > > Am I doing something wrong? > > checking editline/readline.h usability... no > checking editline/readline.h presence... no > checking for editline/readline.h... no > checking editline/editline.h usability... no > checking editline/editline.h presence... no > checking for editline/editline.h... no > checking readline/readline.h usability... yes > checking readline/readline.h presence... yes > checking for readline/readline.h... yes > checking for sign of read_history result on error... negative > checking for rl_completion_matches... no > checking for completion_matches... no > configure: error: editline not found, so this package cannot be built > See `config.log' for more details. > > Error: > Configuring the editline-0.2.1.0 package failed > make: *** [build.stamp] Error 2 The above editline requirement is for the editline C library, not the Haskell bindings: http://www.thrysoee.dk/editline My guess is that you need to install a recent version of the libedit-dev package. Best, -Judah From lists at qseep.net Fri Sep 11 15:59:12 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Sep 11 15:38:06 2009 Subject: [Haskell-cafe] Unable to install Haskell Platform without editline Message-ID: <670e468e0909111259s6332faccpade6a9fc288440e5@mail.gmail.com> On Fri, Sep 11, 2009 at 12:01 PM, Judah Jacobson wrote: > The above editline requirement is for the editline C library, not the > Haskell bindings: > http://www.thrysoee.dk/editline > > My guess is that you need to install a recent version of the > libedit-dev package. > After installing libedit-dev, the rest of the build worked. Thanks! Now I'm having a new problem, that I'll post in another thread. - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/66ae58b4/attachment.html From lists at qseep.net Fri Sep 11 16:04:20 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Sep 11 15:43:13 2009 Subject: [Haskell-cafe] Haskell Platform install fails on mtl Message-ID: <670e468e0909111304n1a5ad155j790627d59592c335@mail.gmail.com> OK, I was able to build the Haskell Platform on Ubuntu 9.04 with GHC 6.10.4. But when I try to install it, I get an error: Registering haskell-platform-2009.2.0.2... Reading package info from "dist/inplace-pkg-config" ... done. Writing new package config file... done. ************************************************** * Building each component completed successfully. * * Now do "sudo make install" ************************************************** lwk@lwk-desktop:~/downloads/haskell-platform-2009.2.0.2$ sudo make install [sudo] password for lwk: scripts/install.sh Installing mtl-1.1.0.2... Error: The mtl-1.1.0.2/Setup script does not exist or cannot be run make: *** [install] Error 2 - Lyle -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/b03b26cc/attachment.html From jefferson.r.heard at gmail.com Fri Sep 11 16:27:46 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Fri Sep 11 16:06:58 2009 Subject: [Haskell-cafe] Just to let people know Message-ID: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> lhs2TeX does not compile with the latest version of base. complaints about Control.Exception abound From leather at cs.uu.nl Fri Sep 11 17:42:10 2009 From: leather at cs.uu.nl (Sean Leather) Date: Fri Sep 11 17:21:23 2009 Subject: [Haskell-cafe] Just to let people know In-Reply-To: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> References: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> Message-ID: <3c6288ab0909111442j48b6302asa6483ee067184701@mail.gmail.com> Thanks, Jeff. I'm CC'ing Andres just in case he didn't get this. Sean On Fri, Sep 11, 2009 at 22:27, Jeff Heard wrote: > lhs2TeX does not compile with the latest version of base. complaints > about Control.Exception abound > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/c37afa89/attachment.html From lists at qseep.net Fri Sep 11 20:26:46 2009 From: lists at qseep.net (Lyle Kopnicky) Date: Fri Sep 11 20:05:39 2009 Subject: [Haskell-cafe] Re: Haskell Platform install fails on mtl In-Reply-To: <670e468e0909111304n1a5ad155j790627d59592c335@mail.gmail.com> References: <670e468e0909111304n1a5ad155j790627d59592c335@mail.gmail.com> Message-ID: <670e468e0909111726y41f162dbj1854e43438032702@mail.gmail.com> It's a bug in the install.sh script. Here's the fix: 36a37,42 > # Is this exact version of the package already installed? > is_pkg_installed () { > PKG_VER=$1 > grep " ${PKG_VER} " installed.packages > /dev/null 2>&1 > } > 40,43c46,53 < cd "${pkg}" || die "The directory for the component ${PKG} is missing" < echo "Installing ${pkg}..." < install_pkg ${pkg} < cd .. --- > if is_pkg_installed "${pkg}"; then > echo "Platform package ${pkg} is already installed. Skipping..." > else > cd "${pkg}" || die "The directory for the component ${PKG} is missing" > echo "Installing ${pkg}..." > install_pkg ${pkg} > cd .. > fi On Fri, Sep 11, 2009 at 1:04 PM, Lyle Kopnicky wrote: > OK, I was able to build the Haskell Platform on Ubuntu 9.04 with GHC > 6.10.4. But when I try to install it, I get an error: > > Registering haskell-platform-2009.2.0.2... > Reading package info from "dist/inplace-pkg-config" ... done. > Writing new package config file... done. > ************************************************** > * Building each component completed successfully. > * > * Now do "sudo make install" > ************************************************** > lwk@lwk-desktop:~/downloads/haskell-platform-2009.2.0.2$ sudo make install > [sudo] password for lwk: > scripts/install.sh > Installing mtl-1.1.0.2... > > Error: > The mtl-1.1.0.2/Setup script does not exist or cannot be run > make: *** [install] Error 2 > > - Lyle > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/9ac95cac/attachment.html From mikesteele81 at gmail.com Fri Sep 11 22:11:57 2009 From: mikesteele81 at gmail.com (Michael Steele) Date: Fri Sep 11 21:50:48 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> Message-ID: > Right. I know there was some argument a while back, but I thought > that position that instances are global period was pretty "official". > At least it made sense to me. The more libraries you import the less > control you have over the extent of what they may import. But I guess > it wouldn't be haskell if every third person didn't have an idea for a > better way to implement the mtl... I just want an exception with a > message though! A few days ago I was trying to refactor some code to use transformers + monads-tf instead of mtl. Eventually I gave up after getting error messages about Either having conflicting Monad instances. A few of the libraries I'm using depend on mtl. if I understand you correctly, all libraries that software I write depends on, directly or indirectly, must be free of namespace conflicts. Is that correct? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090911/fd5221f4/attachment.html From qdunkan at gmail.com Fri Sep 11 22:22:47 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Fri Sep 11 22:01:39 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> Message-ID: <2518b95d0909111922s40747c9eu7ccf8addc76c1f8c@mail.gmail.com> > if I understand you correctly, all libraries that software I write depends > on, directly or indirectly, must be free of namespace conflicts. ?Is that > correct? Well, it may be more accurate to say that class instances have no namespaces, and are all implicitly global. When you import a module, you get all the instances it defines in the global namespace, whether you want them or not. Like I said, there was some argument with people on one side saying importing is a valid way of controlling instance visibility, and another side saying the fact that you have to import at all is an implementation artifact and instances should be considered global. Practically speaking, I buy the second argument more, for the reason you described above. From briand at aracnet.com Sat Sep 12 01:18:43 2009 From: briand at aracnet.com (brian) Date: Sat Sep 12 00:57:42 2009 Subject: [Haskell-cafe] hmatrix on os x In-Reply-To: <4AA8A36F.8040406@van.steenbergen.nl> References: <9157df230909071906p2dbf8135i16a2822a8de3b34@mail.gmail.com> <4AA8A36F.8040406@van.steenbergen.nl> Message-ID: <79DD7AA9-A41F-4CDE-80EF-3AF8CE3BF025@aracnet.com> Hi, yep - that's the problem I had. run cabal with the -v (verbose option) cabal install -v so you can see exactly where it's failing try the following : --extra-lib-dirs=PATH where PATH was (for me) was /sw/lib I'm not sure but I may have had to use --extra-include-dirs also. Generally I have a lot of trouble with cabal installing things properly using the mac, but the above options usually fix the problem. I did get hmatrix working. Then when I ran a an example which did a simple vector operation, it segfaulted. However the linear algebra routines all seemed to work. Let me know what happens. The linux pc gave me even more problems which I eventually traced to LD_LIBRARY_PATH needing to include the lib dirs. HTH. Brian On Sep 9, 2009, at 11:57 PM, Martijn van Steenbergen wrote: > brian wrote: >> yep I had some trouble too, although interestingly less than on >> linux pc. >> can you provide some error messages and we can see if your problems >> are the same one's I saw. > > If this helps, here is the error message I got: > > Configuring hmatrix-0.5.2.2... > Checking foreign libraries... FAIL > *** Sorry, I can't link GSL. > *** Please make sure that the appropriate -dev packages are installed. > *** You can also specify the required libraries using > *** cabal install hmatrix --configure-option=link:lib1,lib2,lib3,etc. > setup: Package hmatrix-0.5.2.2 can't be built on this system. > cabal: Error: some packages failed to install: > hmatrix-0.5.2.2 failed during the building phase. The exception was: > exit: ExitFailure 1 > > M. From alexey.skladnoy at gmail.com Sat Sep 12 06:18:35 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sat Sep 12 05:51:29 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: Message-ID: <200909121418.35909.alexey.skladnoy@gmail.com> ? ????????? ?? ??????? 10 ???????? 2009 17:21:40 ????? Bas van Dijk ???????: > We like to announce the release of a Haskell binding to Manolis > Lourakis's C levmar library bindings-levmar fails to configure on debian testing with following message: $ cabal install bindings-levmar Resolving dependencies... Configuring bindings-levmar-0.1... cabal: The pkg-config package lapack is required but it could not be found. cabal: Error: some packages failed to install: bindings-levmar-0.1 failed during the configure step. The exception was: exit: ExitFailure 1 Following lapack packages are installed > ii liblapack-dev 3.2.1-1 > ii liblapack3gf 3.2.1-1 It seems that debian doesn't provide file `lapack.pc'. So pkg-config fails. From johanj at cs.uu.nl Sat Sep 12 06:16:46 2009 From: johanj at cs.uu.nl (Johan Jeuring) Date: Sat Sep 12 05:55:39 2009 Subject: [Haskell-cafe] ANNOUNCE: Palindromes 0.1 In-Reply-To: References: Message-ID: Hi Henning, Thanks for the many suggestions. > On Sun, 6 Sep 2009, Johan Jeuring wrote: > >> The primary features of Palindromes include: >> >> * Linear-time algorithm for finding exact palindromes >> * Linear-time algorithm for finding text palindromes, >> ignoring spaces, case of characters, and punctuation >> symbols. > > You made me curious, whether there are palindromes in my texts. > However, I have some difficulties getting sensible results from it. > First I found a long palindrome, that was actually a code example > for an array definition. This was using the option -t I suppose. > So I wondered, whether this palindrome shadows nicer shorter > palindromes in the same text. Indeed it might. By using -ts you will get all text palindromes around every position in the string, but I guess you found this option (the description of which was not correct, as you noticed). But on a long text you get (probably too) many results. > How about an option for showing the n longest palindromes or > palindromes with length larger than n? This makes sense. I will add an option -n which takes a number n and outputs all palindromes of length at least n. > Then I found a palindrome in > Functi[on sin is no]t defined > How about restricting text palindromes to sequences that are bounded > by space and punctuation? This makes sense as well. > The Palindrome welcome message is a bit disturbing when running > palindrome on a set of files. I see. I'll remove it. > I also like to filter out HTML markup (with strip-html from tagchup > package), before piping into palindrome. This however would require > to run palindrome on standard input. Again, this makes sense. > The options are '-x' for a single answer and '-xs' for multiple > answers, but for '-ts' this logic does not hold. How about '-lt' or > '-tl' ? I would like to have '-ts' to print all text palindromes (or > actually, I would like to get all palindromes with at least 5 > characters). Corrected. >> Documentation >> ------------- >> >> The API is documented using Haddock and available on the >> Palindromes package >> site. > > It says, that the executable is FindingPalindromes, but actually it > is palindromes, right? Right. > Pretty much suggestions, I know. Don't get worried and thank you for > the program! You're welcome, thanks for the suggestions. I'll try to upload a new version of palindromes that includes your suggestions in the next couple of weeks. -- Johan From dons at galois.com Sat Sep 12 06:19:37 2009 From: dons at galois.com (Don Stewart) Date: Sat Sep 12 06:00:38 2009 Subject: [Haskell-cafe] Just to let people know In-Reply-To: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> References: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> Message-ID: <20090912101937.GC19071@whirlpool.galois.com> jefferson.r.heard: > lhs2TeX does not compile with the latest version of base. complaints > about Control.Exception abound Adding --constraint='base<4' helps. That's what the Arch Linux package uses: http://aur.archlinux.org/packages.php?ID=12648 From jefferson.r.heard at gmail.com Sat Sep 12 08:38:55 2009 From: jefferson.r.heard at gmail.com (Jeff Heard) Date: Sat Sep 12 08:18:05 2009 Subject: [Haskell-cafe] Just to let people know In-Reply-To: <20090912101937.GC19071@whirlpool.galois.com> References: <4165d3a70909111327p33369e2bleb827a1467bc032f@mail.gmail.com> <20090912101937.GC19071@whirlpool.galois.com> Message-ID: <4165d3a70909120538o43b4a850n9e1913c3b671162@mail.gmail.com> I know, but I'm not the package maintainer... I didn't mean it couldn't be installed, just that it didn't compile out of the box On Sat, Sep 12, 2009 at 6:19 AM, Don Stewart wrote: > jefferson.r.heard: >> lhs2TeX does not compile with the latest version of base. ?complaints >> about Control.Exception abound > > Adding --constraint='base<4' helps. > That's what the Arch Linux package uses: > > ? ?http://aur.archlinux.org/packages.php?ID=12648 > > From xj2106 at columbia.edu Sat Sep 12 10:46:28 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Sat Sep 12 10:25:27 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <200909121418.35909.alexey.skladnoy@gmail.com> (Khudyakov Alexey's message of "Sat, 12 Sep 2009 14:18:35 +0400") References: <200909121418.35909.alexey.skladnoy@gmail.com> Message-ID: <87ocpgp6ez.fsf@columbia.edu> Khudyakov Alexey writes: > ? ????????? ?? ??????? 10 ???????? 2009 17:21:40 ????? Bas van Dijk ???????: >> We like to announce the release of a Haskell binding to Manolis >> Lourakis's C levmar library > > bindings-levmar fails to configure on debian testing with following message: > > $ cabal install bindings-levmar > Resolving dependencies... > Configuring bindings-levmar-0.1... > cabal: The pkg-config package lapack is required but it could not be found. > cabal: Error: some packages failed to install: > bindings-levmar-0.1 failed during the configure step. The exception was: > exit: ExitFailure 1 > > > Following lapack packages are installed >> ii liblapack-dev 3.2.1-1 >> ii liblapack3gf 3.2.1-1 > > It seems that debian doesn't provide file `lapack.pc'. So pkg-config fails. I believe most of the linux distributions do not have `lapack.pc', if you install certain implementation of lapack like the one provided by netlib.org, or the one with `ATLAS', or the one provided by intel mkl. So, using such pkgconfig file is rather useless. A configure system like the one used in `hmatrix' should be used to actually adapt various kinds of systems. - jxy -- c/* __o/* <\ * (__ */\ < From trentbuck at gmail.com Sat Sep 12 11:22:54 2009 From: trentbuck at gmail.com (Trent W. Buck) Date: Sat Sep 12 11:02:22 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution References: <20090910183404.CA4223247BC@www.haskell.org> Message-ID: <30hbv85gs1.fsf@gmail.com> [Due to circumstances beyond my control, I cannot CC the OP. Sorry.] Jason Dagit writes: >> [Darcs] assumes that when your OS is [POSIX], all your mounted >> volumes will natively support POSIX. Some CIFS servers (namely, Samba) *do* implement POSIX semantics. I take it to OP is using a Microsoft CIFS server? Is this the same problem as http://wiki.darcs.net/sshfs ? >> renameFile :: FilePath -> FilePath -> IO () >> renameFile old new = -- [...] >> System.Cmd.rawSystem "mv" [old,new] >> -- [...] >> >> which ensures that when the operating system is not WIN32, that >> renaming of files will be performed by the OS shell. Ew. I'm not keen on calling mv(1) to handle each rename, let alone via sh (which WILL explode on some paths, and allow injection attacks). I'm also puzzled as to why this works -- surely mv(1) assumes POSIX semantics, too? I would be interested in seeing the exact error transcript, preferably as an issue on bugs.d.n. I'm not sure the problem has been diagnosed correctly. >> Shelling out is clearly a poor long term solution; a longer term >> solution would ideally introduce into the Haskell System.Directory >> library the ability to apply the correct functions transparently in >> accordance with the file system of the volume. I guess someone should file a bug with them (in GHC's trac?). > Yes, and in the meantime we can implement something like this in > workaround.hs. I definitely think this SHOULD NOT be enabled by default, unless you're going to ONLY enable it in the specific scenario of CIFS on Linux. From max.rabkin at gmail.com Sat Sep 12 11:36:36 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sat Sep 12 11:15:46 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: <30hbv85gs1.fsf@gmail.com> References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> Message-ID: On Sat, Sep 12, 2009 at 5:22 PM, Trent W. Buck wrote: > Ew. ?I'm not keen on calling mv(1) to handle each rename, let alone via > sh (which WILL explode on some paths, and allow injection attacks). rawSystem does not use sh (hence the "raw") --Max From me at mornfall.net Sat Sep 12 12:10:27 2009 From: me at mornfall.net (Petr Rockai) Date: Sat Sep 12 11:49:21 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: <30hbv85gs1.fsf@gmail.com> (Trent W. Buck's message of "Sun, 13 Sep 2009 01:22:54 +1000") References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> Message-ID: <8763bo2lfw.fsf@twilight.int.mornfall.net.> trentbuck@gmail.com (Trent W. Buck) writes: > I'm also puzzled as to why this works -- surely mv(1) assumes POSIX > semantics, too? I would be interested in seeing the exact error > transcript, preferably as an issue on bugs.d.n. I'm not sure the > problem has been diagnosed correctly. Well, not really: mv will try harder than just calling rename(2). E.g. mv also works across mount points, where it'll go as far as doing a copy and unlink. > I definitely think this SHOULD NOT be enabled by default, unless you're > going to ONLY enable it in the specific scenario of CIFS on Linux. Well, we can always catch the rename(2) error and try unlinking and renaming again (carefully, unlike current Workaround's renameFile which just does that on any error). Yours, Petr. From jfredett at gmail.com Sat Sep 12 13:11:59 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 12 12:51:28 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 130 - September 12, 2009 Message-ID: --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090912 Issue 130 - September 12, 2009 --------------------------------------------------------------------------- Welcome to issue 130 of HWN, a newsletter covering developments in the [1]Haskell community. Welcome to issue 130 of HWN! In the last week, HWN has gotten a new editor, me! I'm Joe Fredette (jfredett on IRC, reddit, and everywhere else), and I'll be taking over for Brent (byorgey) from now on. I think I speak for the whole community when I thank him for his excellent work on the HWN and associated tools. I have a few ideas about how I want to change HWN for the better, and hopefully you'll like them too! So, without further ado, The Haskell Weekly News! Announcements Looking for a new HWN editor. Brent Yorgey [2]went looking for a new editor for the HWN, and that's how you got me! See the editorial for more details. CfPart: FMICS 2009, 2-3 November 2009. Christophe Joubert [3]announced FMICS 2009 - FIRST CALL FOR PARTICIPATION, 14th International Workshop on Formal Methods for Industrial Critical Systems. November 2-3, 2009 Call for Posters: APLAS 2009. Kiminori Matsuzaki [4]announced a CALL FOR POSTER PRESENTATIONS The Seventh ASIAN Symposium on Programming Languages and Systems (APLAS 2009) December 14 - 16, 2009 Seoul National University, Seoul, Korea. hecc-0.1. Marcel Fourn?? [5]announced the first release of hecc, the Elliptic Curve Cryptography Library for Haskell. Implemented are affine, projective, jacobian and modified jacobian point formats with the basic operations. Included as an Example is a basic ECDH as well as a basic speed test. HLint 1.6.8. Neil Mitchell [6]announced HLint 1.6.8. HLint is a tool for suggesting improvements to your source code. It suggests the use of library functions you may have been unaware of, finds patterns of recursion that are really folds/maps, hints about extensions you aren't using and much more. HLint is now one of the top 20 applications on Hackage, and is used by the darcs project to improve and statically check their code base. A Levenberg-Marquardt implementation. Bas van Dijk [7]announced the release of a Haskell binding to Manolis Lourakis's C levmar library. This library implements the Levenberg-Marquardt algorithm which is an iterative technique that finds a local minimum of a function that is expressed as the sum of squares of nonlinear functions. It has become a standard technique for nonlinear least-squares problems and can be thought of as a combination of steepest descent and the Gauss-Newton method. CCA-0.1. Paul L [8]announced that a library for Causal Commutative Arrows (CCA) has been uploaded to Hackage DB. It implements CCA normalization using Template Haskell and a modified arrow pre- processor (based on arrowp) to generate outout that Template Haskell can parse. It's highly experimental since we are still fiddling with several design choices, and by no means we imply Template Haskell is the best choice to implement CCA. Any suggestion or comment is welcome! graphviz-2999.5.0.0. Ivan Lazar Miljenovic [9]announced version 2999.5.0.0 of the graphviz package for Haskell. This is what I like to think of as the 'Hey, this is almost getting to be a decent library!' version. The graphviz package provides bindings to the GraphViz suite of programs by providing the ability to generate and parse GraphViz's Dot language as well as wrappers around the tools themselves. uvector-algorithms 0.2. Dan Doel [10]announced version 0.2 of the uvector-algorithms package. The package so far has implementations of several sorting and selection algorithms for use on the mutable arrays from the uvector library, as well as combinators for applying them to immutable arrays. dbmigrations 0.1. Jonathan Daugherty [11]announced dbmigrations, A library and program for the creation, management, and installation of schema updates (called migrations) for a relational database. In particular, this package lets the migration author express explicit dependencies between migrations and the management tool automatically installs or reverts migrations accordingly, using transactions for safety. This package is written to support any HDBC-supported database, although at present only PostgreSQL is fully supported. Palindromes 0.1. Johan Jeuring [12]announced Palindromes, a package for finding palindromes in files. Visit the [13]homepage The primary features of Palindromes include: A linear-time algorithm for finding exact palindromes, A linear-time algorithm for finding text palindromes, ignoring spaces, case of characters, and punctuation symbols. Discussion Averting QuickCheck Madness. Christopher Lane Hinson Christopher Hinson [14]asked about best practices with regards to QuickCheck, and it's inclusion/exclusion as a dependency for end-user programs. How to customize dyre recompile? Andy Stewart Andy Stewart [15]asked about how to customize Dyre's settings to do a whole-program recompilation. Externally derive instance of Data? Dimitry Golubovsky Dimitry Golubovsky [16]asked about stand-alone deriving for third-party datatypes. Parallel parsing & multicore. Anakim Border Anakim Border [17]talked about parallel parsing, specifically about a parser he had put together, which led to a discussion of Edward Kmett's recent talks at BAHUG. Ph.D position, Utrecht University, the Netherlands. S.Doaitse [18]announced Vacancy PhD student on Realizing Optimal Sharing in the Functional Language Implementations Utrecht University, The Netherlands. Blog noise [19]Haskell news from the [20]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Eric Kow (kowey): [21]Cabal-Installing graphical apps on MacOS X. * Don Stewart (dons): [22]Improving Data Structures with Associated Types. * Manuel M T Chakravarty: [23]Haskell Arrays, Accelerated.. * Galois, Inc: [24]Tech Talk: Building Systems That Enforce Measurable Security Goals. * Kevin Reid (kpreid): [25]GSoC conclusion.. * Neil Brown: [26]Boids Simulation: Part 1. * Paul Potts: [27]MacPorts, Snow Leopard, and GHC == Sadness. * Andrew Calleja: [28]Haskell IDEs on Windows. * Sean Leather: [29]"Upwards and downwards accumulations on trees" translated into Haskell. * Xmonad: [30]The Design and Implementation of XMonad. * Galois, Inc: [31]Tech Talk: Constructing a Universal Domain for Reasoning About Haskell Datatypes. * Well-Typed.Com: [32]Slides from the IHG talk at CUFP. * Alex McLean: [33]Hackpact Documentation. This links to part one of a two part series. * Bas van Gijze: [34]Cannibals, Missionaries and the State Monad pt. 1. * Magnus Therning: [35]Wrapping IO. This links to part one of a two part series. * Don Stewart (dons): [36]Stream Fusion for Haskell Arrays. * Tom Schrijvers: [37]EffectiveAdvice: AOP, mixin inheritance, monads, parametricity, non-interference, .... * Johan Jeuring: [38]Finding palindromes. * Neil Brown: [39]Concurrent vs Parallel vs Sequential. * Don Stewart (dons): [40]DEFUN 2009: Multicore Programming in Haskell Now!. * Don Stewart (dons): [41]The Haskell Platform: Status Report: Haskell Symposium 2009. Quotes of the Week * lispy: All haskell lists have less than 400 elements * Jafet: The C preprocessor is purely dysfunctional * edwardk: so the -> is matched on the outside, but the -> and , fail to match on the inside, unification fails, dogs and cats start living together in harmony, general chaos. * yaxu: [about lambdabot] an irc bot that no-one understands the workings of has to be a fine precursor to artificial intelligence * Gracenotes: all in all, you're just another brick in the -Wall About the Haskell Weekly News New editions are posted to [42]the Haskell mailing list as well as to [43]the Haskell Sequence and [44]Planet Haskell. [45]RSS is also available, and headlines appear on [46]haskell.org. To help create new editions of this newsletter, please see the information on [47]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [48]http://code.haskell.org/~byorgey/code/hwn/ . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63133 3. http://article.gmane.org/gmane.comp.lang.haskell.general/17476 4. http://article.gmane.org/gmane.comp.lang.haskell.general/17483 5. http://article.gmane.org/gmane.comp.lang.haskell.general/17482 6. http://article.gmane.org/gmane.comp.lang.haskell.general/17481 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63283 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63233 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63219 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63205 11. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63187 12. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63157 13. http://www.jeuring.net/Palindromes/ 14. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63146 15. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63143 16. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63314 17. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63223 18. http://article.gmane.org/gmane.comp.lang.haskell.general/17478 19. http://planet.haskell.org/ 20. http://haskell.org/haskellwiki/Blog_articles 21. http://koweycode.blogspot.com/2009/09/cabal-installing-graphical-apps-on.html 22. http://donsbot.wordpress.com/2009/09/11/improving-data-structures-with-associated-types/ 23. http://justtesting.org/post/185173082 24. http://www.galois.com/blog/2009/09/10/jaegermeasurablesecurit/ 25. http://kpreid.livejournal.com/16930.html 26. http://chplib.wordpress.com/2009/09/08/boids-simulation-part-1/ 27. http://praisecurseandrecurse.blogspot.com/2009/09/macports-snow-leopard-and-ghc-sadness.html 28. http://lambdacolyte.wordpress.com/2009/09/08/haskell-ides-on-windows/ 29. http://feedproxy.google.com/~r/splonderzoek/~3/4E8TZPDZ-aM/ upwards-and-downwards-accumulations-on.html 30. http://xmonad.wordpress.com/2009/09/09/the-design-and-implementation-of-xmonad/ 31. http://www.galois.com/blog/2009/09/08/huffman_universaldomain/ 32. http://blog.well-typed.com/2009/09/slides-from-the-ihg-talk-at-cufp/ 33. http://yaxu.org/hackpact-documentation/ 34. http://adoseoflogic.blogspot.com/2009/07/cannibals-missionaries-and-state-monad.html 35. http://therning.org/magnus/archives/738 36. http://donsbot.wordpress.com/2009/09/07/stream-fusion-for-haskell-arrays/ 37. http://tomschrijvers.blogspot.com/2009/09/effectiveadvice-aop-mixin-inheritance.html 38. http://johanjeuring.blogspot.com/2007/08/finding-palindromes.html 39. http://chplib.wordpress.com/2009/09/06/concurrent-vs-parallel-vs-sequential/ 40. http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/ 41. http://donsbot.wordpress.com/2009/09/05/the-haskell-platform-status-report-haskell-symposium-2009/ 42. http://www.haskell.org/mailman/listinfo/haskell 43. http://sequence.complete.org/ 44. http://planet.haskell.org/ 45. http://sequence.complete.org/node/feed 46. http://haskell.org/ 47. http://haskell.org/haskellwiki/HWN 48. http://code.haskell.org/~byorgey/code/hwn/ From dsouza at bitforest.org Sat Sep 12 15:08:58 2009 From: dsouza at bitforest.org (Diego Souza) Date: Sat Sep 12 14:51:42 2009 Subject: [Haskell-cafe] why these two are not equivalent? Message-ID: <20090912190858.GA12655@mephisto.bitforest.org> Hi, I was trying to solve a simple problem in SPOJ, however, after two weeks trying almost everything I could think of, I was still getting WrongAnswer. Then I decided to do the same thing in C++ and I really got puzzled when I got ACcepted. I tried to understand what was different without success. I hope someone can tell me why spoj says the Haskell version is wrong: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3583 [Haskell,WA] http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3582 [C++,AC] The problem I'm talking about is this one: https://www.spoj.pl/problems/SBANK/ Thanks, -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From thomas.dubuisson at gmail.com Sat Sep 12 15:20:51 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sat Sep 12 14:59:41 2009 Subject: HECC License (was: [Haskell-cafe] Haskell Weekly News: Issue 130 - September 12, 2009) Message-ID: <4c44d90b0909121220i6310d2d8x949f8f21c6df4e88@mail.gmail.com> > ? hecc-0.1. Marcel Fourn?? [5]announced the first release of hecc, the > ? Elliptic Curve Cryptography Library for Haskell. Implemented are > ? affine, projective, jacobian and modified jacobian point formats with > ? the basic operations. Included as an Example is a basic ECDH as well as > ? a basic speed test. This is great news - I hope it finds its way into the crypto library. One question - is this license a derivative of something I would have heard about? IANAL, but have just read the license it sounds fairly permissive in that it doesn't mandate distribution of source code (BSDish). Was this the intent? Did I miss something? Thomas From dagit at codersbase.com Sat Sep 12 15:46:08 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat Sep 12 15:24:59 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: <20090912190858.GA12655@mephisto.bitforest.org> References: <20090912190858.GA12655@mephisto.bitforest.org> Message-ID: On Sat, Sep 12, 2009 at 12:08 PM, Diego Souza wrote: > Hi, > > I was trying to solve a simple problem in SPOJ, however, after two weeks > trying almost everything I could think of, I was still getting > WrongAnswer. > > Then I decided to do the same thing in C++ and I really got puzzled when > I got ACcepted. > > I tried to understand what was different without success. I hope someone > can tell me why spoj says the Haskell version is wrong: > > http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3583 [Haskell,WA] > http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3582 [C++,AC] > > The problem I'm talking about is this one: > https://www.spoj.pl/problems/SBANK/ Looks like the output should be sorted. The C++ version does this with the iterator over map implicitly. I don't spot where your haskell version sorts the output. There could be other problems, that's just what I can notice in 2 minutes of looking. Good luck! Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/b588111f/attachment.html From dagit at codersbase.com Sat Sep 12 15:55:15 2009 From: dagit at codersbase.com (Jason Dagit) Date: Sat Sep 12 15:34:05 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: References: <20090912190858.GA12655@mephisto.bitforest.org> Message-ID: On Sat, Sep 12, 2009 at 12:46 PM, Jason Dagit wrote: > > > On Sat, Sep 12, 2009 at 12:08 PM, Diego Souza wrote: > >> Hi, >> >> I was trying to solve a simple problem in SPOJ, however, after two weeks >> trying almost everything I could think of, I was still getting >> WrongAnswer. >> >> Then I decided to do the same thing in C++ and I really got puzzled when >> I got ACcepted. >> >> I tried to understand what was different without success. I hope someone >> can tell me why spoj says the Haskell version is wrong: >> >> http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3583 [Haskell,WA] >> http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3582 [C++,AC] >> >> The problem I'm talking about is this one: >> https://www.spoj.pl/problems/SBANK/ > > > Looks like the output should be sorted. The C++ version does this with the > iterator over map implicitly. I don't spot where your haskell > version sorts the output. > I take that back. I see how it sorts it now. Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/7eea819e/attachment-0001.html From dsouza at bitforest.org Sat Sep 12 15:52:03 2009 From: dsouza at bitforest.org (Diego Souza) Date: Sat Sep 12 15:34:46 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: References: <20090912190858.GA12655@mephisto.bitforest.org> Message-ID: <20090912195203.GB12655@mephisto.bitforest.org> > Looks like the output should be sorted. The C++ version does this with the > iterator over map implicitly. I don't spot where your haskell > version sorts the output. > > There could be other problems, that's just what I can notice in 2 minutes of > looking. > > Good luck! Jason, I assumed Data.Map was a tree internally and keep elements ordered, so the following would sort the input and print duplicates in O(n log n), as the C++ version does: sbank :: [B.ByteString] -> [(B.ByteString,Int)] sbank = toAscList . fromListWith (+) . flip zip (repeat 1) Is it wrong to assume this? It worked for all tests cases I could think of though. Thanks, -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From lemming at henning-thielemann.de Sat Sep 12 16:26:54 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Sat Sep 12 16:01:46 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> Message-ID: <4AAC040E.3050503@henning-thielemann.de> Evan Laforge schrieb: > On Fri, Sep 11, 2009 at 6:10 AM, Edward Kmett wrote: >> Unfortunately, the instance of Monad for Either a is somewhat misguided in >> Haskell. >> >> There is a spurious restraint that the Left value in your Either be a member >> of some Error class, which was brought about by the deletion of MonadZero >> from Haskell 98 (as part of the elimination of failure free patterns, and an >> attempted simplification of the language). > > I just tried it, and my own instance for Monad (Either String) (all > I'm really interested in anyway) can coexist with the one for Error e > => Monad (Either e). But indeed, with the presence of fail, you can't > write the general Monad (Either e) which "should" work. And it does > require FlexibleInstances. I suppose as long as flexible instances > aren't standard then even the String instance can't go in the Prelude. Are you sure, that the instance cannot be defined in Haskell 98 using a helper type class for the Char datatype? http://www.haskell.org/haskellwiki/List_instance From allbery at ece.cmu.edu Sat Sep 12 17:40:51 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Sep 12 17:19:56 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: <30hbv85gs1.fsf@gmail.com> References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> Message-ID: <5AAAE6CB-EB12-4993-9E59-6A102F3933D5@ece.cmu.edu> On Sep 12, 2009, at 11:22 , Trent W. Buck wrote: > Jason Dagit writes: >>> which ensures that when the operating system is not WIN32, that >>> renaming of files will be performed by the OS shell. > > I'm also puzzled as to why this works -- surely mv(1) assumes POSIX > semantics, too? I would be interested in seeing the exact error > transcript, preferably as an issue on bugs.d.n. I'm not sure the > problem has been diagnosed correctly. In order to handle the case where you're moving across filesystems, mv(1) gracefully degrades to cp + rm. rename(2) does not. This also happens to work around compatibility issues with native CIFS (and possibly older HP/UX, not that anyone likely cares). >> Yes, and in the meantime we can implement something like this in >> workaround.hs. > > I definitely think this SHOULD NOT be enabled by default, unless > you're > going to ONLY enable it in the specific scenario of CIFS on Linux. I definitely think you've made incorrect assumptions; the proposed workaround is reasonable even if not ideal. (I would fall back to the mv(1) method only if rename(2) fails.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/5b3c061d/PGP.bin From ganesh at earth.li Sat Sep 12 18:24:52 2009 From: ganesh at earth.li (Ganesh Sittampalam) Date: Sat Sep 12 18:03:46 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: <5AAAE6CB-EB12-4993-9E59-6A102F3933D5@ece.cmu.edu> References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> <5AAAE6CB-EB12-4993-9E59-6A102F3933D5@ece.cmu.edu> Message-ID: On Sat, 12 Sep 2009, Brandon S. Allbery KF8NH wrote: > On Sep 12, 2009, at 11:22 , Trent W. Buck wrote: >> Jason Dagit writes: >>>> which ensures that when the operating system is not WIN32, that >>>> renaming of files will be performed by the OS shell. >> >> I'm also puzzled as to why this works -- surely mv(1) assumes POSIX >> semantics, too? I would be interested in seeing the exact error >> transcript, preferably as an issue on bugs.d.n. I'm not sure the >> problem has been diagnosed correctly. > > In order to handle the case where you're moving across filesystems, mv(1) > gracefully degrades to cp + rm. rename(2) does not. This also happens to > work around compatibility issues with native CIFS (and possibly older HP/UX, > not that anyone likely cares). I don't think that darcs is ever likely to want to do a move across filesystems - unless someone has actually put a mount point in the middle of their darcs repo (and perhaps not even then for the metadata operations such as the one that was failing here, as I think those are all inside a single directory). Darcs already has a WIN32-specific workaround for renaming going wrong when the new file exists, and my initial guess was that was what was going wrong here. The workaround just tries to remove the new file and retries the rename. The original poster doesn't make clear whether he tried my suggested fix enabling that workaround unconditionally before resorting to shelling out. Cheers, Ganesh From allbery at ece.cmu.edu Sat Sep 12 19:18:21 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Sep 12 18:57:13 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> <5AAAE6CB-EB12-4993-9E59-6A102F3933D5@ece.cmu.edu> Message-ID: <836E44BD-86AD-4396-AB0E-368DCA0EA8EF@ece.cmu.edu> On Sep 12, 2009, at 18:24 , Ganesh Sittampalam wrote: > On Sat, 12 Sep 2009, Brandon S. Allbery KF8NH wrote: >> In order to handle the case where you're moving across filesystems, >> mv(1) gracefully degrades to cp + rm. rename(2) does not. This >> also happens to work around compatibility issues with native CIFS >> (and possibly older HP/UX, not that anyone likely cares). > > I don't think that darcs is ever likely to want to do a move across > filesystems - unless I'm not claiming it does, only explaining why mv(1) is *not* identical to rename(2) as claimed. It also happens to be true that it will do something instead of failing if the destination exists and is a directory (but possibly not what you want). -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/4dcdb452/PGP.bin From ekmett at gmail.com Sat Sep 12 19:34:36 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sat Sep 12 19:13:25 2009 Subject: [Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either? In-Reply-To: <4AAC040E.3050503@henning-thielemann.de> References: <2518b95d0909101803g2b91394epce8855dee694351d@mail.gmail.com> <7fb8f82f0909110610n6aeca8b8u14ae2d4caffb7920@mail.gmail.com> <2518b95d0909110855l7d7fd1f3o5b91b17dcc30c6ed@mail.gmail.com> <4AAC040E.3050503@henning-thielemann.de> Message-ID: <7fb8f82f0909121634q27a6bc28r7d868781fefe00bc@mail.gmail.com> You could, but then you need overlapping instances to define the one in Control.Monad.Error. -Edward Kmett On Sat, Sep 12, 2009 at 4:26 PM, Henning Thielemann < lemming@henning-thielemann.de> wrote: > Evan Laforge schrieb: > > On Fri, Sep 11, 2009 at 6:10 AM, Edward Kmett wrote: > >> Unfortunately, the instance of Monad for Either a is somewhat misguided > in > >> Haskell. > >> > >> There is a spurious restraint that the Left value in your Either be a > member > >> of some Error class, which was brought about by the deletion of > MonadZero > >> from Haskell 98 (as part of the elimination of failure free patterns, > and an > >> attempted simplification of the language). > > > > I just tried it, and my own instance for Monad (Either String) (all > > I'm really interested in anyway) can coexist with the one for Error e > > => Monad (Either e). But indeed, with the presence of fail, you can't > > write the general Monad (Either e) which "should" work. And it does > > require FlexibleInstances. I suppose as long as flexible instances > > aren't standard then even the String instance can't go in the Prelude. > > Are you sure, that the instance cannot be defined in Haskell 98 using a > helper type class for the Char datatype? > http://www.haskell.org/haskellwiki/List_instance > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/7a1ac6ad/attachment.html From seanmcl at gmail.com Sat Sep 12 20:17:02 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Sat Sep 12 19:55:51 2009 Subject: [Haskell-cafe] flexible contexts problem Message-ID: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> I'm having trouble understanding the following behavior. The following program compiles: {-# OPTIONS_GHC -XMultiParamTypeClasses -XFlexibleContexts #-} import Control.Monad.State class Has ? s where has :: s -> (?, s) project :: (MonadState s m, Has ? s) => m ? project = do (?, s) <- gets has put s return ? f :: (MonadState s m, Has Int s) => m Int f = do x <- project return x However, if you replace the function f with f :: (MonadState s m, Has Int s) => m Int f = do x <- project y <- project return x then it fails with the error Could not deduce (Has ? s) from the context (MonadState s m, Has Int s) arising from a use of `project' at /Users/sean/uploads/Weird.hs:16:12-18 Possible fix: add (Has ? s) to the context of the type signature for `f' In a stmt of a 'do' expression: y <- project In the expression: do x <- project y <- project return x In the definition of `f': f = do x <- project y <- project return x I don't see how the second call to project could possibly make a difference. Could someone please tell me what I'm doing wrong? Thanks in advance. Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/7c66fea8/attachment.html From lrpalmer at gmail.com Sat Sep 12 20:29:55 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Sat Sep 12 20:08:43 2009 Subject: [Haskell-cafe] flexible contexts problem In-Reply-To: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> References: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> Message-ID: <7ca3f0160909121729s46d1062bhdf89fdd38180f641@mail.gmail.com> 2009/9/12 Sean McLaughlin : > I'm having trouble understanding the following behavior. ?The following > program compiles: > {-# OPTIONS_GHC -XMultiParamTypeClasses -XFlexibleContexts ?#-} > import Control.Monad.State > class Has ? s where > ??has :: s -> (?, s) > project :: (MonadState s m, Has ? s) => m ? > project = do (?, s) <- gets has > ?? ? ? ? ? ? put s > ?? ? ? ? ? ? return ? > f :: (MonadState s m, Has Int s) => m Int > f = do x <- project > ?? ? ? ? ?return x > However, if you replace the function f with > f :: (MonadState s m, Has Int s) => m Int > f = do x <- project > ?? ? ? ? ?y <- project > ?? ? ? ? ?return x > then it fails with the error > ?? ?Could not deduce (Has ? s) > ?? ? ?from the context (MonadState s m, Has Int s) > ?? ? ?arising from a use of `project' > ?? ? ? ? ? ? ? ? ? at /Users/sean/uploads/Weird.hs:16:12-18 > ?? ?Possible fix: > ?? ? ?add (Has ? s) to the context of the type signature for `f' > ?? ?In a stmt of a 'do' expression: y <- project > ?? ?In the expression: > ?? ? ? ?do x <- project > ?? ? ? ? ? y <- project > ?? ? ? ? ? return x > ?? ?In the definition of `f': > ?? ? ? ?f = do x <- project > ?? ? ? ? ? ? ? y <- project > ?? ? ? ? ? ? ? return x > > I don't see how the second call to project could possibly make a difference. > ?Could > someone please tell me what I'm doing wrong? Look at the type signature of project: project :: (MonadState s m, Has ? s) => m ? The only way it can know what Has instance to use is by knowing ?. And the only way to know ? is to know the return type. You never use y in your new f, which is the only thing that could have told the compiler what type ? was for the second project call (it's not necessarily the same as in the first). Possible solutions: * Use fundeps to constrain Has so there is only one choice of ? for each choice of s. Do this only if this constraint correctly models the meaning of Has (which is... what?) * Give the compiler some way of knowing what type y is, eg. f :: (MonadState s m, Has Int s) => m Int f = do x <- project y :: Int <- project return x Returning it or taking something of its type as a parameter (constraining with asTypeOf) is just as good, then a constraint can be added to the context. Luke From allbery at ece.cmu.edu Sat Sep 12 20:34:45 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Sep 12 20:13:46 2009 Subject: [Haskell-cafe] flexible contexts problem In-Reply-To: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> References: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/277301d3/PGP.bin From seanmcl at gmail.com Sat Sep 12 20:42:28 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Sat Sep 12 20:21:17 2009 Subject: [Haskell-cafe] flexible contexts problem In-Reply-To: References: <6579f8680909121717i6b569430gfd7aab4a35d3c731@mail.gmail.com> Message-ID: <6579f8680909121742i4c0d48efv4677903fb6b92028@mail.gmail.com> Ah, I see. Thanks very much. For some reason I figured the second type would be resolved to Int, but now I see that is totally wrong. Best, Sean On Sat, Sep 12, 2009 at 8:34 PM, Brandon S. Allbery KF8NH < allbery@ece.cmu.edu> wrote: > On Sep 12, 2009, at 20:17 , Sean McLaughlin wrote: > > However, if you replace the function f with > > f :: (MonadState s m, Has Int s) => m Int > f = do x <- project > y <- project > return x > > then it fails with the error > > Could not deduce (Has ? s) > from the context (MonadState s m, Has Int s) > arising from a use of `project' > at /Users/sean/uploads/Weird.hs:16:12-18 > Possible fix: > add (Has ? s) to the context of the type signature for `f' > In a stmt of a 'do' expression: y <- project > In the expression: > do x <- project > y <- project > return x > In the definition of `f': > f = do x <- project > y <- project > return x > > > I think what this is really telling you is that there's no way for ghc to > tell what type y has. x is fine because it's in the result (hence fixed by > the type (m Int)), but y is just "there" and all ghc knows is that it has > (Has ? s) and (MonadState s m, Has Int s) but no way to get from one to the > other (more specifically: it has no clue what ? might be). > > Note that project is explicitly polymorphic, so the fact that you used it > to get an (Int) does not in any sense guarantee that the subsequent use > *also* produces an Int. If you want this, you'll have to constrain the call > somehow. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/5d43df6b/attachment.html From bos at serpentine.com Sat Sep 12 21:38:53 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Sat Sep 12 21:17:43 2009 Subject: [Haskell-cafe] [ANNOUNCE] A statistics library Message-ID: I'm pleased to announce a new Haskell statistics library, imaginatively named statistics : http://hackage.haskell.org/package/statistics - Support for common discrete and continuous probability distributions (binomial, gamma, exponential, geometric, hypergeometric, normal, and Poisson) - Kernel density estimation - Autocorrelation analysis - Functions over sample data - Quantile estimation - Resampling techniques: jackknife and bootstrap estimation The statistics library certainly isn't yet comprehensive, but it has some features that I think make it very attractive as a base for further work: - It's very fast, building on some of the fantastic software that's available on Hackage these days. I make heavy use of Don Stewart's uvector library (itself a port of Roman Leshchinskiy's vector library), which means that many functions allocate no memory and execute tight loops using only machine registers. I use Dan Doel's uvector-algorithms libraryto perform fast partial sorts. I also use Don's mersenne-random library for fast random number generation when doing bootstrap analysis. - I've put a fair amount of effort into finding and using algorithms that are numerically stable (trying to avoid problems like catastrophic cancellation). Whenever possible, I indicate which methods are used in the documentation. (For more information on numerical stability, see What Every Scientist Should Know About Floating-Point Arithmetic ). If you want to contribute, please get the source code and hack away: darcs get http://darcs.serpentine.com/statistics For more details, see http://bit.ly/ykOeK -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/b79c81e0/attachment.html From fernanbolando at mailc.net Sat Sep 12 23:22:30 2009 From: fernanbolando at mailc.net (Fernan Bolando) Date: Sat Sep 12 23:01:19 2009 Subject: [Haskell-cafe] yhc compiled hbc Message-ID: <1d5d51400909122022n20671456j68841c43b4b275f4@mail.gmail.com> Hi all Are there any yhc users here? Can anybody send me a precompiled yhc cross-platform hbc file? regards fernan -- http://www.fernski.com From lambda-belka at yandex.ru Sun Sep 13 02:45:35 2009 From: lambda-belka at yandex.ru (Belka) Date: Sun Sep 13 02:24:23 2009 Subject: [Haskell-cafe] Using tiny (atomic) mutables between multiple threads Message-ID: <25420972.post@talk.nabble.com> Hello, Haskell Cafe! I used an MVar to signalize to many threads, when it's time to finish their business (I called it a LoopBreaker). Recently I realized, that it might be too expensive (to use MVar) for cases when threads are many and all of them read my LoopBreaker intensively. This assumption appeared in a case, where I widely (in many threads) used my stopableThreadDelay, which checks LoopBreaker every d = 100 milliseconds. So I decided that I don't really need all the great features, that MVar provides, and that a simpler memory usage concept might be applied here. In a most (machinely) reduced view, all I need is a mutable byte. It would be thread safe, since reading and writing are atomic operations. I then wrote a simple experimental module (my first experience with Ptr in Haskell): ----------------- import Control.Monad import Foreign.Marshal.Utils import Foreign.Ptr import Foreign.Storable newtype MyVar a = MyVar { mvPtr :: Ptr a } newMyVar :: Storable a => a -> IO (MyVar a) newMyVar val = MyVar `liftM` new val readMyVar :: Storable a => (MyVar a) -> IO a readMyVar val = peek $ mvPtr val writeMyVar :: Storable a => (MyVar a) -> a -> IO () writeMyVar var val = poke (mvPtr var) val ----------------- Now, please, help me to answer few questions about all it: 1. Might readMVar really be computationally expensive under heavy load, (with all it's wonderful blocking features)? How much (approximately) more expensive, comparing to a assembler's "mov"? 2. Are the above readMyVar and writeMyVar really atomic? Or are they atomic only if I apply them to type? 3. Are the above readMyVar and writeMyVar safe against asynchronous exceptions? Or again, only if I use type? Belka -- View this message in context: http://www.nabble.com/Using-tiny-%28atomic%29-mutables-between-multiple-threads-tp25420972p25420972.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From bulat.ziganshin at gmail.com Sun Sep 13 02:58:54 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Sep 13 02:37:50 2009 Subject: [Haskell-cafe] Using tiny (atomic) mutables between multiple threads In-Reply-To: <25420972.post@talk.nabble.com> References: <25420972.post@talk.nabble.com> Message-ID: <1891029369.20090913105854@gmail.com> Hello Belka, Sunday, September 13, 2009, 10:45:35 AM, you wrote: i suggest you to use IORef Bool instead - as it was said once by SimonM, it's safe to use in m/t environment, of course without all fancy features of MVar locking if you need to be as fast as possible, IOUArray (1,1) may be used - this avoids boxing (array of one element is equivalent to IOURef type lacking in std libs) > Hello, Haskell Cafe! > I used an MVar to signalize to many threads, when it's time to finish their > business (I called it a LoopBreaker). Recently I realized, that it might be > too expensive (to use MVar) for cases when threads are many and all of them > read my LoopBreaker intensively. This assumption appeared in a case, where I > widely (in many threads) used my stopableThreadDelay, which checks > LoopBreaker every d = 100 milliseconds. > So I decided that I don't really need all the great features, that MVar > provides, and that a simpler memory usage concept might be applied here. In > a most (machinely) reduced view, all I need is a mutable byte. It would be > thread safe, since reading and writing are atomic operations. I then wrote a > simple experimental module (my first experience with Ptr in Haskell): > ----------------- > import Control.Monad > import Foreign.Marshal.Utils > import Foreign.Ptr > import Foreign.Storable > newtype MyVar a = MyVar { mvPtr :: Ptr a } > newMyVar :: Storable a => a -> IO (MyVar a) > newMyVar val = MyVar `liftM` new val > readMyVar :: Storable a => (MyVar a) -> IO a > readMyVar val = peek $ mvPtr val > writeMyVar :: Storable a => (MyVar a) -> a -> IO () > writeMyVar var val = poke (mvPtr var) val > ----------------- > Now, please, help me to answer few questions about all it: > 1. Might readMVar really be computationally expensive under heavy load, > (with all it's wonderful blocking features)? How much (approximately) more > expensive, comparing to a assembler's "mov"? > 2. Are the above readMyVar and writeMyVar really atomic? Or are they atomic > only if I apply them to type? > 3. Are the above readMyVar and writeMyVar safe against asynchronous > exceptions? Or again, only if I use type? > Belka -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From bulat.ziganshin at gmail.com Sun Sep 13 03:04:23 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Sun Sep 13 02:43:18 2009 Subject: [Haskell-cafe] Using tiny (atomic) mutables between multiple threads In-Reply-To: <25420972.post@talk.nabble.com> References: <25420972.post@talk.nabble.com> Message-ID: <32984638.20090913110423@gmail.com> Hello Belka, Sunday, September 13, 2009, 10:45:35 AM, you wrote: > I used an MVar to signalize to many threads, when it's time to finish their > business (I called it a LoopBreaker). btw, may be you can change the architecture? in particular, where these threads getting their jobs? if they read them from channels (or you may change your code and split it to job producer and job executor communicating via channel), then you may just push EOF job to each queue when party is over -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From marcel at bitrot.dyndns.org Sun Sep 13 04:26:08 2009 From: marcel at bitrot.dyndns.org (Marcel =?UTF-8?B?Rm91cm7DqQ==?=) Date: Sun Sep 13 04:05:01 2009 Subject: HECC License (was: [Haskell-cafe] Haskell Weekly News: Issue 130 - September 12, 2009) In-Reply-To: <4c44d90b0909121220i6310d2d8x949f8f21c6df4e88@mail.gmail.com> References: <4c44d90b0909121220i6310d2d8x949f8f21c6df4e88@mail.gmail.com> Message-ID: <20090913102608.06d14b50@rechner.Biotop> Thomas DuBuisson wrote: >> ? hecc-0.1. Marcel Fourn? [5]announced the first release of hecc, >> the Elliptic Curve Cryptography Library for Haskell. Implemented are >> ? affine, projective, jacobian and modified jacobian point formats >> with the basic operations. Included as an Example is a basic ECDH as >> well as a basic speed test. > >This is great news Thanks for your interest! >- I hope it finds its way into the crypto library. Erm, I didn't plan that atm, but might be a nice idea. Will have to look up their API and brush my code up "a bit". My interface is just written to keep up with the "strange" bitlength of ECC-curves, like NIST-P521 (that is no typo, it is _not_ 512bit), NIST-P244, NIST-P571 etc., so I see it as not directly fitting to use size-of-2-length Datatypes. That might give some speedup at the cost of wasting space, but I haven't tried it. >One question - is this license a derivative of something I would have >heard about? IANAL, but have just read the license it sounds fairly >permissive in that it doesn't mandate distribution of source code >(BSDish). Was this the intent? Did I miss something? Yeah, it's the MIT X11 License and by the virtue of that it grants for all practical purposes the same rights as the BSD3, but there is no way to mix it up with the BSD4, which is the reason I chose it. -- Marcel Fourn? OpenPGP-Key-ID: 0x74545C72 From max.rabkin at gmail.com Sun Sep 13 05:34:16 2009 From: max.rabkin at gmail.com (Max Rabkin) Date: Sun Sep 13 05:13:25 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: <20090912195203.GB12655@mephisto.bitforest.org> References: <20090912190858.GA12655@mephisto.bitforest.org> <20090912195203.GB12655@mephisto.bitforest.org> Message-ID: On Sat, Sep 12, 2009 at 9:52 PM, Diego Souza wrote: > I assumed Data.Map was a tree internally and keep elements ordered, so > the following would sort the input and print duplicates in O(n log n), > as the C++ version does: > > sbank :: [B.ByteString] -> [(B.ByteString,Int)] > sbank = toAscList . fromListWith (+) . flip zip (repeat 1) > > Is it wrong to assume this? It worked for all tests cases I could think > of though. That is part of the contract of toAscList (the "Asc" stands for "ascending order"), but because of the way Map is implemented, the result of toList is also sorted. --Max From mail at joachim-breitner.de Sun Sep 13 06:12:33 2009 From: mail at joachim-breitner.de (Joachim Breitner) Date: Sun Sep 13 05:51:19 2009 Subject: [Haskell-cafe] ANNOUNCE: arbtt-0.1 Message-ID: <1252836753.4142.59.camel@localhost> Hi, I just uploaded the Automatic Rule-Based Time Tracking tool on hackage. It is written in Haskell (duh :-)) and might be interesting for some of you to either use or hack on (or both). I have put an introduction on https://www.joachim-breitner.de/blog/archives/336-The-Automatic-Rule-Based-Time-Tracker.html As always, comments are very welcome. Enjoy, Joachim PS: If you don?t like to use the DSL I created for the rule, but rather want to use Haskell, it might also be possible to do the xmonad approach (maybe using dyre). If so, I?m curious to hear about it :-) -- Joachim "nomeata" Breitner mail: mail@joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C JID: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/ Debian Developer: nomeata@debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: Dies ist ein digital signierter Nachrichtenteil Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090913/ffcfa3f7/attachment.bin From duncan.coutts at worc.ox.ac.uk Sun Sep 13 07:53:25 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sun Sep 13 11:27:54 2009 Subject: [Haskell-cafe] Re: Darcs and NFS Resolution In-Reply-To: References: <20090910183404.CA4223247BC@www.haskell.org> <30hbv85gs1.fsf@gmail.com> <5AAAE6CB-EB12-4993-9E59-6A102F3933D5@ece.cmu.edu> Message-ID: <1252842805.5266.11031.camel@localhost> On Sat, 2009-09-12 at 23:24 +0100, Ganesh Sittampalam wrote: > Darcs already has a WIN32-specific workaround for renaming going wrong > when the new file exists, and my initial guess was that was what was going > wrong here. BTW, this is not necessary afaik. Rename over an existing file works just fine on Windows. Cabal uses it in its implementation of writeFileAtomic and that certainly works for writing existing files, indeed that is its raison d'?tre. The only time it goes wrong is if another process has the target file open, and in that case removing the target will fail too. Duncan From ndmitchell at gmail.com Sun Sep 13 13:17:54 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Sun Sep 13 12:56:41 2009 Subject: [Haskell-cafe] Community.haskell.org is down Message-ID: <404396ef0909131017j50ce5f67s4a3b01d6489bc439@mail.gmail.com> Hi, http://community.haskell.org/ seems to be down for me. In general, who should this be reported to? Thanks Neil From dsouza at bitforest.org Sun Sep 13 13:15:12 2009 From: dsouza at bitforest.org (Diego Souza) Date: Sun Sep 13 12:57:52 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: References: <20090912190858.GA12655@mephisto.bitforest.org> <20090912195203.GB12655@mephisto.bitforest.org> Message-ID: <20090913171512.GA7862@mephisto.bitforest.org> On Sun, Sep 13, 2009 at 11:34:16AM +0200, Max Rabkin wrote: > That is part of the contract of toAscList (the "Asc" stands for > "ascending order"), but because of the way Map is implemented, the > result of toList is also sorted. Cool. It is good to know that toAscList and toList would produce the same output. However, I think the question remains open. Is this piece of haskell code any different (in terms of the output it produces) from the C++ version? Thanks, -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From jfredett at gmail.com Sun Sep 13 13:31:12 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun Sep 13 13:10:34 2009 Subject: [Haskell-cafe] Community.haskell.org is down In-Reply-To: <404396ef0909131017j50ce5f67s4a3b01d6489bc439@mail.gmail.com> References: <404396ef0909131017j50ce5f67s4a3b01d6489bc439@mail.gmail.com> Message-ID: <237DD943-B014-4A02-912D-0C93FD6ED430@gmail.com> Confirmed for me, I actually have no idea who owns C.H.O, but a WHOIS gives the Yale University Comp. Sci. Dept. Haskell Group as the registrant, maybe someone over there needs to take a look? /Joe On Sep 13, 2009, at 1:17 PM, Neil Mitchell wrote: > Hi, > > http://community.haskell.org/ seems to be down for me. In general, who > should this be reported to? > > Thanks > > Neil > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mf-hcafe-15c311f0c at etc-network.de Sun Sep 13 13:54:26 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sun Sep 13 13:33:21 2009 Subject: [Haskell-cafe] trouble compiling Crypto-4.2.0 / trouble with cabal Message-ID: <20090913175426.GB4717@yoyo> Hi, Cabal is still fighting me all the time. Its latest move is to be oblivious of some of the installed packages: $ cabal unpack crypto Unpacking Crypto-4.2.0... $ cd Crypto-4.2.0/ $ runghc ./Setup.hs configure --prefix=/tmp2/ Configuring Crypto-4.2.0... Setup.hs: At least the following dependencies are missing: HUnit -any, QuickCheck -any $ ghc-pkg list | grep -i -e '\(cabal\|hunit\)' Cabal-1.6.0.3, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, HTTP-4000.0.8, HUnit-1.2.2.0, ObjectName-1.0.0.0, OpenGL-2.3.0.0, My ghc version is 6.10.4.20090719. (Perhaps I should go get myself a more stable version?) How does Cabal find its packages other than by ghc-pkg? I read the documentation, and did a quick search, but came up empty-handed. thanks, matthias From thomas.dubuisson at gmail.com Sun Sep 13 14:26:50 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun Sep 13 14:05:41 2009 Subject: [Haskell-cafe] trouble compiling Crypto-4.2.0 / trouble with cabal In-Reply-To: <20090913175426.GB4717@yoyo> References: <20090913175426.GB4717@yoyo> Message-ID: <4c44d90b0909131126h4a12bc3fj16843f4361e0662e@mail.gmail.com> Cabal, the library you are using when manuallying running Setup.hs, assumes you are doing a global installation and will ignore locally installed libraries (iirc). If you do 'cabal install crypto', cabal-install defaults to user installs and will use the user libraries. Thomas On Sun, Sep 13, 2009 at 10:54 AM, wrote: > > > Hi, > > Cabal is still fighting me all the time. ?Its latest move is to be > oblivious of some of the installed packages: > > $ cabal unpack crypto > Unpacking Crypto-4.2.0... > $ cd Crypto-4.2.0/ > $ runghc ./Setup.hs configure --prefix=/tmp2/ > Configuring Crypto-4.2.0... > Setup.hs: At least the following dependencies are missing: > HUnit -any, QuickCheck -any > $ ghc-pkg list | grep -i -e '\(cabal\|hunit\)' > ? ?Cabal-1.6.0.3, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, > ? ?HTTP-4000.0.8, HUnit-1.2.2.0, ObjectName-1.0.0.0, OpenGL-2.3.0.0, > > My ghc version is 6.10.4.20090719. ?(Perhaps I should go get myself a > more stable version?) > > How does Cabal find its packages other than by ghc-pkg? ?I read the > documentation, and did a quick search, but came up empty-handed. > > thanks, > matthias > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mf-hcafe-15c311f0c at etc-network.de Sun Sep 13 16:01:59 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sun Sep 13 15:43:41 2009 Subject: [Haskell-cafe] [Solved] Re: trouble compiling Crypto-4.2.0 / trouble with cabal In-Reply-To: <4c44d90b0909131126h4a12bc3fj16843f4361e0662e@mail.gmail.com> References: <20090913175426.GB4717@yoyo> <4c44d90b0909131126h4a12bc3fj16843f4361e0662e@mail.gmail.com> Message-ID: <20090913200159.GD4717@yoyo> works, thanks! (: actually, what i did in the end is this (installing everything for my user locally): runghc ./Setup.hs configure --user --prefix=/tmp2/ runghc ./Setup.hs build ... (I first did the 'cabal install crypto', but for ghc-6.10.4 that didn't work. will start debugging now.) matthias On Sun, Sep 13, 2009 at 11:26:50AM -0700, Thomas DuBuisson wrote: > To: mf-hcafe-15c311f0c@etc-network.de > Cc: haskell-cafe@haskell.org > From: Thomas DuBuisson > Date: Sun, 13 Sep 2009 11:26:50 -0700 > Subject: Re: [Haskell-cafe] trouble compiling Crypto-4.2.0 / trouble with > cabal > > Cabal, the library you are using when manuallying running Setup.hs, > assumes you are doing a global installation and will ignore locally > installed libraries (iirc). If you do 'cabal install crypto', > cabal-install defaults to user installs and will use the user > libraries. > > Thomas > > On Sun, Sep 13, 2009 at 10:54 AM, wrote: > > > > > > Hi, > > > > Cabal is still fighting me all the time. ?Its latest move is to be > > oblivious of some of the installed packages: > > > > $ cabal unpack crypto > > Unpacking Crypto-4.2.0... > > $ cd Crypto-4.2.0/ > > $ runghc ./Setup.hs configure --prefix=/tmp2/ > > Configuring Crypto-4.2.0... > > Setup.hs: At least the following dependencies are missing: > > HUnit -any, QuickCheck -any > > $ ghc-pkg list | grep -i -e '\(cabal\|hunit\)' > > ? ?Cabal-1.6.0.3, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, > > ? ?HTTP-4000.0.8, HUnit-1.2.2.0, ObjectName-1.0.0.0, OpenGL-2.3.0.0, > > > > My ghc version is 6.10.4.20090719. ?(Perhaps I should go get myself a > > more stable version?) > > > > How does Cabal find its packages other than by ghc-pkg? ?I read the > > documentation, and did a quick search, but came up empty-handed. > > > > thanks, > > matthias > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** > CLASSIFY succeeds; success probability: 1.0000 pR: 9.9721 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 9.9721 > Total features in input file: 3072 > #0 (nonspam.css): features: 758386, hits: 2510804, prob: 1.00e+00, pR: 9.97 > #1 (spam.css): features: 1686754, hits: 2531046, prob: 1.07e-10, pR: -9.97 > From fmartini at gmail.com Sun Sep 13 18:39:17 2009 From: fmartini at gmail.com (Felix Martini) Date: Sun Sep 13 18:18:03 2009 Subject: [Haskell-cafe] Re: Using tiny (atomic) mutables between multiple threads In-Reply-To: <1891029369.20090913105854@gmail.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> Message-ID: <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Bulat Ziganshin wrote: > i suggest you to use IORef Bool instead - as it was said once by > SimonM, it's safe to use in m/t environment, of course without all > fancy features of MVar locking Is it also safe for other types such as Int? And is this documented somewhere? If not it would be helpful to add this to the Haskell Wiki. From ddssff at gmail.com Sun Sep 13 18:54:58 2009 From: ddssff at gmail.com (David Fox) Date: Sun Sep 13 18:33:46 2009 Subject: [Haskell-cafe] Community.haskell.org is down In-Reply-To: <237DD943-B014-4A02-912D-0C93FD6ED430@gmail.com> References: <404396ef0909131017j50ce5f67s4a3b01d6489bc439@mail.gmail.com> <237DD943-B014-4A02-912D-0C93FD6ED430@gmail.com> Message-ID: I assume this is the same as code.haskell.org, which is also down? On Sun, Sep 13, 2009 at 10:31 AM, Joe Fredette wrote: > Confirmed for me, I actually have no idea who owns C.H.O, but a WHOIS gives > the Yale University Comp. Sci. Dept. Haskell Group as the registrant, maybe > someone over there needs to take a look? > > /Joe > > > On Sep 13, 2009, at 1:17 PM, Neil Mitchell wrote: > > Hi, >> >> http://community.haskell.org/ seems to be down for me. In general, who >> should this be reported to? >> >> Thanks >> >> Neil >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090913/aaaa1b4e/attachment.html From caseyh at istar.ca Sun Sep 13 19:28:29 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Sep 13 19:07:18 2009 Subject: [Haskell-cafe] Do I have this right? "Remembering" Memoization! In-Reply-To: <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: Do I have this right? "Remembering" Memoization! For some applications, a lot of state does not to be saved, since "initialization" functions can be called early, and these functions will "remember" - (memoize) their results when called again, because of lazy evaluation? -- Regards, Casey From caseyh at istar.ca Sun Sep 13 19:31:16 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Sep 13 19:10:05 2009 Subject: [Haskell-cafe] Haskell#? F#? In-Reply-To: <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: The other morning, someone was telling me they had converted most of their VB financial/stock market code to F#. Whereas VB only used one core, the F# code used all four cores. In one software developers meeting, someone was saying that since database work is mostly all state, he didn't see the advantage of a functional programming language. It seems that, if you are doing at least moderately heavy computations, F# buys you a lot of speed on multiple cores. ------------------------------------------ It now occurs to me that he was using an older version of VB, before .NET or for earlier versions of .NET. So maybe the use of multiple cores is now supported by .NET more so than the progamming languages on top of it. -- Regards, Casey From caseyh at istar.ca Sun Sep 13 19:32:21 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Sep 13 19:11:09 2009 Subject: [Haskell-cafe] Haskell#? F#? In-Reply-To: <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: The other morning, someone was telling me they had converted most of their VB financial/stock market code to F#. Whereas VB only used one core, the F# code used all four cores. In one software developers meeting, someone was saying that since database work is mostly all state, he didn't see the advantage of a functional programming language. It seems that, if you are doing at least moderately heavy computations, F# buys you a lot of speed on multiple cores. ------------------------------------------ It now occurs to me that he was using an older version of VB, before .NET or for earlier versions of .NET. So maybe the use of multiple cores is now supported by .NET more so than the progamming languages on top of it. -- Regards, Casey From mwotton at gmail.com Sun Sep 13 19:45:28 2009 From: mwotton at gmail.com (Mark Wotton) Date: Sun Sep 13 19:24:22 2009 Subject: [Haskell-cafe] Do I have this right? "Remembering" Memoization! In-Reply-To: References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: On 14/09/2009, at 9:28 AM, Casey Hawthorne wrote: > Do I have this right? "Remembering" Memoization! > > For some applications, a lot of state does not to be saved, since > "initialization" functions can be called early, and these functions > will "remember" - (memoize) their results when called again, because > of lazy evaluation? You don't get memoisation for free. If you define a variable once in a where block, it's true that you'll evaluate it at most once, but if you repeatedly call a function "foo" that then calls "bar 12" each time, "bar 12" will be evaluated once per "foo" call. Cheers Mark From mgg at giagnocavo.net Sun Sep 13 20:26:54 2009 From: mgg at giagnocavo.net (Michael Giagnocavo) Date: Sun Sep 13 20:05:49 2009 Subject: [Haskell-cafe] Haskell#? F#? In-Reply-To: References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: <6E8D2069C08AA84A83D336E996AE4C6702DCBE45BC@mse17be1.mse17.exchange.ms> >In one software developers meeting, someone was saying that since >database work is mostly all state, he didn't see the advantage of a >functional programming language. Sigh. I'm still waiting for someone to point out how exactly functional languages do a lesser job here. If this was in relation to F#, it makes even less sense, as F# allows you to use the same libraries you would from other .NET languages. The only real argument I've seen is that functional languages don't have all the same pretty designers that, say, VB, has. >So maybe the use of multiple cores is now supported by .NET more so >than the progamming languages on top of it. F# does make it a bit easier as having immutability by default can be helpful. More importantly, VB doesn't support anonymous methods -- only lambda expressions. That can hinder writing clear async or parallel code. Limited type inference can also be annoying at times, especially with heavily generic code. F# doesn't have these problems. .NET 4 will have a nicer multithreading library (http://en.wikipedia.org/wiki/Parallel_Extensions), but F# has some async/parallel support already built-in. I imagine this will let a lot more people to write parallel code without too much pain, even in VB/C#. However, for a lot of async code, F#'s support for monads ("workflows") makes such code many orders of magnitude easier. I don't see any libraries solving this for less capable languages. -Michael -----Original Message----- From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Casey Hawthorne Sent: Sunday, September 13, 2009 5:32 PM To: haskell-cafe@haskell.org Subject: [Haskell-cafe] Haskell#? F#? The other morning, someone was telling me they had converted most of their VB financial/stock market code to F#. Whereas VB only used one core, the F# code used all four cores. In one software developers meeting, someone was saying that since database work is mostly all state, he didn't see the advantage of a functional programming language. It seems that, if you are doing at least moderately heavy computations, F# buys you a lot of speed on multiple cores. ------------------------------------------ It now occurs to me that he was using an older version of VB, before .NET or for earlier versions of .NET. So maybe the use of multiple cores is now supported by .NET more so than the progamming languages on top of it. -- Regards, Casey _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From thomas.dubuisson at gmail.com Sun Sep 13 22:41:14 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Sun Sep 13 22:20:00 2009 Subject: HECC License (was: [Haskell-cafe] Haskell Weekly News: Issue 130 - September 12, 2009) In-Reply-To: <20090913102608.06d14b50@rechner.Biotop> References: <4c44d90b0909121220i6310d2d8x949f8f21c6df4e88@mail.gmail.com> <20090913102608.06d14b50@rechner.Biotop> Message-ID: <4c44d90b0909131941v369f45cahc445f0110c768c9a@mail.gmail.com> >>- I hope it finds its way into the crypto library. > Will have to > look up their API and brush my code up "a bit". Fair enough, but the Crypto library is past due for a major overhaul. I just stirred a pot about networking and still need to get around to seriously addressing that so I won't be stirring the Crypto pot any time soon. So what I'm suggesting right now is: don't worry too much about the Crypto API, worry more about having a good API and hope a Crypto overhaul happens. Thomas From almeidaraf at gmail.com Sun Sep 13 22:42:02 2009 From: almeidaraf at gmail.com (Rafael Cunha de Almeida) Date: Sun Sep 13 22:23:49 2009 Subject: [Haskell-cafe] Plotting parametric functions in Haskell Message-ID: Hello, I think it would be interesting to plot and visualize parametric (and other kind of functions) using the haskell language to define them [functions]. Does anyone know about some software or API that does just that? I started writing a plotter to do that using hopengl. But my computer graphics skills are rather bad and I couldn't produce anything really useful. []'s Rafael From lambda-belka at yandex.ru Mon Sep 14 00:05:26 2009 From: lambda-belka at yandex.ru (Belka) Date: Sun Sep 13 23:44:12 2009 Subject: [Haskell-cafe] Using tiny (atomic) mutables between multiple threads In-Reply-To: <32984638.20090913110423@gmail.com> References: <25420972.post@talk.nabble.com> <32984638.20090913110423@gmail.com> Message-ID: <25430039.post@talk.nabble.com> Thank you, Bulat, for both your suggestions! 1. Since Haskell uses 1 byte for Bool (I confidently guess) and it's safe, it would also be safe to use . Moreover, I found http://hackage.haskell.org/packages/archive/ArrayRef/0.1.3.1/doc/html/Data-Ref-Unboxed.html#v%3AmodifyIOURef your module and http://www.haskell.org/haskellwiki/Library/ArrayRef the corresponding article in HaskellWiki , so I plan to use . I wonder, however, what's the difference between and (or )? 2. As for architecture, I'm not sure that understood the whole suggestion, but got inspired for new ideas for sure! :) My thread's iterations mostly are to acquire resource from load-balancers' chans, and then to react on outer world state changes - networking and DB. I put all the blocking operations to be stoppable by LoopBreaker. There's no real need in job production/execution separation (in most cases) for now (I guess my architecture is not yet mature enough to consist of generalized workers and small business-concept-specific initiative sources; my threads still are very specific to what they are meant to), but I am in need of good resources production/utilization separation. Now in a better architecture I could exchange [stopableThreadDelays between iterations of threads] on [timely sending the LoopBreaker through Chans alone or together with resources (like network handle or the load balancer's permission)]... This way I would definitely minimize some repeating patterns in code, minimize load on LoopBreaker itself, centralize my timing and configuration application management and simplify some resource management processes (like acquiring network handle, when it's required). Added in a ToDo list for next version!.. =) Thanks again! Belka -- View this message in context: http://www.nabble.com/Using-tiny-%28atomic%29-mutables-between-multiple-threads-tp25420972p25430039.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From iavor.diatchki at gmail.com Mon Sep 14 00:54:37 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Mon Sep 14 00:33:23 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: <20090913171512.GA7862@mephisto.bitforest.org> References: <20090912190858.GA12655@mephisto.bitforest.org> <20090912195203.GB12655@mephisto.bitforest.org> <20090913171512.GA7862@mephisto.bitforest.org> Message-ID: <5ab17e790909132154m11a6ae18w2a1aaf1d22bded84@mail.gmail.com> Hi, It seems that the problem is the site is using GHC 6.6.1, and something was broken at the time (I have not looked into what that is). Here are the outputs that I get for the little example on the site that you posted: GHC 6.10.3 and C++: On Sun, Sep 13, 2009 at 10:15 AM, Diego Souza wrote: > On Sun, Sep 13, 2009 at 11:34:16AM +0200, Max Rabkin wrote: >> That is part of the contract of toAscList (the "Asc" stands for >> "ascending order"), but because of the way Map is implemented, the >> result of toList is also sorted. > > Cool. It is good to know that toAscList and toList would produce the > same output. > > However, I think the question remains open. Is this piece of haskell > code any different (in terms of the output it produces) from the C++ > version? > > Thanks, > -- > ~dsouza > yahoo!im: paravinicius > gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B ?9ECE F88E 067F E891 651E > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From iavor.diatchki at gmail.com Mon Sep 14 00:57:50 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Mon Sep 14 00:36:37 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: <5ab17e790909132154m11a6ae18w2a1aaf1d22bded84@mail.gmail.com> References: <20090912190858.GA12655@mephisto.bitforest.org> <20090912195203.GB12655@mephisto.bitforest.org> <20090913171512.GA7862@mephisto.bitforest.org> <5ab17e790909132154m11a6ae18w2a1aaf1d22bded84@mail.gmail.com> Message-ID: <5ab17e790909132157j3fa1eefdg805d2260c24bba7a@mail.gmail.com> (argh, sorry about that, I pressed something and gmail sent my unfinished email!) On Sun, Sep 13, 2009 at 9:54 PM, Iavor Diatchki wrote: > Hi, > It seems that the problem is the site is using GHC 6.6.1, and > something was broken at the time (I have not looked into what that > is). > Here are the outputs that I get for the little example on the site > that you posted: > > GHC 6.10.3 and C++: 03 10103538 2222 1233 6160 0141 1 03 10103538 2222 1233 6160 0142 1 30 10103538 2222 1233 6160 0141 2 30 10103538 2222 1233 6160 0142 2 30 10103538 2222 1233 6160 0142 1 30 10103538 2222 1233 6160 0143 1 30 10103538 2222 1233 6160 0144 1 30 10103538 2222 1233 6160 0145 1 30 10103538 2222 1233 6160 0146 1 With GHC 6.6.1: 03 10103538 2222 1233 6160 0141 1 03 10103538 2222 1233 6160 0142 1 30 10103538 2222 1233 6160 0141 2 30 10103538 2222 1233 6160 0142 2 30 10103538 2222 1233 6160 0142 1 30 10103538 2222 1233 6160 0143 1 30 10103538 2222 1233 6160 0145 1 30 10103538 2222 1233 6160 0146 1 Note that in the second test case one line is missing, the one ending in 44. -Iavor > > > > > > On Sun, Sep 13, 2009 at 10:15 AM, Diego Souza wrote: >> On Sun, Sep 13, 2009 at 11:34:16AM +0200, Max Rabkin wrote: >>> That is part of the contract of toAscList (the "Asc" stands for >>> "ascending order"), but because of the way Map is implemented, the >>> result of toList is also sorted. >> >> Cool. It is good to know that toAscList and toList would produce the >> same output. >> >> However, I think the question remains open. Is this piece of haskell >> code any different (in terms of the output it produces) from the C++ >> version? >> >> Thanks, >> -- >> ~dsouza >> yahoo!im: paravinicius >> gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B ?9ECE F88E 067F E891 651E >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From bulat.ziganshin at gmail.com Mon Sep 14 01:24:23 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Sep 14 01:11:31 2009 Subject: [Haskell-cafe] Re: Using tiny (atomic) mutables between multiple threads In-Reply-To: <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: <17210484298.20090914092423@gmail.com> Hello Felix, Monday, September 14, 2009, 2:39:17 AM, you wrote: >> i suggest you to use IORef Bool instead - as it was said once by >> SimonM, it's safe to use in m/t environment, of course without all >> fancy features of MVar locking > Is it also safe for other types such as Int? And is this documented > somewhere? If not it would be helpful to add this to the Haskell Wiki. afair, it is safe in one-writer-many-readers setup. probably it isn't documented, otherwise Simon hasn't been asked :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ninegua at gmail.com Mon Sep 14 01:36:00 2009 From: ninegua at gmail.com (Paul L) Date: Mon Sep 14 01:14:45 2009 Subject: [Haskell-cafe] ANNOUNCE: LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation Message-ID: <856033f20909132236vf1abb5j66e46776150ad426@mail.gmail.com> It's available on Hackage DB at http://hackage.haskell.org/package/LambdaINet Thanks to Kim-Ee Yeoh for pushing me into releasing this piece of code I wrote two years ago. I'll just quote the README from the source tarball below. LambdaINet ========== LambdaINet implements an interaction net based optimal evaluator following Lambdascope [1], with an interactive graphical interface allowing user to view and directly manipulate interaction net. [1] Vincent van Oostrom, Kees-Jan van de Looij, Marijn Zwitserlood, Lambdascope, Workshop on Algebra and Logic on Programming Systems (ALPS), Kyoto, April 10th 2004 USAGE ===== After "cabal install", just type "LambdaINet" to start the application. Once it starts, press H for help, and ESC to quit. To understand all the operations in detail, you'll have to read the above mentioned paper by Oostrom et. al. Currently there is no way to load input programs except modifying the source, Try src/Main.lhs if you want to change the start-up program, or any of the 1..9 preset programs. At this moment, the object language supports lambda expression with recursion, tuples, and primitives such as numbers, strings and functions. SIDE NOTE ========= The bulk of code was put together in two weeks when I was working on the leak problem for FRP in 2007. So it was really a rushed job with no guarantee of correctness, although I tried to stay faithful to the original paper as much as I could. I only did some moderate clean-ups before releasing this application to public, and the code itself was sparingly documented when it was originally written. Some parts are probably still buggy, like the translation from net to term; other parts could use more improvements, like the node positioning and line layout algorithm. But I decide to release it anyway -- maybe some people some where will find it useful. DEVELOPMENT =========== Please forward bug reports or feedbacks to me (Paul Liu at paul at thev dot net), but don't hold your hope high on timely bug fixes. Help is also needed to develop LambdaINet further, for example, it really needs a way to read lambda expressions from a separate file or standard input, which should be a simple feature to add, but alas! I don't have the time in the nearest future to do this kind of things myself. -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From bulat.ziganshin at gmail.com Mon Sep 14 01:37:04 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Sep 14 01:17:26 2009 Subject: [Haskell-cafe] Using tiny (atomic) mutables between multiple threads In-Reply-To: <25430039.post@talk.nabble.com> References: <25420972.post@talk.nabble.com> <32984638.20090913110423@gmail.com> <25430039.post@talk.nabble.com> Message-ID: <366162163.20090914093704@gmail.com> Hello Belka, Monday, September 14, 2009, 8:05:26 AM, you wrote: > http://www.haskell.org/haskellwiki/Library/ArrayRef the > corresponding article in HaskellWiki , so I plan to use . I if it's compatible with your ghc version :D i don't support this library but other people may keep it up-to-dtae > wonder, however, what's the difference between and > (or )? read http://haskell.org/haskellwiki/Modern_array_libraries , especially "welcome to machine" part. it doesn't describe everything but at least a good starting point > 2. As for architecture, I'm not sure that understood the whole suggestion, > but got inspired for new ideas for sure! :) > My thread's iterations mostly are to acquire resource from load-balancers' > chans, and then to react on outer world state changes - networking and DB. I > put all the blocking operations to be stoppable by LoopBreaker. There's no > real need in job production/execution separation (in most cases) for now it's just a way to stop executor threads when you are done. cheap threads make it possible to use threading as one more control structure. you can capture this pattern in function and stop worrying about program speed/complexity -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From alexey.skladnoy at gmail.com Mon Sep 14 04:41:29 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Sep 14 04:14:17 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <87ocpgp6ez.fsf@columbia.edu> References: <200909121418.35909.alexey.skladnoy@gmail.com> <87ocpgp6ez.fsf@columbia.edu> Message-ID: <200909141241.29734.alexey.skladnoy@gmail.com> ? ????????? ?? ??????? 12 ???????? 2009 18:46:28 ????? Xiao-Yong Jin ???????: > I believe most of the linux distributions do not have > `lapack.pc', if you install certain implementation of lapack > like the one provided by netlib.org, or the one with > `ATLAS', or the one provided by intel mkl. So, using such > pkgconfig file is rather useless. A configure system like > the one used in `hmatrix' should be used to actually adapt > various kinds of systems. > It fails to build on Fedora too. I think bindings-levmar package is unbuildable on most linux distributions. If pkgconfig-depends lines is removed from cabal file it builds fine. From alexey.skladnoy at gmail.com Mon Sep 14 04:50:11 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Sep 14 04:22:57 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <200909141241.29734.alexey.skladnoy@gmail.com> References: <87ocpgp6ez.fsf@columbia.edu> <200909141241.29734.alexey.skladnoy@gmail.com> Message-ID: <200909141250.11286.alexey.skladnoy@gmail.com> ? ????????? ?? ??????????? 14 ???????? 2009 12:41:29 ?? ????????: > If pkgconfig-depends lines is removed from cabal file it builds fine. > But any program which uses levmar fails to link From vandijk.roel at gmail.com Mon Sep 14 04:59:24 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Sep 14 04:38:10 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <200909141250.11286.alexey.skladnoy@gmail.com> References: <87ocpgp6ez.fsf@columbia.edu> <200909141241.29734.alexey.skladnoy@gmail.com> <200909141250.11286.alexey.skladnoy@gmail.com> Message-ID: On Mon, Sep 14, 2009 at 10:50 AM, Khudyakov Alexey wrote: > ? ????????? ?? ??????????? 14 ???????? 2009 12:41:29 ?? ????????: >> If pkgconfig-depends lines is removed from cabal file it builds fine. >> > But any program which uses levmar fails to link Would adding extra-libraries: lapack to the cabal file instead of pkgconfig-depends: lapack be a better solution? From alexey.skladnoy at gmail.com Mon Sep 14 05:12:46 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Sep 14 04:45:31 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: <200909141250.11286.alexey.skladnoy@gmail.com> Message-ID: <200909141312.46160.alexey.skladnoy@gmail.com> ? ????????? ?? ??????????? 14 ???????? 2009 12:59:24 ????? Roel van Dijk ???????: > Would adding > extra-libraries: lapack > to the cabal file instead of > pkgconfig-depends: lapack > be a better solution? Yes. It works this way. Tested in debian and old fedora From malcolm.wallace at cs.york.ac.uk Mon Sep 14 05:08:36 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Mon Sep 14 04:47:22 2009 Subject: [Haskell-cafe] Community.haskell.org is down In-Reply-To: References: <404396ef0909131017j50ce5f67s4a3b01d6489bc439@mail.gmail.com> <237DD943-B014-4A02-912D-0C93FD6ED430@gmail.com> Message-ID: > I assume this is the same as code.haskell.org, which is also down? Yes, code.h.o and community.h.o run on the same virtual machine. > a WHOIS gives the Yale University Comp. Sci. Dept. Haskell Group as > the registrant, maybe someone over there needs to take a look? Yale looks after the DNS records for the entire haskell.org domain, but currently actively hosts only the www server. For general information, current machines and hosts are: www.h.o hosted by Yale, paid for by GSoC darcs.h.o hosted by Galois, donated by Galois hackage.h.o hosted by Galois, donated by Galois code.h.o virtual hosting, paid for by GSoC community.h.o virtual hosting, paid for by GSoC sparky.h.o hosted by Chalmers, donated by Sun > http://community.haskell.org/ seems to be down for me. In general, who > should this be reported to? Reporting it to this list is as good a place as any. Regards, Malcolm From vandijk.roel at gmail.com Mon Sep 14 05:28:33 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Mon Sep 14 05:07:19 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <200909141312.46160.alexey.skladnoy@gmail.com> References: <200909141250.11286.alexey.skladnoy@gmail.com> <200909141312.46160.alexey.skladnoy@gmail.com> Message-ID: 2009/9/14 Khudyakov Alexey : > ? ????????? ?? ??????????? 14 ???????? 2009 12:59:24 ????? Roel van Dijk > ???????: >> Would adding >> ? extra-libraries: lapack >> to the cabal file instead of >> ? pkgconfig-depends: lapack >> be a better solution? > > Yes. It works this way. Tested in debian and old fedora Thank you for testing. I have just released bindings-levmar-0.1.0.1 on hackage. It simply replaces pkgconfig-depends with extra-libraries. I hope this solves the installation problems. http://hackage.haskell.org/package/bindings-levmar-0.1.0.1 From bugfact at gmail.com Mon Sep 14 05:37:34 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Sep 14 05:16:20 2009 Subject: [Haskell-cafe] Plotting parametric functions in Haskell In-Reply-To: References: Message-ID: I did that once a long time ago using GTK2HS; but I don't have that code anymore I think, it was a quick hack anyway. Doing a search for plot on Hackage revealed http://hackage.haskell.org/package/Chart http://hackage.haskell.org/package/gnuplot Maybe that helps. On Mon, Sep 14, 2009 at 4:42 AM, Rafael Cunha de Almeida wrote: > Hello, > > I think it would be interesting to plot and visualize parametric (and > other kind of functions) using the haskell language to define them > [functions]. Does anyone know about some software or API that does just > that? I started writing a plotter to do that using hopengl. But my > computer graphics skills are rather bad and I couldn't produce anything > really useful. > > []'s > Rafael > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From alexey.skladnoy at gmail.com Mon Sep 14 06:08:51 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Sep 14 05:45:33 2009 Subject: [Haskell-cafe] ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: <200909141312.46160.alexey.skladnoy@gmail.com> Message-ID: <200909141408.52081.alexey.skladnoy@gmail.com> ? ????????? ?? 14 ???????? 2009 13:28:33 ????? Roel van Dijk ???????: > Thank you for testing. I have just released bindings-levmar-0.1.0.1 on > hackage. It simply replaces pkgconfig-depends with extra-libraries. I > hope this solves the installation problems. > Yes. Now it installs fine. From lemming at henning-thielemann.de Mon Sep 14 09:11:27 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Sep 14 08:50:13 2009 Subject: [Haskell-cafe] Plotting parametric functions in Haskell In-Reply-To: References: Message-ID: On Sun, 13 Sep 2009, Rafael Cunha de Almeida wrote: > Hello, > > I think it would be interesting to plot and visualize parametric (and > other kind of functions) using the haskell language to define them > [functions]. Does anyone know about some software or API that does just > that? I started writing a plotter to do that using hopengl. But my > computer graphics skills are rather bad and I couldn't produce anything > really useful. Do you mean something like the gnuplot wrapper? http://hackage.haskell.org/package/gnuplot From v.dijk.bas at gmail.com Mon Sep 14 09:17:35 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Mon Sep 14 08:56:20 2009 Subject: [Haskell-cafe] ANNOUNCE: LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation In-Reply-To: <856033f20909132236vf1abb5j66e46776150ad426@mail.gmail.com> References: <856033f20909132236vf1abb5j66e46776150ad426@mail.gmail.com> Message-ID: On Mon, Sep 14, 2009 at 7:36 AM, Paul L wrote: > It's available on Hackage DB at http://hackage.haskell.org/package/LambdaINet Nice! Screenshots anywhere? Bas From almeidaraf at gmail.com Mon Sep 14 09:56:39 2009 From: almeidaraf at gmail.com (Rafael Almeida) Date: Mon Sep 14 09:35:23 2009 Subject: [Haskell-cafe] Plotting parametric functions in Haskell In-Reply-To: References: Message-ID: <6de6b1650909140656j3118398bwf4a3399a1ff50119@mail.gmail.com> On Mon, Sep 14, 2009 at 6:37 AM, Peter Verswyvelen wrote: > I did that once a long time ago using GTK2HS; but I don't have that > code anymore I think, it was a quick hack anyway. > > Doing a search for plot on Hackage revealed > http://hackage.haskell.org/package/Chart > http://hackage.haskell.org/package/gnuplot > > Maybe that helps. > I probably should have mentioned that I really want to plot a 3D function. I've seen those packages before, but I didn't even tried them out. Chart seems to be only for 2D stuff and the reason why I was looking for haskell solutions is because I don't really like gnuplot for 3D plotting. Maybe I'm the one who doesn't get gnuplot's interface, but I find it awful to navigate through a 3D graph using gnuplot. Thanks for the answer, though. From sargrigory at ya.ru Mon Sep 14 10:05:41 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Mon Sep 14 09:49:34 2009 Subject: [Haskell-cafe] Program with ByteStrings leads to memory exhaust. Message-ID: <199691252937141@webmail131.yandex.ru> I have a simple program that first generates a large (~ 500 mb) file of random numbers and then reads the numbers back to find their sum. It uses Data.Binary and Data.ByteString.Lazy. The problem is when the program tries to read the data back it quickly (really quickly) consumes all memory. The source: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3607#a3607 or: module Main where import Data.Binary import Data.Int import System.Random import qualified Data.ByteString.Lazy as BL encodeFileAp f = BL.appendFile f . encode path = "Results.data" n = 20*1024*1024 :: Int getBlockSize :: BL.ByteString -> Int64 getBlockSize bs = round $ (fromIntegral $ BL.length bs) / (fromIntegral n) fillFile :: StdGen -> Int -> IO () fillFile _ 0 =return () fillFile gen i = do let (x, gen') = random gen :: (Double, StdGen) encodeFileAp path x fillFile gen' (i-1) processFile :: BL.ByteString -> Int64 -> Int -> Double -> Double processFile bs blockSize 0 sum = sum processFile bs blockSize i sum = let tmpTuple = BL.splitAt blockSize bs x = decode $ fst $! tmpTuple in processFile (snd tmpTuple) blockSize (i-1) $! sum + x main = do fillFile (mkStdGen 42) n results <- BL.readFile path putStrLn $ show $ processFile results (getBlockSize results) n 0 From nicolas.pouillard at gmail.com Mon Sep 14 10:19:40 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Mon Sep 14 09:57:32 2009 Subject: [Haskell-cafe] Program with ByteStrings leads to memory exhaust. In-Reply-To: <199691252937141@webmail131.yandex.ru> References: <199691252937141@webmail131.yandex.ru> Message-ID: <1252937925-sup-8775@peray> Excerpts from Grigory Sarnitskiy's message of Mon Sep 14 16:05:41 +0200 2009: > I have a simple program that first generates a large (~ 500 mb) file of random numbers and then reads the numbers back to find their sum. > It uses Data.Binary and Data.ByteString.Lazy. I do think that this is due to splitAt but I didn't made a deep investigation. -- Nicolas Pouillard http://nicolaspouillard.fr From dsouza at bitforest.org Mon Sep 14 10:43:48 2009 From: dsouza at bitforest.org (Diego Souza) Date: Mon Sep 14 10:22:46 2009 Subject: [Haskell-cafe] why these two are not equivalent? In-Reply-To: <5ab17e790909132157j3fa1eefdg805d2260c24bba7a@mail.gmail.com> References: <20090912190858.GA12655@mephisto.bitforest.org> <20090912195203.GB12655@mephisto.bitforest.org> <20090913171512.GA7862@mephisto.bitforest.org> <5ab17e790909132154m11a6ae18w2a1aaf1d22bded84@mail.gmail.com> <5ab17e790909132157j3fa1eefdg805d2260c24bba7a@mail.gmail.com> Message-ID: <20090914144348.GA29968@clockdistance.saopaulo.corp.yahoo.com> On Sun, Sep 13, 2009 at 09:57:50PM -0700, Iavor Diatchki wrote: > (argh, sorry about that, I pressed something and gmail sent my > unfinished email!) > > On Sun, Sep 13, 2009 at 9:54 PM, Iavor Diatchki > wrote: > > Hi, > > It seems that the problem is the site is using GHC 6.6.1, and > > something was broken at the time (I have not looked into what that > > is). > > Here are the outputs that I get for the little example on the site > > that you posted: > > > > GHC 6.10.3 and C++: > > 03 10103538 2222 1233 6160 0141 1 > 03 10103538 2222 1233 6160 0142 1 > 30 10103538 2222 1233 6160 0141 2 > 30 10103538 2222 1233 6160 0142 2 > > 30 10103538 2222 1233 6160 0142 1 > 30 10103538 2222 1233 6160 0143 1 > 30 10103538 2222 1233 6160 0144 1 > 30 10103538 2222 1233 6160 0145 1 > 30 10103538 2222 1233 6160 0146 1 > > With GHC 6.6.1: > 03 10103538 2222 1233 6160 0141 1 > 03 10103538 2222 1233 6160 0142 1 > 30 10103538 2222 1233 6160 0141 2 > 30 10103538 2222 1233 6160 0142 2 > > 30 10103538 2222 1233 6160 0142 1 > 30 10103538 2222 1233 6160 0143 1 > 30 10103538 2222 1233 6160 0145 1 > 30 10103538 2222 1233 6160 0146 1 > > Note that in the second test case one line is missing, the one ending in 44. > > -Iavor Hi Iavor, Sweet, it makes a lot of sense. I haven't tried to run this with ghc-6.6.1, though. Thank you for doing this. Just for curiosity I'll try to find out what exactly fails under 6.6.1, just in case anyone else run into the problem in future (as I don't think they will upgrade the ghc any time soon). I'll eventually ask them to upgrade the ghc version. Any recommendation about which version should I ask for? Thanks, -- ~dsouza yahoo!im: paravinicius gpg key fingerprint: 71B8 CE21 3A6E F894 5B1B 9ECE F88E 067F E891 651E From mauricio.antunes at gmail.com Mon Sep 14 10:53:47 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Mon Sep 14 10:32:57 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: References: <200909141250.11286.alexey.skladnoy@gmail.com> <200909141312.46160.alexey.skladnoy@gmail.com> Message-ID: >> Yes. It works this way. Tested in debian and old fedora > Thank you for testing. I have just released bindings-levmar-0.1.0.1 on > hackage. It simply replaces pkgconfig-depends with extra-libraries. I > hope this solves the installation problems. Debian maintainer was willing to add pkg-config to lapack package: http://lists.alioth.debian.org/pipermail/pkg-scicomp-devel/2009-September/004508.html However, he and also Tollef (pkg-config maintainer) believe it's a better idea to add it to upstream package: http://article.gmane.org/gmane.comp.package-management.pkg-config/346 Unless you think that extra-libraries is a good long term solution, I'll still investigate on how to add pkg-config generation to configuration scripts and try to send a sugestion with a patch to maintainers of libraries wrapped in bindings-*. Although I don't know exactly how that patch should exactly be... Best, Maur?cio From xj2106 at columbia.edu Mon Sep 14 11:23:08 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Sep 14 11:02:04 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: (=?utf-8?B?Ik1hdXLDrcKtY2lv?= CA"'s message of "Mon, 14 Sep 2009 11:53:47 -0300") References: <200909141250.11286.alexey.skladnoy@gmail.com> <200909141312.46160.alexey.skladnoy@gmail.com> Message-ID: <87pr9twnxf.fsf@columbia.edu> Maur??cio CA writes: >>> Yes. It works this way. Tested in debian and old fedora > >> Thank you for testing. I have just released bindings-levmar-0.1.0.1 on >> hackage. It simply replaces pkgconfig-depends with extra-libraries. I >> hope this solves the installation problems. > > Debian maintainer was willing to add pkg-config to lapack package: > > http://lists.alioth.debian.org/pipermail/pkg-scicomp-devel/2009-September/004508.html > > However, he and also Tollef (pkg-config maintainer) believe it's a > better idea to add it to upstream package: > > http://article.gmane.org/gmane.comp.package-management.pkg-config/346 > > Unless you think that extra-libraries is a good long term > solution, I'll still investigate on how to add pkg-config > generation to configuration scripts and try to send a sugestion > with a patch to maintainers of libraries wrapped in bindings-*. > Although I don't know exactly how that patch should exactly be... > It is not practical to use pkg-config for such libraries. After you persuade the reference code[1] of lapack to use pkg-config, are you going to make ATLAS[2] do it also? And what about Intel's mkl[3]? Or even lapack bindings provided by Nvidia's CUDA[4]? [1] http://www.netlib.org/lapack/ [2] http://math-atlas.sourceforge.net/ [3] http://software.intel.com/en-us/intel-mkl/ [4] http://www.nvidia.com/object/cuda_home.html One can install them side by side, but for performance's sake, one really wants to link a particular library/binary to the most useful one. I know it's hard to include every possibilities. But I prefer some configuration switch that I can tune when building the library. That's been said, it is still your package. And people can always change the build scripts for their own needs. Best, Xiao-Yong -- c/* __o/* <\ * (__ */\ < From martijn at van.steenbergen.nl Mon Sep 14 11:25:28 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Sep 14 11:04:21 2009 Subject: [Haskell-cafe] Building a monoid, continuation-passing style Message-ID: <4AAE6068.4050702@van.steenbergen.nl> Hello cafe, Inspired by Sean Leather's xformat package [1] I built a datatype with which you can build a monoid with holes, yielding a function type to fill in these holes, continuation-passing style. Here are some primitives and their types: > now :: m -> ContSt m r r > later :: (a -> m) -> ContSt m r (a -> r) > run :: ContSt m m r -> r > instance Monoid m => Category (ContSt m) Here's an example of how to use it: > run (now "hello" . now "world") "helloworld" > run (later id . now "world") "hello" "helloworld" > run (later id . later show) "hello" 567 "hello567" The source code is available at [2]. I have a couple of questions: * ContSt is a Category. Is it also an Arrow? Why (not)? * Did I miss any other obvious classes this type is an instance of? * What is its relation with the Cont and Reader monads? * Are there any other useful applications other than printf-like functionality? * ContSt is a horrible name. What is a better one? For those who have a bit more time: I appreciate any comments and suggestions on the code. :-) Many thanks in advance, Martijn. [1] http://hackage.haskell.org/package/xformat [2] http://code.google.com/p/monoid-cont/source/browse/trunk/ContSt.hs From dons at galois.com Mon Sep 14 12:00:31 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 14 11:41:28 2009 Subject: Solved: [Was: Re: [Haskell-cafe] Program with ByteStrings leads to memory exhaust] In-Reply-To: <199691252937141@webmail131.yandex.ru> References: <199691252937141@webmail131.yandex.ru> Message-ID: <20090914160031.GA31467@whirlpool.galois.com> sargrigory: > I have a simple program that first generates a large (~ 500 mb) file > of random numbers and then reads the numbers back to find their sum. > It uses Data.Binary and Data.ByteString.Lazy. > > The problem is when the program tries to read the data back it quickly > (really quickly) consumes all memory. > > The source: http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=3607#a3607 I have tweaked this program a few ways for you. The big mistake (and why it runs out of space) is that you take ByteString.Lazy.length to compute the block size. This forces the entire file into memory -- so no benefits of lazy IO. As a separate matter, calling 'appendFile . encode' incrementally for each element will be very slow. Much faster to encode an entire list in one go. Finally, using System.Random.Mersenne is significantly faster at Double generation that System.Random. With these changes (below), your program runs in constant space (both writing out and reading in the 0.5Gb file), and is much faster: {-# LANGUAGE BangPatterns #-} import Data.Binary.Put import Data.Binary import System.IO import Data.Int import qualified Data.ByteString.Lazy as BL import System.Random.Mersenne path = "Results.data" n = 20*1024*1024 :: Int -- getBlockSize :: BL.ByteString -> Int64 -- getBlockSize bs = round $ (fromIntegral $ BL.length bs) / (fromIntegral n) -- -- ^^^^^ why do you take the length!? -- -- there's no point doing lazy IO then. -- Custom serialization (no length prefix) fillFile n = do g <- newMTGen (Just 42) rs <- randoms g :: IO [Double] BL.writeFile path $ runPut $ mapM_ put (take n rs) -- fillFile :: MTGen -> Int -> IO () -- fillFile _ 0 = return () -- fillFile g i = do -- x <- random g :: IO Double -- encodeFileAp path x -- fillFile g (i-1) processFile :: BL.ByteString -> Int64 -> Int -> Double -> Double processFile !bs !blockSize 0 !sum = sum processFile bs blockSize i sum = processFile y blockSize (i-1) (sum + decode x) where (x,y) = BL.splitAt blockSize bs main = do fillFile n -- compute the size without loading the file into memory h <- openFile path ReadMode sz <- hFileSize h hClose h results <- BL.readFile path let blockSize = round $ fromIntegral sz / fromIntegral n print $ processFile results blockSize n 0 ------------------------------------------------------------------------ Running this : $ ./A +RTS -sstderr 1.0483476019172292e7 226,256,100,448 bytes allocated in the heap 220,413,096 bytes copied during GC 65,416 bytes maximum residency (1186 sample(s)) 136,376 bytes maximum slop 2 MB total memory in use (0 MB lost due to fragmentation) ^^^^^^^^^^^^^^^^^ It now runs in constant space. Generation 0: 428701 collections, 0 parallel, 3.17s, 3.49s elapsed Generation 1: 1186 collections, 0 parallel, 0.13s, 0.16s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 118.26s (129.19s elapsed) GC time 3.30s ( 3.64s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 121.57s (132.83s elapsed) %GC time 2.7% (2.7% elapsed) ^^^^^^^^^^^^^^^^ Does very little GC. Alloc rate 1,913,172,101 bytes per MUT second Productivity 97.3% of total user, 89.0% of total elapsed -- Don From mauricio.antunes at gmail.com Mon Sep 14 12:30:10 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Mon Sep 14 12:09:24 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: <87pr9twnxf.fsf@columbia.edu> References: <200909141250.11286.alexey.skladnoy@gmail.com> <200909141312.46160.alexey.skladnoy@gmail.com> <87pr9twnxf.fsf@columbia.edu> Message-ID: >> Unless you think that extra-libraries is a good long term >> solution, I'll still investigate on how to add pkg-config >> generation to configuration scripts and try to send a sugestion >> with a patch to maintainers of libraries wrapped in bindings-*. > It is not practical to use pkg-config for such libraries. After > you persuade the reference code[1] of lapack to use pkg-config, > are you going to make ATLAS[2] do it also? And what about > Intel's mkl[3]? Or even lapack bindings provided by Nvidia's > CUDA[4]? Sure. But only for packages we have direct Haskell bindings to. You only need pkg-config available for the libraries you directly need for a cabal package. For complicated dependencies, just rely on your OS distribution (or Haskell Platform etc.). > I know it's hard to include every possibilities. But I prefer > some configuration switch that I can tune when building the > library. The idea is just to provide a default, working configuration. Anyway, I imagine this tunning should be done in a way that is transparent to a cabal package. > That's been said, it is still your package. And people can > always change the build scripts for their own needs. Not actually! I didn't work on bindings-levmar. I'm just the guy who started the idea of having low level bindings packages as basis for higher level bindings (so that this kind of problem can be solved at the same time for many, say, levmar high level bindings). That's why I would like to help acchieving good general guides for easy building. Wrapping of levmar is entirely van Dijk brothers' work. http://hackage.haskell.org/package/bindings-common Best, Maur?cio From sargrigory at ya.ru Mon Sep 14 12:49:44 2009 From: sargrigory at ya.ru (Grigory Sarnitskiy) Date: Mon Sep 14 12:28:28 2009 Subject: Solved: [Was: Re: [Haskell-cafe] Program with ByteStrings leads to memory exhaust] In-Reply-To: <20090914160031.GA31467@whirlpool.galois.com> References: <199691252937141@webmail131.yandex.ru> <20090914160031.GA31467@whirlpool.galois.com> Message-ID: <506891252946984@webmail89.yandex.ru> > I have tweaked this program a few ways for you. > The big mistake (and why it runs out of space) is that you take > ByteString.Lazy.length to compute the block size. This forces the entire > file into memory -- so no benefits of lazy IO. > As a separate matter, calling 'appendFile . encode' incrementally for > each element will be very slow. Much faster to encode an entire list in > one go. > Finally, using System.Random.Mersenne is significantly faster at Double > generation that System.Random. Thank you! Just excellent! // I'm so happy :-) From jakewheatmail at googlemail.com Mon Sep 14 13:55:24 2009 From: jakewheatmail at googlemail.com (Jake Wheat) Date: Mon Sep 14 13:34:12 2009 Subject: [Haskell-cafe] ANNOUNCE: hssqlppp, sql parser and type checker, pre-alpha Message-ID: <4b5b53360909141055u28f3bf74v19086f420579a0e5@mail.gmail.com> Hello all, I've started on a SQL parser and type checker, which I'm currently planning on evolving into a lint-type program for PL/pgSQL, called HsSqlPpp. It currently parses a subset of PostGreSQL SQL and PL/pgSQL, can type check some select, insert, update, delete and create statements, and is pretty rough all round at the moment. It uses Parsec and UUAGC, comes with a small HUnit test suite, and has a Cabal file. The code is on Launchpad here: https://launchpad.net/hssqlppp You can get a snapshot here: http://launchpad.net/hssqlppp/prealpha/secondtypechecking/+download/hssqlppp-140909-rev276.zip More information in the readme: http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/README and brief the usage guide gives you an idea of what you can do with it right now: http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/usage I'm pretty new to Haskell, parsing, attribute grammars and type checking - any comments, advice, criticism welcome. Thanks, Jake Wheat From dons at galois.com Mon Sep 14 13:59:58 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 14 13:40:56 2009 Subject: [Haskell-cafe] ANNOUNCE: hssqlppp, sql parser and type checker, pre-alpha In-Reply-To: <4b5b53360909141055u28f3bf74v19086f420579a0e5@mail.gmail.com> References: <4b5b53360909141055u28f3bf74v19086f420579a0e5@mail.gmail.com> Message-ID: <20090914175958.GA31712@whirlpool.galois.com> jakewheatmail: > Hello all, > > I've started on a SQL parser and type checker, which I'm currently > planning on evolving into a lint-type program for PL/pgSQL, called > HsSqlPpp. > > It currently parses a subset of PostGreSQL SQL and PL/pgSQL, can type > check some select, insert, update, delete and create statements, and > is pretty rough all round at the moment. > > It uses Parsec and UUAGC, comes with a small HUnit test suite, and has > a Cabal file. > > The code is on Launchpad here: > https://launchpad.net/hssqlppp > > You can get a snapshot here: > http://launchpad.net/hssqlppp/prealpha/secondtypechecking/+download/hssqlppp-140909-rev276.zip > > More information in the readme: > http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/README > and brief the usage guide gives you an idea of what you can do with it > right now: > http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/usage > > I'm pretty new to Haskell, parsing, attribute grammars and type > checking - any comments, advice, criticism welcome. Will you be releasing it on Hackage? Bonus: if you do, it can be cabal-installed :) -- Don From vanenkj at gmail.com Mon Sep 14 14:08:12 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Sep 14 13:46:56 2009 Subject: [Haskell-cafe] ANNOUNCE: hssqlppp, sql parser and type checker, pre-alpha In-Reply-To: <20090914175958.GA31712@whirlpool.galois.com> References: <4b5b53360909141055u28f3bf74v19086f420579a0e5@mail.gmail.com> <20090914175958.GA31712@whirlpool.galois.com> Message-ID: Second the hackage suggestion. `cabal unpack [package name]` is a really nice way to grab sources. On Mon, Sep 14, 2009 at 1:59 PM, Don Stewart wrote: > jakewheatmail: > > Hello all, > > > > I've started on a SQL parser and type checker, which I'm currently > > planning on evolving into a lint-type program for PL/pgSQL, called > > HsSqlPpp. > > > > It currently parses a subset of PostGreSQL SQL and PL/pgSQL, can type > > check some select, insert, update, delete and create statements, and > > is pretty rough all round at the moment. > > > > It uses Parsec and UUAGC, comes with a small HUnit test suite, and has > > a Cabal file. > > > > The code is on Launchpad here: > > https://launchpad.net/hssqlppp > > > > You can get a snapshot here: > > > http://launchpad.net/hssqlppp/prealpha/secondtypechecking/+download/hssqlppp-140909-rev276.zip > > > > More information in the readme: > > > http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/README > > and brief the usage guide gives you an idea of what you can do with it > > right now: > > > http://bazaar.launchpad.net/~jakewheat/hssqlppp/trunk/annotate/head%3A/usage > > > > I'm pretty new to Haskell, parsing, attribute grammars and type > > checking - any comments, advice, criticism welcome. > > Will you be releasing it on Hackage? > > Bonus: if you do, it can be cabal-installed :) > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090914/4e58e757/attachment.html From duncan.coutts at worc.ox.ac.uk Mon Sep 14 14:38:03 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Sep 14 14:35:58 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> Message-ID: <1252953483.19215.215.camel@localhost> On Thu, 2009-09-10 at 15:18 +0200, Regis Saint-Paul wrote: > One way in which cabal can be made UAC aware (and therefore request for > elevation privileges instead of just failing) would be to embed a manifest > in the cabal.exe. This can be done by changing the default manifest (an XML > file) that is embedded at link time by GHC. > However, a problem with this approach is that cabal.exe as a whole would be > seen as needing administrator privilege, regardless of whether the setting > is global or user. If we want to request admin privileges only when actually > needed (i.e., when writing in a protected folder). To address this, there > are several options: > - have two distinct executables for cabal, cabal-global and cabal-user with > different manifest > - use windows API for requesting elevation during the process (ugly) If it really has to be done, then this seems like the best approach. In principle there's no problem with calling funky win32 functions in Cabal, it's mostly a matter of working out what bahaviour we want and what UAC lets us do. > Also, the AppData folder is for application data, not for the application > itself. I'm not sure how far one needs to go in terms of well-behaving for > windows when it comes to multi-platform applications. I'd like to point out > the "Application Compatibility Toolkit" which allows testing if an > application is well behaved for vista and 7 and provides guidelines for that > (it's a free download): > You can use also on XP to test for vista and 7. I tried running it with > cabal install somepackage and it points out a number of privilege errors. Thanks for that. > Note that if cabal was writing packages in AppData instead of "program > files", then the problem would only surface when cabal install moves > executable in the bin directory. > > It seems to me that the cygwin/mingw and, more generally, the GNU way of > dealing with windows is to mainly ignore the directory structure of windows > and install things in a separate directory chosen by the user (possibly in > program files or elsewhere), requesting the user to manually change the path > accordingly. That could be a solution to consider too. Our aim is really to do things the proper way on each platform. We follow FSH/autoconf conventions on Unix and we aim to do the right thing on Windows and OSX. The main issue is that there's not many of us who are familiar with what the "right thing" is on the other platforms. Duncan From mikesteele81 at gmail.com Mon Sep 14 15:05:14 2009 From: mikesteele81 at gmail.com (Michael Steele) Date: Mon Sep 14 14:43:58 2009 Subject: [Haskell-cafe] Can't install chp (confused by cabal yet again) In-Reply-To: References: Message-ID: You got the original error because cabal chose to use base-3 when compiling chp, and then identifiers found only in base-4 were referenced. Download the cabal package, and edit chp.cabal so that it depends on base >= 4. On Sat, Jun 6, 2009 at 7:00 AM, Colin Paul Adams wrote: > I tried a cabal install chp: It complained that base was hidden. > > So I unpacked the archive, and tried installing using runhaskell > Setup configure/build/install. Now I get (from install): > > Setup: You need to re-run the 'configure' command. The version of Cabal > being > used has changed (was Cabal-1.6.0.3, now Cabal-1.6.0.2). > > So I repeated the process and get the same message again. > > ghc version is 6.10.3 > > Also: > cabal --version > cabal-install version 0.6.2 > using version 1.6.0.2 of the Cabal library > > Where does this 1-6.0.3 come from (Ghc HEAD perhaps?)? What can I do > about it? > -- > Colin Adams > Preston Lancashire > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090914/ee9bc149/attachment.html From noteed at gmail.com Mon Sep 14 15:24:53 2009 From: noteed at gmail.com (minh thu) Date: Mon Sep 14 15:03:57 2009 Subject: [Haskell-cafe] Coercion from a Word32/64 to a Float/Double Message-ID: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> Hi, I'd like to know if this should work: -- GHC coercion getFloat :: BHeader -> Get Float getFloat h = case endianness h of LittleEndian -> fmap (coerce . fromIntegral) getWord32le BigEndian -> fmap (coerce . fromIntegral) getWord32be where coerce (I32# x) = F# (unsafeCoerce# x) -- GHC coercion getDouble :: BHeader -> Get Double getDouble h = case endianness h of LittleEndian -> fmap (coerce . fromIntegral) getWord64le BigEndian -> fmap (coerce . fromIntegral) getWord64be where coerce (I64# x) = D# (unsafeCoerce# x) Loading this into ghci compiles fine (but I haven't try to parse data), but compiling with ghc (6.10.1 or 6.10.4) reports: /tmp/ghc1967_0/ghc1967_0.s: Assembler messages: /tmp/ghc1967_0/ghc1967_0.s:287:0: Error: bad register name `%fake0' /tmp/ghc1967_0/ghc1967_0.s:349:0: Error: bad register name `%fake0' Thanks for any help, Thu From xj2106 at columbia.edu Mon Sep 14 15:26:27 2009 From: xj2106 at columbia.edu (Xiao-Yong Jin) Date: Mon Sep 14 15:05:21 2009 Subject: [Haskell-cafe] Re: ANNOUNCE: A Levenberg-Marquardt implementation In-Reply-To: (=?utf-8?B?Ik1hdXLDrcKtY2lv?= CA"'s message of "Mon, 14 Sep 2009 13:30:10 -0300") References: <200909141250.11286.alexey.skladnoy@gmail.com> <200909141312.46160.alexey.skladnoy@gmail.com> <87pr9twnxf.fsf@columbia.edu> Message-ID: <87pr9tqqe4.fsf@columbia.edu> Maur??cio CA writes: >> That's been said, it is still your package. And people can >> always change the build scripts for their own needs. > > Not actually! I didn't work on bindings-levmar. I'm just the guy > who started the idea of having low level bindings packages as > basis for higher level bindings (so that this kind of problem > can be solved at the same time for many, say, levmar high level > bindings). That's why I would like to help acchieving good general > guides for easy building. Wrapping of levmar is entirely van Dijk > brothers' work. Sorry, I didn't mean that. I was just trying to say that it might be wiser to put in a configure script like most of the open source software do. It does not need to be very complicated, because usually people know what they are doing when they want to link against different optimized libraries. The one[1] provided by hmatrix[2] is sufficient and easy to use for most of the purposes. [1] http://perception.inf.um.es/cgi-bin/darcsweb.cgi?r=hmatrix;a=headblob;f=/configure.hs [2] http://www.hmatrix.googlepages.com/ In the case of hmatrix, it is good that you only need to run $ cabal install hmatrix -fmkl to build it against Intel mkl instead of the default BLAS/LAPACK. And you can also add other shared libraries to link against as a command line switch when you run `cabal install'. I just don't see the problem with bindings-levmar. Because compared with bindings-levmar, hmatrix actually needs GSL, BLAS and LAPACK, but it builds fine on hackage and the documents[3] are very well built. [3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hmatrix Just my 2 cents. Xiao-Yong -- c/* __o/* <\ * (__ */\ < From jmillikin at gmail.com Mon Sep 14 16:15:37 2009 From: jmillikin at gmail.com (John Millikin) Date: Mon Sep 14 15:54:21 2009 Subject: [Haskell-cafe] Coercion from a Word32/64 to a Float/Double In-Reply-To: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> References: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> Message-ID: <3283f7fe0909141315o41b80422x171c7c2cdffec8ac@mail.gmail.com> If you don't mind a small performance penalty, have you considered using my library data-binary-ieee754? It contains functions for parsing floats and doubles within the Get monad. On Mon, Sep 14, 2009 at 12:24, minh thu wrote: > Hi, > > I'd like to know if this should work: > > -- GHC coercion > getFloat :: BHeader -> Get Float > getFloat h = > ?case endianness h of > ? ?LittleEndian -> fmap (coerce . fromIntegral) getWord32le > ? ?BigEndian -> fmap (coerce . fromIntegral) getWord32be > ?where coerce (I32# x) = F# (unsafeCoerce# x) > > -- GHC coercion > getDouble :: BHeader -> Get Double > getDouble h = > ?case endianness h of > ? ?LittleEndian -> fmap (coerce . fromIntegral) getWord64le > ? ?BigEndian -> fmap (coerce . fromIntegral) getWord64be > ?where coerce (I64# x) = D# (unsafeCoerce# x) > > Loading this into ghci compiles fine (but I haven't try to parse > data), but compiling with ghc (6.10.1 or 6.10.4) reports: > /tmp/ghc1967_0/ghc1967_0.s: Assembler messages: > > /tmp/ghc1967_0/ghc1967_0.s:287:0: > ? ? Error: bad register name `%fake0' > > /tmp/ghc1967_0/ghc1967_0.s:349:0: > ? ? Error: bad register name `%fake0' > > Thanks for any help, > Thu > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dons at galois.com Mon Sep 14 16:15:10 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 14 15:56:04 2009 Subject: [Haskell-cafe] Haskell#? F#? In-Reply-To: References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: <20090914201510.GE31712@whirlpool.galois.com> caseyh: > The other morning, someone was telling me they had converted most of > their VB financial/stock market code to F#. > Whereas VB only used one core, the F# code used all four cores. > > In one software developers meeting, someone was saying that since > database work is mostly all state, he didn't see the advantage of a > functional programming language. State /= Imperative Programming :-) -- Don From noteed at gmail.com Mon Sep 14 16:31:37 2009 From: noteed at gmail.com (minh thu) Date: Mon Sep 14 16:10:40 2009 Subject: [Haskell-cafe] Coercion from a Word32/64 to a Float/Double In-Reply-To: <3283f7fe0909141315o41b80422x171c7c2cdffec8ac@mail.gmail.com> References: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> <3283f7fe0909141315o41b80422x171c7c2cdffec8ac@mail.gmail.com> Message-ID: <40a414c20909141331p13fbd32fh7de3296cb6677743@mail.gmail.com> Hi, Yes I did but since I saw that 'solution', I wanted to try it. There is something that bothers me with your library: its licence. Reading a float shouldn't force me to go GPL (I makes an utility to read Blender files and like to make it BSD3). Thanks for pointing it though. Cheers, Thu 2009/9/14 John Millikin : > If you don't mind a small performance penalty, have you considered > using my library data-binary-ieee754? It contains functions for > parsing floats and doubles within the Get monad. > > On Mon, Sep 14, 2009 at 12:24, minh thu wrote: >> Hi, >> >> I'd like to know if this should work: >> >> -- GHC coercion >> getFloat :: BHeader -> Get Float >> getFloat h = >> case endianness h of >> LittleEndian -> fmap (coerce . fromIntegral) getWord32le >> BigEndian -> fmap (coerce . fromIntegral) getWord32be >> where coerce (I32# x) = F# (unsafeCoerce# x) >> >> -- GHC coercion >> getDouble :: BHeader -> Get Double >> getDouble h = >> case endianness h of >> LittleEndian -> fmap (coerce . fromIntegral) getWord64le >> BigEndian -> fmap (coerce . fromIntegral) getWord64be >> where coerce (I64# x) = D# (unsafeCoerce# x) >> >> Loading this into ghci compiles fine (but I haven't try to parse >> data), but compiling with ghc (6.10.1 or 6.10.4) reports: >> /tmp/ghc1967_0/ghc1967_0.s: Assembler messages: >> >> /tmp/ghc1967_0/ghc1967_0.s:287:0: >> Error: bad register name `%fake0' >> >> /tmp/ghc1967_0/ghc1967_0.s:349:0: >> Error: bad register name `%fake0' >> >> Thanks for any help, >> Thu >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > From maydwell at gmail.com Mon Sep 14 16:47:55 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Mon Sep 14 16:26:38 2009 Subject: [Haskell-cafe] Native windowing for glut applications on OS X. In-Reply-To: References: <6BD93A0B-7DEF-4C91-948F-34C645C89DD1@ece.cmu.edu> Message-ID: I just upgraded ghc to 6.10.4 and the problem seems to have fixed itself :) On Tue, Sep 8, 2009 at 11:34 AM, Lyndon Maydwell wrote: > I just realized that I only replied to Brandon. Sorry about that :) > > > ---------- Forwarded message ---------- > From: Lyndon Maydwell > Date: Sat, Sep 5, 2009 at 4:22 PM > Subject: Re: [Haskell-cafe] Native windowing for glut applications on OS X. > To: "Brandon S. Allbery KF8NH" > > > I installed opengl via macports. Can I adjust my path somehow so that > it prefers the native libraries? > > On Sat, Sep 5, 2009 at 8:57 AM, Brandon S. Allbery > KF8NH wrote: >> On Sep 4, 2009, at 03:13 , Lyndon Maydwell wrote: >>> >>> I recently updated glut through cabal to version GLUT-2.2.1.0, and >>> where once I had native windowing, now I can only seem to use X11. >>> >>> Does anyone know how to use native windowing? >> >> >> Do you use Fink or MacPorts? ?Check for OpenGL libraries installed via >> those; they're probably shadowing the native libraries. >> >> -- >> brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com >> system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu >> electrical and computer engineering, carnegie mellon university ? ?KF8NH >> >> >> > From judah.jacobson at gmail.com Mon Sep 14 17:00:23 2009 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Mon Sep 14 16:39:27 2009 Subject: [Haskell-cafe] Coercion from a Word32/64 to a Float/Double In-Reply-To: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> References: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> Message-ID: <6d74b0d20909141400y7f15479bg7d0f8051f8d97065@mail.gmail.com> On Mon, Sep 14, 2009 at 12:24 PM, minh thu wrote: > Hi, > > I'd like to know if this should work: > > -- GHC coercion > getFloat :: BHeader -> Get Float > getFloat h = > ?case endianness h of > ? ?LittleEndian -> fmap (coerce . fromIntegral) getWord32le > ? ?BigEndian -> fmap (coerce . fromIntegral) getWord32be > ?where coerce (I32# x) = F# (unsafeCoerce# x) > > -- GHC coercion > getDouble :: BHeader -> Get Double > getDouble h = > ?case endianness h of > ? ?LittleEndian -> fmap (coerce . fromIntegral) getWord64le > ? ?BigEndian -> fmap (coerce . fromIntegral) getWord64be > ?where coerce (I64# x) = D# (unsafeCoerce# x) > > Loading this into ghci compiles fine (but I haven't try to parse > data), but compiling with ghc (6.10.1 or 6.10.4) reports: > /tmp/ghc1967_0/ghc1967_0.s: Assembler messages: > > /tmp/ghc1967_0/ghc1967_0.s:287:0: > ? ? Error: bad register name `%fake0' > > /tmp/ghc1967_0/ghc1967_0.s:349:0: > ? ? Error: bad register name `%fake0' I think that a more reliable (though not very pretty) way to do the casts is via pointer manipulation. Code like the following has worked for me in the past: getDouble :: Get Double getDouble = fmap word2Double getWord64le where word2Double w = unsafePerformIO $ with w $ \p -> do d :: CDouble <- peek (castPr p) return (realToFrac d :: Double) Best, -Judah From noteed at gmail.com Mon Sep 14 17:16:20 2009 From: noteed at gmail.com (minh thu) Date: Mon Sep 14 16:55:23 2009 Subject: [Haskell-cafe] Coercion from a Word32/64 to a Float/Double In-Reply-To: <6d74b0d20909141400y7f15479bg7d0f8051f8d97065@mail.gmail.com> References: <40a414c20909141224u54de4ae1ue5fe0369653d5f0c@mail.gmail.com> <6d74b0d20909141400y7f15479bg7d0f8051f8d97065@mail.gmail.com> Message-ID: <40a414c20909141416h2da6900dxa78c4c9037fd8ff6@mail.gmail.com> 2009/9/14 Judah Jacobson : > On Mon, Sep 14, 2009 at 12:24 PM, minh thu wrote: >> Hi, >> >> I'd like to know if this should work: >> >> -- GHC coercion >> getFloat :: BHeader -> Get Float >> getFloat h = >> case endianness h of >> LittleEndian -> fmap (coerce . fromIntegral) getWord32le >> BigEndian -> fmap (coerce . fromIntegral) getWord32be >> where coerce (I32# x) = F# (unsafeCoerce# x) >> >> -- GHC coercion >> getDouble :: BHeader -> Get Double >> getDouble h = >> case endianness h of >> LittleEndian -> fmap (coerce . fromIntegral) getWord64le >> BigEndian -> fmap (coerce . fromIntegral) getWord64be >> where coerce (I64# x) = D# (unsafeCoerce# x) >> >> Loading this into ghci compiles fine (but I haven't try to parse >> data), but compiling with ghc (6.10.1 or 6.10.4) reports: >> /tmp/ghc1967_0/ghc1967_0.s: Assembler messages: >> >> /tmp/ghc1967_0/ghc1967_0.s:287:0: >> Error: bad register name `%fake0' >> >> /tmp/ghc1967_0/ghc1967_0.s:349:0: >> Error: bad register name `%fake0' > > I think that a more reliable (though not very pretty) way to do the > casts is via pointer manipulation. Code like the following has worked > for me in the past: > > getDouble :: Get Double > getDouble = fmap word2Double getWord64le > where > word2Double w = unsafePerformIO $ with w $ \p -> do > d :: CDouble <- peek (castPr p) > return (realToFrac d :: Double) > > Best, > -Judah > Thank you, it compiles fine. Thu From jakewheatmail at googlemail.com Mon Sep 14 17:23:36 2009 From: jakewheatmail at googlemail.com (Jake Wheat) Date: Mon Sep 14 17:02:21 2009 Subject: [Haskell-cafe] ANNOUNCE: hssqlppp, sql parser and type checker, pre-alpha In-Reply-To: References: <4b5b53360909141055u28f3bf74v19086f420579a0e5@mail.gmail.com> <20090914175958.GA31712@whirlpool.galois.com> Message-ID: <4b5b53360909141423j520e39e0uc36aa8e49a93cac2@mail.gmail.com> I've uploaded the code to Hackage, you can install it with: cabal install hssqlppp or you can get the source using cabal unpack hssqlppp 2009/9/14 John Van Enk : > Second the hackage suggestion. > > `cabal unpack [package name]` is a really nice way to grab sources. > > On Mon, Sep 14, 2009 at 1:59 PM, Don Stewart wrote: >> Will you be releasing it on Hackage? >> >> Bonus: if you do, it can be cabal-installed :) >> >> -- Don From alexey.skladnoy at gmail.com Mon Sep 14 17:02:42 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Mon Sep 14 17:55:09 2009 Subject: [Haskell-cafe] Haskell#? F#? In-Reply-To: <20090914201510.GE31712@whirlpool.galois.com> References: <25420972.post@talk.nabble.com> <20090914201510.GE31712@whirlpool.galois.com> Message-ID: <200909150102.42575.alexey.skladnoy@gmail.com> ? ????????? ?? ??????? 15 ???????? 2009 00:15:10 ????? Don Stewart ???????: > State /= Imperative Programming > Yup, it's anarchy at times... From jeremy at n-heptane.com Mon Sep 14 18:58:00 2009 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon Sep 14 18:37:04 2009 Subject: [Haskell-cafe] algebra/grammar/language for expressing time intervals Message-ID: <60F6D84E-DE43-4E7F-95A0-96099AD41F7D@n-heptane.com> Hello, I need some cron-like functionality for long running daemon written in Haskell. I want to be able to schedule an event to be run: 1. once, at a specific time 2. some regularly scheduled time I don't see an existing library to do this, so I am starting work on my own. The first issue I am looking at is how to specify time intervals. The primary example I have looked at is cron. Cron is pretty good, but I don't see a way to do something like, run a job every other Wednesday. I also want to be able to display the interval schedule to the user, allow them to modify it, and also save the schedule to disk and reload it. So this essentially means that the type for describing the intervals can not contain any functions. Does anyone know of a good language for describing intervals? I want to be able to express things like: - run every other wednesday - run at 15 minutes past the hour - run at 15 minutes past the hour every wednesday - run at 15 and 25 minutes past the hour between the hours of 2 and 6 AM. - run every weekday at 8AM unless it is a holiday (the list of holidays would be supplied). Basically, everything you can express with cron, and a bit more. Is there any existing languages/grammars/algebras for this that I should look at? thanks! - jeremy From duncan.coutts at worc.ox.ac.uk Mon Sep 14 19:05:08 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Sep 14 18:44:43 2009 Subject: [Haskell-cafe] Can't install chp (confused by cabal yet again) In-Reply-To: References: Message-ID: <1252969508.19215.687.camel@localhost> On Mon, 2009-09-14 at 12:05 -0700, Michael Steele wrote: > You got the original error because cabal chose to use base-3 when > compiling chp, and then identifiers found only in base-4 were > referenced. > > > Download the cabal package, and edit chp.cabal so that it depends on > base >= 4. Or as another workaround use: $ cabal install chp --preference="base >= 4" Duncan From duncan.coutts at worc.ox.ac.uk Mon Sep 14 19:03:38 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Mon Sep 14 18:44:45 2009 Subject: [Haskell-cafe] trouble compiling Crypto-4.2.0 / trouble with cabal In-Reply-To: <20090913175426.GB4717@yoyo> References: <20090913175426.GB4717@yoyo> Message-ID: <1252969418.19215.683.camel@localhost> On Sun, 2009-09-13 at 19:54 +0200, mf-hcafe-15c311f0c@etc-network.de wrote: > > Hi, > > Cabal is still fighting me all the time. Its latest move is to be > oblivious of some of the installed packages: For future reference: http://haskell.org/cabal/FAQ.html#runghc-setup-complains-of-missing-packages The simple solution is don't mix cabal and "runghc Setup.hs", stick to cabal. Remember that cabal subsumes the command line interface provided by "runghc Setup.hs". Duncan From felipe.lessa at gmail.com Mon Sep 14 12:27:07 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Sep 14 21:14:30 2009 Subject: [Haskell-cafe] Announce: EnumMap-0.0.1 In-Reply-To: References: <87zla73ip7.fsf@malde.org> <20090810140918.GA26102@kira.casa> <87ocqlzhot.fsf@malde.org> <49a77b7a0908120834g3369a8e2l4082a45ca5c15e89@mail.gmail.com> <49a77b7a0908120958t6e3f8a34u88e45a3ab43537fe@mail.gmail.com> Message-ID: <20090914162707.GA27424@kira> On Wed, Aug 12, 2009 at 01:03:55PM -0400, John Van Enk wrote: > > EnumMap silently passes this responsibility to the user, without even a note in the documentation. > > Like I've said, I made no modifications to the documentation other > than replacing IntMap with EnumMap. Should the community show more > interest in the EnumMap, such a change will show up in the docs. I'm showing interest in EnumMap :). I have some IntMap's that provide no type safety about what is inserted and EnumMap solves that problem as nicely as possible. Right now I don't really care about the doumentation problems, but I would like to see the SPECIALIZE and INLINE improvements, when will there be a new version? Thanks a lot! -- Felipe. From ninegua at gmail.com Mon Sep 14 22:08:44 2009 From: ninegua at gmail.com (Paul L) Date: Mon Sep 14 21:47:28 2009 Subject: [Haskell-cafe] ANNOUNCE: LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation In-Reply-To: References: <856033f20909132236vf1abb5j66e46776150ad426@mail.gmail.com> Message-ID: <856033f20909141908w6191e9d8gdd54aeceac8db5d8@mail.gmail.com> I just bumped the version to 0.1.1 that fixes an embarrassing bug, i.e., the first example shown on the screen was actually wrong. I took a screenshot of the interaction net showing (church 2) f x, i.e., (\f x -> f (f x)) f x together with on-screen help messages. It is the first example right after you start the LambdaINet application, and erase redundant nodes, relayout, and auto zoom (key sequence E, L, Space"). It will reduce to f (f x) if you hit R key, or if you want to see the step by step outermost reduction, just keep hitting O key. The picture is here http://www.thev.net/download/church_2_f_x-with-helpmsg.jpg Pressing 1 to 9 will show a more complicated example that actually demonstrates the power of optimal evaluation: opt n = (church n) (church 2) i i. Standard call-by-need takes 37 beta reductions to evaluate opt 4, but optimal only needs 15. On 9/14/09, Bas van Dijk wrote: > On Mon, Sep 14, 2009 at 7:36 AM, Paul L wrote: >> It's available on Hackage DB at >> http://hackage.haskell.org/package/LambdaINet > > Nice! Screenshots anywhere? > > Bas > -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From vanenkj at gmail.com Mon Sep 14 23:23:09 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Sep 14 23:01:53 2009 Subject: [Haskell-cafe] Announce: EnumMap-0.0.1 In-Reply-To: <20090914162707.GA27424@kira> References: <87zla73ip7.fsf@malde.org> <20090810140918.GA26102@kira.casa> <87ocqlzhot.fsf@malde.org> <49a77b7a0908120834g3369a8e2l4082a45ca5c15e89@mail.gmail.com> <49a77b7a0908120958t6e3f8a34u88e45a3ab43537fe@mail.gmail.com> <20090914162707.GA27424@kira> Message-ID: I'll hunt down those changes and push something new to hackage. :) On Mon, Sep 14, 2009 at 12:27 PM, Felipe Lessa wrote: > On Wed, Aug 12, 2009 at 01:03:55PM -0400, John Van Enk wrote: > > > EnumMap silently passes this responsibility to the user, without even a > note in the documentation. > > > > Like I've said, I made no modifications to the documentation other > > than replacing IntMap with EnumMap. Should the community show more > > interest in the EnumMap, such a change will show up in the docs. > > I'm showing interest in EnumMap :). I have some IntMap's that > provide no type safety about what is inserted and EnumMap solves > that problem as nicely as possible. > > Right now I don't really care about the doumentation problems, > but I would like to see the SPECIALIZE and INLINE improvements, > when will there be a new version? > > Thanks a lot! > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090914/8ea190c2/attachment-0001.html From vanenkj at gmail.com Mon Sep 14 23:32:04 2009 From: vanenkj at gmail.com (John Van Enk) Date: Mon Sep 14 23:10:47 2009 Subject: [Haskell-cafe] Announce: EnumMap-0.0.1 In-Reply-To: <20090914162707.GA27424@kira> References: <87zla73ip7.fsf@malde.org> <20090810140918.GA26102@kira.casa> <87ocqlzhot.fsf@malde.org> <49a77b7a0908120834g3369a8e2l4082a45ca5c15e89@mail.gmail.com> <49a77b7a0908120958t6e3f8a34u88e45a3ab43537fe@mail.gmail.com> <20090914162707.GA27424@kira> Message-ID: http://hackage.haskell.org/package/EnumMap Changes pushed. Job Vranish added the SPECIALIZE pragmas, and I believe he has more data concerning how much this helps. Note, the git repo is here: http://github.com/sw17ch/EnumMap /jve On Mon, Sep 14, 2009 at 12:27 PM, Felipe Lessa wrote: > On Wed, Aug 12, 2009 at 01:03:55PM -0400, John Van Enk wrote: > > > EnumMap silently passes this responsibility to the user, without even a > note in the documentation. > > > > Like I've said, I made no modifications to the documentation other > > than replacing IntMap with EnumMap. Should the community show more > > interest in the EnumMap, such a change will show up in the docs. > > I'm showing interest in EnumMap :). I have some IntMap's that > provide no type safety about what is inserted and EnumMap solves > that problem as nicely as possible. > > Right now I don't really care about the doumentation problems, > but I would like to see the SPECIALIZE and INLINE improvements, > when will there be a new version? > > Thanks a lot! > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090914/259891f1/attachment.html From regis.saint-paul at create-net.org Tue Sep 15 04:14:42 2009 From: regis.saint-paul at create-net.org (Regis Saint-Paul) Date: Tue Sep 15 03:53:31 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <1252953483.19215.215.camel@localhost> References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <1252953483.19215.215.camel@localhost> Message-ID: > > - use windows API for requesting elevation during the process (ugly) > > If it really has to be done, then this seems like the best approach. In > principle there's no problem with calling funky win32 functions in > Cabal, it's mostly a matter of working out what bahaviour we want and > what UAC lets us do. To achieve this, a candidate solution would be: - to have a separate executable with a manifest indicating that administrator privilege are needed (and, ideally, signed) and able to perform the tasks necessitating elevation - from cabal, to run this separate process (calling shellexecute) exactly at the point when elevation is needed - alternatively, it might be possible to try the operation, catch the exception that would happen if it fails, and call the separate process in this case (see: http://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path -is-protected#17544) The advantage is that, with this solution, users only use "cabal" and the elevation is performed when needed. By contrast, the other suggested solution of having two executables (cabal-user and cabal-global) leaves the choice of elevating cabal to the user and only needs to modify the build process (no code changed in cabal). Its drawback is that elevation will be requested even when unnecessary every time cabal-global is launched. So a first task would be to identify the cases where cabal needs to run with elevated rights and the task to perform in that case. - Is cabal going to be modified to use AppData for library install? - If this is the case, then writing in protected folders would be only for binary install (with cabal install). Are there other cases? - If this is not the case, then writing in protected folder is for all package install when in global mode...other cases? - Am I missing operations where cabal would need admin privileges? For instance, may cabal need to modify some environment variable? Cheers, Regis From bugfact at gmail.com Tue Sep 15 05:24:26 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 15 05:03:10 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <1252953483.19215.215.camel@localhost> Message-ID: It is possible for an executable with less privileges to "shellexecute" an executable that requires admin rights? Won't this immediately raise an "access denied" or other security exception again? Don't know, it might be possible, but it's worth to check it out before going this route (which is rather clever IMHO :) On Tue, Sep 15, 2009 at 10:14 AM, Regis Saint-Paul wrote: > >> > - use windows API for requesting elevation during the process (ugly) >> >> If it really has to be done, then this seems like the best approach. In >> principle there's no problem with calling funky win32 functions in >> Cabal, it's mostly a matter of working out what bahaviour we want and >> what UAC lets us do. > > To achieve this, a candidate solution would be: > - to have a separate executable with a manifest indicating that > administrator privilege are needed (and, ideally, signed) and able to > perform the tasks necessitating elevation > - from cabal, to run this separate process (calling shellexecute) exactly at > the point when elevation is needed > - alternatively, it might be possible to try the operation, catch the > exception that would happen if it fails, and call the separate process in > this case (see: > http://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path > -is-protected#17544) > > The advantage is that, with this solution, users only use "cabal" and the > elevation is performed when needed. > > By contrast, the other suggested solution of having two executables > (cabal-user and cabal-global) leaves the choice of elevating cabal to the > user and only needs to modify the build process (no code changed in cabal). > Its drawback is that elevation will be requested even when unnecessary every > time cabal-global is launched. > > So a first task would be to identify the cases where cabal needs to run with > elevated rights and the task to perform in that case. > - Is cabal going to be modified to use AppData for library install? > - If this is the case, then writing in protected folders would be only for > binary install (with cabal install). Are there other cases? > - If this is not the case, then writing in protected folder is for all > package install when in global mode...other cases? > - Am I missing operations where cabal would need admin privileges? For > instance, may cabal need to modify some environment variable? > > Cheers, > Regis > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From bulat.ziganshin at gmail.com Tue Sep 15 05:49:05 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Tue Sep 15 05:27:59 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: References: <50c1e0910909080758g4710f485qb9cc0b77c288fc25@mail.gmail.com> <1252499327.5266.5117.camel@localhost> <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <1252953483.19215.215.camel@localhost> Message-ID: <1126891566.20090915134905@gmail.com> Hello Peter, Tuesday, September 15, 2009, 1:24:26 PM, you wrote: in order to protect from viruses and so now windows programs should be split into two parts - one that doesn't need admin privileges and one that needs them. as far as your actions doesn't need second part, you are running first program, when things haapened that needs admin priv., second executable should be run and *OS* will ask whether yot trust it. so it's pretty the same as sudo built-in in the system via exe manifest files. with UAC enabled, you are never have admin privileges while you run only first part of program > It is possible for an executable with less privileges to > "shellexecute" an executable that requires admin rights? Won't this > immediately raise an "access denied" or other security exception > again? Don't know, it might be possible, but it's worth to check it > out before going this route (which is rather clever IMHO :) > On Tue, Sep 15, 2009 at 10:14 AM, Regis Saint-Paul > wrote: >> >>> > - use windows API for requesting elevation during the process (ugly) >>> >>> If it really has to be done, then this seems like the best approach. In >>> principle there's no problem with calling funky win32 functions in >>> Cabal, it's mostly a matter of working out what bahaviour we want and >>> what UAC lets us do. >> >> To achieve this, a candidate solution would be: >> - to have a separate executable with a manifest indicating that >> administrator privilege are needed (and, ideally, signed) and able to >> perform the tasks necessitating elevation >> - from cabal, to run this separate process (calling shellexecute) exactly at >> the point when elevation is needed >> - alternatively, it might be possible to try the operation, catch the >> exception that would happen if it fails, and call the separate process in >> this case (see: >> http://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path >> -is-protected#17544) >> >> The advantage is that, with this solution, users only use "cabal" and the >> elevation is performed when needed. >> >> By contrast, the other suggested solution of having two executables >> (cabal-user and cabal-global) leaves the choice of elevating cabal to the >> user and only needs to modify the build process (no code changed in cabal). >> Its drawback is that elevation will be requested even when unnecessary every >> time cabal-global is launched. >> >> So a first task would be to identify the cases where cabal needs to run with >> elevated rights and the task to perform in that case. >> - Is cabal going to be modified to use AppData for library install? >> - If this is the case, then writing in protected folders would be only for >> binary install (with cabal install). Are there other cases? >> - If this is not the case, then writing in protected folder is for all >> package install when in global mode...other cases? >> - Am I missing operations where cabal would need admin privileges? For >> instance, may cabal need to modify some environment variable? >> >> Cheers, >> Regis >> >> _______________________________________________ >> 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 -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From hoknamahn at gmail.com Tue Sep 15 06:29:55 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 06:08:40 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? Message-ID: Hey guys, It's a dumb question but I'd like to know a right answer... Let's say we have some geometry data that can be Sphere, Cylinder, Circle and so on. We can implement it as new data type plus a bunch of functions that work on this data: data Geometry = Sphere Position Radius | Cylinder Position Radius Height | Circle Position Radius deriving (Show) perimeter (Sphere _ r) = 0.0 perimeter (Cylinder _ r h) = 0.0 perimeter (Circle _ r) = 2.0 * pi * r Perimeter doesn't make sense for Sphere or Cylinder. So we could define a type class for objects that have perimeter and make an instance of it only for Circle (data Circle = Circle Position Radius). Make sense. But these three functions above have desired behaviour. If user has a list of objects like [Sphere, Circle, Circle, Cylinder] he would like to calculate perimeters of each object using map perimerer list (in this case we also have to modify Geometry data type). So we could make instances of "perimeter" type class for all objects and return zero in case if perimeter doesn't make sense. Same as previous version but with typeclasses and with additional constructors (constructors for each type of object + constructors in Geometry data). Looks a bit overcomplicated. Any reasons to use type classes in this case? Maybe there is something I'm missing? Cheers, -O -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/5ede4019/attachment.html From hoknamahn at gmail.com Tue Sep 15 07:21:16 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 06:59:58 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: Sure! I completely forgot about Maybe. The only one question is is it good from the point of view of ordinary user who doesn't know about such things like functional programming, monads etc. Imagine average user who is looking into a spreadsheet and sees values 0.1, 1.4, Nothing... From other side it seems to be logical. Why not. Thanks for the idea :) On Tue, Sep 15, 2009 at 12:05 PM, Lyndon Maydwell wrote: > I think the problem is that you want to compose a list with no > indication of weather one member can have a perimeter or not. I'm not > sure if this is a good solution or not, but I immediately think to > make all Geometry objects instances of a class that return a Maybe > value for the perimeter: > > e.g. > > --- > > import Data.Maybe > > data Geometry = Sphere Position Radius | Circle Position Radius deriving > (Show) > > type Position = (Double, Double) > type Radius = Double > type Height = Double > > class Encircled x where > perimeter :: x -> Maybe Double > > instance Encircled Geometry where > perimeter (Sphere _ r) = Nothing > perimeter (Circle _ r) = Just $ 2.0 * pi * r > > list = [Sphere (1,1) 1, Circle (2,2) 2] > > main = (print . catMaybes . map perimeter) list > > --- [12.566370614359172] > > On Tue, Sep 15, 2009 at 6:29 PM, Olex P wrote: > > Hey guys, > > > > It's a dumb question but I'd like to know a right answer... > > Let's say we have some geometry data that can be Sphere, Cylinder, Circle > > and so on. We can implement it as new data type plus a bunch of functions > > that work on this data: > > > > data Geometry = Sphere Position Radius > > | Cylinder Position Radius Height > > | Circle Position Radius > > deriving (Show) > > > > perimeter (Sphere _ r) = 0.0 > > perimeter (Cylinder _ r h) = 0.0 > > perimeter (Circle _ r) = 2.0 * pi * r > > > > Perimeter doesn't make sense for Sphere or Cylinder. So we could define a > > type class for objects that have perimeter and make an instance of it > only > > for Circle (data Circle = Circle Position Radius). Make sense. But these > > three functions above have desired behaviour. If user has a list of > objects > > like [Sphere, Circle, Circle, Cylinder] he would like to calculate > > perimeters of each object using map perimerer list (in this case we also > > have to modify Geometry data type). > > So we could make instances of "perimeter" type class for all objects and > > return zero in case if perimeter doesn't make sense. > > Same as previous version but with typeclasses and with additional > > constructors (constructors for each type of object + constructors in > > Geometry data). Looks a bit overcomplicated. > > Any reasons to use type classes in this case? Maybe there is something > I'm > > missing? > > > > Cheers, > > -O > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/bd445466/attachment.html From andrewcoppin at btinternet.com Tue Sep 15 07:48:02 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Sep 15 07:26:46 2009 Subject: [Haskell-cafe] Parallel graphics Message-ID: <4AAF7EF2.9050203@btinternet.com> I have a number of compute-bound graphics programs written in Haskell. (Fractal generators, ray tracers, that kind of thing.) GHC offers several concurrency and parallelism abstractions, but what's the best way to use these to get images rendered as fast as possible, using the available compute power? (OK, well the *best* way is to use the GPU. But AFAIK that's still a theoretical research project, so we'll leave that for now.) I've identified a couple of common cases. You have a 2D grid of points, and you want to compute the value at each point. Eventually you will have a grid of /pixels/ where each value is a /colour/, but there may be intermediate steps before that. So, what cases exist? 1. A point's value is a function of its coordinates. 2. A point's value is a function of its previous value from the last frame. 3. A point's value is a function of /several/ points from the last frame. How can we accelerate this? I see a few options: - Create a spark for every point in the grid. - Create several explicit threads to populate non-overlapping regions of the grid. - Use parallel arrays. (Does this actually works yet??) I'm presuming that sparking every individual point is going to create billions of absolutely tiny sparks, which probably won't give great performance. We could spark every line rather than every point? Using explicit threads has the nice side-effect that we can produce progress information. Few things are more frustrating than staring at a blank screen with no idea how long it's going to take. I'm thinking this method might also allow you to avoid two cores tripping over each other's caches. And then there's parallel arrays, which presumably are designed from the ground up for exactly this type of task. But are they usable yet? Any further options? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/c5be9e18/attachment.html From noteed at gmail.com Tue Sep 15 08:04:35 2009 From: noteed at gmail.com (minh thu) Date: Tue Sep 15 07:43:37 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: <4AAF7EF2.9050203@btinternet.com> References: <4AAF7EF2.9050203@btinternet.com> Message-ID: <40a414c20909150504v40df49d7x15a2df0e60661884@mail.gmail.com> Hi Andrew, 2009/9/15 Andrew Coppin : > ... > I'm presuming that sparking every individual point is going to create > billions of absolutely tiny sparks, which probably won't give great > performance. We could spark every line rather than every point? > ... You should just try: no one can say if pixels, lines, image buckets or complete images is the right granularity. As for progress information, probably the needed granularity is not the same as the above one. Also, parallelizing a raytracer or the computation of a simple function of coordinates won't need the same solution. For instance ray coherence can be used to more efficiently traverse the accelarating data structure of the raytracer with many rays at once. Maybe before looking at what haskell has to offer you should look how your program can be parallelized then see if your solution maps well to one of haskell technical solutions. Cheers, Thu From bugfact at gmail.com Tue Sep 15 08:29:27 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 15 08:08:09 2009 Subject: [Haskell-cafe] Cabal install on Windows 7 In-Reply-To: <1126891566.20090915134905@gmail.com> References: <3d96ac180909091219g57f09ffn6f0aa826aa569b06@mail.gmail.com> <1252576701.5266.6434.camel@localhost> <3d96ac180909100339y798f9b00g24ee16b5d7345e63@mail.gmail.com> <7b501d5c0909100416x5bbb50a8o76617ed22c4be112@mail.gmail.com> <1252953483.19215.215.camel@localhost> <1126891566.20090915134905@gmail.com> Message-ID: Yes, I'm aware of that, but not the details, so thanks for the info. Anyway, I quickly tested Regis's idea in C#, and it works as he said. http://hpaste.org/fastcgi/hpaste.fcgi/view?id=9392#a9392 - When trying to create a folder in ProgramFiles, you get an access denied exception, unless the program is run as admin. - When trying to "shellexec" a program requiring admin rights - in this case regedit.exe - you get a popup, unless run as admin So this looks like a really clever & simple solution :-) On Tue, Sep 15, 2009 at 11:49 AM, Bulat Ziganshin wrote: > Hello Peter, > > Tuesday, September 15, 2009, 1:24:26 PM, you wrote: > > in order to protect from viruses and so now windows programs should be > split into two parts - one that doesn't need admin privileges and one > that needs them. as far as your actions doesn't need second part, you > are running first program, when things haapened that needs admin > priv., second executable should be run and *OS* will ask whether yot > trust it. so it's pretty the same as sudo built-in in the system via > exe manifest files. with UAC enabled, you are never have admin > privileges while you run only first part of program > >> It is possible for an executable with less privileges to >> "shellexecute" an executable that requires admin rights? Won't this >> immediately raise an "access denied" or other security exception >> again? Don't know, it might be possible, but it's worth to check it >> out before going this route (which is rather clever IMHO :) > >> On Tue, Sep 15, 2009 at 10:14 AM, Regis Saint-Paul >> wrote: >>> >>>> > - use windows API for requesting elevation during the process (ugly) >>>> >>>> If it really has to be done, then this seems like the best approach. In >>>> principle there's no problem with calling funky win32 functions in >>>> Cabal, it's mostly a matter of working out what bahaviour we want and >>>> what UAC lets us do. >>> >>> To achieve this, a candidate solution would be: >>> - to have a separate executable with a manifest indicating that >>> administrator privilege are needed (and, ideally, signed) and able to >>> perform the tasks necessitating elevation >>> - from cabal, to run this separate process (calling shellexecute) exactly at >>> the point when elevation is needed >>> - alternatively, it might be possible to try the operation, catch the >>> exception that would happen if it fails, and call the separate process in >>> this case (see: >>> http://stackoverflow.com/questions/17533/request-vista-uac-elevation-if-path >>> -is-protected#17544) >>> >>> The advantage is that, with this solution, users only use "cabal" and the >>> elevation is performed when needed. >>> >>> By contrast, the other suggested solution of having two executables >>> (cabal-user and cabal-global) leaves the choice of elevating cabal to the >>> user and only needs to modify the build process (no code changed in cabal). >>> Its drawback is that elevation will be requested even when unnecessary every >>> time cabal-global is launched. >>> >>> So a first task would be to identify the cases where cabal needs to run with >>> elevated rights and the task to perform in that case. >>> - Is cabal going to be modified to use AppData for library install? >>> - If this is the case, then writing in protected folders would be only for >>> binary install (with cabal install). Are there other cases? >>> - If this is not the case, then writing in protected folder is for all >>> package install when in global mode...other cases? >>> - Am I missing operations where cabal would need admin privileges? For >>> instance, may cabal need to modify some environment variable? >>> >>> Cheers, >>> Regis >>> >>> _______________________________________________ >>> 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 > > > -- > Best regards, > ?Bulat ? ? ? ? ? ? ? ? ? ? ? ? ? ?mailto:Bulat.Ziganshin@gmail.com > > From daniil.elovkov at googlemail.com Tue Sep 15 08:44:19 2009 From: daniil.elovkov at googlemail.com (Daniil Elovkov) Date: Tue Sep 15 08:22:21 2009 Subject: [Haskell-cafe] HDBC Oracle bindings(?/!) In-Reply-To: References: <20081030174820.GA403@hustlerturf.com> Message-ID: <4AAF8C23.8030609@googlemail.com> Hello Thiago, John. I've taken the Oracle HDBC driver at http://thiagoarrais.com/repos/hdbc-oracle modified it just a little to suite 6.10.4 and briefly looked if it works. It does, that's cool! Thanks Thiago! A question follows, maybe it's worth to mention it at the HDBC page and/or put it to Hackage? And another question: Thiago, John how do you think what is the appropriate place to put the function that sets prefetch row count? The thing is that (at least in my case) by default Oracle returns rows very slowly. Setting prefetch count speeds it up dramatically. It's not the case with MySQL, for example, but the functionality is never the less quite generic. For example, this method is part of JDBC api. Thiago Arrais wrote: > John, > > On Thu, Oct 30, 2008 at 2:48 PM, John Goerzen wrote: >> I would certainly happily reference anyone's native Oracle HDBC >> backend too, though! > > You may want to reference mine, given that there aren't any others > currently. Just be aware that it really isn't ready for mass > consumption yet. > From ninegua at gmail.com Tue Sep 15 09:25:47 2009 From: ninegua at gmail.com (Paul L) Date: Tue Sep 15 09:04:29 2009 Subject: [Haskell-cafe] ANNOUNCE: LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation In-Reply-To: <856033f20909141908w6191e9d8gdd54aeceac8db5d8@mail.gmail.com> References: <856033f20909132236vf1abb5j66e46776150ad426@mail.gmail.com> <856033f20909141908w6191e9d8gdd54aeceac8db5d8@mail.gmail.com> Message-ID: <856033f20909150625h85ce029pa015bca95d0340af@mail.gmail.com> Now it's at version 0.1.2 with the EnableGUI fix for Mac OS X. On 9/14/09, Paul L wrote: > I just bumped the version to 0.1.1 that fixes an embarrassing bug, > i.e., the first example shown on the screen was actually wrong. > > I took a screenshot of the interaction net showing (church 2) f x, > i.e., (\f x -> f (f x)) f x together with on-screen help messages. It > is the first example right after you start the LambdaINet application, > and erase redundant nodes, relayout, and auto zoom (key sequence E, L, > Space"). It will reduce to f (f x) if you hit R key, or if you want to > see the step by step outermost reduction, just keep hitting O key. > > The picture is here > http://www.thev.net/download/church_2_f_x-with-helpmsg.jpg > > Pressing 1 to 9 will show a more complicated example that actually > demonstrates the power of optimal evaluation: opt n = (church n) > (church 2) i i. Standard call-by-need takes 37 beta reductions to > evaluate opt 4, but optimal only needs 15. > > On 9/14/09, Bas van Dijk wrote: >> On Mon, Sep 14, 2009 at 7:36 AM, Paul L wrote: >>> It's available on Hackage DB at >>> http://hackage.haskell.org/package/LambdaINet >> >> Nice! Screenshots anywhere? >> >> Bas >> > > > -- > Regards, > Paul Liu > > Yale Haskell Group > http://www.haskell.org/yale > -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From hoknamahn at gmail.com Tue Sep 15 09:57:07 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 09:35:49 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: Well... How this: instance Encircled Geometry where perimeter (Sphere _ r) = Nothing perimeter (Circle _ r) = Just $ 2.0 * pi * r differs from this: perimeter :: Geometry -> Maybe Double perimeter (Sphere _ r) = Nothing perimeter (Circle _ r) = Just $ 2.0 * pi * r and from this: perimeter :: Geometry -> Double perimeter (Sphere _ r) = 0.0 perimeter (Circle _ r) = 2.0 * pi * r The latter is even simpler because there is no need in extraction of Double value from Maybe. So the question is still there: do I need a type class? On Tue, Sep 15, 2009 at 12:21 PM, Olex P wrote: > Sure! I completely forgot about Maybe. The only one question is is it good > from the point of view of ordinary user who doesn't know about such things > like functional programming, monads etc. Imagine average user who is looking > into a spreadsheet and sees values 0.1, 1.4, Nothing... From other side it > seems to be logical. Why not. > Thanks for the idea :) > > On Tue, Sep 15, 2009 at 12:05 PM, Lyndon Maydwell wrote: > >> I think the problem is that you want to compose a list with no >> indication of weather one member can have a perimeter or not. I'm not >> sure if this is a good solution or not, but I immediately think to >> make all Geometry objects instances of a class that return a Maybe >> value for the perimeter: >> >> e.g. >> >> --- >> >> import Data.Maybe >> >> data Geometry = Sphere Position Radius | Circle Position Radius deriving >> (Show) >> >> type Position = (Double, Double) >> type Radius = Double >> type Height = Double >> >> class Encircled x where >> perimeter :: x -> Maybe Double >> >> instance Encircled Geometry where >> perimeter (Sphere _ r) = Nothing >> perimeter (Circle _ r) = Just $ 2.0 * pi * r >> >> list = [Sphere (1,1) 1, Circle (2,2) 2] >> >> main = (print . catMaybes . map perimeter) list >> >> --- [12.566370614359172] >> >> On Tue, Sep 15, 2009 at 6:29 PM, Olex P wrote: >> > Hey guys, >> > >> > It's a dumb question but I'd like to know a right answer... >> > Let's say we have some geometry data that can be Sphere, Cylinder, >> Circle >> > and so on. We can implement it as new data type plus a bunch of >> functions >> > that work on this data: >> > >> > data Geometry = Sphere Position Radius >> > | Cylinder Position Radius Height >> > | Circle Position Radius >> > deriving (Show) >> > >> > perimeter (Sphere _ r) = 0.0 >> > perimeter (Cylinder _ r h) = 0.0 >> > perimeter (Circle _ r) = 2.0 * pi * r >> > >> > Perimeter doesn't make sense for Sphere or Cylinder. So we could define >> a >> > type class for objects that have perimeter and make an instance of it >> only >> > for Circle (data Circle = Circle Position Radius). Make sense. But these >> > three functions above have desired behaviour. If user has a list of >> objects >> > like [Sphere, Circle, Circle, Cylinder] he would like to calculate >> > perimeters of each object using map perimerer list (in this case we also >> > have to modify Geometry data type). >> > So we could make instances of "perimeter" type class for all objects and >> > return zero in case if perimeter doesn't make sense. >> > Same as previous version but with typeclasses and with additional >> > constructors (constructors for each type of object + constructors in >> > Geometry data). Looks a bit overcomplicated. >> > Any reasons to use type classes in this case? Maybe there is something >> I'm >> > missing? >> > >> > Cheers, >> > -O >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> > >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/2792192f/attachment.html From maydwell at gmail.com Tue Sep 15 10:04:39 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Tue Sep 15 09:43:21 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: ---------- Forwarded message ---------- From: Lyndon Maydwell Date: Tue, Sep 15, 2009 at 10:03 PM Subject: Re: [Haskell-cafe] Typeclasses vs simple functions? To: Olex P I think it depends on what is going to be using the functions, data. As far as I can tell, type classes seem to be used in code designed for reuse. So if it is just for a small part of a project that is hidden behind an interface or something, then it's probably fine to just use data/functions without type classes. Keep in mind that these are the musings of someone who only recently began using Haskell. If someone else has a better explanation, then I'd be interested as well :) On Tue, Sep 15, 2009 at 9:57 PM, Olex P wrote: > Well... How this: > > instance Encircled Geometry where > ? ? ? ?perimeter (Sphere _ r) = Nothing > ? ? ? ?perimeter (Circle _ r) = Just $ 2.0 * pi * r > > differs from this: > > perimeter :: Geometry -> Maybe Double > perimeter (Sphere _ r) = Nothing > perimeter (Circle _ r) = Just $ 2.0 * pi * r > > and from this: > > perimeter :: Geometry -> Double > perimeter (Sphere _ r) = 0.0 > perimeter (Circle _ r) = 2.0 * pi * r > > The latter is even simpler because there is no need in extraction of Double > value from Maybe. > So the question is still there: do I need a type class? > > On Tue, Sep 15, 2009 at 12:21 PM, Olex P wrote: >> >> Sure! I completely forgot about Maybe. The only one question is is it good >> from the point of view of ordinary user who doesn't know about such things >> like functional programming, monads etc. Imagine average user who is looking >> into a spreadsheet and sees values 0.1, 1.4, Nothing... From other side it >> seems to be logical. Why not. >> Thanks for the idea :) >> >> On Tue, Sep 15, 2009 at 12:05 PM, Lyndon Maydwell >> wrote: >>> >>> I think the problem is that you want to compose a list with no >>> indication of weather one member can have a perimeter or not. I'm not >>> sure if this is a good solution or not, but I immediately think to >>> make all Geometry objects instances of a class that return a Maybe >>> value for the perimeter: >>> >>> e.g. >>> >>> --- >>> >>> import Data.Maybe >>> >>> data Geometry = Sphere Position Radius | Circle Position Radius deriving >>> (Show) >>> >>> type Position = (Double, Double) >>> type Radius = Double >>> type Height = Double >>> >>> class Encircled x where >>> ? ? ? ?perimeter :: x -> Maybe Double >>> >>> instance Encircled Geometry where >>> ? ? ? ?perimeter (Sphere _ r) = Nothing >>> ? ? ? ?perimeter (Circle _ r) = Just $ 2.0 * pi * r >>> >>> list = [Sphere (1,1) 1, Circle (2,2) 2] >>> >>> main = (print . catMaybes . map perimeter) list >>> >>> --- [12.566370614359172] >>> >>> On Tue, Sep 15, 2009 at 6:29 PM, Olex P wrote: >>> > Hey guys, >>> > >>> > It's a dumb question but I'd like to know a right answer... >>> > Let's say we have some geometry data that can be Sphere, Cylinder, >>> > Circle >>> > and so on. We can implement it as new data type plus a bunch of >>> > functions >>> > that work on this data: >>> > >>> > data Geometry = Sphere Position Radius >>> > ? ? ? ? ? ? ? ? ? ? ? ? | Cylinder Position Radius Height >>> > ? ? ? ? ? ? ? ? ? ? ? ? | Circle Position Radius >>> > ??????????????????????? deriving (Show) >>> > >>> > perimeter (Sphere _ r) = 0.0 >>> > perimeter (Cylinder _ r h) = 0.0 >>> > perimeter (Circle _ r) = 2.0 * pi * r >>> > >>> > Perimeter doesn't make sense for Sphere or Cylinder. So we could define >>> > a >>> > type class for objects that have perimeter and make an instance of it >>> > only >>> > for Circle (data Circle = Circle Position Radius). Make sense. But >>> > these >>> > three functions above have desired behaviour. If user has a list of >>> > objects >>> > like [Sphere, Circle, Circle, Cylinder] he would like to calculate >>> > perimeters of each object using map perimerer list (in this case we >>> > also >>> > have to modify Geometry data type). >>> > So we could make instances of "perimeter" type class for all objects >>> > and >>> > return zero in case if perimeter doesn't make sense. >>> > Same as previous version but with typeclasses and with additional >>> > constructors (constructors for each type of object + constructors in >>> > Geometry data). Looks a bit overcomplicated. >>> > Any reasons to use type classes in this case? Maybe there is something >>> > I'm >>> > missing? >>> > >>> > Cheers, >>> > -O >>> > >>> > _______________________________________________ >>> > 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 > > From haskell at colquitt.org Tue Sep 15 10:20:00 2009 From: haskell at colquitt.org (John Dorsey) Date: Tue Sep 15 09:58:45 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: <20090915142000.GL14826@colquitt.org> > perimeter :: Geometry -> Double > perimeter (Sphere _ r) = 0.0 > perimeter (Circle _ r) = 2.0 * pi * r > > The latter is even simpler because there is no need in extraction of Double > value from Maybe. I'd strongly advise against this last one on style grounds. (0 :: Double) isn't nearly as suitable as a distinguished value indicating an invalid result as Nothing. It can be made to work, in the same way that you can write complex code in asm; instead, use a solution that gives you type-level help in getting it right. I'd use Maybe. Regards, John From leather at cs.uu.nl Tue Sep 15 10:26:55 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Sep 15 10:05:57 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: <3c6288ab0909150726y210d4249ka52b97dfd8d3cd02@mail.gmail.com> > Perimeter doesn't make sense for Sphere or Cylinder. So we could define a > type class for objects that have perimeter and make an instance of it only > for Circle (data Circle = Circle Position Radius). Make sense. But these > three functions above have desired behaviour. If user has a list of objects > like [Sphere, Circle, Circle, Cylinder] he would like to calculate > perimeters of each object using map perimerer list (in this case we also > have to modify Geometry data type). > So we could make instances of "perimeter" type class for all objects and > return zero in case if perimeter doesn't make sense. > Same as previous version but with typeclasses and with additional > constructors (constructors for each type of object + constructors in > Geometry data). Looks a bit overcomplicated. > Any reasons to use type classes in this case? Maybe there is something I'm > missing? > If you're talking about a single datatype with multiple constructors, then the function 'perimeter :: Geometry -> Maybe Double' makes sense. If you're talking about multiple datatypes, then you probably want to go type class route. data Sphere = Sphere ... data Circle = Circle ... class Perimeter a where perimeter :: a -> Double instance Perimeter Circle where perimeter (Circle ...) = ... -- No instance for Sphere class Volume a where volume :: a -> Double instance Volume Sphere where volume (Sphere ...) = ... -- No instance for Circle You have to decide whether (1) a datatype Geometry makes sense or (2) a datatype per geometric entity is better. One advantage to #1 is that writing functions over the datatype is easy. One advantage to #2 is that you have fewer (partial) 'Maybe' functions. This is also related to the "expression problem," a Googleable term. As for having a list of objects, you can do it with either approach. The second approach may require existential types. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/72272fbd/attachment.html From hoknamahn at gmail.com Tue Sep 15 10:35:32 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 10:14:15 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: <3c6288ab0909150726y210d4249ka52b97dfd8d3cd02@mail.gmail.com> References: <3c6288ab0909150726y210d4249ka52b97dfd8d3cd02@mail.gmail.com> Message-ID: Cool. It's more and more clear guys. Thanks a lot. I'll check that "expression problem". "Existential types" sounds a bit scary :) On Tue, Sep 15, 2009 at 3:26 PM, Sean Leather wrote: > > >> Perimeter doesn't make sense for Sphere or Cylinder. So we could define a >> type class for objects that have perimeter and make an instance of it only >> for Circle (data Circle = Circle Position Radius). Make sense. But these >> three functions above have desired behaviour. If user has a list of objects >> like [Sphere, Circle, Circle, Cylinder] he would like to calculate >> perimeters of each object using map perimerer list (in this case we also >> have to modify Geometry data type). >> So we could make instances of "perimeter" type class for all objects and >> return zero in case if perimeter doesn't make sense. >> Same as previous version but with typeclasses and with additional >> constructors (constructors for each type of object + constructors in >> Geometry data). Looks a bit overcomplicated. >> Any reasons to use type classes in this case? Maybe there is something I'm >> missing? >> > > If you're talking about a single datatype with multiple constructors, then > the function 'perimeter :: Geometry -> Maybe Double' makes sense. If you're > talking about multiple datatypes, then you probably want to go type class > route. > > data Sphere = Sphere ... > data Circle = Circle ... > > class Perimeter a where perimeter :: a -> Double > instance Perimeter Circle where perimeter (Circle ...) = ... > -- No instance for Sphere > > class Volume a where volume :: a -> Double > instance Volume Sphere where volume (Sphere ...) = ... > -- No instance for Circle > > You have to decide whether (1) a datatype Geometry makes sense or (2) a > datatype per geometric entity is better. One advantage to #1 is that writing > functions over the datatype is easy. One advantage to #2 is that you have > fewer (partial) 'Maybe' functions. This is also related to the "expression > problem," a Googleable term. > > As for having a list of objects, you can do it with either approach. The > second approach may require existential types. > > Regards, > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/b30e3a92/attachment.html From tanielsen at gmail.com Tue Sep 15 10:48:17 2009 From: tanielsen at gmail.com (Tom Nielsen) Date: Tue Sep 15 10:27:20 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: Message-ID: <78dc001e0909150748v4b9ed6fk60b8f27357b3516c@mail.gmail.com> I think you are in trouble because you have mixed 2D and 3D shapes in one data type. --not checked for typos, syntax, idiocy etc. {-# LANGUAGE GADTs #-} data Z data S n type Two = S (S Z) type Three = S Two data Geometry dims where Sphere :: Position -> Radius -> Geometry Three Cylinder :: Position -> Radius -> Height -> Geometry Three Circle :: Position -> Radius -> Geometry Two Postcard :: Position -> Orientation -> Geometry Two -> Geometry Three perimeter :: Geometry Two -> Double perimeter (Circle _ r) = 2*pi*r Tom On Tue, Sep 15, 2009 at 11:29 AM, Olex P wrote: > Hey guys, > > It's a dumb question but I'd like to know a right answer... > Let's say we have some geometry data that can be Sphere, Cylinder, Circle > and so on. We can implement it as new data type plus a bunch of functions > that work on this data: > > data Geometry = Sphere Position Radius > ? ? ? ? ? ? ? ? ? ? ? ? | Cylinder Position Radius Height > ? ? ? ? ? ? ? ? ? ? ? ? | Circle Position Radius > ??????????????????????? deriving (Show) > > perimeter (Sphere _ r) = 0.0 > perimeter (Cylinder _ r h) = 0.0 > perimeter (Circle _ r) = 2.0 * pi * r > > Perimeter doesn't make sense for Sphere or Cylinder. So we could define a > type class for objects that have perimeter and make an instance of it only > for Circle (data Circle = Circle Position Radius). Make sense. But these > three functions above have desired behaviour. If user has a list of objects > like [Sphere, Circle, Circle, Cylinder] he would like to calculate > perimeters of each object using map perimerer list (in this case we also > have to modify Geometry data type). > So we could make instances of "perimeter" type class for all objects and > return zero in case if perimeter doesn't make sense. > Same as previous version but with typeclasses and with additional > constructors (constructors for each type of object + constructors in > Geometry data). Looks a bit overcomplicated. > Any reasons to use type classes in this case? Maybe there is something I'm > missing? > > Cheers, > -O > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From hoknamahn at gmail.com Tue Sep 15 10:55:09 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 10:33:52 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: <78dc001e0909150748v4b9ed6fk60b8f27357b3516c@mail.gmail.com> References: <78dc001e0909150748v4b9ed6fk60b8f27357b3516c@mail.gmail.com> Message-ID: It's hard to say what really is 2d or 3d. Think about closed 3d curve (points placed in 3d space somehow). Is it 2d or 3d? Depends on the interpretation. Usually DCC packages don't care about this. And I wouldn't too :p Who needs extra level of complexity without any reason? On Tue, Sep 15, 2009 at 3:48 PM, Tom Nielsen wrote: > I think you are in trouble because you have mixed 2D and 3D shapes in > one data type. > > --not checked for typos, syntax, idiocy etc. > {-# LANGUAGE GADTs #-} > > data Z > data S n > > type Two = S (S Z) > type Three = S Two > > data Geometry dims where > Sphere :: Position -> Radius -> Geometry Three > Cylinder :: Position -> Radius -> Height -> Geometry Three > Circle :: Position -> Radius -> Geometry Two > > Postcard :: Position -> Orientation -> Geometry Two -> Geometry Three > > perimeter :: Geometry Two -> Double > perimeter (Circle _ r) = 2*pi*r > > Tom > > On Tue, Sep 15, 2009 at 11:29 AM, Olex P wrote: > > Hey guys, > > > > It's a dumb question but I'd like to know a right answer... > > Let's say we have some geometry data that can be Sphere, Cylinder, Circle > > and so on. We can implement it as new data type plus a bunch of functions > > that work on this data: > > > > data Geometry = Sphere Position Radius > > | Cylinder Position Radius Height > > | Circle Position Radius > > deriving (Show) > > > > perimeter (Sphere _ r) = 0.0 > > perimeter (Cylinder _ r h) = 0.0 > > perimeter (Circle _ r) = 2.0 * pi * r > > > > Perimeter doesn't make sense for Sphere or Cylinder. So we could define a > > type class for objects that have perimeter and make an instance of it > only > > for Circle (data Circle = Circle Position Radius). Make sense. But these > > three functions above have desired behaviour. If user has a list of > objects > > like [Sphere, Circle, Circle, Cylinder] he would like to calculate > > perimeters of each object using map perimerer list (in this case we also > > have to modify Geometry data type). > > So we could make instances of "perimeter" type class for all objects and > > return zero in case if perimeter doesn't make sense. > > Same as previous version but with typeclasses and with additional > > constructors (constructors for each type of object + constructors in > > Geometry data). Looks a bit overcomplicated. > > Any reasons to use type classes in this case? Maybe there is something > I'm > > missing? > > > > Cheers, > > -O > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/e670aa85/attachment.html From msimoni at gmail.com Tue Sep 15 11:14:59 2009 From: msimoni at gmail.com (Manuel Simoni) Date: Tue Sep 15 10:53:41 2009 Subject: [Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell) Message-ID: <37707ed10909150814s544e75d5o18d0413d4ec5d8e4@mail.gmail.com> Hello! I'm trying to wrap my head around OO'Haskell's notion of objects as fixpoints. Is OO'Haskell's use of mfix simply a use of something like a monadic Y-combinator to give the object access to its own "identity"? Thanks, Manuel From leather at cs.uu.nl Tue Sep 15 11:30:23 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Sep 15 11:09:24 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: References: <3c6288ab0909150726y210d4249ka52b97dfd8d3cd02@mail.gmail.com> Message-ID: <3c6288ab0909150830r1c3ae579x5225c51278c1bc7c@mail.gmail.com> > "Existential types" sounds a bit scary :) > >> It's unfortunate that they've developed a scariness feeling associated with them. They can be used in strange ways, but simple uses are quite approachable. One way to think of them is like implementing an object-oriented interface. You know it's an object, but you can't do anything with it except use the methods of the interface. --- {-# LANGUAGE ExistentialQuantification #-} data Square = Square ... data Circle = Circle ... class Perimeter a where perimeter :: a -> Double instance Perimeter Square where perimeter (Square ...) = ... instance Perimeter Circle where perimeter (Circle ...) = ... -- The 'a' is hidden here. The interface is defined by the class constraint. data Perimeterizable = forall a . (Perimeter a) => P a -- This is the accessor method for things Perimeterizable. getPerimeter (P x) = perimeter x vals :: [Perimeterizable] vals = [P Square, P Circle] perims = map getPerimeter vals --- Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/74fa911f/attachment.html From leather at cs.uu.nl Tue Sep 15 11:40:07 2009 From: leather at cs.uu.nl (Sean Leather) Date: Tue Sep 15 11:19:09 2009 Subject: [Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell) In-Reply-To: <37707ed10909150814s544e75d5o18d0413d4ec5d8e4@mail.gmail.com> References: <37707ed10909150814s544e75d5o18d0413d4ec5d8e4@mail.gmail.com> Message-ID: <3c6288ab0909150840v2145dd9by83ce80285dd06c07@mail.gmail.com> > I'm trying to wrap my head around OO'Haskell's notion of objects as > fixpoints. > > Is OO'Haskell's use of mfix simply a use of something like a monadic > Y-combinator to give the object access to its own "identity"? > I don't remember the details exactly, but isn't it to support open recursion for inherited/overridden methods? http://etymon.blogspot.com/2006/04/open-recursion-definition.html Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/05bc33ff/attachment.html From hoknamahn at gmail.com Tue Sep 15 13:00:56 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 15 12:39:38 2009 Subject: [Haskell-cafe] Typeclasses vs simple functions? In-Reply-To: <3c6288ab0909150830r1c3ae579x5225c51278c1bc7c@mail.gmail.com> References: <3c6288ab0909150726y210d4249ka52b97dfd8d3cd02@mail.gmail.com> <3c6288ab0909150830r1c3ae579x5225c51278c1bc7c@mail.gmail.com> Message-ID: Thanks for explanation Sean! On Tue, Sep 15, 2009 at 4:30 PM, Sean Leather wrote: > > >> "Existential types" sounds a bit scary :) >> >>> > It's unfortunate that they've developed a scariness feeling associated with > them. They can be used in strange ways, but simple uses are quite > approachable. One way to think of them is like implementing an > object-oriented interface. You know it's an object, but you can't do > anything with it except use the methods of the interface. > > --- > > {-# LANGUAGE ExistentialQuantification #-} > > data Square = Square ... > data Circle = Circle ... > > class Perimeter a where perimeter :: a -> Double > instance Perimeter Square where perimeter (Square ...) = ... > instance Perimeter Circle where perimeter (Circle ...) = ... > > -- The 'a' is hidden here. The interface is defined by the class > constraint. > data Perimeterizable = forall a . (Perimeter a) => P a > > -- This is the accessor method for things Perimeterizable. > getPerimeter (P x) = perimeter x > > vals :: [Perimeterizable] > vals = [P Square, P Circle] > > perims = map getPerimeter vals > > --- > > Regards, > Sean > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/861ba65d/attachment.html From cristiano.paris at gmail.com Tue Sep 15 14:36:06 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Tue Sep 15 14:16:30 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? Message-ID: Hi Caf?, I've the following problem: I have a (possibly very long) list of files on disk. Each file contains some metadata at the beginning and continues with a (possibly very large) chunk of data. Now, the program I'm writing can be run in two modes: either read a specific file from the disk and show the whole chunk of data on screen, or read all the files' metadata, sort the file list based on the metadata, and display a summary of those without reading the chunk of data from each file. I've factored out the file access machinery in a single module so as to use it indifferently under the two scenarios. At first, I wrote a piece of code which, in spirit, works like the following reduced case: ------ module Main where import System.IO import Control.Applicative import Data.List import Data.Ord import Debug.Trace data Bit = Bit { index :: Integer, body :: String } readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) <*> readBody where readBody = withFile fn ReadMode $ \h -> do b <- hGetContents h seq b $ trace ("Read body from: " ++ fn) $ return b main = do bl <- mapM readBit ["file1.txt","file2.txt"] mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl ---- which is very expressive as it's written in applicative style. Each file is like the following: ---- file1.txt ---- 1 foo ---- I've created a separate IO action for reading the body in the hope that it wouldn't get executed when the file list is sorted. But, to my surprise, it didn't work as the trace message gets written for each file before the summary is displayed. Thinking about this, I came to the conclusion that the IO Monad is enforcing proper IO ordering so that the IO action for file1's body must be executed right before IO action for file2's index one. If this is true, the only solution that came into my mind was to wrap the IO action for reading the body in an unsafePerformIO call. I actually ran the program with this modification and it works properly. So, as using unsafePerformIO is a Great Evil (TM), I'm wondering if there's a different way to do this which doesn't rely on retyping body as an IO action returning a String, which would break my pure code manipulating the files. My opinion is that using unsafePerformIO here is like ensuring the compiler that there're no observable side effects in running the IO action for reading the body and that no other side effects would impact this IO action. Thank you for any thoughts. Cristiano From daniel.is.fischer at web.de Tue Sep 15 15:13:02 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 14:52:53 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: Message-ID: <200909152113.02587.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 20:36:06 schrieb Cristiano Paris: > Hi Caf?, > > I've the following problem: I have a (possibly very long) list of > files on disk. Each file contains some metadata at the beginning and > continues with a (possibly very large) chunk of data. > > Now, the program I'm writing can be run in two modes: either read a > specific file from the disk and show the whole chunk of data on > screen, or read all the files' metadata, sort the file list based on > the metadata, and display a summary of those without reading the chunk > of data from each file. I've factored out the file access machinery in > a single module so as to use it indifferently under the two scenarios. > > At first, I wrote a piece of code which, in spirit, works like the > following reduced case: > > ------ > module Main where > > import System.IO > import Control.Applicative > import Data.List > import Data.Ord > > import Debug.Trace > > data Bit = Bit { index :: Integer, body :: String } > > readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= > return . read) <*> readBody > where readBody = withFile fn ReadMode $ \h -> do b <- > hGetContents h > seq b $ > trace ("Read body from: " ++ fn) $ return b Still, the body should be read lazily. I'm not sure, but the tracing message may be output because of its position. With where readBody = withFile fn ReadMode $ \h -> do b <- hGetContents h seq b $ return (trace ("Read body from: " ++ fn) b) there's no tracing output. > > main = do bl <- mapM readBit ["file1.txt","file2.txt"] > mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > ---- > > which is very expressive as it's written in applicative style. > > Each file is like the following: > > ---- file1.txt ---- > 1 > foo > ---- > > I've created a separate IO action for reading the body in the hope > that it wouldn't get executed when the file list is sorted. But, to my > surprise, it didn't work as the trace message gets written for each > file before the summary is displayed. > > Thinking about this, I came to the conclusion that the IO Monad is > enforcing proper IO ordering so that the IO action for file1's body > must be executed right before IO action for file2's index one. > > If this is true, the only solution that came into my mind was to wrap > the IO action for reading the body in an unsafePerformIO call. I > actually ran the program with this modification and it works properly. > > So, as using unsafePerformIO is a Great Evil (TM), I'm wondering if > there's a different way to do this which doesn't rely on retyping body > as an IO action returning a String, which would break my pure code > manipulating the files. > > My opinion is that using unsafePerformIO here is like ensuring the > compiler that there're no observable side effects in running the IO > action for reading the body and that no other side effects would > impact this IO action. > > Thank you for any thoughts. > > Cristiano From svein.ove at aas.no Tue Sep 15 15:16:22 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Sep 15 14:55:02 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: Message-ID: <221b53ab0909151216y6bb1525cu8b9953f2ddf4425f@mail.gmail.com> I have a number of suggestions, some of which conflict with each other, so I'll just throw them out here. Let's see.. First off, the IO monad does indeed enforce sequencing; that's its primary purpose. However, you can ask for it to run I/O out of order, specifically when the value the out-of-order action returns is actually forced (used); that's lazy I/O, and is implemented using unsafeInterleaveIO. You would not usually use unsafeInterleaveIO directly, though. Instead, you'd use an existing wrapper, such as hGetContents. (for Strings, or lazy bytestrings; the strict bytestring variant reasonably has a strict semantics) One thing to keep in mind about lazy I/O is that the I/O in question can run at any arbitrary time, or not at all; not more than once, though. You must make sure this is safe. For file input, that basically means the file should not change during the program's lifetime. hGetLine is not lazy in this way, but the hGetContents you use is. I'm not sure whether this means your program should work as-is, and I'm not going to examine it closely enough to tell - as you mentioned it's a mockup anyway. Besides.. Strings are also *slow*. What you want for I/O is, when reasonably possible, bytestrings. You'd then use parsec-bytestring, or if possible Data.Binary, to parse said bytestring; the latter is faster (..probably), if more limited in function. You could use the lazy bytestring hGetContents for this. However... There is also a bytestring-mmap package on hackage, which outsources the decision of what blocks to load into memory to the OS, and has the best performance overall. Use this. Oh. And unsafePerformIO is a trap that will kill you. See http://www.girlgeniusonline.com/comic.php?date=20070725 for details. On Tue, Sep 15, 2009 at 8:36 PM, Cristiano Paris wrote: > Hi Caf?, > > I've the following problem: I have a (possibly very long) list of > files on disk. Each file contains some metadata at the beginning and > continues with a (possibly very large) chunk of data. > > Now, the program I'm writing can be run in two modes: either read a > specific file from the disk and show the whole chunk of data on > screen, or read all the files' metadata, sort the file list based on > the metadata, and display a summary of those without reading the chunk > of data from each file. I've factored out the file access machinery in > a single module so as to use it indifferently under the two scenarios. > > At first, I wrote a piece of code which, in spirit, works like the > following reduced case: > > ------ > module Main where > > import System.IO > import Control.Applicative > import Data.List > import Data.Ord > > import Debug.Trace > > data Bit = Bit { index :: Integer, body :: String } > > readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= > return . read) <*> readBody > ? ? ? ? ? ? where readBody = withFile fn ReadMode $ \h -> do b <- > hGetContents h > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?seq b $ > trace ("Read body from: " ++ fn) $ return b > > main = do bl <- mapM readBit ["file1.txt","file2.txt"] > ? ? ? ? ?mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > ---- > > which is very expressive as it's written in applicative style. > > Each file is like the following: > > ---- file1.txt ---- > 1 > foo > ---- > > I've created a separate IO action for reading the body in the hope > that it wouldn't get executed when the file list is sorted. But, to my > surprise, it didn't work as the trace message gets written for each > file before the summary is displayed. > > Thinking about this, I came to the conclusion that the IO Monad is > enforcing proper IO ordering so that the IO action for file1's body > must be executed right before IO action for file2's index one. > > If this is true, the only solution that came into my mind was to wrap > the IO action for reading the body in an unsafePerformIO call. I > actually ran the program with this modification and it works properly. > > So, as using unsafePerformIO is a Great Evil (TM), I'm wondering if > there's a different way to do this which doesn't rely on retyping body > as an IO action returning a String, which would break my pure code > manipulating the files. > > My opinion is that using unsafePerformIO here is like ensuring the > compiler that there're no observable side effects in running the IO > action for reading the body and that no other side effects would > impact this IO action. > > Thank you for any thoughts. > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Svein Ove Aas From cristiano.paris at gmail.com Tue Sep 15 15:29:24 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Tue Sep 15 15:08:25 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152113.02587.daniel.is.fischer@web.de> References: <200909152113.02587.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 9:13 PM, Daniel Fischer wrote: > ... > Still, the body should be read lazily. > I'm not sure, but the tracing message may be output because of its position. > > With > > where > ? ?readBody = withFile fn ReadMode $ \h -> do > ? ? ? ?b <- hGetContents h > ? ? ? ?seq b $ return (trace ("Read body from: " ++ fn) b) > > there's no tracing output. Impressive as I can't spot the difference. But my question is: is the chunk of data actually read or not? Consider the following code: ---- readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) <*> readBody where readBody = trace "In readBody" $ withFile fn ReadMode $ \h -> do b <- hGetContents h seq b $ return $ trace ("Read body from: " ++ fn) b ---- The message "In readBody" gets written, while "Read body from..." don't. So? I think that the IO action is actually performed but the result is simply discarded. Am I right? Cristiano From daniel.is.fischer at web.de Tue Sep 15 15:29:18 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 15:09:07 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152113.02587.daniel.is.fischer@web.de> References: <200909152113.02587.daniel.is.fischer@web.de> Message-ID: <200909152129.18789.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: > Still, the body should be read lazily. > I'm not sure, but the tracing message may be output because of its > position. > > With > > where > ? ? readBody = withFile fn ReadMode $ \h -> do > ? ? ? ? b <- hGetContents h > ? ? ? ? seq b $ return (trace ("Read body from: " ++ fn) b) > > there's no tracing output. Yes, tested with -rw-r--r-- 1 me users 243M 15. Sep 21:17 file1.txt -rw-r--r-- 1 me users 243M 15. Sep 21:18 file2.txt original: ./cparis2 +RTS -Sstderr Alloc Copied Live GC GC TOT TOT Page Flts bytes bytes bytes user elap user elap Read body: file1.txt Read body: file2.txt 2 3 427996 1408 18620 0.00 0.00 0.00 0.00 0 0 (Gen: 1) 4096 0.00 0.00 432,092 bytes allocated in the heap 1,408 bytes copied during GC 18,620 bytes maximum residency (1 sample(s)) 22,340 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 0 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.00s ( 0.00s elapsed) GC time 0.00s ( 0.00s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.00s ( 0.00s elapsed) %GC time 0.0% (8.3% elapsed) Alloc rate 432,092,000,000 bytes per MUT second Productivity 100.0% of total user, 0.1% of total elapsed moved trace: ./CParis +RTS -Sstderr Alloc Copied Live GC GC TOT TOT Page Flts bytes bytes bytes user elap user elap 2 3 426100 1408 18476 0.00 0.00 0.00 0.00 0 0 (Gen: 1) 4096 0.00 0.00 430,196 bytes allocated in the heap 1,408 bytes copied during GC 18,476 bytes maximum residency (1 sample(s)) 22,484 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 0 collections, 0 parallel, 0.00s, 0.00s elapsed Generation 1: 1 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.00s ( 0.00s elapsed) GC time 0.00s ( 0.00s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.00s ( 0.00s elapsed) %GC time 0.0% (9.3% elapsed) Alloc rate 107,549,000 bytes per MUT second Productivity 100.0% of total user, 230.3% of total elapsed From cristiano.paris at gmail.com Tue Sep 15 15:34:46 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Tue Sep 15 15:13:46 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <221b53ab0909151216y6bb1525cu8b9953f2ddf4425f@mail.gmail.com> References: <221b53ab0909151216y6bb1525cu8b9953f2ddf4425f@mail.gmail.com> Message-ID: On Tue, Sep 15, 2009 at 9:16 PM, Svein Ove Aas wrote: > I have a number of suggestions, some of which conflict with each > other, so I'll just throw them out here. Let's see.. :) > First off, the IO monad does indeed enforce sequencing; that's its > primary purpose. So, unsafePerformIO can be thought as an escape to this strict rule. > However, you can ask for it to run I/O out of order, > specifically when the value the out-of-order action returns is > actually forced (used); that's lazy I/O, and is implemented using > unsafeInterleaveIO. I imagined that. But I hate to have to use unsafePerformIO when hGetContets is already using it. > You would not usually use unsafeInterleaveIO directly, though. That's the point. > Instead, you'd use an existing wrapper, such as hGetContents. (for > Strings, or lazy bytestrings; the strict bytestring variant reasonably > has a strict semantics) > > One thing to keep in mind about lazy I/O is that the I/O in question > can run at any arbitrary time, or not at all; not more than once, > though. You must make sure this is safe. For file input, that > basically means the file should not change during the program's > lifetime. Ok. > hGetLine is not lazy in this way, but the hGetContents you use is. I'm > not sure whether this means your program should work as-is, and I'm > not going to examine it closely enough to tell - as you mentioned it's > a mockup anyway. Besides.. > > Strings are also *slow*. What you want for I/O is, when reasonably > possible, bytestrings. You'd then use parsec-bytestring, or if > possible Data.Binary, to parse said bytestring; the latter is faster > (..probably), if more limited in function. Yes, that was only a first attempt, kind of prototype... > You could use the lazy bytestring hGetContents for this. However... > > There is also a bytestring-mmap package on hackage, which outsources > the decision of what blocks to load into memory to the OS, and has the > best performance overall. Use this. > > > Oh. And unsafePerformIO is a trap that will kill you. See > http://www.girlgeniusonline.com/comic.php?date=20070725 for details. Thank you for the link. Cristiano From svein.ove at aas.no Tue Sep 15 15:39:17 2009 From: svein.ove at aas.no (Svein Ove Aas) Date: Tue Sep 15 15:17:58 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <221b53ab0909151216y6bb1525cu8b9953f2ddf4425f@mail.gmail.com> Message-ID: <221b53ab0909151239s50da47fdyf7b9e91a71a6516f@mail.gmail.com> As a general sort of warning, do not use hGetContents (or lazy i/o, in general) in combination with withFile. withFile closes the handle when the program lexically exits its scope. However, when using hGetContents, the file contents will not be read until after you do this, and will therefore fail to be read at all; I'm not sure whether this will produce a truncated string or an exception. Instead, use openFile directly. Handles have (ISTR) finalizers on them, and so should be automatically closed if you lose hold of one.. eventually. getContents of course closes it once it hits EOF, but that isn't exactly reliable. If that isn't satisfactory, use strict I/O. It's less convenient, but it's also easier to reason about. -- Svein Ove Aas From cristiano.paris at gmail.com Tue Sep 15 15:41:04 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Tue Sep 15 15:20:06 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <221b53ab0909151239s50da47fdyf7b9e91a71a6516f@mail.gmail.com> References: <221b53ab0909151216y6bb1525cu8b9953f2ddf4425f@mail.gmail.com> <221b53ab0909151239s50da47fdyf7b9e91a71a6516f@mail.gmail.com> Message-ID: On Tue, Sep 15, 2009 at 9:39 PM, Svein Ove Aas wrote: > As a general sort of warning, do not use hGetContents (or lazy i/o, in > general) in combination with withFile. > > withFile closes the handle when the program lexically exits its scope. > However, when using hGetContents, the file contents will not be read > until after you do this, and will therefore fail to be read at all; > I'm not sure whether this will produce a truncated string or an > exception. A truncated string. I already encountered such a scenario. > Instead, use openFile directly. Handles have (ISTR) finalizers on > them, and so should be automatically closed if you lose hold of one.. > eventually. getContents of course closes it once it hits EOF, but that > isn't exactly reliable. > > If that isn't satisfactory, use strict I/O. It's less convenient, but > it's also easier to reason about. Thank you. Cristiano From ekmett at gmail.com Tue Sep 15 16:00:56 2009 From: ekmett at gmail.com (Edward Kmett) Date: Tue Sep 15 15:39:40 2009 Subject: [Haskell-cafe] Do I have this right? "Remembering" Memoization! In-Reply-To: References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> Message-ID: <7fb8f82f0909151300v20b9e8bdke8dce48f1e8b3a7c@mail.gmail.com> I agree with what you meant, but not quite with what you said. To be pedantic: > import Debug.Trace > foo :: Int > foo = trace "Foo" (bar 12) > bar :: Int -> Int > bar x = trace "Bar" x > main :: IO () > main = foo `seq` foo `seq` return () main prints "Foo\nBar\n" showing that the bar is only evaluated once, because foo is already evaluated, even though it is referenced twice. So attempting to evaluate foo again just returns the same result. > baz :: Int -> Int > baz x = trace "Baz" (bar x) > correct :: IO () > correct = baz 10 `seq` baz 11 `seq` return () Though, as you said, call, you probably meant foo was a function, and correct prints "Baz\nBar\nBaz\nBar\n" like you had indicated. But pedantically even the function: > quux :: Int -> Int > quux x = trace "Quux" (bar 12) > optmain :: IO () > optmain = quux 10 `seq` quux 11 `seq` return () might print only once if GHC at the optimization level selected recognizes that quux doesn't depend on its argument and rewrote your code with more sharing. -Edward Kmett On Sun, Sep 13, 2009 at 7:45 PM, Mark Wotton wrote: > > On 14/09/2009, at 9:28 AM, Casey Hawthorne wrote: > > Do I have this right? "Remembering" Memoization! >> >> For some applications, a lot of state does not to be saved, since >> "initialization" functions can be called early, and these functions >> will "remember" - (memoize) their results when called again, because >> of lazy evaluation? >> > > You don't get memoisation for free. > If you define a variable once in a where block, it's true that you'll > evaluate it at most once, but if you repeatedly call a function "foo" that > then calls "bar 12" each time, "bar 12" will be evaluated once per "foo" > call. > > Cheers > Mark > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/7d2f200b/attachment.html From kili at outback.escape.de Tue Sep 15 16:06:36 2009 From: kili at outback.escape.de (Matthias Kilian) Date: Tue Sep 15 15:45:45 2009 Subject: [Haskell-cafe] (weird stuff) Kernel Modules in Haskell ;-) Message-ID: <20090915200636.GA6087@petunia.outback.escape.de> A fellow openbsd developer told me the URL below... I hope this hasn't been posted on this list already (at least I didn't find it in my local archives): http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ Ciao, Kili -- Logging should be in debug mode only. If every network driver did a dmesg printf everytime they came up, would that be a better world? -- Theo de Raadt From frodo at theshire.org Tue Sep 15 16:08:46 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 15:47:46 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152129.18789.daniel.is.fischer@web.de> References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 9:29 PM, Daniel Fischer wrote: > Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: >> Still, the body should be read lazily. >> I'm not sure, but the tracing message may be output because of its >> position. >> >> With >> >> where >> ? ? readBody = withFile fn ReadMode $ \h -> do >> ? ? ? ? b <- hGetContents h >> ? ? ? ? seq b $ return (trace ("Read body from: " ++ fn) b) >> >> there's no tracing output. > > Yes, tested with > -rw-r--r-- 1 me users 243M 15. Sep 21:17 file1.txt > -rw-r--r-- 1 me users 243M 15. Sep 21:18 file2.txt Ok, Daniel, I got the point: the IO action gets performed but there's no need to use unsafePerformIO as hGetContents is already lazy and the IO action is "ineffective" anyway when the result is not needed. Yet, I'm still confused as "seq b" should force the complete execution of hGetContents. So I decided to run a different test: I'm using this code: --- module Main where import System.IO import System.IO.Unsafe import Control.Applicative import Data.List import Data.Ord import Debug.Trace data Bit = Bit { index :: Integer, body :: String } readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) <*> readBody where readBody = trace "In readBody" $ withFile fn ReadMode $ \h -> do b <- hGetContents h seq b $ return $ trace ("Read body from: " ++ fn) b main = do bl <- mapM readBit ["file1.txt","file2.txt"] mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl putStrLn $ body $ head bl ---- (Hope this looks better than before). I ran this on a 115KB-long file1.txt file and traced with dtruss (OSX strace equivalent). You know what? Only the first 1024 bytes of file1.txt are read and actually displayed. So, it seems that "seq b" is completely ineffective and program is not correct. Cristiano From frodo at theshire.org Tue Sep 15 16:11:50 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 15:50:51 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris wrote: > ... > So, it seems that "seq b" is completely ineffective and program is not correct. Correction: removing "seq b" results in nothing being displayed :) So, it's not "completely" effective. I suspect this is related to the fact that a String in Haskell is just a list of Char so we should use seq on every element of b. Let me try... Cristiano From rmm-haskell at z.odi.ac Tue Sep 15 16:12:21 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Sep 15 15:51:08 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> Message-ID: <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> Wouldn't seq b only force (at minimum) the first character of the file? -Ross On Sep 15, 2009, at 4:08 PM, Cristiano Paris wrote: > On Tue, Sep 15, 2009 at 9:29 PM, Daniel Fischer > wrote: >> Am Dienstag 15 September 2009 21:13:02 schrieb Daniel Fischer: >>> Still, the body should be read lazily. >>> I'm not sure, but the tracing message may be output because of its >>> position. >>> >>> With >>> >>> where >>> readBody = withFile fn ReadMode $ \h -> do >>> b <- hGetContents h >>> seq b $ return (trace ("Read body from: " ++ fn) b) >>> >>> there's no tracing output. >> >> Yes, tested with >> -rw-r--r-- 1 me users 243M 15. Sep 21:17 file1.txt >> -rw-r--r-- 1 me users 243M 15. Sep 21:18 file2.txt > > Ok, Daniel, I got the point: the IO action gets performed but there's > no need to use unsafePerformIO as hGetContents is already lazy and the > IO action is "ineffective" anyway when the result is not needed. Yet, > I'm still confused as "seq b" should force the complete execution of > hGetContents. So I decided to run a different test: > > I'm using this code: > > --- > module Main where > > import System.IO > import System.IO.Unsafe > import Control.Applicative > import Data.List > import Data.Ord > > import Debug.Trace > > data Bit = Bit { index :: Integer, body :: String } > > readBit fn = > withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) > <*> readBody > where readBody = trace "In readBody" > $ withFile fn ReadMode > $ \h -> do b <- hGetContents h > seq b $ return $ trace ("Read body > from: " ++ fn) b > > main = do bl <- mapM readBit ["file1.txt","file2.txt"] > mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > putStrLn $ body $ head bl > ---- > > (Hope this looks better than before). > > I ran this on a 115KB-long file1.txt file and traced with dtruss (OSX > strace equivalent). You know what? Only the first 1024 bytes of > file1.txt are read and actually displayed. > > So, it seems that "seq b" is completely ineffective and program is > not correct. > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From frodo at theshire.org Tue Sep 15 16:17:00 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 15:57:08 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> Message-ID: On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren wrote: > Wouldn't seq b only force (at minimum) the first character of the file? I think it force the evaluation of the "Cons" in the String but not the characters therein. Cristiano From rmm-haskell at z.odi.ac Tue Sep 15 16:20:20 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Sep 15 15:59:05 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> Message-ID: <91633A0B-F80C-4771-B6B7-C58C79C1F2E0@z.odi.ac> Ah yeah, that too. Control.Parallel.Strategies.rnf to the rescue? -Ross On Sep 15, 2009, at 4:17 PM, Cristiano Paris wrote: > On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren haskell@z.odi.ac> wrote: >> Wouldn't seq b only force (at minimum) the first character of the >> file? > > I think it force the evaluation of the "Cons" in the String but not > the characters therein. > > Cristiano From rmm-haskell at z.odi.ac Tue Sep 15 16:20:56 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Tue Sep 15 15:59:38 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <91633A0B-F80C-4771-B6B7-C58C79C1F2E0@z.odi.ac> References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> <91633A0B-F80C-4771-B6B7-C58C79C1F2E0@z.odi.ac> Message-ID: <211F5D1A-D2D6-46BF-9C42-F32411C19B76@z.odi.ac> Ack, IGNORE ME! Way too strict. -Ross On Sep 15, 2009, at 4:20 PM, Ross Mellgren wrote: > Ah yeah, that too. Control.Parallel.Strategies.rnf to the rescue? > > -Ross > > On Sep 15, 2009, at 4:17 PM, Cristiano Paris wrote: > >> On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren > haskell@z.odi.ac> wrote: >>> Wouldn't seq b only force (at minimum) the first character of the >>> file? >> >> I think it force the evaluation of the "Cons" in the String but not >> the characters therein. >> >> Cristiano > From ekmett at gmail.com Tue Sep 15 16:21:11 2009 From: ekmett at gmail.com (Edward Kmett) Date: Tue Sep 15 15:59:55 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: <4AAF7EF2.9050203@btinternet.com> References: <4AAF7EF2.9050203@btinternet.com> Message-ID: <7fb8f82f0909151321t2453c0ado7281a91e15ee4e6e@mail.gmail.com> Block, line or 'beam' decomposition tends to work well for raytracing tasks, because they tend to give you a good cache locality and don't create a ridiculous explosion of parallel jobs. You'll need to do some tuning to figure out the right granularity for the decomposition. But typically a few hundred tasks works a lot better than tens of thousands or millions. You need to balance the tension between having too much overhead maintaining the decomposition with wasted work from lumpy task completion times and coarse grain sizes. Unfortunately, using Haskell it is hard to do what you can do, say, in C++ with Intel Thread Building Blocks to get a self-tuning decomposition of your range, which self-tunes by splitting stolen tasks. You don't get the same visibility into whether or not the task you are doing was stolen from elsewhere when using GHC's sparks. -Edward Kmett On Tue, Sep 15, 2009 at 7:48 AM, Andrew Coppin wrote: > I have a number of compute-bound graphics programs written in Haskell. > (Fractal generators, ray tracers, that kind of thing.) GHC offers several > concurrency and parallelism abstractions, but what's the best way to use > these to get images rendered as fast as possible, using the available > compute power? > > (OK, well the *best* way is to use the GPU. But AFAIK that's still a > theoretical research project, so we'll leave that for now.) > > I've identified a couple of common cases. You have a 2D grid of points, and > you want to compute the value at each point. Eventually you will have a grid > of *pixels* where each value is a *colour*, but there may be intermediate > steps before that. So, what cases exist? > > 1. A point's value is a function of its coordinates. > > 2. A point's value is a function of its previous value from the last frame. > > 3. A point's value is a function of *several* points from the last frame. > > How can we accelerate this? I see a few options: > > - Create a spark for every point in the grid. > - Create several explicit threads to populate non-overlapping regions of > the grid. > - Use parallel arrays. (Does this actually works yet??) > > I'm presuming that sparking every individual point is going to create > billions of absolutely tiny sparks, which probably won't give great > performance. We could spark every line rather than every point? > > Using explicit threads has the nice side-effect that we can produce > progress information. Few things are more frustrating than staring at a > blank screen with no idea how long it's going to take. I'm thinking this > method might also allow you to avoid two cores tripping over each other's > caches. > > And then there's parallel arrays, which presumably are designed from the > ground up for exactly this type of task. But are they usable yet? > > Any further options? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/e11f4d96/attachment-0001.html From frodo at theshire.org Tue Sep 15 16:25:31 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:04:32 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 10:11 PM, Cristiano Paris wrote: > On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris wrote: >> ... >> So, it seems that "seq b" is completely ineffective and program is not correct. > > Correction: removing "seq b" results in nothing being displayed :) > > So, it's not "completely" effective. I suspect this is related to the > fact that a String in Haskell is just a list of Char so we should use > seq on every element of b. Let me try... Now it works as expected: --- module Main where import System.IO import System.IO.Unsafe import Control.Applicative import Data.List import Data.Ord import Debug.Trace data Bit = Bit { index :: Integer, body :: String } readBit fn = withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) <*> readBody where readBody = trace "In readBody" $ withFile fn ReadMode $ \h -> do b <- hGetContents h let b' = foldr (\e a -> seq e (a ++ [e])) [] b seq b' $ return $ trace ("Read body from: " ++ fn) b' main = do bl <- mapM readBit ["file1.txt","file2.txt"] mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl putStrLn $ body $ head bl ---- Two points: 1 - I had to cut off file1.txt to be just above 1024 bytes otherwise the program becomes extremely slow even on a 100KB file with a line being output every 5 seconds and with my CPU being completely busy (I'm using a modern MacBook Pro). 2 - Omitting the last line in my program actually causes the body to be completely read even if it's not used: this is consistent with my hypotesis on seq which now works properly. :) Cristiano From frodo at theshire.org Tue Sep 15 16:27:01 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:06:02 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <211F5D1A-D2D6-46BF-9C42-F32411C19B76@z.odi.ac> References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> <91633A0B-F80C-4771-B6B7-C58C79C1F2E0@z.odi.ac> <211F5D1A-D2D6-46BF-9C42-F32411C19B76@z.odi.ac> Message-ID: On Tue, Sep 15, 2009 at 10:20 PM, Ross Mellgren wrote: > Ack, IGNORE ME! Way too strict. Oh, well, I used foldr+seq to achieve the same result... I think, but I think that, if this is the solution, I'll use rnf as I did on other occasions. Thanks. Cristiano From frodo at theshire.org Tue Sep 15 16:30:52 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:09:53 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152113.02587.daniel.is.fischer@web.de> <200909152129.18789.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 10:25 PM, Cristiano Paris wrote: > ... > Two points: > > 1 - I had to cut off file1.txt to be just above 1024 bytes otherwise > the program becomes extremely slow even on a 100KB file with a line > being output every 5 seconds and with my CPU being completely busy > (I'm using a modern MacBook Pro). GC in charge here. Using "foldl" resolves the problem. Maybe too many thunks are being created on the stack... Cristiano From daniel.is.fischer at web.de Tue Sep 15 16:29:47 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 16:10:30 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> Message-ID: <200909152229.47613.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 22:17:00 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:12 PM, Ross Mellgren wrote: > > Wouldn't seq b only force (at minimum) the first character of the file? > > I think it force the evaluation of the "Cons" in the String but not > the characters therein. It evaluates the String far enough to know whether it's "" or (_:_), that is, to weak head normal form. It doesn't look at any character, but it forces at least one character to be read from the file. > > Cristiano From frodo at theshire.org Tue Sep 15 16:35:58 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:15:00 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152229.47613.daniel.is.fischer@web.de> References: <977D181D-AD30-4231-BEF6-39A8935E959E@z.odi.ac> <200909152229.47613.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 10:29 PM, Daniel Fischer wrote: > ... > It evaluates the String far enough to know whether it's "" or (_:_), that is, to weak head > normal form. It doesn't look at any character, but it forces at least one character to be > read from the file. Yep, the head. That explains why only the first 1024 bytes are read and displayed... Cristiano From daniel.is.fischer at web.de Tue Sep 15 16:42:49 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 16:24:59 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: Message-ID: <200909152242.50033.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 22:25:31 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:11 PM, Cristiano Paris wrote: > > On Tue, Sep 15, 2009 at 10:08 PM, Cristiano Paris wrote: > >> ... > >> So, it seems that "seq b" is completely ineffective and program is not > >> correct. > > > > Correction: removing "seq b" results in nothing being displayed :) > > > > So, it's not "completely" effective. I suspect this is related to the > > fact that a String in Haskell is just a list of Char so we should use > > seq on every element of b. Let me try... > > Now it works as expected: > > --- > module Main where > > import System.IO > import System.IO.Unsafe > import Control.Applicative > import Data.List > import Data.Ord > > import Debug.Trace > > data Bit = Bit { index :: Integer, body :: String } > > readBit fn = > withFile fn ReadMode $ \h -> Bit <$> (hGetLine h >>= return . read) > <*> readBody > where readBody = trace "In readBody" > $ withFile fn ReadMode > $ \h -> do b <- hGetContents h > let b' = foldr (\e a -> seq e (a ++ [e])) [] b Aaawww. let b' = length b or let b' = foldl' seq () b or let b' = b `using` rnf if you want to force the whole file to be read. But then you should definitely be using ByteStrings. > seq b' $ return $ trace ("Read body from: " ++ fn) b' > > main = do bl <- mapM readBit ["file1.txt","file2.txt"] > mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > putStrLn $ body $ head bl > ---- > > Two points: > > 1 - I had to cut off file1.txt to be just above 1024 bytes otherwise > the program becomes extremely slow even on a 100KB file with a line > being output every 5 seconds and with my CPU being completely busy > (I'm using a modern MacBook Pro). > > 2 - Omitting the last line in my program actually causes the body to > be completely read even if it's not used: this is consistent with my > hypotesis on seq which now works properly. > > :) > > Cristiano From frodo at theshire.org Tue Sep 15 17:00:40 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:41:13 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152242.50033.daniel.is.fischer@web.de> References: <200909152242.50033.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 10:42 PM, Daniel Fischer wrote: > .... > Aaawww. > let b' = length b > or > let b' = foldl' seq () b > or > let b' = b `using` rnf > > if you want to force the whole file to be read. But then you should definitely be using > ByteStrings. Yep. But that doesn't solve the original problem of not reading the body at all when not needed. Unless using unsafePerformIO. Cristiano From felipe.lessa at gmail.com Tue Sep 15 17:11:52 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Tue Sep 15 16:50:39 2009 Subject: [Haskell-cafe] Announce: EnumMap-0.0.1 In-Reply-To: References: <87zla73ip7.fsf@malde.org> <20090810140918.GA26102@kira.casa> <87ocqlzhot.fsf@malde.org> <49a77b7a0908120834g3369a8e2l4082a45ca5c15e89@mail.gmail.com> <49a77b7a0908120958t6e3f8a34u88e45a3ab43537fe@mail.gmail.com> <20090914162707.GA27424@kira> Message-ID: <20090915211152.GA23132@kira.casa> On Mon, Sep 14, 2009 at 11:32:04PM -0400, John Van Enk wrote: > http://hackage.haskell.org/package/EnumMap > > Changes pushed. Job Vranish added the SPECIALIZE pragmas, and I believe he > has more data concerning how much this helps. Thanks a lot! :) -- Felipe. From frodo at theshire.org Tue Sep 15 17:13:59 2009 From: frodo at theshire.org (Cristiano Paris) Date: Tue Sep 15 16:53:02 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <25251783.post@talk.nabble.com> References: <25250783.post@talk.nabble.com> <5e0214850909012020i687d9de8mf6eb4f199f9a0832@mail.gmail.com> <25251783.post@talk.nabble.com> Message-ID: On Wed, Sep 2, 2009 at 7:16 AM, zaxis wrote: > > Isnot it clear without the 'forall' ? > data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok st > b) > > thanks! I elaborated on this and I wish to add my personal way of figuring out what the "forall" keyword means. When you define: foo :: a -> a you are actually defining a _function for every type of a_, which can be read: for every a there exists a function foo which can operate on it (universal quantification). When you define something like: foo :: forall a. a -> a you are actually defining a _single_ function which must work for every a (that's why we use the "forall" keyword). The difference is subtle but the direct consequences of this are: a) that one function can't use any information about a apart from the fact that it eventually belongs to the type classes specified in the context, b) in the case of [a] (or any other type of higher kind, * -> *, * -> * -> * and so on) you can mix values of different types. I hope I haven't written anything wrong :) Cristiano From daniel.is.fischer at web.de Tue Sep 15 17:31:09 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 17:10:58 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152242.50033.daniel.is.fischer@web.de> Message-ID: <200909152331.09797.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 23:00:40 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 10:42 PM, Daniel Fischer > > wrote: > > .... > > Aaawww. > > let b' = length b > > or > > let b' = foldl' seq () b > > or > > let b' = b `using` rnf > > > > if you want to force the whole file to be read. But then you should > > definitely be using ByteStrings. > > Yep. But that doesn't solve the original problem of not reading the > body at all when not needed. Unless using unsafePerformIO. Yeah, you do *not* want the whole file to be read here, except above for testing purposes. Still, ByteStrings are probably the better choice (if you want the body and that can be large). To avoid reading the body without unsafePerformIO: readBit fn = Control.Exception.bracket (openFile fn ReadMode) hClose (\h -> do l <- hGetLine h let i = read l bdy <- hGetContents h return $ Bit i bdy) > > Cristiano From namekuseijin at gmail.com Tue Sep 15 17:39:39 2009 From: namekuseijin at gmail.com (namekuseijin) Date: Tue Sep 15 17:18:19 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: <4AAF7EF2.9050203@btinternet.com> References: <4AAF7EF2.9050203@btinternet.com> Message-ID: <67d0527e0909151439o201b7861k4d11675016bd19ec@mail.gmail.com> On Tue, Sep 15, 2009 at 8:48 AM, Andrew Coppin wrote: > Using explicit threads has the nice side-effect... side-effects are bad! ;-) From daniel.is.fischer at web.de Tue Sep 15 17:38:40 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 15 17:19:41 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> Message-ID: <200909152338.41603.daniel.is.fischer@web.de> Am Dienstag 15 September 2009 23:13:59 schrieb Cristiano Paris: > On Wed, Sep 2, 2009 at 7:16 AM, zaxis wrote: > > Isnot it clear without the 'forall' ? > > data Branch tok st a = Branch (PermParser tok st (b -> a)) (GenParser tok > > st b) > > > > thanks! > > I elaborated on this and I wish to add my personal way of figuring out > what the "forall" keyword means. > > When you define: > > foo :: a -> a > > you are actually defining a _function for every type of a_, which can > be read: for every a there exists a function foo which can operate on > it (universal quantification). > > When you define something like: > > foo :: forall a. a -> a This is exactly the same type as foo :: a -> a (unless you're using ScopedTypeVariables and there's a type variable a in scope), since type signatures are implicitly forall'd. > > you are actually defining a _single_ function which must work for > every a (that's why we use the "forall" keyword). The difference is > subtle but the direct consequences of this are: a) that one function > can't use any information about a apart from the fact that it > eventually belongs to the type classes specified in the context, b) in > the case of [a] (or any other type of higher kind, * -> *, * -> * -> * > and so on) you can mix values of different types. > > I hope I haven't written anything wrong :) > > Cristiano From derek.a.elkins at gmail.com Tue Sep 15 17:59:19 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Sep 15 17:37:58 2009 Subject: [Haskell-cafe] Do I have this right? "Remembering" Memoization! In-Reply-To: <7fb8f82f0909151300v20b9e8bdke8dce48f1e8b3a7c@mail.gmail.com> References: <25420972.post@talk.nabble.com> <1891029369.20090913105854@gmail.com> <26359f49-5a82-4eee-9a5b-5b30be34ef30@j19g2000yqk.googlegroups.com> <7fb8f82f0909151300v20b9e8bdke8dce48f1e8b3a7c@mail.gmail.com> Message-ID: <61f84eff0909151459q8578763kcfb408cf066ce09b@mail.gmail.com> > But pedantically even the function: > >> quux :: Int -> Int >> quux x = trace "Quux" (bar 12) > >> optmain :: IO () >> optmain = quux 10 `seq` quux 11 `seq` return () > > might print only once if GHC at the optimization level selected recognizes > that quux doesn't depend on its argument and rewrote your code with more > sharing. Well to be specific, it depends on how you define "function", quux :: Int -> Int quux = trace "Quux" bar will print "Quux" once under the naive semantics. From derek.a.elkins at gmail.com Tue Sep 15 18:10:50 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Sep 15 17:49:30 2009 Subject: [Haskell-cafe] What does it mean that objects are fixpoints? (OO'Haskell) In-Reply-To: <37707ed10909150814s544e75d5o18d0413d4ec5d8e4@mail.gmail.com> References: <37707ed10909150814s544e75d5o18d0413d4ec5d8e4@mail.gmail.com> Message-ID: <61f84eff0909151510p433b17ddl77ab3c12d673e5ea@mail.gmail.com> On Tue, Sep 15, 2009 at 10:14 AM, Manuel Simoni wrote: > Hello! > > I'm trying to wrap my head around OO'Haskell's notion of objects as fixpoints. > > Is OO'Haskell's use of mfix simply a use of something like a monadic > Y-combinator to give the object access to its own "identity"? More or less, yes. To define 'self' or 'this'. From ryan at peerium.com Tue Sep 15 18:27:05 2009 From: ryan at peerium.com (Ryan Wisnesky) Date: Tue Sep 15 18:05:45 2009 Subject: [Haskell-cafe] loading object code with ghci Message-ID: Hello, I'm having some trouble correctly linking to externally generated object code when using ghci. I'm loading a Cabal package Foo, that has already been successfully installed: >ghci -package Foo ghc-6.8.3: unknown symbol `_iceExePath' Loading package Foo-0.1 ... linking ... ghc-6.8.3: unable to load package `Foo-0.1' I have a file Bar.o which contains the definition of _iceExePath: >nm ./Bar.o ... U _ProcessInformationCopyDictionary 000000a0 b _exepath 00000000 T _iceExePath U _kCFBundleExecutableKey ... The documentation at http://www.haskell.org/ghc/docs/6.8.3/html/users_guide/ghci-invocation.html#id307468 says that: "GHCi can also load plain object files (.o or .obj depending on your platform) from the command-line. Just add the name the object file to the command line." So, I've tried both of these command lines: > ghci ./Bar.o -package Foo > ghci -package Foo ./Bar.o but ghci still can't find _iceExePath, and the same error occurs. I'm using GHC 6.8.3. I'm not sure how to proceed and would appreciate any advice. Thanks for your help, Ryan Wisnesky -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/7aaef628/attachment.html From ia at stryx.demon.co.uk Tue Sep 15 19:03:43 2009 From: ia at stryx.demon.co.uk (Iain Alexander) Date: Tue Sep 15 18:44:43 2009 Subject: [Haskell-cafe] algebra/grammar/language for expressing time intervals In-Reply-To: <60F6D84E-DE43-4E7F-95A0-96099AD41F7D@n-heptane.com> Message-ID: <4AB02B5F.29038.3713D69@ia.stryx.demon.co.uk> You might want to take a look at RFC 2445 Internet Calendaring and Scheduling Core Object Specification Section 4.8.5.4 Recurrence Rule -- Iain Alexander ia@stryx.demon.co.uk From dave at zednenem.com Tue Sep 15 21:07:13 2009 From: dave at zednenem.com (David Menendez) Date: Tue Sep 15 20:45:53 2009 Subject: [Haskell-cafe] Building a monoid, continuation-passing style In-Reply-To: <4AAE6068.4050702@van.steenbergen.nl> References: <4AAE6068.4050702@van.steenbergen.nl> Message-ID: <49a77b7a0909151807j436fe6f0wcf71a06f24d632ad@mail.gmail.com> On Mon, Sep 14, 2009 at 11:25 AM, Martijn van Steenbergen wrote: > Inspired by Sean Leather's xformat package [1] I built a datatype with which > you can build a monoid with holes, yielding a function type to fill in these > holes, continuation-passing style. Neat! > I have a couple of questions: > * ContSt is a Category. Is it also an Arrow? Why (not)? I think it isn't. To be an Arrow, you need a definition for first, and to write first you need to be able to transform a function of type f r -> a into a function of type f (r,b) -> (a,b), which I'm pretty sure is impossible. > * What is its relation with the Cont and Reader monads? I'm reminded of the parameterized monad of continuations that Oleg mentioned a few years back. Here's one way of expressing it: class Paramonad m where ret :: a -> m x x a bind :: m x y a -> (a -> m y z b) -> m x z b liftP2 :: (Paramonad m) => (a -> b -> c) -> m x y a -> m y z b -> m x z c liftP2 (*) m1 m2 = m1 `bind` \a -> m2 `bind` \b -> ret (a * b) newtype Cont x y a = Cont { runCont :: (a -> y) -> x } run :: Cont x a a -> x run m = runCont m id instance Paramonad Cont where ret a = Cont $ \k -> k a m `bind` f = Cont $ \k -> runCont m (\a -> runCont (f a) k) shift :: ((a -> Cont z z y) -> Cont x b b) -> Cont x y a shift f = Cont $ \k -> run $ f (ret . k) (<>) :: Monoid m => Cont x y m -> Cont y z m -> Cont x z m (<>) = liftP2 mappend later :: (a -> m) -> Cont (a -> r) r m later f = shift $ \k -> ret (run . k . f) -- equivalently, -- later f = Cont $ \k -> k . f > run (ret "x" <> ret "y") "xy" > run (ret "x" <> later id) "y" "xy" and so forth. In fact, this is a good candidate for an alternative implementation. newtype ContSt m r a = ContSt (Cont a r m) It would be interesting to compare their relative efficiency. > * ContSt is a horrible name. What is a better one? HoleyMonoid? -- Dave Menendez From derek.a.elkins at gmail.com Tue Sep 15 21:17:09 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Tue Sep 15 20:55:51 2009 Subject: [Haskell-cafe] Building a monoid, continuation-passing style In-Reply-To: <4AAE6068.4050702@van.steenbergen.nl> References: <4AAE6068.4050702@van.steenbergen.nl> Message-ID: <61f84eff0909151817r19c53810la4dc080e03a3ea68@mail.gmail.com> On Mon, Sep 14, 2009 at 10:25 AM, Martijn van Steenbergen wrote: > Hello cafe, > > Inspired by Sean Leather's xformat package [1] I built a datatype with which > you can build a monoid with holes, yielding a function type to fill in these > holes, continuation-passing style. Here are some primitives and their types: > >> now ? :: m -> ContSt m r r >> later :: (a -> m) -> ContSt m r (a -> r) >> run ? :: ContSt m m r -> r >> instance Monoid m => Category (ContSt m) > > Here's an example of how to use it: > >> run (now "hello" . now "world") > > "helloworld" > >> run (later id . now "world") "hello" > > "helloworld" > >> run (later id . later show) "hello" 567 > > "hello567" > > The source code is available at [2]. > > I have a couple of questions: > * ContSt is a Category. Is it also an Arrow? Why (not)? > * Did I miss any other obvious classes this type is an instance of? > * What is its relation with the Cont and Reader monads? > * Are there any other useful applications other than printf-like > functionality? > * ContSt is a horrible name. What is a better one? > > For those who have a bit more time: I appreciate any comments and > suggestions on the code. :-) I believe this technique is based on a technique introduced in Olivier Danvy's "Functional Unparsing". While not immediately applicable to Haskell unless you want to make/use a delimited continuation monad, you may find the paper "On Typing Delimited Continuations: Three New Solutions to the Printf Problem" by Kenichi Asai interesting. It is available at the following url: http://pllab.is.ocha.ac.jp/~asai/papers/papers.html From alp at mestan.fr Tue Sep 15 23:59:12 2009 From: alp at mestan.fr (Alp Mestan) Date: Tue Sep 15 23:37:51 2009 Subject: [Haskell-cafe] adding state in GUIs (qtHaskell) In-Reply-To: <4AAA7306.7050301@gmail.com> References: <4AA8567D.20206@alumni.caltech.edu> <1252615434.5266.7115.camel@localhost> <4AA96C0F.6070302@alumni.caltech.edu> <4AAA7306.7050301@gmail.com> Message-ID: On Fri, Sep 11, 2009 at 5:55 PM, Jeremy O'Donoghue < jeremy.odonoghue@gmail.com> wrote: > > > I don't have anything as neat to show you as Duncan's suggetion (I'd also > be interested to see a cleaner way to do it - this sort of code always > grates a little with me, although all of the major Haskell GUI bindings seem > to need a similar programming style. > > However, at the most basic 'trying it out' level, I suspect that something > very like this will work just as well for qtHaskell as it does for > wxHaskell. > Regards > Jeremy > Very interesting code. However, I'd be very curious to see if qthaskell handles .ui files. And how it does. With C++, thanks to the 'uic' command line tool, we generate a class from the .ui file, and then just have to store an instance of it in our window/dialog/widget/whatever. This class has a setupUI member function, taking a QWidget*/QDialog*/QMainWindow*/whatever, which initializes all the ui components and put them on our widget just like we asked it to do in the designer. Actually, I'm wondering how the trick could be done (and if it is already done ?) in Haskell without letting too much things generated and compiled at the C++ level with some FFI magic. -- Alp Mestan http://blog.mestan.fr/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090915/39d78dc1/attachment.html From porges at porg.es Wed Sep 16 01:59:29 2009 From: porges at porg.es (George Pollard) Date: Wed Sep 16 01:38:08 2009 Subject: [Haskell-cafe] A thought about liberating Haskell's syntax Message-ID: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> Dear all, Here is a note concerning a thought I just had. I have written a rough sketch/outline and would like feedback upon this. The beginning thought: I would like to be able to write new bracket-like operators without having to rewrite GHC. (Case in point: applicative brackets.) First idea is to make them Template Haskell so we can mess with the internals (write custom list/set comprehension implementations). However a type (String ? Exp) is not good enough; parsing the String is too much work! (Think precedence, etc.) We want to be able to have something (Exp ? Exp). For this, we probably also need Template Haskell versions of normal (infix) operators, so that we can have something like: template infixr , (-1) -- lower precedence than $ a, b = if isList b then a : b else a : [b] Problem with this; [x, [y,z]] would have type :: [?] Lists constructed with ',' should have a different type from normal lists; call it QList. , :: Exp ? Exp ? Exp a, b@(AppE (ConE 'QCons) _) = a `qcons` b a, b = a `qcons` (b `qcons` QNil) where qcons a b = (ConE 'QCons) `AppE` a `AppE` b {- NB: we also need to provide implementations for type and pattern contexts, see next section. -} I believe that with this we can have the tuple and list syntax not hard-coded in. An example: -- note we need to provide the context for TH: Pattern, Expression, or Type -- no thought to sections here -- how to add tuple sections? -- perhaps relax operator rules for templates so that a, , , b is legitimate template outfix ( ) expression = (\x ? case x of (QCons _ _) ? TupE $ fromQList x _ ? x template outfix ( ) pattern = (\x ? case x of (QCons _ _) ? TupP $ fromQList x _ ? x template outfix ( ) type = (\x ? case x of (QCons _ _) ? foldl (\z x ? z `AppT` x) (TupleT (length x)) x _ ? x Anyway, we could then have easily-written syntax for; - sets - applicative brackets - parallel list comprehensions wouldn't have to be hardcoded (provide something like the above ',' but '|' returning something else. Perhaps QList should be tagged by a phantom type.) - statically-lengthed vectors Problems I can see: - QList (or other use-only-for-x types) could turn up in an actual program; l = a, b :: QList ? -- is this actually a problem? - "Hidden" rewriting/macros not really the Template Haskell way, this is more scheme-like. A further (possibly evil) extension: template outfix do {-outdent-} expression = ... >:) -- would require thinking about EOL handling/semi-colon insertion From noteed at gmail.com Wed Sep 16 02:56:34 2009 From: noteed at gmail.com (minh thu) Date: Wed Sep 16 02:35:33 2009 Subject: [Haskell-cafe] (weird stuff) Kernel Modules in Haskell ;-) In-Reply-To: <20090915200636.GA6087@petunia.outback.escape.de> References: <20090915200636.GA6087@petunia.outback.escape.de> Message-ID: <40a414c20909152356k9a9e06dga5baa9ec5f1bad42@mail.gmail.com> 2009/9/15 Matthias Kilian : > A fellow openbsd developer told me the URL below... > > I hope this hasn't been posted on this list already (at least I > didn't find it in my local archives): > > http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ I don't think it was posted here, but it was on reddit. You might want to follow it. http://www.reddit.com/r/haskell Cheers, Thu From oleg at okmij.org Wed Sep 16 02:58:39 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Wed Sep 16 02:40:35 2009 Subject: [Haskell-cafe] Re: retrieving arguments for functions from a heterogenous list Message-ID: <20090916065839.86512176DC@Adric.metnet.navy.mil> Andrew U. Frank wrote: > I have a number of functions which have some arguments and produce a single > result. all the arguments are in a heterogenous list and the results should > update the list. If I understand the problem correctly, you have a typed-indexed collection TIP and you would like to apply a transformation function to it, whose argument types and the result type are in the TIP. The function should locate its arguments based on their types, and update the TIP with the result. The function may have any number of arguments, including zero; the order of arguments should not matter. Then the following code seems to solve the problem. It starts with the examples. {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables, UndecidableInstances #-} -- Transforming a TIP: applying to a TIP a (polyvariadic) function -- that takes arguments from a TIP and updates the TIP with the result module TIPTransform where import Data.HList import Data.HList.TIP import Data.HList.TypeEqGeneric1 import Data.HList.TypeCastGeneric1 import Data.HList.Label5 newtype MyVal = MyVal Int deriving Show -- A sample TIP tip1 = MyVal 20 .*. (1::Int) .*. True .*. emptyTIP -- TIP (HCons (MyVal 20) (HCons 1 (HCons True HNil))) -- Update the Int component of tip1 to 2. The Int component must -- exist. Otherwise, it is a type error tip2 = ttip (2::Int) tip1 -- TIP (HCons (MyVal 20) (HCons 2 (HCons True HNil))) -- Negate the boolean component of tip1 tip3 = ttip not tip1 -- TIP (HCons (MyVal 20) (HCons 1 (HCons False HNil))) -- Update the Int component from the values of two other components tip4 = ttip (\(MyVal x) y -> x+y) tip1 -- TIP (HCons (MyVal 20) (HCons 21 (HCons True HNil))) -- Update the MyVal component from the values of three other components tip5 = ttip (\b (MyVal x) y -> MyVal $ if b then x+y else 0) tip1 -- TIP (HCons (MyVal 21) (HCons 1 (HCons True HNil))) -- The same but with the permuted argument order. -- The order of arguments is immaterial: the values will be looked up using -- their types tip5' = ttip (\b y (MyVal x)-> MyVal $ if b then x+y else 0) tip1 -- TIP (HCons (MyVal 21) (HCons 1 (HCons True HNil))) -- The implementation class TransTIP op db where ttip :: op -> db -> db instance (HMember op db b, TransTIP' b op (TIP db)) => TransTIP op (TIP db) where ttip = ttip' (undefined::b) class TransTIP' b op db where ttip' :: b -> op -> db -> db -- If op is found in a TIP, update the TIP with op instance (HTypeIndexed db, HUpdateAtHNat n op db db, HType2HNat op db n) => TransTIP' HTrue op (TIP db) where ttip' _ = tipyUpdate -- If op is not found in a TIP, it must be a function. Look up -- its argument in a TIP and recur. instance (HOccurs arg db, TransTIP op db) => TransTIP' HFalse (arg -> op) db where ttip' _ f db = ttip (f (hOccurs db)) db From frodo at theshire.org Wed Sep 16 04:04:48 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Sep 16 03:45:07 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <200909152338.41603.daniel.is.fischer@web.de> References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 11:38 PM, Daniel Fischer wrote: > ... >> foo :: forall a. a -> a > > This is exactly the same type as > > foo :: a -> a > > (unless you're using ScopedTypeVariables and there's a type variable a in scope), since > type signatures are implicitly forall'd. Yep, perhaps I used the wrong example. What about foo: (forall a. a) -> Int? Cristiano From bulat.ziganshin at gmail.com Wed Sep 16 04:18:34 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 16 03:59:00 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> Message-ID: <1828245985.20090916121834@gmail.com> Hello Cristiano, Wednesday, September 16, 2009, 12:04:48 PM, you wrote: > Yep, perhaps I used the wrong example. What about foo: (forall a. a) -> Int? it's a function that convert anything to integer. for example: foo _ = 1 it's hard to find better examples, since haskell has very few functions with fully polymorphic arguments -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From dave at zednenem.com Wed Sep 16 05:11:25 2009 From: dave at zednenem.com (David Menendez) Date: Wed Sep 16 04:50:05 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <1828245985.20090916121834@gmail.com> References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <1828245985.20090916121834@gmail.com> Message-ID: <49a77b7a0909160211p254c69a8o16d3b5ce56077f66@mail.gmail.com> On Wed, Sep 16, 2009 at 4:18 AM, Bulat Ziganshin wrote: > Hello Cristiano, > > Wednesday, September 16, 2009, 12:04:48 PM, you wrote: > >> Yep, perhaps I used the wrong example. What about foo: (forall a. a) -> Int? > > it's a function that convert anything to integer. That would be forall a. a -> Int. The only value of type (forall a. a) is _|_. -- Dave Menendez From vandijk.roel at gmail.com Wed Sep 16 05:25:44 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Wed Sep 16 05:04:24 2009 Subject: [Haskell-cafe] ANNOUNCE: bindings-levmar-0.1.1 Message-ID: I am pleased to announce the release of bindings-levmar-0.1.1: http://hackage.haskell.org/package/bindings-levmar The most important change compared to the previous version is a custom configure script (copied from hmatrix) that detects which libraries are needed. The cabal file also has some flags which allow you to choose for instance intel's mkl library instead of the normal lapack (also copied from hmatrix). Happy hacking, Roel and Bas van Dijk From v.dijk.bas at gmail.com Wed Sep 16 05:35:25 2009 From: v.dijk.bas at gmail.com (Bas van Dijk) Date: Wed Sep 16 05:14:06 2009 Subject: [Haskell-cafe] ANNOUNCE: levmar-0.2 Message-ID: Hello, We like to announce a new release of the high-level Levenberg-Marquardt library levmar: http://hackage.haskell.org/package/levmar-0.2 Changes: * There's one new major feature: automatic calculation of the Jacobian using automatic differentiation with Conal Elliott's vector-space library. (Conal: would you like to take a quick look at the implementation and see if I'm using vector-space the way it supposed to be used, thanks) * Furthermore we made the type Model from LevMar more type-safe by replacing: type Model m r = NFunction m r [r] with: type Model m n r = NFunction m r (SizedList n r) * Finally we did lot's of internal refactorings and updated the documentation. regards, Bas and Roel van Dijk From gregorypropf at yahoo.com Wed Sep 16 06:23:30 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Wed Sep 16 06:02:09 2009 Subject: [Haskell-cafe] Hopefully simple monad question Message-ID: <202670.9323.qm@web112207.mail.gq1.yahoo.com> I'm playing around with a little program that implements a simple virtual machine.? I want to use a monad to represent machine state.? I created a data type for the machine (VM) and a monadic type for the monadic computations using it.? I declared this an instance of MonadState and Monad and created the usual operators.? That stuff works.? My issue is that I want to run some functions in the machine monad, call it VMS - "virtual machine w/state" and then pull the underlying VM data structure out and print it. I've read about monad transformers, lift, liftM, liftIO and all these instances in the libraries like MonadIO and am rather confused.? The most sensible conclusion I can reach is that I probably need to create my own Transformer monad and define liftIO.? Is this where I need to go?? Also, my VMS monad doesn't really do anything different from the State monad except explicitly specify that state is a VM and not a generic type.? Am I doing too much work creating my own instances here?? Would a simple "type" statement work? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/e5242cd1/attachment.html From holgersiegel74 at yahoo.de Wed Sep 16 06:37:43 2009 From: holgersiegel74 at yahoo.de (Holger Siegel) Date: Wed Sep 16 06:19:10 2009 Subject: [Haskell-cafe] Hopefully simple monad question In-Reply-To: <202670.9323.qm@web112207.mail.gq1.yahoo.com> References: <202670.9323.qm@web112207.mail.gq1.yahoo.com> Message-ID: <1253097463.8986.10.camel@cornfed> Am Mittwoch, den 16.09.2009, 03:23 -0700 schrieb Gregory Propf: > I'm playing around with a little program that implements a simple > virtual machine. I want to use a monad to represent machine state. I > created a data type for the machine (VM) and a monadic type for the > monadic computations using it. I declared this an instance of > MonadState and Monad and created the usual operators. That stuff > works. My issue is that I want to run some functions in the machine > monad, call it VMS - "virtual machine w/state" and then pull the > underlying VM data structure out and print it. > > I've read about monad transformers, lift, liftM, liftIO and all these > instances in the libraries like MonadIO and am rather confused. The > most sensible conclusion I can reach is that I probably need to create > my own Transformer monad and define liftIO. Is this where I need to > go? Also, my VMS monad doesn't really do anything different from the > State monad except explicitly specify that state is a VM and not a > generic type. Am I doing too much work creating my own instances > here? Would a simple "type" statement work? Yes. You can use the existing implementation of state monads: import Control.Monad.State and define a data type for the machine state data MS = VM { pc :: Int, heap :: MyHeap } and then you can define your monad via type MSM = State MS or, if you want your virtual machine to do some IO, type MSM = StateT IO MS Now functions that operate on the virtual machine state might have the following types: isInStopState :: MSM Bool doOneStep :: MSM () runUntilStopState :: MSM () doSomeSteps :: Int -> MSM Int From miguelimo38 at yandex.ru Wed Sep 16 06:42:21 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Sep 16 06:22:53 2009 Subject: [Haskell-cafe] Hopefully simple monad question In-Reply-To: <202670.9323.qm@web112207.mail.gq1.yahoo.com> References: <202670.9323.qm@web112207.mail.gq1.yahoo.com> Message-ID: <4AB0C10D.50401@yandex.ru> Well, it's almost always better to reuse as much code as possible. But I don't think "type" is an answer here. I recommend using a "newtype", enabling "GeneralizedNewtypeDeriving" and deriving as much as possible: {-# LANGUAGE GeneralizedNewtypeDeriving #-} ... newtype VM a = VM {runVM :: State VMState a} deriving Monad or newtype VMT m a = VMT {runVMT :: StateT VMState m a} deriving (Monad, MonadIO, MonadTrans, TransM) Unfortunately, you can't automatically derive MonadState, since it's a multi-paremeter type class. You'll have to write down the derivation yourself. Gregory Propf wrote: > I'm playing around with a little program that implements a simple > virtual machine. I want to use a monad to represent machine state. I > created a data type for the machine (VM) and a monadic type for the > monadic computations using it. I declared this an instance of > MonadState and Monad and created the usual operators. That stuff > works. My issue is that I want to run some functions in the machine > monad, call it VMS - "virtual machine w/state" and then pull the > underlying VM data structure out and print it. > > I've read about monad transformers, lift, liftM, liftIO and all these > instances in the libraries like MonadIO and am rather confused. The > most sensible conclusion I can reach is that I probably need to create > my own Transformer monad and define liftIO. Is this where I need to > go? Also, my VMS monad doesn't really do anything different from the > State monad except explicitly specify that state is a VM and not a > generic type. Am I doing too much work creating my own instances here? > Would a simple "type" statement work? > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From tanielsen at gmail.com Wed Sep 16 06:51:49 2009 From: tanielsen at gmail.com (Tom Nielsen) Date: Wed Sep 16 06:30:50 2009 Subject: [Haskell-cafe] Hopefully simple monad question In-Reply-To: <4AB0C10D.50401@yandex.ru> References: <202670.9323.qm@web112207.mail.gq1.yahoo.com> <4AB0C10D.50401@yandex.ru> Message-ID: <78dc001e0909160351h498592a8r8142bd3bf10b52e@mail.gmail.com> newtype VMT m a = ?VMT {runVMT :: StateT VMState m a} ? ?deriving (Monad, MonadIO, MonadTrans, TransM, MonadState VMState) works here (ghc-6.10.3) On Wed, Sep 16, 2009 at 11:42 AM, Miguel Mitrofanov wrote: > newtype VMT m a = > ?VMT {runVMT :: StateT VMState m a} > ? ?deriving (Monad, MonadIO, MonadTrans, TransM) > > Unfortunately, you can't automatically derive MonadState, since it's a > multi-paremeter type class. You'll have to write down the derivation > yourself. From miguelimo38 at yandex.ru Wed Sep 16 07:01:18 2009 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Wed Sep 16 06:41:51 2009 Subject: [Haskell-cafe] Hopefully simple monad question In-Reply-To: <78dc001e0909160351h498592a8r8142bd3bf10b52e@mail.gmail.com> References: <202670.9323.qm@web112207.mail.gq1.yahoo.com> <4AB0C10D.50401@yandex.ru> <78dc001e0909160351h498592a8r8142bd3bf10b52e@mail.gmail.com> Message-ID: <4AB0C57E.9010700@yandex.ru> O, great. I didn't know you can write it this way. Tom Nielsen wrote: > newtype VMT m a = > VMT {runVMT :: StateT VMState m a} > deriving (Monad, MonadIO, MonadTrans, TransM, MonadState VMState) > > works here (ghc-6.10.3) > > On Wed, Sep 16, 2009 at 11:42 AM, Miguel Mitrofanov > wrote: > >> newtype VMT m a = >> VMT {runVMT :: StateT VMState m a} >> deriving (Monad, MonadIO, MonadTrans, TransM) >> >> Unfortunately, you can't automatically derive MonadState, since it's a >> multi-paremeter type class. You'll have to write down the derivation >> yourself. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From martijn at van.steenbergen.nl Wed Sep 16 07:07:47 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Wed Sep 16 06:46:32 2009 Subject: [Haskell-cafe] Building a monoid, continuation-passing style In-Reply-To: <49a77b7a0909151807j436fe6f0wcf71a06f24d632ad@mail.gmail.com> References: <4AAE6068.4050702@van.steenbergen.nl> <49a77b7a0909151807j436fe6f0wcf71a06f24d632ad@mail.gmail.com> Message-ID: <4AB0C703.2040107@van.steenbergen.nl> David Menendez wrote: > I'm reminded of the parameterized monad of continuations that Oleg > mentioned a few years back. > > This is all very interesting, thank you both for the pointers! I was trying to get rid of the newtypes but couldn't think of how to do that. I can't believe the solution now is as simple as (m -> r) -> a. There's hardly any code left, now. The fact that it all exists already is nice on the one hand and sad on the other. :-) I will have to look into parametrized monads and parametrized applicatives. Thanks again, Martijn. From porges at porg.es Wed Sep 16 08:36:01 2009 From: porges at porg.es (George Pollard) Date: Wed Sep 16 08:14:39 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> Message-ID: <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> Just occurred to me that you can actually do this with a preprocessor. If we extract the "template" declarations to a separate module, then it can happen something like this (I have corrected some errors in the above code): ---- main.hs ---- import Language.Haskell.TH import QList import Control.Monad {- pretend we had this: main = do print (1,2,3) print (1) print (1,(2,3)) print ((1,2),3) - "template_outfix_lparen_rparen_expression" matches normal parens in the expression context - we also have a template operator for commas The rules for the preprocessor are: inputs to the templates are always wrapped in [| |]. The templates are wrapped in $(). This explains some of the extraneous nesting below (trying to pretend I'm a machine!) -} main = do print $( template_outfix_lparen_rparen_expression `fmap` [| $( comma `fmap` [| 1 |] `ap` (comma `fmap` [| 2 |] `ap` [| 3 |]) ) |]) print $( template_outfix_lparen_rparen_expression `fmap` [| $( [| 1 |] ) |]) print $( template_outfix_lparen_rparen_expression `fmap` [| $( comma `fmap` [| 1 |] `ap` [| $(template_outfix_lparen_rparen_expression `fmap` [| $( comma `fmap` [| 2 |] `ap` [| 3 |]) |] ) |] ) |]) print $( template_outfix_lparen_rparen_expression `fmap` [| $( comma `fmap` [| $( template_outfix_lparen_rparen_expression `fmap` [| $(comma `fmap` [| 1 |] `ap` [| 2 |]) |] ) |] `ap` [| 3 |] ) |]) ---------------------- QList.hs ------------------------------- {- contains the templates and QList. (the module created by preprocessor would usually only include templates, with QList being a helper module) -} module QList where import Debug.Trace import Language.Haskell.TH data QList a = QCons a (QList a) | QNil comma :: Exp ? Exp ? Exp a `comma` b@(AppE (AppE (ConE x) _) _) | x == qconsName = a `qcons` b | otherwise = a `qcons` (b `qcons` qnil) a `comma` b = a `qcons` (b `qcons` qnil) qnil :: Exp qnil = ConE (mkName "QNil") qcons :: Exp ? Exp ? Exp a `qcons` b = (ConE (mkName "QCons")) `AppE` a `AppE` b template_outfix_lparen_rparen_expression :: Exp ? Exp template_outfix_lparen_rparen_expression x = case x of (AppE (AppE (ConE y) _) _) ? if y == qconsName then TupE $ fromQList x else x _ ? x fromQList :: Exp ? [Exp] fromQList (AppE (AppE (ConE c) h) t) | c == qconsName = h:fromQList t | otherwise = error "malformed qlist (head)" fromQList (ConE n) | n == mkName "QNil" = [] | otherwise = error "malformed qlist (tail)" qconsName = mkName "QCons" From porges at porg.es Wed Sep 16 08:37:45 2009 From: porges at porg.es (George Pollard) Date: Wed Sep 16 08:16:23 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> Message-ID: <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> Oh, and output is as expected: > ./test (1,2,3) 1 (1,(2,3)) ((1,2),3) From porges at porg.es Wed Sep 16 08:44:58 2009 From: porges at porg.es (George Pollard) Date: Wed Sep 16 08:23:36 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> Message-ID: <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> Also (sorry for the triple-post!) I noticed that in the TH documentation, it says: Type splices are not implemented, and neither are pattern splices This means, while we could write a preprocessor that would give us, e.g.: x :: Set Int x = {1,2,3,4} We cannot splice in the right places to allow: x :: {Int} x = {1,2,3,4} isSetEmpty :: {a} ? Bool isSetEmpty {} = True isSetEmpty _ = False From gregorypropf at yahoo.com Wed Sep 16 09:17:01 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Wed Sep 16 08:55:40 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions Message-ID: <660693.30994.qm@web112215.mail.gq1.yahoo.com> One of the things I liked about Haskell was the notion of pure functions and the fact that they can be, in theory, automatically parallelized on multicore hardware. I think this will become a huge deal in a few years as cores multiply.? My question is simply this: under GHC is this what really happens with, say a mapping over a pure function.? Yes, I compiled with --threaded and am using the +RTS -N2 options on my dual core machine.? Here's the code I wrote as a speed test.? It just doesn't seem any faster with -N2.? Using the ps command I found that multiple threads are indeed launched (this is Linux) but all but one show as being in a state of waiting for some event to finish (the ps output flags them all 'Sl'. main = do rg <- getStdGen ????????? let rs = take 10000000 $ randomRs (1::Int,100000::Int) rg ????????????? rs'= map (\n -> n*n) rs ????????? print rs' -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/c9ed98b2/attachment.html From bulat.ziganshin at gmail.com Wed Sep 16 09:29:45 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 16 09:09:14 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <660693.30994.qm@web112215.mail.gq1.yahoo.com> References: <660693.30994.qm@web112215.mail.gq1.yahoo.com> Message-ID: <1617371669.20090916172945@gmail.com> Hello Gregory, Wednesday, September 16, 2009, 5:17:01 PM, you wrote: no. additional threads are launched for i/o system and, as you requested by -N2 for haskell workload. but ghc don't auto-parallelize your code. it's a bit too hard, since making too much threads (e.g. one for every addition) will make bookkeeping too heavy and it's impossible to automatically deduce how much operations each computation will require. instead, you are provided with 'par' primitive to show compiler explicitly what parts to run in parallel > One of the things I liked about Haskell was the notion of pure > functions and the fact that they can be, in theory, automatically > parallelized on multicore hardware. I think this will become a huge > deal in a few years as cores multiply.? My question is simply this: > under GHC is this what really happens with, say a mapping over a > pure function.? Yes, I compiled with --threaded and am using the > +RTS -N2 options on my dual core machine.? Here's the code I wrote > as a speed test.? It just doesn't seem any faster with -N2.? Using > the ps command I found that multiple threads are indeed launched > (this is Linux) but all but one show as being in a state of waiting > for some event to finish (the ps output flags them all 'Sl'. > main = do rg <- getStdGen > ????????? let rs = take 10000000 $ randomRs (1::Int,100000::Int) rg > ????????????? rs'= map (\n -> n*n) rs > ????????? print rs' > -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ekmett at gmail.com Wed Sep 16 09:41:34 2009 From: ekmett at gmail.com (Edward Kmett) Date: Wed Sep 16 09:20:13 2009 Subject: [Haskell-cafe] Building a monoid, continuation-passing style In-Reply-To: <4AB0C703.2040107@van.steenbergen.nl> References: <4AAE6068.4050702@van.steenbergen.nl> <49a77b7a0909151807j436fe6f0wcf71a06f24d632ad@mail.gmail.com> <4AB0C703.2040107@van.steenbergen.nl> Message-ID: <7fb8f82f0909160641s440cd412waa11bc241e7a56b2@mail.gmail.com> For reference Oleg's indexed continuation monad is packaged on hackage in category-extras as: http://hackage.haskell.org/packages/archive/category-extras/latest/doc/html/Control-Monad-Indexed-Cont.html -Edward Kmett On Wed, Sep 16, 2009 at 7:07 AM, Martijn van Steenbergen < martijn@van.steenbergen.nl> wrote: > David Menendez wrote: > >> I'm reminded of the parameterized monad of continuations that Oleg >> mentioned a few years back. >> >> >> > > This is all very interesting, thank you both for the pointers! > > I was trying to get rid of the newtypes but couldn't think of how to do > that. I can't believe the solution now is as simple as (m -> r) -> a. > There's hardly any code left, now. > > The fact that it all exists already is nice on the one hand and sad on the > other. :-) > > I will have to look into parametrized monads and parametrized applicatives. > > Thanks again, > > Martijn. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/2447e714/attachment.html From bugfact at gmail.com Wed Sep 16 09:54:27 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Sep 16 09:33:06 2009 Subject: [Haskell-cafe] Haskell -> .NET Message-ID: I heard that compiling Haskell to Java is not obvious since tail calls are not supported. .NET's intermediate language (IL) does support tail calls, however it is currently slower than regular calls, and is not always supported by all JITs. But given that F# will soon be officially released, I hope that eventually tail calls will work as expected, and fast See e.g. http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx So, might it be worth considering a .NET backend for a Haskell compiler? Peter Verswyvelen From psujkov at gmail.com Wed Sep 16 10:03:04 2009 From: psujkov at gmail.com (Paul Sujkov) Date: Wed Sep 16 09:41:44 2009 Subject: [Haskell-cafe] Haskell -> .NET In-Reply-To: References: Message-ID: <9760562b0909160703p43a44881u5b1a3e14b36bc885@mail.gmail.com> Hi Peter, it seems that this question has been already raised before: http://www.haskell.org/pipermail/haskell-cafe/2005-January/008244.html and there are some .Net interop implementations on the net (it is a question how mature they are, however): http://php.cin.ufpe.br/~haskell/haskelldotnet/ http://haskell.forkio.com/dotnet/ 2009/9/16 Peter Verswyvelen > I heard that compiling Haskell to Java is not obvious since tail calls > are not supported. > > .NET's intermediate language (IL) does support tail calls, however it > is currently slower than regular calls, and is not always supported by > all JITs. > > But given that F# will soon be officially released, I hope that > eventually tail calls will work as expected, and fast > > See e.g. > http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx > > So, might it be worth considering a .NET backend for a Haskell compiler? > > Peter Verswyvelen > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Regards, Paul Sujkov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/abed3c3c/attachment.html From bugfact at gmail.com Wed Sep 16 10:21:28 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Wed Sep 16 10:00:08 2009 Subject: [Haskell-cafe] Haskell -> .NET In-Reply-To: <9760562b0909160703p43a44881u5b1a3e14b36bc885@mail.gmail.com> References: <9760562b0909160703p43a44881u5b1a3e14b36bc885@mail.gmail.com> Message-ID: Yes, but interop only touches the surface of what is possible. When a Haskell compiler could create IL code, it would be possible to use the generated code inside a sandbox, e.g. to be used on the web as loadable Silverlight code. Of course the same could be said about other virtual machines, such as Flash or Java, but I don't know about the tail call issue here. I guess for now F# would be the best option, but it would be awesome if Haskell compilers could have more backends. I realize this is a very big undertaking, and has been mentioned before, but it doesn't hurt to refresh the cache lines once in a while, so maybe some bright student picks this up and hacks together something cool during the summer :) On Wed, Sep 16, 2009 at 4:03 PM, Paul Sujkov wrote: > Hi Peter, > > it seems that this question has been already raised before: > > http://www.haskell.org/pipermail/haskell-cafe/2005-January/008244.html > > and there are some .Net interop implementations on the net (it is a question > how mature they are, however): > > http://php.cin.ufpe.br/~haskell/haskelldotnet/ > http://haskell.forkio.com/dotnet/ > > 2009/9/16 Peter Verswyvelen >> >> I heard that compiling Haskell to Java is not obvious since tail calls >> are not supported. >> >> .NET's intermediate language (IL) does support tail calls, however it >> is currently slower than regular calls, and is not always supported by >> all JITs. >> >> But given that F# will soon be officially released, I hope that >> eventually tail calls will work as expected, and fast >> >> See e.g. >> http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx >> >> So, might it be worth considering a .NET backend for a Haskell compiler? >> >> Peter Verswyvelen >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Regards, Paul Sujkov > From matthew.podwysocki at gmail.com Wed Sep 16 10:25:01 2009 From: matthew.podwysocki at gmail.com (Matthew Podwysocki) Date: Wed Sep 16 10:03:42 2009 Subject: [Haskell-cafe] Haskell -> .NET In-Reply-To: References: <9760562b0909160703p43a44881u5b1a3e14b36bc885@mail.gmail.com> Message-ID: <642ac3770909160725j1006c82age37f38ca9b43e974@mail.gmail.com> There was in fact another attempt as well, Salsa: http://haskell.org/haskellwiki/Salsa This showed quite a bit of promise but unfortunately was not more than just an experiment. Matt On Wed, Sep 16, 2009 at 10:21 AM, Peter Verswyvelen wrote: > Yes, but interop only touches the surface of what is possible. > > When a Haskell compiler could create IL code, it would be possible to > use the generated code inside a sandbox, e.g. to be used on the web as > loadable Silverlight code. > > Of course the same could be said about other virtual machines, such as > Flash or Java, but I don't know about the tail call issue here. > > I guess for now F# would be the best option, but it would be awesome > if Haskell compilers could have more backends. > > I realize this is a very big undertaking, and has been mentioned > before, but it doesn't hurt to refresh the cache lines once in a > while, so maybe some bright student picks this up and hacks together > something cool during the summer :) > > On Wed, Sep 16, 2009 at 4:03 PM, Paul Sujkov wrote: > > Hi Peter, > > > > it seems that this question has been already raised before: > > > > http://www.haskell.org/pipermail/haskell-cafe/2005-January/008244.html > > > > and there are some .Net interop implementations on the net (it is a > question > > how mature they are, however): > > > > http://php.cin.ufpe.br/~haskell/haskelldotnet/ > > http://haskell.forkio.com/dotnet/ > > > > 2009/9/16 Peter Verswyvelen > >> > >> I heard that compiling Haskell to Java is not obvious since tail calls > >> are not supported. > >> > >> .NET's intermediate language (IL) does support tail calls, however it > >> is currently slower than regular calls, and is not always supported by > >> all JITs. > >> > >> But given that F# will soon be officially released, I hope that > >> eventually tail calls will work as expected, and fast > >> > >> See e.g. > >> > http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx > >> > >> So, might it be worth considering a .NET backend for a Haskell compiler? > >> > >> Peter Verswyvelen > >> _______________________________________________ > >> Haskell-Cafe mailing list > >> Haskell-Cafe@haskell.org > >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > > > -- > > Regards, Paul Sujkov > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/48106d15/attachment.html From dons at galois.com Wed Sep 16 10:23:14 2009 From: dons at galois.com (Don Stewart) Date: Wed Sep 16 10:04:07 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <660693.30994.qm@web112215.mail.gq1.yahoo.com> References: <660693.30994.qm@web112215.mail.gq1.yahoo.com> Message-ID: <20090916142314.GA8255@whirlpool.galois.com> gregorypropf: > One of the things I liked about Haskell was the notion of pure functions and > the fact that they can be, in theory, automatically parallelized on multicore > hardware. I think this will become a huge deal in a few years as cores > multiply. My question is simply this: under GHC is this what really happens > with, say a mapping over a pure function. Yes, I compiled with --threaded and > am using the +RTS -N2 options on my dual core machine. Here's the code I wrote > as a speed test. It just doesn't seem any faster with -N2. Using the ps > command I found that multiple threads are indeed launched (this is Linux) but > all but one show as being in a state of waiting for some event to finish (the > ps output flags them all 'Sl'. > > > > > main = do rg <- getStdGen > let rs = take 10000000 $ randomRs (1::Int,100000::Int) rg > rs'= map (\n -> n*n) rs > print rs' GHC doesn't auto-parallelize. You would have to use one of the several fine parallelism constructrs to achieve a speedup. Here's a recent tutorial, http://donsbot.wordpress.com/2009/09/05/defun-2009-multicore-programming-in-haskell-now/ and some background reading, http://donsbot.wordpress.com/2009/09/03/parallel-programming-in-haskell-a-reading-list/ -- Don From ganesh.sittampalam at credit-suisse.com Wed Sep 16 10:27:31 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Wed Sep 16 10:06:30 2009 Subject: [Haskell-cafe] Haskell -> .NET In-Reply-To: <642ac3770909160725j1006c82age37f38ca9b43e974@mail.gmail.com> References: <9760562b0909160703p43a44881u5b1a3e14b36bc885@mail.gmail.com> <642ac3770909160725j1006c82age37f38ca9b43e974@mail.gmail.com> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9FA1A@ELON17P32001A.csfb.cs-group.com> I think Sigbjorn's binding (http://haskell.forkio.com/dotnet/ as linked below) is the most complete and likely to work, but it's still just a binding not a compiler backend. ________________________________ From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Matthew Podwysocki Sent: 16 September 2009 15:25 To: Peter Verswyvelen Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] Haskell -> .NET There was in fact another attempt as well, Salsa: http://haskell.org/haskellwiki/Salsa This showed quite a bit of promise but unfortunately was not more than just an experiment. Matt On Wed, Sep 16, 2009 at 10:21 AM, Peter Verswyvelen wrote: Yes, but interop only touches the surface of what is possible. When a Haskell compiler could create IL code, it would be possible to use the generated code inside a sandbox, e.g. to be used on the web as loadable Silverlight code. Of course the same could be said about other virtual machines, such as Flash or Java, but I don't know about the tail call issue here. I guess for now F# would be the best option, but it would be awesome if Haskell compilers could have more backends. I realize this is a very big undertaking, and has been mentioned before, but it doesn't hurt to refresh the cache lines once in a while, so maybe some bright student picks this up and hacks together something cool during the summer :) On Wed, Sep 16, 2009 at 4:03 PM, Paul Sujkov wrote: > Hi Peter, > > it seems that this question has been already raised before: > > http://www.haskell.org/pipermail/haskell-cafe/2005-January/008244.html > > and there are some .Net interop implementations on the net (it is a question > how mature they are, however): > > http://php.cin.ufpe.br/~haskell/haskelldotnet/ > http://haskell.forkio.com/dotnet/ > > 2009/9/16 Peter Verswyvelen >> >> I heard that compiling Haskell to Java is not obvious since tail calls >> are not supported. >> >> .NET's intermediate language (IL) does support tail calls, however it >> is currently slower than regular calls, and is not always supported by >> all JITs. >> >> But given that F# will soon be officially released, I hope that >> eventually tail calls will work as expected, and fast >> >> See e.g. >> http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-imp rovements-in-net-framework-4.aspx >> >> So, might it be worth considering a .NET backend for a Haskell compiler? >> >> Peter Verswyvelen >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Regards, Paul Sujkov > _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/629caf78/attachment.html From tanimoto at arizona.edu Wed Sep 16 10:28:15 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Sep 16 10:07:13 2009 Subject: [Haskell-cafe] Haskell -> .NET In-Reply-To: References: Message-ID: Hello! On Wed, Sep 16, 2009 at 8:54 AM, Peter Verswyvelen wrote: > I heard that compiling Haskell to Java is not obvious since tail calls > are not supported. > > .NET's intermediate language (IL) does support tail calls, however it > is currently slower than regular calls, and is not always supported by > all JITs. > > But given that F# will soon be officially released, I hope that > eventually tail calls will work as expected, and fast > > See e.g. http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx > > So, might it be worth considering a .NET backend for a Haskell compiler? > > Peter Verswyvelen > I remember reading this a while ago -- I think SPJ wrote it. It may be relevant for this discussion. http://www.haskell.org/haskellwiki/GHC:FAQ#.NET.2FJVM_Availability Take care, Paulo From gregorypropf at yahoo.com Wed Sep 16 10:34:49 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Wed Sep 16 10:13:28 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <1617371669.20090916172945@gmail.com> Message-ID: <253314.79051.qm@web112213.mail.gq1.yahoo.com> That makes sense.? So maybe I should split my mapping into two parallel ones or however many CPUs there are using par. --- On Wed, 9/16/09, Bulat Ziganshin wrote: From: Bulat Ziganshin Subject: Re: [Haskell-cafe] GHC threaded runtimes and pure functions To: "Gregory Propf" Cc: "Haskell-Cafe" Date: Wednesday, September 16, 2009, 6:29 AM Hello Gregory, Wednesday, September 16, 2009, 5:17:01 PM, you wrote: no. additional threads are launched for i/o system and, as you requested by -N2 for haskell workload. but ghc don't auto-parallelize your code. it's a bit too hard, since making too much threads (e.g. one for every addition) will make bookkeeping too heavy and it's impossible to automatically deduce how much operations each computation will require. instead, you are provided with 'par' primitive to show compiler explicitly what parts to run in parallel > One of the things I liked about Haskell was the notion of pure > functions and the fact that they can be, in theory, automatically > parallelized on multicore hardware. I think this will become a huge > deal in a few years as cores multiply.? My question is simply this: > under GHC is this what really happens with, say a mapping over a > pure function.? Yes, I compiled with --threaded and am using the > +RTS -N2 options on my dual core machine.? Here's the code I wrote > as a speed test.? It just doesn't seem any faster with -N2.? Using > the ps command I found that multiple threads are indeed launched > (this is Linux) but all but one show as being in a state of waiting > for some event to finish (the ps output flags them all 'Sl'. > main = do rg <- getStdGen > ????????? let rs = take? 10000000 $ randomRs (1::Int,100000::Int) rg > ????????????? rs'= map (\n -> n*n) rs > ????????? print rs' >??? -- Best regards, Bulat? ? ? ? ? ? ? ? ? ? ? ? ? ? mailto:Bulat.Ziganshin@gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/b72e0223/attachment.html From lemming at henning-thielemann.de Wed Sep 16 10:59:59 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Wed Sep 16 10:38:42 2009 Subject: [Haskell-cafe] Parallel lazy zip Message-ID: When reading http://www.macs.hw.ac.uk/~dsg/gph/papers/html/Strategies/strategies.html I got the impression, that when I want to compute in parallel I have to suppress laziness at all costs, otherwise only a neglible portion of the code is run in parallel. How can I parallelize the computation of two lazily generated lists, where the list generation is expensive, but the combination of the lists is cheap? For example: module Main where expensiveList :: Int -> [Int] expensiveList n = map (\m -> sum [n..m]) [10000000..] sequentialZip :: [Int] sequentialZip = zipWith (+) (expensiveList 1) (expensiveList 2) main :: IO () main = mapM_ print $ take 10 sequentialZip It seems to me that this program must run almost twice as fast when using two cores, because the expensive lists can be computed perfectly in parallel. It requires however, that the zipWith can fetch data lazily across threads. However applying a Parallel strategy to the expensive list, will certainly try to evaluate it completely. From marlowsd at gmail.com Wed Sep 16 11:05:04 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Wed Sep 16 10:43:45 2009 Subject: [Haskell-cafe] Re: Using tiny (atomic) mutables between multiple threads In-Reply-To: <25420972.post@talk.nabble.com> References: <25420972.post@talk.nabble.com> Message-ID: <4AB0FEA0.9000404@gmail.com> On 13/09/2009 07:45, Belka wrote: > > Hello, Haskell Cafe! > > I used an MVar to signalize to many threads, when it's time to finish their > business (I called it a LoopBreaker). Recently I realized, that it might be > too expensive (to use MVar) for cases when threads are many and all of them > read my LoopBreaker intensively. This assumption appeared in a case, where I > widely (in many threads) used my stopableThreadDelay, which checks > LoopBreaker every d = 100 milliseconds. > > So I decided that I don't really need all the great features, that MVar > provides, and that a simpler memory usage concept might be applied here. In > a most (machinely) reduced view, all I need is a mutable byte. It would be > thread safe, since reading and writing are atomic operations. I then wrote a > simple experimental module (my first experience with Ptr in Haskell): > ----------------- > import Control.Monad > import Foreign.Marshal.Utils > import Foreign.Ptr > import Foreign.Storable > > newtype MyVar a = MyVar { mvPtr :: Ptr a } > > newMyVar :: Storable a => a -> IO (MyVar a) > newMyVar val = MyVar `liftM` new val > > readMyVar :: Storable a => (MyVar a) -> IO a > readMyVar val = peek $ mvPtr val > > writeMyVar :: Storable a => (MyVar a) -> a -> IO () > writeMyVar var val = poke (mvPtr var) val > ----------------- > > Now, please, help me to answer few questions about all it: > 1. Might readMVar really be computationally expensive under heavy load, > (with all it's wonderful blocking features)? How much (approximately) more > expensive, comparing to a assembler's "mov"? Probably 10-100 times more expensive than a mov, depending on the cache state. > 2. Are the above readMyVar and writeMyVar really atomic? Or are they atomic > only if I apply them to type? It depends what you mean by atomic. If you mean is readMyVar atomic with respect to writeMyVar, then it depends on which type you're instantiating MyVar with, and what machine you're running on. e.g. a MyVar Word32 will probably be atomic, but MyVar Word64 might only be atomic on a 64-bit platform. You'd also have to check your machine's architecture manuals to be sure. MyVar Word8 is atomic on some platforms but not others. The upshot is that it's not a good idea to rely on atomicity here. I'd recommend using IORef and atomicModifyIORef when you need atomicity. > 3. Are the above readMyVar and writeMyVar safe against asynchronous > exceptions? Or again, only if I use type? It depends what you mean by "safe", but probably you're worried about atomicity again. It's pretty unusual to want just a mutable variable for communication between threads, normally you need *some* kind of synchronisation. What's your application? Cheers, Simon From lazycat.manatee at gmail.com Wed Sep 16 10:56:15 2009 From: lazycat.manatee at gmail.com (Andy Stewart) Date: Wed Sep 16 10:47:13 2009 Subject: [Haskell-cafe] Some question about c2hs. Message-ID: <87y6of546o.fsf@ubuntu.domain> Hi all, I try to binding Haskell to VTE library. Below are Vte.chs file i wrote. -------------- next part -------------- A non-text attachment was scrubbed... Name: Vte.chs Type: application/octet-stream Size: 26264 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/36debd98/Vte-0001.obj -------------- next part -------------- I use c2hs with below command LANG=C c2hs -d trace -l $(pkg-config --cflags vte | sed 's/-I/-C-I/g') vte/vte.h Vte.chs generate Vte.hs file. When i compile Vte.hs file, i got below error: Vte.chs:67:89: Couldn't match expected type `Widget' against inferred type `()' Expected type: IO (Ptr Widget) Inferred type: IO (Ptr ()) In the second argument of `($)', namely `vte_terminal_new' In the second argument of `($)', namely `liftM (castPtr :: Ptr Widget -> Ptr Terminal) $ vte_terminal_new' for binding code: terminalNew :: IO Terminal terminalNew = makeNewObject mkTerminal $ liftM (castPtr :: Ptr Widget -> Ptr Terminal) $ {#call unsafe terminal_new#} In C code, fucntion `GtkWidget *vte_terminal_new(void);' return `IO (Ptr Widget), then i use castPtr transform (Ptr Widget) to (Ptr Terminal), right? Why GHC report function `vte_terminal_new` return `IO (Ptr ())', I do something wrong? Any help? Thanks! -- Andy From bulat.ziganshin at gmail.com Wed Sep 16 11:30:25 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 16 11:19:21 2009 Subject: [Haskell-cafe] Re: Using tiny (atomic) mutables between multiple threads In-Reply-To: <4AB0FEA0.9000404@gmail.com> References: <25420972.post@talk.nabble.com> <4AB0FEA0.9000404@gmail.com> Message-ID: <1655424474.20090916193025@gmail.com> Hello Simon, Wednesday, September 16, 2009, 7:05:04 PM, you wrote: >> 1. Might readMVar really be computationally expensive under heavy load, >> (with all it's wonderful blocking features)? How much (approximately) more >> expensive, comparing to a assembler's "mov"? > Probably 10-100 times more expensive than a mov, depending on the cache > state. many years ago, with ghc 6.6 and duron-1000, i had million or two of withMVar per second. anyway, this sort of things is easier to test herself -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ryani.spam at gmail.com Wed Sep 16 13:12:00 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Wed Sep 16 12:50:39 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> Message-ID: <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> Here's the difference between these two types: test1 :: forall a. a -> Int -- The caller of test1 determines the type for test1 test2 :: (forall a. a) -> Int -- The internals of test2 determines what type, or types, to instantiate the argument at Or, to put it another way, since there are no non-bottom objects of type (forall a. a): test1 converts *anything* to an Int. test2 converts *nothing* to an Int -- type-correct implementation -- instantiates the (forall a. a) argument at Int test2 x = x -- type error, the caller chose "a" and it is not necessarily Int -- test1 x = x -- type-correct implementation: ignore the argument test1 _ = 1 -- ryan On Wed, Sep 16, 2009 at 1:04 AM, Cristiano Paris wrote: > On Tue, Sep 15, 2009 at 11:38 PM, Daniel Fischer > wrote: > > ... > >> foo :: forall a. a -> a > > > > This is exactly the same type as > > > > foo :: a -> a > > > > (unless you're using ScopedTypeVariables and there's a type variable a in > scope), since > > type signatures are implicitly forall'd. > > Yep, perhaps I used the wrong example. What about foo: (forall a. a) -> > Int? > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/5fa679dc/attachment.html From pumpkingod at gmail.com Wed Sep 16 13:50:47 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Wed Sep 16 13:29:27 2009 Subject: [Haskell-cafe] Parallel lazy zip In-Reply-To: References: Message-ID: Would using zipWith (\x y -> x `par` y `pseq` x + y) (expensiveList 1) (expensiveList 2) do it? it seems to help a bit on my machine, but doesn't give me twice the performance On Wed, Sep 16, 2009 at 10:59 AM, Henning Thielemann wrote: > > When reading > ?http://www.macs.hw.ac.uk/~dsg/gph/papers/html/Strategies/strategies.html > ?I got the impression, that when I want to compute in parallel I have to > suppress laziness at all costs, otherwise only a neglible portion of the > code is run in parallel. How can I parallelize the computation of two lazily > generated lists, where the list generation is expensive, but the combination > of the lists is cheap? > > For example: > > > module Main where > > expensiveList :: Int -> [Int] > expensiveList n = > ? map (\m -> sum [n..m]) [10000000..] > > sequentialZip :: [Int] > sequentialZip = > ? zipWith (+) > ? ? ?(expensiveList 1) > ? ? ?(expensiveList 2) > > main :: IO () > main = > ? mapM_ print $ take 10 sequentialZip > > > It seems to me that this program must run almost twice as fast when using > two cores, because the expensive lists can be computed perfectly in > parallel. It requires however, that the zipWith can fetch data lazily across > threads. However applying a Parallel strategy to the expensive list, will > certainly try to evaluate it completely. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From frodo at theshire.org Wed Sep 16 14:58:11 2009 From: frodo at theshire.org (Cristiano Paris) Date: Wed Sep 16 14:37:09 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> Message-ID: On Wed, Sep 16, 2009 at 7:12 PM, Ryan Ingram wrote: > Here's the difference between these two types: > > test1 :: forall a. a -> Int > -- The caller of test1 determines the type for test1 > test2 :: (forall a. a) -> Int > -- The internals of test2 determines what type, or types, to instantiate the > argument at I can easily understand your explanation for test2: the type var a is closed under existential (?) quantification. I can't do the same for test1, even if it seems that a is closed under universal (?) quantification as well. > Or, to put it another way, since there are no non-bottom objects of type > (forall a. a): Why? > test1 converts *anything* to an Int. Is the only possible implementation of test1 the one ignoring its argument (apart from bottom of course)? > test2 converts *nothing* to an Int > > -- type-correct implementation > -- instantiates the (forall a. a) argument at Int > test2 x = x > -- type error, the caller chose "a" and it is not necessarily Int > -- test1 x = x > > -- type-correct implementation: ignore the argument > test1 _ = 1 Cristiano From andrewcoppin at btinternet.com Wed Sep 16 15:31:22 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Wed Sep 16 15:10:04 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <253314.79051.qm@web112213.mail.gq1.yahoo.com> References: <253314.79051.qm@web112213.mail.gq1.yahoo.com> Message-ID: <4AB13D0A.60400@btinternet.com> Gregory Propf wrote: > That makes sense. So maybe I should split my mapping into two > parallel ones or however many CPUs there are using par. > If you're going to use par, it doesn't really matter how many sparks you create. You just need to avoid creating millions of really tiny sparks. You could create, say, eight and let GHC figure out the rest itself... From bulat.ziganshin at gmail.com Wed Sep 16 16:02:11 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 16 15:41:16 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <4AB13D0A.60400@btinternet.com> References: <253314.79051.qm@web112213.mail.gq1.yahoo.com> <4AB13D0A.60400@btinternet.com> Message-ID: <248533423.20090917000211@gmail.com> Hello Andrew, Wednesday, September 16, 2009, 11:31:22 PM, you wrote: >> That makes sense. So maybe I should split my mapping into two >> parallel ones or however many CPUs there are using par. >> > If you're going to use par, it doesn't really matter how many sparks you > create. You just need to avoid creating millions of really tiny sparks. > You could create, say, eight and let GHC figure out the rest itself... since these are green threads, 1 millisecond sparks should be acceptable and may be even 1 microsecod too. afair, overhead expenses was significantly reduced in ghc 6.12, soon to be released -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From rodprice at raytheon.com Wed Sep 16 16:48:39 2009 From: rodprice at raytheon.com (Rodney Price) Date: Wed Sep 16 16:27:37 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> Message-ID: <20090916144839.34273cb1@jabber.aur.us.ray.com> How does garbage collection work in an example like the one below? You memoize a function with some sort of lookup table, which stores function arguments as keys and function results as values. As long as the function remains in scope, the keys in the lookup table remain in memory, which means that the keys themselves always remain reachable and they cannot be garbage collected. Right? So what do you do in the case where you know that, after some period of time, some entries in the lookup table will never be accessed? That is, there are no references to the keys for some entries remaining, except for the references in the lookup table itself. You'd like to allow the memory occupied by the keys to be garbage collected. Otherwise, if the function stays around for a long time, the size of the lookup table always grows. How do you avoid the space leak? I notice that there is a function in Data.IORef, mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) which looks promising. In the code below, however, there's only one IORef, so either the entire table gets garbage collected or none of it does. I've been reading the paper "Stretching the storage manager: weak pointers and stable names in Haskell," which seems to answer my question. When I attempt to run the memoization code in the paper on the simple fib example, I find that -- apparently due to lazy evaluation -- no new entries are entered into the lookup table, and therefore no lookups are ever successful! So apparently there is some interaction between lazy evaluation and garbage collection that I don't understand. My head hurts. Is it necessary to make the table lookup operation strict? Or is it something entirely different that I am missing? -Rod On Thu, 10 Sep 2009 18:33:47 -0700 Ryan Ingram wrote: > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) > memoIO f = do > cache <- newIORef M.empty > return $ \x -> do > m <- readIORef cache > case M.lookup x m of > Just y -> return y > Nothing -> do let res = f x > writeIORef cache $ M.insert x res m > return res > > memo :: Ord a => (a -> b) -> (a -> b) > memo f = unsafePerformIO $ do > fmemo <- memoIO f > return (unsafePerformIO . fmemo) > > I don't think there is any valid transformation that breaks this, > since the compiler can't lift anything through unsafePerformIO. Am I > mistaken? > > -- ryan From westondan at imageworks.com Wed Sep 16 16:48:59 2009 From: westondan at imageworks.com (Dan Weston) Date: Wed Sep 16 16:27:48 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> Message-ID: <4AB14F3B.9090007@imageworks.com> There is no magic here. This is merely explicit type specialization from the most general inferred type to something more specific. The denotational semantics of a function whose type is specialized does not change for those values belonging to the more specialized type. f :: forall a. (Num a) => a -> a -> a f x y = x + y g :: Int -> Int -> Int g x y = x + y f and g denote (extensionally) the identical function, differing only in their type. g is a specialization of f. It is possible that (operationally) f could be slower if the compiler is not clever enough to avoid passing a type witness dictionary. h :: forall b. b -> Char h = const 'a' k :: () -> Char k = const 'a' data Void m :: Void -> Char m = const 'a' n :: (forall a. a) -> Char n = const 'a' h, k, m, and n yield *identical* values for any input compatible with the type of any two of the functions. In constrast, whether a function is strict or non-strict is *not* a function of type specialization. Strictness is not reflected in the type system. Compare: u x y = y `seq` const x y v x y = const x y Both have type forall a b. a -> b -> a but are denotationally different functions: u 2 undefined = undefined v 2 undefined = 2 Cristiano Paris wrote: > On Wed, Sep 16, 2009 at 7:12 PM, Ryan Ingram wrote: >> Here's the difference between these two types: >> >> test1 :: forall a. a -> Int >> -- The caller of test1 determines the type for test1 >> test2 :: (forall a. a) -> Int >> -- The internals of test2 determines what type, or types, to instantiate the >> argument at > > I can easily understand your explanation for test2: the type var a is > closed under existential (?) quantification. I can't do the same for > test1, even if it seems that a is closed under universal (?) > quantification as well. > >> Or, to put it another way, since there are no non-bottom objects of type >> (forall a. a): > > Why? > >> test1 converts *anything* to an Int. > > Is the only possible implementation of test1 the one ignoring its > argument (apart from bottom of course)? > >> test2 converts *nothing* to an Int >> >> -- type-correct implementation >> -- instantiates the (forall a. a) argument at Int >> test2 x = x > >> -- type error, the caller chose "a" and it is not necessarily Int >> -- test1 x = x >> >> -- type-correct implementation: ignore the argument >> test1 _ = 1 > > Cristiano > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From gregorypropf at yahoo.com Wed Sep 16 19:51:45 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Wed Sep 16 19:30:23 2009 Subject: [Haskell-cafe] Can't install Haskell Platform (Ubuntu 9.02) Message-ID: <904421.1043.qm@web112205.mail.gq1.yahoo.com> I'm trying to install the Haskell Platform.? I'm using Ubuntu 9.02 and GHC 6.10.4 on a 64 bit AMD and keep getting this crap when I do 'make install'.? The stuff builds OK and the script in question does indeed exist.? Anybody know what this is.? I've looked online and none of the other people with this issue seem to know the fix. Error: The mtl-1.1.0.2/Setup script does not exist or cannot be run -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/651d855d/attachment.html From gregorypropf at yahoo.com Wed Sep 16 21:30:36 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Wed Sep 16 21:09:14 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> Message-ID: <629611.52802.qm@web112219.mail.gq1.yahoo.com> I just rejoined the list and am a bit new to things here anyway but this sounds a lot Lisp's old macro system a little. I'm guessing you're not proposing runtime execution of runtime generated code though.? I don't know much about Lisp internals but I suspect Lisp runtimes are quite different from any in Haskell.? Which leads to my real question - is there any talk of runtime compilation and execution capability in any of the extension proposals?? Or would that crap all over Haskell's reputation for reliable execution? --- On Wed, 9/16/09, George Pollard wrote: From: George Pollard Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax To: "Haskell Caf?" Date: Wednesday, September 16, 2009, 5:44 AM Also (sorry for the triple-post!) I noticed that in the TH documentation, it says: ? ? Type splices are not implemented, and neither are pattern splices This means, while we could write a preprocessor that would give us, e.g.: ? ? x :: Set Int ? ? x = {1,2,3,4} We cannot splice in the right places to allow: ? ? x :: {Int} ? ? x = {1,2,3,4} ? ? isSetEmpty :: {a} ? Bool ? ? isSetEmpty {} = True ? ? isSetEmpty _ = False _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090916/b9df6330/attachment.html From tanimoto at arizona.edu Wed Sep 16 22:24:41 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Wed Sep 16 22:03:37 2009 Subject: [Haskell-cafe] Can't install Haskell Platform (Ubuntu 9.02) In-Reply-To: <904421.1043.qm@web112205.mail.gq1.yahoo.com> References: <904421.1043.qm@web112205.mail.gq1.yahoo.com> Message-ID: Hi Gregory, On Wed, Sep 16, 2009 at 6:51 PM, Gregory Propf wrote: > > I'm trying to install the Haskell Platform.? I'm using Ubuntu 9.02 and GHC 6.10.4 on a 64 bit AMD and keep getting this crap when I do 'make install'.? The stuff builds OK and the script in question does indeed exist.? Anybody know what this is.? I've looked online and none of the other people with this issue seem to know the fix. > > Error: > The mtl-1.1.0.2/Setup script does not exist or cannot be run > > Can you try this: http://trac.haskell.org/haskell-platform/ticket/84 Let us know if you need help applying the patch. Paulo From ryani.spam at gmail.com Thu Sep 17 02:36:55 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Sep 17 02:15:31 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> Message-ID: <2f9b2d30909162336o216a4207pb28ce9d69ea08e61@mail.gmail.com> On Wed, Sep 16, 2009 at 11:58 AM, Cristiano Paris wrote: > On Wed, Sep 16, 2009 at 7:12 PM, Ryan Ingram wrote: > > Here's the difference between these two types: > > > > test1 :: forall a. a -> Int > > -- The caller of test1 determines the type for test1 > > test2 :: (forall a. a) -> Int > > -- The internals of test2 determines what type, or types, to instantiate > the > > argument at > > I can easily understand your explanation for test2: the type var a is > closed under existential (?) quantification. I can't do the same for > test1, even if it seems that a is closed under universal (?) > quantification as well. > Both are universally quantified, but at a different level. To look at it in System F-land, you have two levels of types that can get passed in lambdas. Explicitly: Haskell: > test1 :: forall a. a -> Int > test1 _ = 1 > test2 :: (forall a. a) -> Int > test2 x = x explicitly in System F: test1 = /\a \(x :: a). 1 test2 = \(x :: forall a. a). x @Int /\ is type-level lambda, and @ is type-level application. In test1, the caller specifies "a" and then passes in an object of that type. In test2, the caller must pass in an object which is of all types, and test2 asks for that object to be instantiated at the type "Int" > Or, to put it another way, since there are no non-bottom objects of type > > (forall a. a): > > Why? > Informally, because you can't create something that can be any type. For example, what could the result of test3 :: (forall a. a) -> Int test3 x = length (x `asTypeOf` [()]) be? How could you call it? > test1 converts *anything* to an Int. > > Is the only possible implementation of test1 the one ignoring its > argument (apart from bottom of course)? > There's one way that doesn't entirely ignore its argument. test4 x = seq x 1 But I don't like to talk about that one :) -- ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/9798dd8b/attachment.html From gregorypropf at yahoo.com Thu Sep 17 02:49:21 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Sep 17 02:36:00 2009 Subject: [Haskell-cafe] Can't install Haskell Platform (Ubuntu 9.02) In-Reply-To: Message-ID: <918560.6880.qm@web112203.mail.gq1.yahoo.com> Yes that worked. --- On Wed, 9/16/09, Paulo Tanimoto wrote: From: Paulo Tanimoto Subject: Re: [Haskell-cafe] Can't install Haskell Platform (Ubuntu 9.02) To: "Gregory Propf" Cc: "Haskell-Cafe" Date: Wednesday, September 16, 2009, 7:24 PM Hi Gregory, On Wed, Sep 16, 2009 at 6:51 PM, Gregory Propf wrote: > > I'm trying to install the Haskell Platform.? I'm using Ubuntu 9.02 and GHC 6.10.4 on a 64 bit AMD and keep getting this crap when I do 'make install'.? The stuff builds OK and the script in question does indeed exist.? Anybody know what this is.? I've looked online and none of the other people with this issue seem to know the fix. > > Error: > The mtl-1.1.0.2/Setup script does not exist or cannot be run > > Can you try this: http://trac.haskell.org/haskell-platform/ticket/84 Let us know if you need help applying the patch. Paulo -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/eb6da29c/attachment.html From gregorypropf at yahoo.com Thu Sep 17 03:01:33 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Sep 17 02:40:10 2009 Subject: [Haskell-cafe] Trouble installing leksah Message-ID: <760816.10446.qm@web112202.mail.gq1.yahoo.com> I now have the Haskell platform install problem solved but I'm now trying to get the leksah IDE installed and I'm getting this. runhaskell Setup configure Configuring leksah-0.6.1... Setup: At least the following dependencies are missing: glib >=0.10, gtk >=0.10, gtksourceview2 >=0.10.0 I am aware that these are actually C development libraries, not Haskell modules.? The thing is that they are all installed, using the Ubuntu synaptic tool.? This is Ubuntu 9.04.? Is there something I need to tell cabal about where these libraries are? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/e1370c19/attachment.html From dav.vire+haskell at gmail.com Thu Sep 17 03:39:59 2009 From: dav.vire+haskell at gmail.com (david48) Date: Thu Sep 17 03:18:35 2009 Subject: [Haskell-cafe] Trouble installing leksah In-Reply-To: <760816.10446.qm@web112202.mail.gq1.yahoo.com> References: <760816.10446.qm@web112202.mail.gq1.yahoo.com> Message-ID: <4c88418c0909170039u1fd22936lffa8cb0408edd9c5@mail.gmail.com> On Thu, Sep 17, 2009 at 9:01 AM, Gregory Propf wrote: > > I now have the Haskell platform install problem solved but I'm now trying to get the leksah IDE installed and I'm getting this. > > runhaskell Setup configure > Configuring leksah-0.6.1... > Setup: At least the following dependencies are missing: > glib >=0.10, gtk >=0.10, gtksourceview2 >=0.10.0 > > I am aware that these are actually C development libraries, not Haskell modules.? The thing is that they are all installed, using the Ubuntu synaptic tool.? This is Ubuntu 9.04.? Is there something I need to tell cabal about where these libraries are? You need to install gtk2hs, a haskell binding to gtk libraries. When you build it, make sure to build the gtksourceview component as well. On (K)ubuntu you will need to download the gtk2hs tarball, install gtk dev libraries, and the usual configure, make and make install. From andrewcoppin at btinternet.com Thu Sep 17 04:14:19 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Thu Sep 17 03:52:56 2009 Subject: [Haskell-cafe] GHC threaded runtimes and pure functions In-Reply-To: <248533423.20090917000211@gmail.com> References: <253314.79051.qm@web112213.mail.gq1.yahoo.com> <4AB13D0A.60400@btinternet.com> <248533423.20090917000211@gmail.com> Message-ID: <4AB1EFDB.803@btinternet.com> Bulat Ziganshin wrote: > Hello Andrew, > > Wednesday, September 16, 2009, 11:31:22 PM, you wrote: > > >> If you're going to use par, it doesn't really matter how many sparks you >> create. You just need to avoid creating millions of really tiny sparks. >> You could create, say, eight and let GHC figure out the rest itself... >> > > since these are green threads, 1 millisecond sparks should be > acceptable and may be even 1 microsecod too. Of course, how many split seconds it takes depends on the speed of the processor running it. ;-) But you probably don't want to spark, say, one addition operation. (Unless perhaps you're adding *really huge* arbitrary-precision integers or something.) Actually, it might be interesting to benchmark where the balance tips; exactly how much work you need to do for the spark overhead to be worth it. It's likely to vary by GHC version though... > afair, overhead expenses > was significantly reduced in ghc 6.12, soon to be released > I've heard similar things. I think I even read a paper about it. (Those GHC guys... always putting out such interesting papers! If it weren't for them, I might actually get some work done...) If you wanted to benchmark anything, it would seem prudent to wait for this. ;-) From DekuDekuplex at Yahoo.com Thu Sep 17 04:41:21 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Sep 17 04:20:25 2009 Subject: [Haskell-cafe] Where can I find a non-fee-based version of Hudak's paper, "Conception, evolution, and application of functional programming languages"? Message-ID: Does anybody know where I can find a non-fee-based version of Paul Hudak's paper, "Conception, evolution, and application of functional programming languages" [1]? There used to be a version that did not require an ACM account available at http://www.cs.berkeley.edu/~jcondit/pl-prelim/hudak89functional.pdf , but when I try to download that file, the following error message appears: >The server has encountered a problem because access is restricted. > >Your request was : > http://www.cs.berkeley.edu/~jcondit/pl-prelim/hudak89functional.pdf -- Benjamin L. Russell [1] Hudak, Paul. "Conception, Evolution and Application of Functional Programming Languages." New York, NY: _ACM Computing Surveys (CSUR)_ 21(3) (September 1989): 359-411. . Also available at . -- 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^ From marcus at gabriel.name Thu Sep 17 05:58:32 2009 From: marcus at gabriel.name (Marcus D. Gabriel) Date: Thu Sep 17 05:37:10 2009 Subject: [Haskell-cafe] Suggested additions to System.FilePath.Posix/Windows Message-ID: <4AB20848.1030505@gabriel.name> Hello Neil I used System.FilePath.Posix quite extensively recently, and I thank you for the package filepath. There were however two words that I needed which I could not construct from those in System.FilePath.Posix. They are maybe of interest to you and others. I submit these two words to you for consideration for inclusion in System.FilePath.Posix. Please change the names as you see fit. I do not know if they make sense for System.FilePath.Windows. If the do not make sense, then please feel free to drop them so as to preserve the interface. As requested, I Cc'ed the haskell-cafe, but I am not at the moment following these threads, so if anyone else responds, please Cc me if you wish. Thanks again and cheers, - Marcus P.S. Here they are. Although I use ksh(1) as an example, this is a feature of POSIX shells. > -- | 'reduceFilePath' returns a pathname that is reduced to canonical > -- form equivalent to that of ksh(1), that is, symbolic link names are > -- treated literally when finding the directory name. See @cd -L@ of > -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot > -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. > > reduceFilePath :: FilePath -> FilePath > reduceFilePath = joinPath . filePathComponents This is in turn built on filePathComponents that does all the work. > filePathComponents :: FilePath -> [FilePath] > filePathComponents "" = [] > filePathComponents (c:cs) = > reverse $ snd $ foldl accumulate > (if c == pathSeparator then ([],["/"]) else > ([c],[])) > (cs++[pathSeparator]) > where > accumulate :: (String,[String]) -> Char -> (String,[String]) > accumulate (cs, css) c = > if c == pathSeparator > then ([],(if null cs then id else cons cs) css) > else (cs++[c],css) > cons :: String -> [String] -> [String] > cons cs css > | cs == "." = css > | cs /= ".." || null css = cs : css > | otherwise = > let hd = head css > tl = tail css > in if hd == [pathSeparator] > then css > else if hd == ".." > then cs : css > else if null tl > then ["."] > else tl // -- Marcus D. Gabriel, Ph.D. Saint Louis, FRANCE http://www.marcus.gabriel.name mailto:marcus@gabriel.name Tel: +33.3.89.69.05.06 Portable: +33.6.34.56.07.75 From magnus at therning.org Thu Sep 17 06:07:14 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Sep 17 05:45:50 2009 Subject: [Haskell-cafe] Re: Question about haskell.cs.yale.edu/ In-Reply-To: References: Message-ID: Today I received the request below. At first the URL confused me, but apparently www.haskell.org is known under two names :-) The request should probably be handled by someone involved in ICFP. /M On Wed, Sep 16, 2009 at 11:53 PM, Peter Green wrote: > Hi, > > I was wondering whether you would be interested in linking to my website http://www.frixo.com from your page? > > http://haskell.cs.yale.edu/haskellwiki/icfp_2009_local_arrangements > > Frixo is a road traffic reporting site and think it may be a useful resource for your readers. It provides users with live traffic information and gets updated every 3 minutes using various road sensors. > > Thank you for your consideration. > > Kind Regards, > Peter > http://www.frixo.com > > -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe From ivan.miljenovic at gmail.com Thu Sep 17 06:30:37 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu Sep 17 06:09:19 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.5.1.0 Message-ID: <87eiq5ooc2.fsf@gmail.com> I'm pleased to announce version 2999.5.1.0 [1] of the graphviz library, which provides bindings to the GraphViz [2] suite of tools for drawing graphs. [1] http://hackage.haskell.org/package/graphviz-2999.5.1.0 [2] http://www.graphviz.org/ This is mainly a bug-fix release; as such, there is no API change (though if you use the graphvizWithHandle function in Data.GraphViz.Commands, you should ensure that your Handle -> IO a function closes the Handle when done). Changes in this release are: * Potentially fixed the graphvizWithHandle bug where warnings would be emitted about Handles not being closed correctly or too early; correct approach spotted by Nikolas Mayr. * Fixed up Parsing of various Attribute sub-values, especially Point and Spline (and hence Pos, which uses them). * Pre-process out comments and join together multi-line strings before parsing. * Properly parse Doubles like ".2". -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From gregorypropf at yahoo.com Thu Sep 17 06:35:19 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Sep 17 06:13:56 2009 Subject: [Haskell-cafe] Trouble installing leksah In-Reply-To: <4c88418c0909170039u1fd22936lffa8cb0408edd9c5@mail.gmail.com> Message-ID: <22146.81533.qm@web112220.mail.gq1.yahoo.com> There's no such named package in Hackage though.? That was the first thing I looked for.? All Hackage has with the string "gtk2hs" is this stuff gtk2hs-cast-glade library: A type class for cast functions of Gtk2hs: glade packagegtk2hs-cast-glib library: A type class for cast functions of Gtk2hs: glib packagegtk2hs-cast-gnomevfs library: A type class for cast functions of Gtk2hs: gnomevfs packagegtk2hs-cast-gtk library: A type class for cast functions of Gtk2hs: gtk packagegtk2hs-cast-gtkglext library: A type class for cast functions of Gtk2hs: gtkglext packagegtk2hs-cast-gtksourceview2 library: A type class for cast functions of Gtk2hs: gtksourceview2 packagegtk2hs-cast-th library: A type class for cast functions of Gtk2hs: TH packagegtk2hs-rpn library: Adds a module to gtk2hs allowing layouts to be defined using reverse polish notation. --- On Thu, 9/17/09, david48 wrote: From: david48 Subject: Re: [Haskell-cafe] Trouble installing leksah To: "Gregory Propf" Cc: "Haskell-Cafe" Date: Thursday, September 17, 2009, 12:39 AM On Thu, Sep 17, 2009 at 9:01 AM, Gregory Propf wrote: > > I now have the Haskell platform install problem solved but I'm now trying to get the leksah IDE installed and I'm getting this. > > runhaskell Setup configure > Configuring leksah-0.6.1... > Setup: At least the following dependencies are missing: > glib >=0.10, gtk >=0.10, gtksourceview2 >=0.10.0 > > I am aware that these are actually C development libraries, not Haskell modules.? The thing is that they are all installed, using the Ubuntu synaptic tool.? This is Ubuntu 9.04.? Is there something I need to tell cabal about where these libraries are? You need to install gtk2hs, a haskell binding to gtk libraries. When you build it, make sure to build the gtksourceview component as well. On (K)ubuntu you will need to download the gtk2hs tarball, install gtk dev libraries, and the usual configure, make and make install. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/cfe77625/attachment.html From daniel.is.fischer at web.de Thu Sep 17 07:13:51 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 06:53:36 2009 Subject: [Haskell-cafe] Trouble installing leksah In-Reply-To: <22146.81533.qm@web112220.mail.gq1.yahoo.com> References: <22146.81533.qm@web112220.mail.gq1.yahoo.com> Message-ID: <200909171313.52034.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 12:35:19 schrieb Gregory Propf: > There's no such named package in Hackage though.? That was the first thing > I looked for.? All Hackage has with the string "gtk2hs" is this stuff AFAIK, gtk2hs is not yet cabalized and not on Hackage, look at http://haskell.org/gtk2hs/ From haskell at gimbo.org.uk Thu Sep 17 09:40:10 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 17 09:18:52 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) Message-ID: Hi all. This email is in literate Haskell; you should be able to load it into ghci and verify what I'm saying (nb: it won't compile without alteration: see below). I'm trying to do something which may anyway be stupid / not the best approach to what I'm trying to achieve; however, it's not working and I can't see why not. So I'm asking for help on two fronts: 1) Why is this failing? 2) Maybe more usefully, how should I actually be doing this? It seems an ugly approach; a voice in my head is saying "scrap your boilerplate", but I've no idea yet if that's actually applicable here; should I look at it? On with the show... I need these for "subclass" stuff later on... > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE OverlappingInstances #-} > {-# LANGUAGE UndecidableInstances #-} > module Ambig where I wish to define a number of algebraic data types with the ability to turn Int values into instances of those types. So I define a typeclass saying this is possible. I use Maybe so I can encode the existence of out-of-range Int values, which will vary from target type to target type. > class Target a where > convert :: Int -> Maybe a E.g. here's a type Foo which only wants values between 1 and 10: > data Foo = Foo Int deriving (Show) > instance Target Foo where > convert n | n `elem` [1..10] = Just $ Foo n > | otherwise = Nothing (That's a simple example; some are rather more complex. How to do this isn't what I'm asking about, really.) So we have, for example: *Ambig> (convert 1) :: Maybe Foo Just (Foo 1) *Ambig> (convert 11) :: Maybe Foo Nothing Now, some of those algebraic data type types happen to be enumerations; in this case, my idea is to list the constructors, with the rule that each constructor's position in the list is the Int which gets converted into that constructor. > class Enumerated a where > constructors :: [a] E.g. here's a type Bar with three constructors: > data Bar = X | Y | Z deriving (Show) > instance Enumerated Bar where > constructors = [X, Y, Z] (This is certainly ugly. Any suggestions?) Now we get to the crux. If a type is an instance of Enumerated, it should also be a Target, because we should be able to convert from Int just by list lookup. But we include a bounds check, naturally... > instance (Enumerated a) => Target a where > convert n | n `elem` [0..len-1] = Just $ constructors !! n > | otherwise = Nothing > where len = length constructors So I would _hope_ that then, e.g., we'd have: *Ambig> (convert 0) :: Maybe Bar Just X *Ambig> (convert 1) :: Maybe Bar Just Y *Ambig> (convert 3) :: Maybe Bar Nothing Sadly, this function doesn't compile, dying with an "Ambiguous type variable" error: Ambig.lhs:75:29: Ambiguous type variable `a' in the constraint: `Enumerated a' arising from a use of `constructors' at Ambig.lhs:74:29-40 Probable fix: add a type signature that fixes these type variable(s) If we replace "length constructors" with "3" (say), it compiles (but is useless). Adding a type signature doesn't help: it's "misplaced" in that context. If I break it out of the instance declaration so I can add one, I still get the same problem: > convert' :: (Enumerated a, Target a) => Int -> Maybe a > convert' n | n `elem` [0..len-1] = Just $ constructors !! n > | otherwise = Nothing > where len = length constructors I guess I see roughly what's going on; the question is "which constructors instance is meant?", right? In the "Just" part it's OK, because it can be inferred from the function's return type (right?). But in the guard we don't have that help, so it could be any Enumerated instance? Any advice appreciated! Particularly if this is just a dumb approach. For context, this is related to deserialisation of binary data (they'll actually be Word8's, not Int's) into a variety of data structures. Hmmm, maybe I should just be using Data.Binary... Many thanks, -Andy From jpm at cs.uu.nl Thu Sep 17 09:56:03 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Thu Sep 17 09:34:59 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: References: Message-ID: <52f14b210909170656w5244ef97rd9246aeed2721c5f@mail.gmail.com> Hey Andy, On Thu, Sep 17, 2009 at 15:40, Andy Gimblett wrote: > > Now, some of those algebraic data type types happen to be > enumerations; in this case, my idea is to list the constructors, with > the rule that each constructor's position in the list is the Int which > gets converted into that constructor. > > > class Enumerated a where > > constructors :: [a] > > E.g. here's a type Bar with three constructors: > > > data Bar = X | Y | Z deriving (Show) > > instance Enumerated Bar where > > constructors = [X, Y, Z] > > (This is certainly ugly. Any suggestions?) > |constructors| is expressible in SYB: {-# LANGUAGE ScopedTypeVariables #-} > {-# LANGUAGE FlexibleContexts #-} > > module Test where > > import Data.Data > import Data.Generics.Aliases (extB) > > -- | Construct the empty value for a datatype. For algebraic datatypes, the > -- leftmost constructor is chosen. > empty :: forall a. Data a => a > empty = general > `extB` char > `extB` int > `extB` integer > `extB` float > `extB` double where > -- Generic case > general :: Data a => a > general = fromConstrB empty (indexConstr (dataTypeOf general) 1) > > -- Base cases > char = '\NUL' > int = 0 :: Int > integer = 0 :: Integer > float = 0.0 :: Float > double = 0.0 :: Double > > -- | Return a list of values of a datatype. Each value is one of the > possible > -- constructors of the datatype, populated with 'empty' values. > constrs :: forall a. Data a => [a] > constrs = general > `extB` char > `extB` int > `extB` integer > `extB` float > `extB` double where > -- Generic case > general :: Data a => [a] > general = map (fromConstrB empty) > (dataTypeConstrs (dataTypeOf (unList general))) where > unList :: Data a => [a] -> a > unList = undefined > > -- Base cases > char = "\NUL" > int = [0 :: Int] > integer = [0 :: Integer] > float = [0.0 :: Float] > double = [0.0 :: Double] > |constrs| is similar to your |constructors|, but in this way you get it for free for any datatype with a |Data| instance. Then I guess your |convert| is: convert :: forall a. Data a => Int -> Maybe a > convert n = let cs :: [a] > cs = constrs > in if (length cs > n) then (Just (cs !! n)) else Nothing > Note that ScopedTypeVariables are essential to typecheck this code. Cheers, Pedro -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/4c9e2053/attachment.html From frodo at theshire.org Thu Sep 17 09:59:24 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Sep 17 09:38:19 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: <2f9b2d30909162336o216a4207pb28ce9d69ea08e61@mail.gmail.com> References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> <2f9b2d30909162336o216a4207pb28ce9d69ea08e61@mail.gmail.com> Message-ID: On Thu, Sep 17, 2009 at 8:36 AM, Ryan Ingram wrote: > ... > Explicitly: > > Haskell: >> test1 :: forall a. a -> Int >> test1 _ = 1 >> test2 :: (forall a. a) -> Int >> test2 x = x > > explicitly in System F: > > test1 = /\a \(x :: a). 1 > test2 = \(x :: forall a. a). x @Int > > /\ is type-level lambda, and @ is type-level application. Ok. But let me be pedantic: where is the universal quantification in test1? It seems to me the a is a free variable in test1 while being closed under universal quantification in test2. > In test1, the caller specifies "a" and then passes in an object of that > type. The witness? > In test2, the caller must pass in an object which is of all types, and test2 > asks for that object to be instantiated at the type "Int" "of all types" means "a value which belongs to all the sets of all the types", i.e. bottom? >> > Or, to put it another way, since there are no non-bottom objects of type >> > (forall a. a): >> >> Why? > > Informally, because you can't create something that can be any type. Yes, I misread the initial statement. I missed the "non-bottom" part :) > There's one way that doesn't entirely ignore its argument. > > test4 x = seq x 1 > > But I don't like to talk about that one :) :) Thank you Ryan, you were very explicative. I may say that the use of the System-F's notation, making everything explicit, clarifies this a bit. Cristiano From daniel.is.fischer at web.de Thu Sep 17 10:05:05 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 09:46:05 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <52f14b210909170656w5244ef97rd9246aeed2721c5f@mail.gmail.com> References: <52f14b210909170656w5244ef97rd9246aeed2721c5f@mail.gmail.com> Message-ID: <200909171605.05411.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 15:56:03 schrieb Jos? Pedro Magalh?es: > Hey Andy, > > On Thu, Sep 17, 2009 at 15:40, Andy Gimblett wrote: > > Now, some of those algebraic data type types happen to be > > enumerations; in this case, my idea is to list the constructors, with > > the rule that each constructor's position in the list is the Int which > > gets converted into that constructor. > > > > > class Enumerated a where > > > constructors :: [a] > > > > E.g. here's a type Bar with three constructors: > > > data Bar = X | Y | Z deriving (Show) > > > instance Enumerated Bar where > > > constructors = [X, Y, Z] > > > > (This is certainly ugly. Any suggestions?) > > > |constructors| is expressible in SYB: Wow. What about data Bar = X | Y | Z deriving (Show, Eq, Ord, Enum, Bounded) instance Enumerated Bar where constructors = [minBound .. maxBound] ? From jpm at cs.uu.nl Thu Sep 17 10:21:34 2009 From: jpm at cs.uu.nl (=?ISO-8859-1?Q?Jos=E9_Pedro_Magalh=E3es?=) Date: Thu Sep 17 10:01:29 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <200909171605.05411.daniel.is.fischer@web.de> References: <52f14b210909170656w5244ef97rd9246aeed2721c5f@mail.gmail.com> <200909171605.05411.daniel.is.fischer@web.de> Message-ID: <52f14b210909170721o612e02fdya6cb17bd2d4a8b7@mail.gmail.com> Hello, On Thu, Sep 17, 2009 at 16:05, Daniel Fischer wrote: > Am Donnerstag 17 September 2009 15:56:03 schrieb Jos? Pedro Magalh?es: > > Hey Andy, > > > > On Thu, Sep 17, 2009 at 15:40, Andy Gimblett > wrote: > > > Now, some of those algebraic data type types happen to be > > > enumerations; in this case, my idea is to list the constructors, with > > > the rule that each constructor's position in the list is the Int which > > > gets converted into that constructor. > > > > > > > class Enumerated a where > > > > constructors :: [a] > > > > > > E.g. here's a type Bar with three constructors: > > > > data Bar = X | Y | Z deriving (Show) > > > > instance Enumerated Bar where > > > > constructors = [X, Y, Z] > > > > > > (This is certainly ugly. Any suggestions?) > > > > > |constructors| is expressible in SYB: > Wow. > > What about > > data Bar = X | Y | Z deriving (Show, Eq, Ord, Enum, Bounded) > > instance Enumerated Bar where > constructors = [minBound .. maxBound] > > ? > Oh yes, that will certainly work for this very simple datatype. However, one cannot automatically derive instances of |Bounded| for datatypes with non-nullary constructors. Cheers, Pedro > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/c859e2e5/attachment.html From haskell at gimbo.org.uk Thu Sep 17 10:30:14 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 17 10:08:57 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <52f14b210909170721o612e02fdya6cb17bd2d4a8b7@mail.gmail.com> References: <52f14b210909170656w5244ef97rd9246aeed2721c5f@mail.gmail.com> <200909171605.05411.daniel.is.fischer@web.de> <52f14b210909170721o612e02fdya6cb17bd2d4a8b7@mail.gmail.com> Message-ID: <948FF298-2A29-4DBB-A172-AFA0813D7FB5@gimbo.org.uk> On 17 Sep 2009, at 15:21, Jos? Pedro Magalh?es wrote: > > > E.g. here's a type Bar with three constructors: > > > > data Bar = X | Y | Z deriving (Show) > > > > instance Enumerated Bar where > > > > constructors = [X, Y, Z] > > > > > > (This is certainly ugly. Any suggestions?) > > > > > |constructors| is expressible in SYB: > Wow. > > What about > > data Bar = X | Y | Z deriving (Show, Eq, Ord, Enum, Bounded) > > instance Enumerated Bar where > constructors = [minBound .. maxBound] > > ? > > Oh yes, that will certainly work for this very simple datatype. > However, one cannot automatically derive instances of |Bounded| for > datatypes with non-nullary constructors. That would be OK in this instance, I think; I'm already dealing with some of those cases by hand, but there were enough purely nullary ones that this seemed worth doing. I don't know if that will work any better with Foo/convert, though... :-) Thanks though Daniel - it's good to meet Enum and Bounded. -Andy From daniel.is.fischer at web.de Thu Sep 17 10:55:20 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 10:35:04 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <948FF298-2A29-4DBB-A172-AFA0813D7FB5@gimbo.org.uk> References: <52f14b210909170721o612e02fdya6cb17bd2d4a8b7@mail.gmail.com> <948FF298-2A29-4DBB-A172-AFA0813D7FB5@gimbo.org.uk> Message-ID: <200909171655.20253.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 16:30:14 schrieb Andy Gimblett: > On 17 Sep 2009, at 15:21, Jos? Pedro Magalh?es wrote: > > > > E.g. here's a type Bar with three constructors: > > > > > data Bar = X | Y | Z deriving (Show) > > > > > instance Enumerated Bar where > > > > > constructors = [X, Y, Z] > > > > > > > > (This is certainly ugly. Any suggestions?) > > > > > > > |constructors| is expressible in SYB: > > > > Wow. > > > > What about > > > > data Bar = X | Y | Z deriving (Show, Eq, Ord, Enum, Bounded) > > > > instance Enumerated Bar where > > constructors = [minBound .. maxBound] > > > > ? > > > > Oh yes, that will certainly work for this very simple datatype. > > However, one cannot automatically derive instances of |Bounded| for > > datatypes with non-nullary constructors. Andy's original message hasn't found its way into my inbox yet (neither has yours which Andy here quotes), so I don't know what Andy wants to do. From the part you quoted, I drew the conclusion that one thing Andy wanted was a more elegant way for the case of nullary constructors. For that, SYB is certainly overkill. I haven't looked at your code, I suppose it also does something reasonable in the presence of non-nullary constructors, in which case the separate treatment of only nullary constructors would of course be unnecessary. > > That would be OK in this instance, I think; I'm already dealing with > some of those cases by hand, but there were enough purely nullary ones > that this seemed worth doing. > > I don't know if that will work any better with Foo/convert, > though... :-) I'll probably understand that when your original message arrives :-) > > Thanks though Daniel - it's good to meet Enum and Bounded. > > -Andy From gregorypropf at yahoo.com Thu Sep 17 11:08:09 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Sep 17 10:46:45 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <19e5d1d00909170606l18ef6ae6n45cd4c2f69532820@mail.gmail.com> Message-ID: <261647.46992.qm@web112202.mail.gq1.yahoo.com> Remember that there is asymmetry between (+) and (-).? The former has the commutative property and the latter does not so: (+) 3 4 = 7 and (+) 4 3 = 7 but (-) 3 4 = -1 and (-) 4 3 = 1 --- On Thu, 9/17/09, Tom Doris wrote: From: Tom Doris Subject: Re: [Haskell-beginners] map question To: "Joost Kremers" Cc: beginners@haskell.org Date: Thursday, September 17, 2009, 6:06 AM This works: map (+ (-1)) [1,2,3,4] 2009/9/17 Joost Kremers Hi all, I've just started learning Haskell and while experimenting with map a bit, I ran into something I don't understand. The following commands do what I'd expect: Prelude> map (+ 1) [1,2,3,4] [2,3,4,5] Prelude> map (* 2) [1,2,3,4] [2,4,6,8] Prelude> map (/ 2) [1,2,3,4] [0.5,1.0,1.5,2.0] Prelude> map (2 /) [1,2,3,4] [2.0,1.0,0.6666666666666666,0.5] But I can't seem to find a way to get map to substract 1 from all members of the list. The following form is the only one that works, but it doesn't give the result I'd expect: Prelude> map ((-) 1) [1,2,3,4] [0,-1,-2,-3] I know I can use an anonymous function, but I'm just trying to understand the result here... I'd appreciate any hints to help me graps this. TIA Joost -- Joost Kremers, PhD University of Frankfurt Institute for Cognitive Linguistics Gr?neburgplatz 1 60629 Frankfurt am Main, Germany _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -----Inline Attachment Follows----- _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/c21563a7/attachment.html From kkwweett at yahoo.fr Thu Sep 17 11:32:51 2009 From: kkwweett at yahoo.fr (jean legrand) Date: Thu Sep 17 11:11:28 2009 Subject: [Haskell-cafe] Re: Where can I find a non-fee-based version of Hudak's paper, "Conception, evolution, and application of functional programming languages"? Message-ID: <111099.17243.qm@web24506.mail.ird.yahoo.com> > Does anybody know where I can find a non-fee-based version of Paul > Hudak's paper, "Conception, evolution, and application of functional > programming languages" [1]? There used to be a version that did not seems you can get a djvu copy here http://lib.org.by/info/Cs_Computer science/CsPl_Programming languages/Hudak P. Conception, evolution, and application of functional programming languages (ACM comp.surveys 21, 1989)(T)(53s).djvu the site is in Russian and you wait 30s before a link to the file appears. From daniel.is.fischer at web.de Thu Sep 17 11:50:27 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 11:30:10 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: References: Message-ID: <200909171750.27590.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 15:40:10 schrieb Andy Gimblett: > > > instance (Enumerated a) => Target a where > > convert n | n `elem` [0..len-1] = Just $ constructors !! n > > > > | otherwise = Nothing > > > > where len = length constructors Yes, the second appearance of 'constructors' is at an unspecified type. instance (Enumerated a) => Target a where convert n | n < 0 = Nothing | otherwise = case drop n constructors of (x:_) -> Just x _ -> Nothing would make it compile. But there'd be a risk that Target is unusable, depending on how instance resolution is done. > > I guess I see roughly what's going on; the question is "which > constructors instance is meant?", right? In the "Just" part it's OK, > because it can be inferred from the function's return type (right?). > But in the guard we don't have that help, so it could be any > Enumerated instance? Exactly. > > Any advice appreciated! Particularly if this is just a dumb approach. > For context, this is related to deserialisation of binary data (they'll > actually be Word8's, not Int's) into a variety of data structures. > > Hmmm, maybe I should just be using Data.Binary... > > Many thanks, > > -Andy From list at phaedrusdeinus.org Thu Sep 17 11:55:19 2009 From: list at phaedrusdeinus.org (John Melesky) Date: Thu Sep 17 11:34:38 2009 Subject: [Haskell-cafe] Where can I find a non-fee-based version of Hudak's paper, "Conception, evolution, and application of functional programming languages"? In-Reply-To: References: Message-ID: <78BFDF05-0D88-4B1D-A1C6-513EE9518156@phaedrusdeinus.org> On 2009-09-17, at 1:41 AM, Benjamin L.Russell wrote: > Does anybody know where I can find a non-fee-based version of Paul > Hudak's paper, "Conception, evolution, and application of functional > programming languages" [1]? When in doubt, check citeseer. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.6505 -johnnnn From haskell at gimbo.org.uk Thu Sep 17 12:01:36 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 17 11:40:18 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <200909171750.27590.daniel.is.fischer@web.de> References: <200909171750.27590.daniel.is.fischer@web.de> Message-ID: <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> On 17 Sep 2009, at 16:50, Daniel Fischer wrote: > Yes, the second appearance of 'constructors' is at an unspecified > type. > > instance (Enumerated a) => Target a where > convert n > | n < 0 = Nothing > | otherwise = case drop n constructors of > (x:_) -> Just x > _ -> Nothing > > would make it compile. Neat trick. It works: thanks! > But there'd be a risk that Target is unusable, depending on how > instance resolution is > done. Unusable? How so? Sorry, but I don't follow... -Andy From jvranish at gmail.com Thu Sep 17 12:04:02 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Sep 17 11:42:38 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <261647.46992.qm@web112202.mail.gq1.yahoo.com> References: <19e5d1d00909170606l18ef6ae6n45cd4c2f69532820@mail.gmail.com> <261647.46992.qm@web112202.mail.gq1.yahoo.com> Message-ID: (-) happens to be the only prefix operator in haskell, it also an infix operator. so: > 4 - 2 2 > -3 -3 > ((-) 5) 3 -- note that in this case (-) is treated like any regular function so 5 is the first parameter 2 > (5 - ) 3 2 > (-5 ) -5 > (flip (-) 5) 3 -2 It's a little wart brought about by the ambiguity in common mathematical syntax. If you play around in ghci you should get the hang of it pretty quick. - Job On Thu, Sep 17, 2009 at 11:08 AM, Gregory Propf wrote: > Remember that there is asymmetry between (+) and (-). The former has the > commutative property and the latter does not so: > > (+) 3 4 = 7 > > and > > (+) 4 3 = 7 > > but > > (-) 3 4 = -1 > > and > > (-) 4 3 = 1 > > --- On *Thu, 9/17/09, Tom Doris * wrote: > > > From: Tom Doris > Subject: Re: [Haskell-beginners] map question > To: "Joost Kremers" > Cc: beginners@haskell.org > Date: Thursday, September 17, 2009, 6:06 AM > > This works: > > map (+ (-1)) [1,2,3,4] > > > 2009/9/17 Joost Kremers > > > >> Hi all, >> >> I've just started learning Haskell and while experimenting with map a bit, >> I ran >> into something I don't understand. The following commands do what I'd >> expect: >> >> Prelude> map (+ 1) [1,2,3,4] >> [2,3,4,5] >> Prelude> map (* 2) [1,2,3,4] >> [2,4,6,8] >> Prelude> map (/ 2) [1,2,3,4] >> [0.5,1.0,1.5,2.0] >> Prelude> map (2 /) [1,2,3,4] >> [2.0,1.0,0.6666666666666666,0.5] >> >> But I can't seem to find a way to get map to substract 1 from all members >> of the >> list. The following form is the only one that works, but it doesn't give >> the >> result I'd expect: >> >> Prelude> map ((-) 1) [1,2,3,4] >> [0,-1,-2,-3] >> >> I know I can use an anonymous function, but I'm just trying to understand >> the >> result here... I'd appreciate any hints to help me graps this. >> >> TIA >> >> Joost >> >> >> -- >> Joost Kremers, PhD >> University of Frankfurt >> Institute for Cognitive Linguistics >> Gr?neburgplatz 1 >> 60629 Frankfurt am Main, Germany >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > > > -----Inline Attachment Follows----- > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/dec99a61/attachment.html From deniz.a.m.dogan at gmail.com Thu Sep 17 12:10:44 2009 From: deniz.a.m.dogan at gmail.com (Deniz Dogan) Date: Thu Sep 17 11:49:39 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <261647.46992.qm@web112202.mail.gq1.yahoo.com> References: <19e5d1d00909170606l18ef6ae6n45cd4c2f69532820@mail.gmail.com> <261647.46992.qm@web112202.mail.gq1.yahoo.com> Message-ID: <7b501d5c0909170910q78bbe05m5f944f8868371e5c@mail.gmail.com> > 2009/9/17 Joost Kremers >> >> Hi all, >> >> I've just started learning Haskell and while experimenting with map a bit, I ran >> into something I don't understand. The following commands do what I'd expect: >> >> Prelude> map (+ 1) [1,2,3,4] >> [2,3,4,5] >> Prelude> map (* 2) [1,2,3,4] >> [2,4,6,8] >> Prelude> map (/ 2) [1,2,3,4] >> [0.5,1.0,1.5,2.0] >> Prelude> map (2 /) [1,2,3,4] >> [2.0,1.0,0.6666666666666666,0.5] >> >> But I can't seem to find a way to get map to substract 1 from all members of the >> list. The following form is the only one that works, but it doesn't give the >> result I'd expect: >> >> Prelude> map ((-) 1) [1,2,3,4] >> [0,-1,-2,-3] >> >> I know I can use an anonymous function, but I'm just trying to understand the >> result here... I'd appreciate any hints to help me graps this. >> >> TIA >> >> Joost The reason that "map (-1) [1,2,3,4]" doesn't work as you'd expect it to is that "-" is ambiguous in Haskell (some may disagree). "-1" means "-1" in Haskell, i.e. negative 1, not "the function that subtracts 1 from its argument". "(-) 1" is the function that subtracts its argument from 1, which is not what you were looking for either! You're looking for the function that subtracts 1 from its argument, which is `subtract 1'. Prelude> map (subtract 1) [1..4] [0,1,2,3] Note that `subtract' is just another name for `flip (-)', i.e. subtraction with its argument in reverse order. -- Deniz Dogan From ryani.spam at gmail.com Thu Sep 17 12:49:32 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Sep 17 12:28:08 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> <2f9b2d30909162336o216a4207pb28ce9d69ea08e61@mail.gmail.com> Message-ID: <2f9b2d30909170949t5a53146ep505990a703c982d8@mail.gmail.com> On Thu, Sep 17, 2009 at 6:59 AM, Cristiano Paris wrote: > On Thu, Sep 17, 2009 at 8:36 AM, Ryan Ingram wrote: > > ... > > Explicitly: > > > > Haskell: > >> test1 :: forall a. a -> Int > >> test1 _ = 1 > >> test2 :: (forall a. a) -> Int > >> test2 x = x > > > > explicitly in System F: > > > > test1 = /\a \(x :: a). 1 > > test2 = \(x :: forall a. a). x @Int > > > > /\ is type-level lambda, and @ is type-level application. > > Ok. But let me be pedantic: where is the universal quantification in > test1? It seems to me the a is a free variable in test1 while being > closed under universal quantification in test2. > The universal quantification is right in the extra lambda: it works for all types "a". Just like this works on all lists [a]: length = /\a. \(xs :: [a]). case xs of { [] -> 0 ; (x:ys) -> 1 + length @a ys } Here are some uses of test1: v1 = test1 @Int 0 v2 = test1 @[Char] "hello" v3 = test1 @() () Here's a use of test2: v4 = test2 (/\a. error @a "broken") given error :: forall a. String -> a -- ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/7427d394/attachment.html From daniel.is.fischer at web.de Thu Sep 17 12:48:46 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 12:28:32 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> References: <200909171750.27590.daniel.is.fischer@web.de> <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> Message-ID: <200909171848.46438.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 18:01:36 schrieb Andy Gimblett: > On 17 Sep 2009, at 16:50, Daniel Fischer wrote: > > Yes, the second appearance of 'constructors' is at an unspecified > > type. > > > > instance (Enumerated a) => Target a where > > convert n > > > > | n < 0 = Nothing > > | otherwise = case drop n constructors of > > > > (x:_) -> Just x > > _ -> Nothing > > > > would make it compile. > > Neat trick. It works: thanks! > > > But there'd be a risk that Target is unusable, depending on how > > instance resolution is > > done. > > Unusable? How so? Sorry, but I don't follow... > Cf. Section 7.6.3.3 of the user's guide: "When matching, GHC takes no account of the context of the instance declaration (context1 etc). GHC's default behaviour is that exactly one instance must match the constraint it is trying to resolve. It is fine for there to be a potential of overlap (by including both declarations (A) and (B), say); an error is only reported if a particular constraint matches more than one. The -XOverlappingInstances flag instructs GHC to allow more than one instance to match, provided there is a most specific one. For example, the constraint C Int [Int] matches instances (A), (C) and (D), but the last is more specific, and hence is chosen. If there is no most-specific match, the program is rejected." So for the matching, you have now instance Target a where ... which matches everything. Add an instance declaration of the form instance (SomeClass b) => Target b where ... and you're hosed. Though I think that wouldn't compile, at least not without IncoherentInstances. Actually, I think now that with one-parameter type classes, if it compiles, it will most likely work, at least I don't see the problems one can create with multi-parameter type classes now. > -Andy > From ryani.spam at gmail.com Thu Sep 17 13:01:17 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Sep 17 12:39:53 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> References: <200909171750.27590.daniel.is.fischer@web.de> <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> Message-ID: <2f9b2d30909171001k6db61cadwf23c1b735bb9e1f3@mail.gmail.com> Here's a way that works more closely to your original version: instance Enumerated a => Target a where convert n | n >= 0 && n < numConstrs = Just (constrs !! n) | otherwise = Nothing where constrs = constructors numConstrs = length constrs Alternatively: instance Enumerated a => Target a where convert n | n >= 0 && n < numConstrs = Just result | otherwise = Nothing where numConstrs = length (constructors `asTypeOf` [result]) result = constructors !! n However let me warn you that you aren't going to be happy with this instance when it comes time to use this. Instead, you probably want one of the following: defaultConvert :: Enumerated a => Int -> a defaultConvert n | n >= 0 && n < numConstrs = Just (WithEnumerated (constrs !! n)) | otherwise = Nothing where constrs = constructors numConstrs = length constrs (a) instance Target SomeEnumeratedType where convert = defaultConvert (b) newtype WithEnumerated a = WithEnumerated a instance Enumerated a => Target (WithEnumerated a) where convert n = WithEnumerated (defaultConvert n) OverlappingInstances basically never does what you want in the long run. -- ryan On Thu, Sep 17, 2009 at 9:01 AM, Andy Gimblett wrote: > > On 17 Sep 2009, at 16:50, Daniel Fischer wrote: > > Yes, the second appearance of 'constructors' is at an unspecified type. >> >> instance (Enumerated a) => Target a where >> convert n >> | n < 0 = Nothing >> | otherwise = case drop n constructors of >> (x:_) -> Just x >> _ -> Nothing >> >> would make it compile. >> > > Neat trick. It works: thanks! > > But there'd be a risk that Target is unusable, depending on how instance >> resolution is >> done. >> > > Unusable? How so? Sorry, but I don't follow... > > > -Andy > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/8e43ef19/attachment.html From jvranish at gmail.com Thu Sep 17 13:32:13 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Sep 17 13:10:49 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: <20090916144839.34273cb1@jabber.aur.us.ray.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> <20090916144839.34273cb1@jabber.aur.us.ray.com> Message-ID: What are you trying to use this for? It seems to me that for memo tables you almost never have references to they keys outside the lookup table since the keys are usually computed right at the last minute, and then discarded (otherwise it might be easier to just cache stuff outside the function). For example with a naive fibs, the values you are passing in are computed, and probably don't exist before you do the recursive call, and then are discarded shortly afterward. It seems like putting a cap on the cache size, and then just overwriting old entries would be better. Am I missing something? - Job On Wed, Sep 16, 2009 at 4:48 PM, Rodney Price wrote: > How does garbage collection work in an example like the one below? You > memoize a function with some sort of lookup table, which stores function > arguments as keys and function results as values. As long as the > function remains in scope, the keys in the lookup table remain in > memory, which means that the keys themselves always remain reachable > and they cannot be garbage collected. Right? > > So what do you do in the case where you know that, after some period of > time, some entries in the lookup table will never be accessed? That is, > there are no references to the keys for some entries remaining, except > for the references in the lookup table itself. You'd like to allow the > memory occupied by the keys to be garbage collected. Otherwise, if the > function stays around for a long time, the size of the lookup table > always grows. How do you avoid the space leak? > > I notice that there is a function in Data.IORef, > > mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) > > which looks promising. In the code below, however, there's only one > IORef, so either the entire table gets garbage collected or none of it > does. > > I've been reading the paper "Stretching the storage manager: weak > pointers and stable names in Haskell," which seems to answer my > question. When I attempt to run the memoization code in the paper on > the simple fib example, I find that -- apparently due to lazy > evaluation -- no new entries are entered into the lookup table, and > therefore no lookups are ever successful! > > So apparently there is some interaction between lazy evaluation and > garbage collection that I don't understand. My head hurts. Is it > necessary to make the table lookup operation strict? Or is it > something entirely different that I am missing? > > -Rod > > > On Thu, 10 Sep 2009 18:33:47 -0700 > Ryan Ingram wrote: > > > > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) > > memoIO f = do > > cache <- newIORef M.empty > > return $ \x -> do > > m <- readIORef cache > > case M.lookup x m of > > Just y -> return y > > Nothing -> do let res = f x > > writeIORef cache $ M.insert x res m > > return res > > > > memo :: Ord a => (a -> b) -> (a -> b) > > memo f = unsafePerformIO $ do > > fmemo <- memoIO f > > return (unsafePerformIO . fmemo) > > > > I don't think there is any valid transformation that breaks this, > > since the compiler can't lift anything through unsafePerformIO. Am I > > mistaken? > > > > -- ryan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/0b8aec60/attachment.html From Patrick.Browne at comp.dit.ie Thu Sep 17 14:36:37 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Thu Sep 17 14:17:03 2009 Subject: [Haskell-cafe] Peano axioms In-Reply-To: <4A843E45.7040107@comp.dit.ie> References: <4A843E45.7040107@comp.dit.ie> Message-ID: <4AB281B5.9080603@comp.dit.ie> Hi, Below are two attempts to define Peano arithmetic in Haskell. The first attempt, Peano1, consists of just a signature in the class with the axioms in the instance. In the second attempt, Peano2, I am trying to move the axioms into the class. The reason is, I want to put as much specification as possible into the class. Then I would like to include properties in the class such as commutativity something like: infixl 5 `com` com :: Int -> Int -> Int x `com` y = (x + y) commutative com a b = (a `com` b) == (b `com` a) I seem to be able to include just one default equation the Peano2 attempt. Any ideas? I have looked at http://www.haskell.org/haskellwiki/Peano_numbers Regards, Pat -- Attempt 1 -- In this attempt the axioms are in the instance and things seem OK module Peano1 where infixl 6 `eq` infixl 5 `plus` class Peano1 n where suc :: n -> n eq :: n -> n -> Bool plus :: n -> n -> n data Nat = One | Suc Nat deriving Show instance Peano1 Nat where suc = Suc One `eq` One = True (Suc m) `eq` (Suc n) = m `eq` n _`eq`_ = False m `plus` One = Suc m m `plus` (Suc n) = Suc (m `plus` n) -- Evaluation *Peano1> Suc(One) `plus` ( Suc (One)) -- Attempt 2 -- In this attempt the axioms are in the class and things are not OK. module Peano2 where infixl 6 `eq` infixl 5 `plus` class Peano2 n where one :: n eq :: n -> n -> Bool plus :: n -> n -> n suc :: n -> n suc a = a `plus` one {- I cannot add the remaining default axioms one `eq` one = True (suc m) `eq` (suc n) = m `eq` n (suc a) `eq` (suc b) = a `eq` b _`eq`_ = False -} From frodo at theshire.org Thu Sep 17 15:07:28 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Sep 17 14:46:22 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909152331.09797.daniel.is.fischer@web.de> References: <200909152242.50033.daniel.is.fischer@web.de> <200909152331.09797.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 15, 2009 at 11:31 PM, Daniel Fischer wrote: > ... > Yeah, you do *not* want the whole file to be read here, except above for testing purposes. That's not true. Sometimes I want to, sometimes don't. But I want to use the same code for reading files and exploit laziness to avoid reading the body. > Still, ByteStrings are probably the better choice (if you want the body and that can be > large). That's not a problem by now. > To avoid reading the body without unsafePerformIO: > > readBit fn > ? ?= Control.Exception.bracket (openFile fn ReadMode) hClose > ? ? ? ? ?(\h -> do > ? ? ? ? ? ? ? ?l <- hGetLine h > ? ? ? ? ? ? ? ?let i = read l > ? ? ? ? ? ? ? ?bdy <- hGetContents h > ? ? ? ? ? ? ? ?return $ Bit i bdy) Same problem with the "withFile"-version: nothing gets printed if I try to print out the body: that's way I used seq. I'm starting to think that the only way to do this without using unsafePerformIO is to have the body being an IO action: simply, under Haskell assumption, that's not possible to write, because Haskell enforce safety above all. Cristiano From jvranish at gmail.com Thu Sep 17 15:17:50 2009 From: jvranish at gmail.com (Job Vranish) Date: Thu Sep 17 14:56:28 2009 Subject: [Haskell-cafe] Peano axioms In-Reply-To: <4AB281B5.9080603@comp.dit.ie> References: <4A843E45.7040107@comp.dit.ie> <4AB281B5.9080603@comp.dit.ie> Message-ID: The problem is that you are using 'suc' as if it is a constructor: ((suc m) `eq` (suc n) = m `eq` n) You'll have to change it to something else, and it will probably require adding an unpacking function to your class and it will probably be messy. I'd suggest you make use of the Eq typeclass and defined the Eq instances separately: class (Eq n) => Peano2 n where one :: n plus :: n -> n -> n suc :: n -> n suc a = a `plus` one - Job On Thu, Sep 17, 2009 at 2:36 PM, pat browne wrote: > Hi, > Below are two attempts to define Peano arithmetic in Haskell. > The first attempt, Peano1, consists of just a signature in the class > with the axioms in the instance. In the second attempt, Peano2, I am > trying to move the axioms into the class. The reason is, I want to put > as much specification as possible into the class. Then I would like to > include properties in the class such as commutativity something like: > infixl 5 `com` > com :: Int -> Int -> Int > x `com` y = (x + y) > commutative com a b = (a `com` b) == (b `com` a) > > I seem to be able to include just one default equation the Peano2 attempt. > Any ideas? > I have looked at > http://www.haskell.org/haskellwiki/Peano_numbers > > Regards, > Pat > > -- Attempt 1 > -- In this attempt the axioms are in the instance and things seem OK > module Peano1 where > infixl 6 `eq` > infixl 5 `plus` > > class Peano1 n where > suc :: n -> n > eq :: n -> n -> Bool > plus :: n -> n -> n > > data Nat = One | Suc Nat deriving Show > > > instance Peano1 Nat where > suc = Suc > One `eq` One = True > (Suc m) `eq` (Suc n) = m `eq` n > _`eq`_ = False > m `plus` One = Suc m > m `plus` (Suc n) = Suc (m `plus` n) > -- Evaluation *Peano1> Suc(One) `plus` ( Suc (One)) > > > > > > -- Attempt 2 > -- In this attempt the axioms are in the class and things are not OK. > module Peano2 where > infixl 6 `eq` > infixl 5 `plus` > > class Peano2 n where > one :: n > eq :: n -> n -> Bool > plus :: n -> n -> n > suc :: n -> n > suc a = a `plus` one > > {- > I cannot add the remaining default axioms > one `eq` one = True > (suc m) `eq` (suc n) = m `eq` n > (suc a) `eq` (suc b) = a `eq` b > _`eq`_ = False > -} > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/1e72ac4a/attachment-0001.html From lgreg.meredith at biosimilarity.com Thu Sep 17 15:30:01 2009 From: lgreg.meredith at biosimilarity.com (Greg Meredith) Date: Thu Sep 17 15:08:36 2009 Subject: [Haskell-cafe] Composition, delegation and interfaces -- a 20K ft critique of Noop In-Reply-To: <5de3f5ca0909171226o3eb1c987nc59d9b18579a6dd8@mail.gmail.com> References: <5de3f5ca0909171226o3eb1c987nc59d9b18579a6dd8@mail.gmail.com> Message-ID: <5de3f5ca0909171230q5d8c618em2635f50bed9deb73@mail.gmail.com> Dear Programmers, Someone just asked me to give my opinion on Noop's composition proposal. It reminds me a little bit of Selfwhich found its way into JavaScript. It also reminds me a little of Haskell's type classes . In general, movement away from inheritance is good. The proposal, however, feels a bit like looking for the lost quarter where the light is good, rather than where you lost it. Before considering delegation machinery, let's consider the *value*of an interface. How many interfaces are there? One way to see that is just to consider all the sub interfaces of a single interface with n methods on it. Hmmm... that's 2^n interfaces. That's a lot. Does that give us any confidence that any one way of carving up functionality via interfaces is going to be sane? Further, in practice, do we see random distribution through this very large space? What we see over and over again in practice is that the answer to these questions is 'no!'. That means that there is *something* that binds a collection of methods together. What might that something be? One place to look is mathematics. Which maths should we look at? The maths of category has been very fruitful both in explaining existing functional programming techniques and -- perhaps more importantly -- suggesting ways to improve them as well as wholly new techniques. What we find in category theory is that it is natural to collect maps (read functions) together. A good example of such a beast is a monad. A monad -- viewed categorically -- is - a map, T, taking types to new types and functions on those types to new functions. Let's call the universe of types and functions expressible in our model of computation (as proscribed by our programming language), C. Then T : C -> C. - a higher order map, unit. Just like T takes C to C, we can understand a "noop" like map that takes C to C, call it Id. Then unit : Id -> T. We intuitively think about it as putting basic types inside the container T, but it's really a higher order map. - another higher order map, mult : T^2 -> T. We talk about it as a kind of flattening (and in Scala it's called flatMap), but it's a higher order map. Now, one is not finished spelling out a monad when giving this collection of maps. One must also show that they satisfy certain constraints. - T is functorial, meaning T g f = T(g) T(f) - unit and mult are natural transformations, look up the meaning because unpacking it here would take to long - mult( mult T ) = mult( T mult ) - mult( unit T ) = mult( T unit ) This set of constraints must go with the monad. This example provides a little more detail in terms of what binds a group of maps together, and hence of what *might* replace the notion of interface and *explain* what we see in practice. Good programmers invariably pick out just a few factorizations of possible interfaces -- from the giant sea of factorizations (read different ways to carve up the functionality). The reason -- i submit -- is because in their minds there are some constraints they know or at least intuit must hold -- but they have no good way at the language level to express those constraints. A really practical language should help the programmer by providing a way express and check the constraints that hold amongst the maps in an interface. i submit that this idea is not the same as "design by contract". i am not proposing an Eiffel-like mechanism. Again, taking a functional approach to computation via category theory leads one towards modeling interfaces as categorical "situations" like monads, comonads, distribution laws, etc. This means that a large number of the constraints come down to - functoriality - naturality - coherence Language support for this approach might include *keywords for these kinds of assertions*. It is a gnarly beast to offer automatic and/or compiler support for checking general constraints. Even this limited family of constraints that i'm proposing can generate some very difficult computations, with very bad complexity. However, for those situations where a general purpose solution to check assertions of functoriality, naturality and coherence are infeasible, one can use these hints to generate tests to probe for possible failures. This idea follows the in the same spirit of replacing proof with proof-checking. Of course, this is not the only way to go. i've yet to be convinced that category theory offers a good account of concurrency. Specifically, categorical composition does not line up well with concurrent composition. So, interfaces organized around types for concurrency is also something to consider. In this case, one might find a natural beginning in interfaces in which -- roughly speaking -- the methods constitute the tokens of a formal language the constructors of which are given by the types for concurrency paradigm. Best wishes, --greg On Thu, Sep 17, 2009 at 11:14 AM, Charles F. Munat wrote: > http://code.google.com/p/noop/wiki/ProposalForComposition > -- L.G. Meredith Managing Partner Biosimilarity LLC 1219 NW 83rd St Seattle, WA 98117 +1 206.650.3740 http://biosimilarity.blogspot.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/01a9544c/attachment.html From daniel.is.fischer at web.de Thu Sep 17 16:01:01 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 15:42:56 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909152331.09797.daniel.is.fischer@web.de> Message-ID: <200909172201.01878.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 21:07:28 schrieb Cristiano Paris: > On Tue, Sep 15, 2009 at 11:31 PM, Daniel Fischer > > wrote: > > ... > > Yeah, you do *not* want the whole file to be read here, except above for > > testing purposes. > > That's not true. Sometimes I want to, sometimes don't. The "for the case of sorting by metadata" was tacitly assumed :) > But I want to use the same code for reading files and exploit laziness > to avoid reading the body. > > > Still, ByteStrings are probably the better choice (if you want the body > > and that can be large). > > That's not a problem by now. > > > To avoid reading the body without unsafePerformIO: > > > > readBit fn > > ? ?= Control.Exception.bracket (openFile fn ReadMode) hClose > > ? ? ? ? ?(\h -> do > > ? ? ? ? ? ? ? ?l <- hGetLine h > > ? ? ? ? ? ? ? ?let i = read l > > ? ? ? ? ? ? ? ?bdy <- hGetContents h > > ? ? ? ? ? ? ? ?return $ Bit i bdy) > > Same problem with the "withFile"-version: nothing gets printed if I > try to print out the body: that's way I used seq. Ah, yes. The file is closed too soon. > > I'm starting to think that the only way to do this without using > unsafePerformIO is to have the body being an IO action: simply, under > Haskell assumption, that's not possible to write, because Haskell > enforce safety above all. Well, what about readBit fn = do txt <- readFile fn let (l,_:bdy) = span (/= '\n') txt return $ Bit (read l) bdy ? With main = do args <- getArgs let n = case args of (a:_) -> read a _ -> 1000 bl <- mapM readBit ["file1.txt","file2.txt"] mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl mapM_ (putStrLn . take 20 . drop n . body) bl ./cparis3 30 +RTS -sstderr 2 3 CCGGGCGCGGTGGCTCACGC CCGGGCGCGGTGGCTCACGC 408,320 bytes allocated in the heap 1,220 bytes copied during GC 34,440 bytes maximum residency (1 sample(s)) 31,096 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) ./cparis3 20000 +RTS -sstderr 2 3 AAAATTAGCCGGGCGTGGTG AAAATTAGCCGGGCGTGGTG 1,069,168 bytes allocated in the heap 105,700 bytes copied during GC 137,356 bytes maximum residency (1 sample(s)) 27,344 bytes maximum slop 1 MB total memory in use (0 MB lost due to fragmentation) ./cparis3 2000000 +RTS -sstderr 2 3 CCTGGCCAACATGGTGAAAC CCTGGCCAACATGGTGAAAC 80,939,296 bytes allocated in the heap 8,925,240 bytes copied during GC 137,056 bytes maximum residency (2 sample(s)) 45,528 bytes maximum slop 2 MB total memory in use (0 MB lost due to fragmentation) %GC time 38.5% (27.0% elapsed) Alloc rate 1,264,577,704 bytes per MUT second Productivity 61.5% of total user, 38.8% of total elapsed ./cparis3 20000000 +RTS -sstderr 2 3 CAGAGCGAGACTCCGTCTCA CAGAGCGAGACTCCGTCTCA 806,034,756 bytes allocated in the heap 76,775,944 bytes copied during GC 136,876 bytes maximum residency (2 sample(s)) 43,324 bytes maximum slop 2 MB total memory in use (0 MB lost due to fragmentation) Generation 0: 1536 collections, 0 parallel, 0.35s, 0.35s elapsed Generation 1: 2 collections, 0 parallel, 0.00s, 0.00s elapsed INIT time 0.00s ( 0.00s elapsed) MUT time 0.53s ( 0.67s elapsed) GC time 0.35s ( 0.36s elapsed) EXIT time 0.00s ( 0.00s elapsed) Total time 0.88s ( 1.02s elapsed) %GC time 40.0% (34.9% elapsed) Alloc rate 1,526,482,681 bytes per MUT second Productivity 60.0% of total user, 51.7% of total elapsed Seems to work as desired. > > Cristiano From frodo at theshire.org Thu Sep 17 16:20:55 2009 From: frodo at theshire.org (Cristiano Paris) Date: Thu Sep 17 15:59:49 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909172201.01878.daniel.is.fischer@web.de> References: <200909152331.09797.daniel.is.fischer@web.de> <200909172201.01878.daniel.is.fischer@web.de> Message-ID: On Thu, Sep 17, 2009 at 10:01 PM, Daniel Fischer wrote: > ... > readBit fn = do > ? ?txt <- readFile fn > ? ?let (l,_:bdy) = span (/= '\n') txt > ? ?return $ Bit (read l) bdy > > ? > > With > > main = do > ? ?args <- getArgs > ? ?let n = case args of > ? ? ? ? ? ? ? ?(a:_) -> read a > ? ? ? ? ? ? ? ?_ -> 1000 > ? ?bl <- mapM readBit ["file1.txt","file2.txt"] > ? ?mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > ? ?mapM_ (putStrLn . take 20 . drop n . body) bl Yes, it *seems* to work but... the files don't get closed (readFile is unfinished until body is read) so I think I'm going to have problems when the number of files to read is higher than the maximum number of open handles a process can have. That's a possibility I considered even if not directly using readFile. Cristiano From magnus at therning.org Thu Sep 17 17:20:05 2009 From: magnus at therning.org (Magnus Therning) Date: Thu Sep 17 16:58:49 2009 Subject: [Haskell-cafe] algebra/grammar/language for expressing time intervals In-Reply-To: <4AB02B5F.29038.3713D69@ia.stryx.demon.co.uk> References: <4AB02B5F.29038.3713D69@ia.stryx.demon.co.uk> Message-ID: <4AB2A805.1090603@therning.org> Iain Alexander wrote: > You might want to take a look at > RFC 2445 > Internet Calendaring and Scheduling Core Object Specification > Section 4.8.5.4 Recurrence Rule Another source of inspiration might be the syntax used in remind[1]. /M [1]: http://www.roaringpenguin.com/products/remind -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus?therning?org Jabber: magnus?therning?org http://therning.org/magnus identi.ca|twitter: magthe -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/96ee357f/signature.bin From ramsdell0 at gmail.com Thu Sep 17 17:21:01 2009 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Thu Sep 17 16:59:34 2009 Subject: [Haskell-cafe] Peano axioms In-Reply-To: References: <4A843E45.7040107@comp.dit.ie> <4AB281B5.9080603@comp.dit.ie> Message-ID: <7687290b0909171421md7d64bbt9521fa9ca0f6a5d0@mail.gmail.com> I don't understand your goal. Isn't Peano arithmetic summarized in Haskell as: data Peano = Zero | Succ Peano deriving Eq This corresponds to a first-order logic over a signature that has equality, a constant symbol 0, and a one-place successor function symbol S. Function symbols such as < and + can be introduced as defined function symbols that do not add substantive information to the theory. The only axioms you want are the ones for equality. John From ramsdell0 at gmail.com Thu Sep 17 17:39:19 2009 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Thu Sep 17 17:17:54 2009 Subject: [Haskell-cafe] ANN: Unification in a Commutative Monoid (cmu 1.1) and a new release of Abelian group unification and matching (agum 2.2) Message-ID: <7687290b0909171439u2f0788fbj238e8a15d989b418@mail.gmail.com> Package cmu 1.1 provides unification in a commutative monoid, also know as ACU-unification. The core computation finds the minimal non-zero solutions to homogeneous linear Diaphantine equations. The linear equation solver has been place in a separate module so it can be used for other applications Package agum 2.2 provides unification and matching in an Abelian group, also know as AG-unification and matching. The core computation finds the integer solutions to inhomogeneous linear equations. The linear equation solver has been place in a separate module so it can be used for other applications John From daniel.is.fischer at web.de Thu Sep 17 18:41:26 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 18:21:08 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909172201.01878.daniel.is.fischer@web.de> Message-ID: <200909180041.26241.daniel.is.fischer@web.de> Am Donnerstag 17 September 2009 22:20:55 schrieb Cristiano Paris: > On Thu, Sep 17, 2009 at 10:01 PM, Daniel Fischer > > wrote: > > ... > > readBit fn = do > > ? ?txt <- readFile fn > > ? ?let (l,_:bdy) = span (/= '\n') txt > > ? ?return $ Bit (read l) bdy > > > > ? > > > > With > > > > main = do > > ? ?args <- getArgs > > ? ?let n = case args of > > ? ? ? ? ? ? ? ?(a:_) -> read a > > ? ? ? ? ? ? ? ?_ -> 1000 > > ? ?bl <- mapM readBit ["file1.txt","file2.txt"] > > ? ?mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > > ? ?mapM_ (putStrLn . take 20 . drop n . body) bl > > Yes, it *seems* to work but... the files don't get closed (readFile is > unfinished until body is read) so I think I'm going to have problems > when the number of files to read is higher than the maximum number of > open handles a process can have. Indeed. If the number of files is large, reading lazily with readFile is not so good. Eat the cake and have it. If you have a lot of files, want to read the metadata of all, select a (much) smaller number of files by some criterion on the set of metadata and then read the body of the selected files, it's hairy. Reading all bodies immediately is probably out due to memory restrictions. The clean approach would be to separate the reading of metadata and body. The drawback is that then you have a second entry into IO. Using unsafePerformIO, you can pretend that you don't reenter IO. Whether that is safe in your situation, I don't know. Probably not (rule of thumb: all nontrivial actions wrapped in unsafePerformIO aren't safe, though chances aren't bad that it works most of the time). > > That's a possibility I considered even if not directly using readFile. > > Cristiano From hiena03 at gmail.com Thu Sep 17 19:10:51 2009 From: hiena03 at gmail.com (=?ISO-8859-1?Q?Jos=E9_Prous?=) Date: Thu Sep 17 18:49:26 2009 Subject: [Haskell-cafe] help with FFI Message-ID: Hello Lets say I have a library in C with a header like this: #include /*really big structure*/ typedef struct { int *a; int *b; /*lots of stuff ... */ int *z; } foo; /*this function allocate memory and fill the structure, reading from a file*/ int create_foo(foo *f,FILE *file,int x,int y); /*some functions that use the structure*/ int use_foo(foo *f,int w); /*a funtion that releases the memory*/ int destroy_foo(foo *f); And I want to use it in haskell using FFI. I can create a .hsc file like this: {-# LANGUAGE CPP, ForeignFunctionInterface #-} import Foreign import Foreign.C.Types #include "foo.h" newtype Foo = Foo () foreign import ccall "static foo.h create_foo" c_create_foo :: Ptr (Foo) -> Ptr (CFile) -> CInt -> CInt -> IO CInt foreign import ccall "static foo.h use_foo" c_use_foo :: Ptr (Foo) -> CInt -> IO CInt foreign import ccall "static foo.h destroy_foo" c_destroy_foo :: Ptr (Foo) -> IO CInt It compiles but I have no idea how to call c_create_foo and get back Foo Any suggestions? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/88a9333a/attachment.html From rodprice at raytheon.com Thu Sep 17 19:39:01 2009 From: rodprice at raytheon.com (Rodney Price) Date: Thu Sep 17 19:17:46 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> <20090916144839.34273cb1@jabber.aur.us.ray.com> Message-ID: <20090917173901.47cbe3a9@jabber.aur.us.ray.com> In my case, the results of each computation are used to generate a node in a graph structure (dag). The key, oddly, is a hash of a two-tuple that gets stored in the data structure after the computation of the node finishes. If I don't memoize the function to build a node, the cost of generating the tree is exponential; if I do, it's somewhere between linear and quadratic. Another process prunes parts of this graph structure as time goes on. The entire data structure is intended to be persistent, lasting for days at a time in a server-like application. If the parts pruned aren't garbage collected, the space leak will eventually be catastrophic. Either the memo table or the graph structure itself will outgrow available memory. -Rod On Thu, 17 Sep 2009 13:32:13 -0400 Job Vranish wrote: > What are you trying to use this for? It seems to me that for memo > tables you almost never have references to they keys outside the > lookup table since the keys are usually computed right at the last > minute, and then discarded (otherwise it might be easier to just > cache stuff outside the function). > > For example with a naive fibs, the values you are passing in are > computed, and probably don't exist before you do the recursive call, > and then are discarded shortly afterward. > > It seems like putting a cap on the cache size, and then just > overwriting old entries would be better. > Am I missing something? > > - Job > > > > On Wed, Sep 16, 2009 at 4:48 PM, Rodney Price > wrote: > > > How does garbage collection work in an example like the one below? > > You memoize a function with some sort of lookup table, which stores > > function arguments as keys and function results as values. As long > > as the function remains in scope, the keys in the lookup table > > remain in memory, which means that the keys themselves always > > remain reachable and they cannot be garbage collected. Right? > > > > So what do you do in the case where you know that, after some > > period of time, some entries in the lookup table will never be > > accessed? That is, there are no references to the keys for some > > entries remaining, except for the references in the lookup table > > itself. You'd like to allow the memory occupied by the keys to be > > garbage collected. Otherwise, if the function stays around for a > > long time, the size of the lookup table always grows. How do you > > avoid the space leak? > > > > I notice that there is a function in Data.IORef, > > > > mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) > > > > which looks promising. In the code below, however, there's only one > > IORef, so either the entire table gets garbage collected or none of > > it does. > > > > I've been reading the paper "Stretching the storage manager: weak > > pointers and stable names in Haskell," which seems to answer my > > question. When I attempt to run the memoization code in the paper > > on the simple fib example, I find that -- apparently due to lazy > > evaluation -- no new entries are entered into the lookup table, and > > therefore no lookups are ever successful! > > > > So apparently there is some interaction between lazy evaluation and > > garbage collection that I don't understand. My head hurts. Is it > > necessary to make the table lookup operation strict? Or is it > > something entirely different that I am missing? > > > > -Rod > > > > > > On Thu, 10 Sep 2009 18:33:47 -0700 > > Ryan Ingram wrote: > > > > > > > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) > > > memoIO f = do > > > cache <- newIORef M.empty > > > return $ \x -> do > > > m <- readIORef cache > > > case M.lookup x m of > > > Just y -> return y > > > Nothing -> do let res = f x > > > writeIORef cache $ M.insert x res m > > > return res > > > > > > memo :: Ord a => (a -> b) -> (a -> b) > > > memo f = unsafePerformIO $ do > > > fmemo <- memoIO f > > > return (unsafePerformIO . fmemo) > > > > > > I don't think there is any valid transformation that breaks this, > > > since the compiler can't lift anything through unsafePerformIO. > > > Am I mistaken? > > > > > > -- ryan > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From mauricio.antunes at gmail.com Thu Sep 17 19:53:31 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Thu Sep 17 19:32:28 2009 Subject: [Haskell-cafe] Re: help with FFI In-Reply-To: References: Message-ID: > typedef struct { > int *a; > int *b; > /*lots of stuff > ... > */ > int *z; > } foo; > int create_foo(foo *f,FILE *file,int x,int y); > int use_foo(foo *f,int w); > int destroy_foo(foo *f); > newtype Foo = Foo () > foreign import ccall "static foo.h create_foo" > c_create_foo :: Ptr (Foo) -> Ptr (CFile) -> CInt -> CInt -> IO CInt > foreign import ccall "static foo.h use_foo" > c_use_foo :: Ptr (Foo) -> CInt -> IO CInt > foreign import ccall "static foo.h destroy_foo" > c_destroy_foo :: Ptr (Foo) -> IO CInt Your 'create_foo' is only an initialization function, i.e., it initializes data in a Foo but do not allocate memory for the data such pointer points to. So, what you would like to do is something like this: import Foreign.Marshall.Alloc (...) ptrFoo <- malloc c_create_foo ptrFoo ptrCFile (...) (...) free ptrFoo Looking at malloc you see: malloc :: Storable a => IO (Ptr a) and this gives you the hint: you need to make an instance of Storable class with your Foo type. Storable method 'sizeOf' should provide the proper size to be used in such kind of memory allocation. (After that, you would probably want to learn about ForeignPtr, which would call, say, free and c_destroy_foo when your pointer is not beeing used anymore.) Best, Maur?cio P.S.: (Warning: spam promoting my own work.) If you use my package bindings-common, available in hackage, you can get that type and instance in a .hsc file by doing this: #bindings_starttype struct foo #bindings_stoptype _ But this package is not very popular yet, so I can't guarantee it's bug free. From douyaxu at gmail.com Thu Sep 17 20:17:22 2009 From: douyaxu at gmail.com (xu zhang) Date: Thu Sep 17 19:55:59 2009 Subject: [Haskell-cafe] About the parse error (possibly incorrect indentation) Message-ID: Hi, I am trying to get the function showMinProp to return String, but I always get an error of parse error (possibly incorrect indentation) Who can help with this? any idea? Thank u in advance! data Prop = Var String | Negation Prop | BinOp Op Prop Prop data Op = And | Or | Implies | Equiv derived Eq showOp :: Op -> String showOp And = "&" showOp Or = "|" showOp Implies = "=>" showOp Equiv = "<=>" instance Show Op where show = showOp precList = [(And,4),(Or,3),(Implies,2),(Equiv,1)] showProp :: Prop -> String showProp (Var s) = s showProp (Negation p) = "~" ++ showProp p showProp (BinOp op p q) = paren (showProp a p ++ space (showOp op) ++ showProp a q) showMinProp :: Int -> Prop -> String showMinProp preNo (BinOp op p q) = case op of And -> let a = 4 Or -> let a = 3 Implies -> let a = 2 Equiv -> let a = 1 if (a > preNo) then (showMinProp a p ++ space (showOp op) ++ showMinProp a q) else paren (showMinProp a p ++ space (showOp op) ++ showMinProp a q)) space s = " " ++ s ++ " " paren s = "(" ++ s ++ ")" instance Show Prop where show = showProp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/06077285/attachment.html From daniel.is.fischer at web.de Thu Sep 17 20:37:54 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 20:17:36 2009 Subject: [Haskell-cafe] About the parse error (possibly incorrect indentation) In-Reply-To: References: Message-ID: <200909180237.54903.daniel.is.fischer@web.de> Am Freitag 18 September 2009 02:17:22 schrieb xu zhang: > showMinProp :: Int -> Prop -> String > showMinProp preNo (BinOp op p q) = > ? ? ? ?case op of > ? ? ? ? ?And -> let a = 4 > ? ? ? ? ?Or ?-> let a = 3 > ? ? ? ? ?Implies -> let a = 2 > ? ? ? ? ?Equiv ? -> let a = 1 > ? ? ? ?if (a > preNo) > ? ? ? ? ?then (showMinProp a p ?++ space (showOp op) ++ showMinProp a q) > ? ? ? ? ?else paren (showMinProp a p ++ space (showOp op) ++ showMinProp a q)) showMinProp preNo (BinOp op p q) = let a = case op of And -> 4 ... in if a > preNo then (...) else (...) From wren at freegeek.org Thu Sep 17 21:20:42 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Sep 17 21:00:35 2009 Subject: [Haskell-cafe] How to understand the 'forall' ? In-Reply-To: References: <25250783.post@talk.nabble.com> <25251783.post@talk.nabble.com> <200909152338.41603.daniel.is.fischer@web.de> <2f9b2d30909161012v25628ae3sede443a789126400@mail.gmail.com> Message-ID: <4AB2E06A.70503@freegeek.org> Cristiano Paris wrote: > On Wed, Sep 16, 2009 at 7:12 PM, Ryan Ingram wrote: >> Here's the difference between these two types: >> >> test1 :: forall a. a -> Int >> -- The caller of test1 determines the type for test1 >> test2 :: (forall a. a) -> Int >> -- The internals of test2 determines what type, or types, to instantiate the >> argument at > > I can easily understand your explanation for test2: the type var a is > closed under existential (?) quantification. I can't do the same for > test1, even if it seems that a is closed under universal (?) > quantification as well. It's not existential, it's rank-2 universal. The first function is saying that "for every type, a, there is a function, test1@a, taking a into Int". This is very different than the second function which says "there is a function, test2, taking values which belong to all types into Int". The test2 function is not polymorphic, instead it takes arguments which are polymorphic. Since _|_ is the only inhabitant of all types, it may be helpful to consider these functions instead: f :: forall a. (a -> a) -> Int g :: (forall a. a -> a) -> Int The function f takes a monomorphic function of type (a->a) for some predefined a. Which a? Well it can be any of them, but it can only be one of them at a time. That is, the invocation of f will make the a concrete. The function g takes a polymorphic function which, being polymorphic, will work for every a. That is, the invocation of g does not make the type concrete; only the invocation of the argument within the body of g will make the type concrete. Moreover, the argument must be able to be made concrete for every a, it can't pick and choose. This is different from existential quantification which means the argument works for some a, but it won't tell us which one. To put it another way, this is a valid definition of g: (\ r -> let _ = r Nothing ; _ r "hello" in 42) Since r is polymorphic, we can use it at two different types. Whereas if we gave this definition for f it wouldn't type check since we can't unify (Maybe a) and String. >> Or, to put it another way, since there are no non-bottom objects of type >> (forall a. a): > > Why? By definition of Haskell semantics. The only value belonging to all types is _|_ (whether undefined or various exception bottoms). Perhaps it'd make more sense to look at another type. What values inhabit (forall a. Maybe a)? Well _|_ inhabits all types, so it's there. And Nothing doesn't say anything about a, so it's there too since it works for all a. And (Just _|_) is there since Just doesn't say anything about the type a and _|_ belongs to all types so it doesn't say anything about a either. And that's it. Any other value must say something about the type a, thus restricting it, and then it would no longer be universally quantified. -- Live well, ~wren From seanmcl at gmail.com Thu Sep 17 21:31:13 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Thu Sep 17 21:09:46 2009 Subject: [Haskell-cafe] =?utf-8?q?=E2=88=80_lexing_in_ghc_and_ghci?= Message-ID: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> Hi, I'm getting different behavior in ghci and ghc with the identifier ?. In ghc I need to wrap it with parens, as in > (?) :: Var -> Base -> Formula -> Formula > (?) = All In ghci, I get an error this way Formula.lhs:112:2: Invalid type signature In ghci I can do > ? :: Var -> Base -> Formula -> Formula > ? = All fine. But then ghc complains. What's going on here? Thanks! Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/bd16a4cf/attachment.html From daniel.is.fischer at web.de Thu Sep 17 21:41:45 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 21:23:48 2009 Subject: [Haskell-cafe] =?utf-8?q?=E2=88=80_lexing_in_ghc_and?= ghci In-Reply-To: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> Message-ID: <200909180341.45854.daniel.is.fischer@web.de> Am Freitag 18 September 2009 03:31:13 schrieb Sean McLaughlin: > Hi, > I'm getting different behavior in ghci and ghc with the identifier ?. In > ghc I need > to wrap it with parens, as in > > > (?) :: Var -> Base -> Formula -> Formula > > (?) = All > > In ghci, I get an error this way > > Formula.lhs:112:2: > Invalid type signature > > In ghci I can do > > > ? :: Var -> Base -> Formula -> Formula > > ? = All > > fine. But then ghc complains. What's going on here? Very odd: GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Prelude> let ? :: Int -> Int -> Int; ? x y = x*(y-x) :1:4: parse error on input `?' Prelude> let (?) :: Int -> Int -> Int; x ? y = x*(y-x) Prelude> 3 ? 5 6 Maybe your encodings aren't UTF8? > > Thanks! > > Sean From seanmcl at gmail.com Thu Sep 17 21:51:40 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Thu Sep 17 21:30:14 2009 Subject: =?UTF-8?Q?Re=3A_=5BHaskell=2Dcafe=5D_=E2=88=80_lexing_in_ghc_and_ghci?= In-Reply-To: <200909180341.45854.daniel.is.fischer@web.de> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180341.45854.daniel.is.fischer@web.de> Message-ID: <6579f8680909171851u7607a62cgfe5e5e61dd8b9d09@mail.gmail.com> Hi Daniel, Would you try putting that in a file and loading it in ghci? Your example also works for me. Prelude> let (?) = 5 Prelude> (?) 5 Sean On Thu, Sep 17, 2009 at 9:41 PM, Daniel Fischer wrote: > Am Freitag 18 September 2009 03:31:13 schrieb Sean McLaughlin: > > Hi, > > I'm getting different behavior in ghci and ghc with the identifier ?. > In > > ghc I need > > to wrap it with parens, as in > > > > > (?) :: Var -> Base -> Formula -> Formula > > > (?) = All > > > > In ghci, I get an error this way > > > > Formula.lhs:112:2: > > Invalid type signature > > > > In ghci I can do > > > > > ? :: Var -> Base -> Formula -> Formula > > > ? = All > > > > fine. But then ghc complains. What's going on here? > > Very odd: > > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > Prelude> let ? :: Int -> Int -> Int; ? x y = x*(y-x) > > :1:4: parse error on input `?' > Prelude> let (?) :: Int -> Int -> Int; x ? y = x*(y-x) > Prelude> 3 ? 5 > 6 > > Maybe your encodings aren't UTF8? > > > > > Thanks! > > > > Sean > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/38bec3e6/attachment.html From daniel.is.fischer at web.de Thu Sep 17 22:00:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 21:40:12 2009 Subject: [Haskell-cafe] =?utf-8?q?=E2=88=80_lexing_in_ghc_and?= ghci In-Reply-To: <6579f8680909171851u7607a62cgfe5e5e61dd8b9d09@mail.gmail.com> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180341.45854.daniel.is.fischer@web.de> <6579f8680909171851u7607a62cgfe5e5e61dd8b9d09@mail.gmail.com> Message-ID: <200909180400.31264.daniel.is.fischer@web.de> Am Freitag 18 September 2009 03:51:40 schrieb Sean McLaughlin: > Hi Daniel, > Would you try putting that in a file and loading it in ghci? Your > example also works for me. > > Prelude> let (?) = 5 > Prelude> (?) > 5 > > Sean Sure: dafis@linux-mkk1:~/Haskell/CafeTesting> cat Forall.hs module Forall where (?) :: Int -> Int -> Int x ? y = x*(y-x) dafis@linux-mkk1:~/Haskell/CafeTesting> ghci Forall GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. [1 of 1] Compiling Forall ( Forall.hs, interpreted ) Ok, modules loaded: Forall. *Forall> 7 ? 4 -21 *Forall> Works here. From ryani.spam at gmail.com Thu Sep 17 22:06:11 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Thu Sep 17 21:44:45 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909180041.26241.daniel.is.fischer@web.de> References: <200909172201.01878.daniel.is.fischer@web.de> <200909180041.26241.daniel.is.fischer@web.de> Message-ID: <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> I am confused about why this thread is talking about unsafePerformIO at all. It seems like everything you all want to do can be accomplished with the much less evil unsafeInterleaveIO instead. (Which is still a bit evil; but it's the difference between stealing cookies from the cookie jar and committing genocide) I wrote this function recently for a quick'n'dirty script: > readFiles :: [FilePath] -> String > readFiles [] = return "" > readFiles (f:fs) = do > f_data <- readFile f > rest <- unsafeInterleaveIO (readFiles fs) > return (f_data ++ rest) It lazily reads from many files and concatenates all the input. But I probably wouldn't use it in a serious application. -- ryan On Thu, Sep 17, 2009 at 3:41 PM, Daniel Fischer wrote: > Am Donnerstag 17 September 2009 22:20:55 schrieb Cristiano Paris: > > On Thu, Sep 17, 2009 at 10:01 PM, Daniel Fischer > > > > wrote: > > > ... > > > readBit fn = do > > > txt <- readFile fn > > > let (l,_:bdy) = span (/= '\n') txt > > > return $ Bit (read l) bdy > > > > > > ? > > > > > > With > > > > > > main = do > > > args <- getArgs > > > let n = case args of > > > (a:_) -> read a > > > _ -> 1000 > > > bl <- mapM readBit ["file1.txt","file2.txt"] > > > mapM_ (putStrLn . show . index) $ sortBy (comparing index) bl > > > mapM_ (putStrLn . take 20 . drop n . body) bl > > > > Yes, it *seems* to work but... the files don't get closed (readFile is > > unfinished until body is read) so I think I'm going to have problems > > when the number of files to read is higher than the maximum number of > > open handles a process can have. > > Indeed. If the number of files is large, reading lazily with readFile is > not so good. > Eat the cake and have it. > If you have a lot of files, want to read the metadata of all, select a > (much) smaller > number of files by some criterion on the set of metadata and then read the > body of the > selected files, it's hairy. > Reading all bodies immediately is probably out due to memory restrictions. > The clean approach would be to separate the reading of metadata and body. > The drawback is that then you have a second entry into IO. > Using unsafePerformIO, you can pretend that you don't reenter IO. > Whether that is safe in your situation, I don't know. Probably not (rule of > thumb: all > nontrivial actions wrapped in unsafePerformIO aren't safe, though chances > aren't bad that > it works most of the time). > > > > > That's a possibility I considered even if not directly using readFile. > > > > Cristiano > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/5d24ef96/attachment.html From gregorypropf at yahoo.com Thu Sep 17 22:32:32 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Thu Sep 17 22:11:08 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: Message-ID: <304845.54987.qm@web112208.mail.gq1.yahoo.com> Heh, perhaps we should petition to have a new computer key and symbol added to the world's way of writing maths, something like maybe a downward angled slash to mean prefix (-) :) --- On Thu, 9/17/09, Job Vranish wrote: From: Job Vranish Subject: Re: [Haskell-cafe] Re: [Haskell-beginners] map question To: "Gregory Propf" Cc: "Tom Doris" , "Haskell-Cafe" , joostkremers@fastmail.fm Date: Thursday, September 17, 2009, 9:04 AM (-) happens to be the only prefix operator in haskell, it also an infix operator. so: > 4 - 2 2 > -3 -3 > ((-) 5) 3? -- note that in this case (-) is treated like any regular function so 5 is the first parameter 2 > (5 - ) 3 2 > (-5 ) -5 > (flip (-) 5) 3? -2 It's a little wart brought about by the ambiguity in common mathematical syntax. If you play around in ghci you should get the hang of it pretty quick. - Job On Thu, Sep 17, 2009 at 11:08 AM, Gregory Propf wrote: Remember that there is asymmetry between (+) and (-).? The former has the commutative property and the latter does not so: (+) 3 4 = 7 and (+) 4 3 = 7 but (-) 3 4 = -1 and (-) 4 3 = 1 --- On Thu, 9/17/09, Tom Doris wrote: From: Tom Doris Subject: Re: [Haskell-beginners] map question To: "Joost Kremers" Cc: beginners@haskell.org Date: Thursday, September 17, 2009, 6:06 AM This works: map (+ (-1)) [1,2,3,4] 2009/9/17 Joost Kremers Hi all, I've just started learning Haskell and while experimenting with map a bit, I ran into something I don't understand. The following commands do what I'd expect: Prelude> map (+ 1) [1,2,3,4] [2,3,4,5] Prelude> map (* 2) [1,2,3,4] [2,4,6,8] Prelude> map (/ 2) [1,2,3,4] [0.5,1.0,1.5,2.0] Prelude> map (2 /) [1,2,3,4] [2.0,1.0,0.6666666666666666,0.5] But I can't seem to find a way to get map to substract 1 from all members of the list. The following form is the only one that works, but it doesn't give the result I'd expect: Prelude> map ((-) 1) [1,2,3,4] [0,-1,-2,-3] I know I can use an anonymous function, but I'm just trying to understand the result here... I'd appreciate any hints to help me graps this. TIA Joost -- Joost Kremers, PhD University of Frankfurt Institute for Cognitive Linguistics Gr?neburgplatz 1 60629 Frankfurt am Main, Germany _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners -----Inline Attachment Follows----- _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/e391ca65/attachment-0001.html From DekuDekuplex at Yahoo.com Thu Sep 17 22:33:56 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Thu Sep 17 22:12:56 2009 Subject: [Haskell-cafe] Re: Where can I find a non-fee-based version of Hudak's paper, "Conception, evolution, and application of functional programming languages"? References: <78BFDF05-0D88-4B1D-A1C6-513EE9518156@phaedrusdeinus.org> Message-ID: On Thu, 17 Sep 2009 08:55:19 -0700, John Melesky wrote: >On 2009-09-17, at 1:41 AM, Benjamin L.Russell wrote: >> Does anybody know where I can find a non-fee-based version of Paul >> Hudak's paper, "Conception, evolution, and application of functional >> programming languages" [1]? > >When in doubt, check citeseer. > >http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.6505 Thank you; although attempting a download from the referenced "DOWNLOAD" site at http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=4185A586D773743C182087024049A81E?doi=10.1.1.83.6505&rep=rep1&type=url&i=0 resulted in the same error as before, I was still able to download a cached copy from the referenced "CACHED" site at http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=4185A586D773743C182087024049A81E?doi=10.1.1.83.6505&rep=rep1&type=pdf; that is a very useful service. -- Benjamin L. Russell -- 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^ From seanmcl at gmail.com Thu Sep 17 22:41:13 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Thu Sep 17 22:19:46 2009 Subject: =?UTF-8?Q?Re=3A_=5BHaskell=2Dcafe=5D_=E2=88=80_lexing_in_ghc_and_ghci?= In-Reply-To: <200909180400.31264.daniel.is.fischer@web.de> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180341.45854.daniel.is.fischer@web.de> <6579f8680909171851u7607a62cgfe5e5e61dd8b9d09@mail.gmail.com> <200909180400.31264.daniel.is.fischer@web.de> Message-ID: <6579f8680909171941g213bf1c5w5d49bc9f4a6c939@mail.gmail.com> Weird. OK, thanks a lot! I'm switching to ? until I get this figured out. Sean On Thu, Sep 17, 2009 at 10:00 PM, Daniel Fischer wrote: > Am Freitag 18 September 2009 03:51:40 schrieb Sean McLaughlin: > > Hi Daniel, > > Would you try putting that in a file and loading it in ghci? Your > > example also works for me. > > > > Prelude> let (?) = 5 > > Prelude> (?) > > 5 > > > > Sean > > Sure: > dafis@linux-mkk1:~/Haskell/CafeTesting> cat Forall.hs > module Forall where > > (?) :: Int -> Int -> Int > x ? y = x*(y-x) > dafis@linux-mkk1:~/Haskell/CafeTesting> ghci Forall > GHCi, version 6.10.3: http://www.haskell.org/ghc/ :? for help > Loading package ghc-prim ... linking ... done. > Loading package integer ... linking ... done. > Loading package base ... linking ... done. > [1 of 1] Compiling Forall ( Forall.hs, interpreted ) > Ok, modules loaded: Forall. > *Forall> 7 ? 4 > -21 > *Forall> > > Works here. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/eca7fffe/attachment.html From mpm at alumni.caltech.edu Thu Sep 17 22:42:32 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Thu Sep 17 22:21:16 2009 Subject: [Haskell-cafe] code-build-test cycle Message-ID: <4AB2F398.7060703@alumni.caltech.edu> I'm working on a GUI application in qtHaskell, and I have a bit of a bind. Using ghci, it launches quickly but runs slowly. On the other hand, compiling (mainly linking) takes a while---several minutes. The truth is that I can compile it much faster if I selectively import the needed modules, so figure the actual compilation/link time is more like 15 to 30 seconds. (This is Windows on a very old laptop.) I'm used to working in Python, so I'm used to a nearly instant code-build-test cycle, and GUI applications in PyQt run briskly, faster than ghci/qtHaskell. Now I'm wondering if Hugs is a faster interpreter. So during development I don't want to give up the quick cycle you get with an interpreter, but the application may be much too slow to use in any meaningful way without compilation. Any advice welcome. Maybe there is a way to speed up the interpretation. -Mike From daniel.is.fischer at web.de Thu Sep 17 23:09:15 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 22:48:56 2009 Subject: [Haskell-cafe] =?utf-8?q?=E2=88=80_lexing_in_ghc_and?= ghci In-Reply-To: <6579f8680909171941g213bf1c5w5d49bc9f4a6c939@mail.gmail.com> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180400.31264.daniel.is.fischer@web.de> <6579f8680909171941g213bf1c5w5d49bc9f4a6c939@mail.gmail.com> Message-ID: <200909180509.15844.daniel.is.fischer@web.de> Am Friday 18 September 2009 04:41:13 schrieben Sie: > Weird. OK, thanks a lot! I'm switching to ? until I get this figured > out. Sean > What does your ghci say for Data.Char.isSymbol (toEnum 8704) ? From daniel.is.fischer at web.de Thu Sep 17 23:15:12 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 22:56:43 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> References: <200909180041.26241.daniel.is.fischer@web.de> <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> Message-ID: <200909180515.12969.daniel.is.fischer@web.de> Am Freitag 18 September 2009 04:06:11 schrieb Ryan Ingram: > I am confused about why this thread is talking about unsafePerformIO at > all. ?It seems like everything you all want to do can be accomplished with > the much less evil unsafeInterleaveIO instead. ?(Which is still a bit evil; > but it's the difference between stealing cookies from the cookie jar and > committing genocide) I find that remark in rather bad taste. > > I wrote this function recently for a quick'n'dirty script: > > readFiles :: [FilePath] -> String > > readFiles [] = return "" > > readFiles (f:fs) = do > > ? ? f_data <- readFile f > > ? ? rest <- unsafeInterleaveIO (readFiles fs) > > ? ? return (f_data ++ rest) > > It lazily reads from many files and concatenates all the input. ?But I > probably wouldn't use it in a serious application. > > ? -- ryan But that does something completely different from what Cristiano wants to do. He wants to read many files files quasi-parallel. As far as I can tell, he needs to read a small chunk from the beginning of every file, then, depending on what he got from that, he needs to read the rest of some files. If he reads all the files lazily, he (maybe) runs into the open file limit (a semi-closed handle is still open from the OS' point of view, isn't it?). So he has to close the first files before he opens the Nth. But what if later he finds out that he has to read the body of a previously closed file? I would separate the reading of headers and bodies, reopening the files whose body is needed, for some (maybe compelling) reason he wants to do it differently. From daniel.is.fischer at web.de Thu Sep 17 23:21:58 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Thu Sep 17 23:01:40 2009 Subject: [Haskell-cafe] code-build-test cycle In-Reply-To: <4AB2F398.7060703@alumni.caltech.edu> References: <4AB2F398.7060703@alumni.caltech.edu> Message-ID: <200909180521.59169.daniel.is.fischer@web.de> Am Freitag 18 September 2009 04:42:32 schrieb Michael Mossey: > I'm working on a GUI application in qtHaskell, and I have a bit of a bind. > Using ghci, it launches quickly but runs slowly. On the other hand, > compiling (mainly linking) takes a while---several minutes. The truth is Is the library you're using built with split-objs? If not, that would explain the long link time. > that I can compile it much faster if I selectively import the needed > modules, so figure the actual compilation/link time is more like 15 to 30 > seconds. (This is Windows on a very old laptop.) I'm used to working in > Python, so I'm used to a nearly instant code-build-test cycle, and GUI > applications in PyQt run briskly, faster than ghci/qtHaskell. > > Now I'm wondering if Hugs is a faster interpreter. Usually it isn't. It's faster loading the code than ghci, but slower running it. > > So during development I don't want to give up the quick cycle you get with > an interpreter, but the application may be much too slow to use in any > meaningful way without compilation. Any advice welcome. Maybe there is a > way to speed up the interpretation. Smaller modules, so that only the hopefully few modules that were changed or depend on a changed module need be recompiled? (Not sure that would help with linking, though) > > -Mike From allbery at ece.cmu.edu Thu Sep 17 23:45:51 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Sep 17 23:24:42 2009 Subject: [Haskell-cafe] About the parse error (possibly incorrect indentation) In-Reply-To: References: Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090917/5f1ccc49/PGP.bin From bulat.ziganshin at gmail.com Fri Sep 18 00:34:16 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Sep 18 00:15:15 2009 Subject: [Haskell-cafe] code-build-test cycle In-Reply-To: <4AB2F398.7060703@alumni.caltech.edu> References: <4AB2F398.7060703@alumni.caltech.edu> Message-ID: <974426058.20090918083416@gmail.com> Hello Michael, Friday, September 18, 2009, 6:42:32 AM, you wrote: > Now I'm wondering if Hugs is a faster interpreter. 2x slower, and incompatib;e with qtHaskell > meaningful way without compilation. Any advice welcome. Maybe there is a > way to speed up the interpretation. if compilation is fast and only linking is slow, you may recompile haskell modules every time but use ghci to omit linking. just execute ghc compilation command inside ghci before running your app -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From ketil at malde.org Fri Sep 18 02:28:41 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Sep 18 02:07:07 2009 Subject: [Haskell-cafe] =?utf-8?Q?=E2=88=80?= lexing in ghc and ghci In-Reply-To: <200909180341.45854.daniel.is.fischer@web.de> (Daniel Fischer's message of "Fri, 18 Sep 2009 03:41:45 +0200") References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180341.45854.daniel.is.fischer@web.de> Message-ID: <873a6kahra.fsf@malde.org> Daniel Fischer writes: >> In ghci I can do >> >> > ? :: Var -> Base -> Formula -> Formula >> > ? = All >> >> fine. But then ghc complains. What's going on here? > Maybe your encodings aren't UTF8? Or rather, one of them is UTF-8, and the other isn't. So that in one case, you get the 'forall' Unicode symbol, and in the other, you get a sequence of two (or more?) code-points between 128 and 255, which happen to not be declared as symbols. (This is just a guess, I haven't really checked) See also this thread: http://www.mail-archive.com/haskell-cafe@haskell.org/msg63555.html -k -- If I haven't seen further, it is by standing in the footprints of giants From ketil at malde.org Fri Sep 18 02:30:34 2009 From: ketil at malde.org (Ketil Malde) Date: Fri Sep 18 02:08:50 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <304845.54987.qm@web112208.mail.gq1.yahoo.com> (Gregory Propf's message of "Thu, 17 Sep 2009 19:32:32 -0700 (PDT)") References: <304845.54987.qm@web112208.mail.gq1.yahoo.com> Message-ID: <87y6oc933p.fsf@malde.org> Gregory Propf writes: > Heh, perhaps we should petition to have a new computer key and symbol > added to the world's way of writing maths, something like maybe a > downward angled slash to mean prefix (-) Or just use 'negate' and 'subtract'? -k -- If I haven't seen further, it is by standing in the footprints of giants From DekuDekuplex at Yahoo.com Fri Sep 18 02:42:48 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Fri Sep 18 02:21:44 2009 Subject: [Haskell-cafe] Re: Where can I find a non-fee-based version of Hudak's paper, "Conception, evolution, and application of functional programming languages"? References: <111099.17243.qm@web24506.mail.ird.yahoo.com> Message-ID: <2ca6b5tpj8arn51b109n04kppt9jo9tci6@4ax.com> On Thu, 17 Sep 2009 15:32:51 +0000 (GMT), jean legrand wrote: >> Does anybody know where I can find a non-fee-based version of Paul >> Hudak's paper, "Conception, evolution, and application of functional >> programming languages" [1]? There used to be a version that did not > >seems you can get a djvu copy here > >http://lib.org.by/info/Cs_Computer science/CsPl_Programming languages/Hudak P. Conception, evolution, and application of functional programming languages (ACM comp.surveys 21, 1989)(T)(53s).djvu > >the site is in Russian and you wait 30s before a link to the file appears. Thank you for the link. Actually, I had encountered this site earlier, but it had caused my browser to hang, and I had been unable to download the file earlier. For some reason, control-clicking the button to download thirty seconds after visiting the site only causes the thirty-second-waiting process to repeat in another tab, where the button must be clicked (as opposed to control-clicked) thereafter in order to cause a download in the same tab. Then the .djvu-suffixed file downloads, but viewing the file requires installing a DjVu file viewer; I downloaded and installed DjVuLibre 3.5.22+DjView 4.5 from SourceForge at http://sourceforge.net/projects/djvu/files/DjVuLibre_Windows/3.5.22%2B4.5/DjVuLibre%2BDjView-3.5.22%2B4.5-Setup.exe/download. Then the file opens. The file is approximately 731 KB, as opposed to 5.067 MB for the PDF version of the same content (available by clicking on the "CACHED" button at CiteSeerX at http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.83.6505). The image quality appears identical. -- Benjamin L. Russell -- 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^ From frodo at theshire.org Fri Sep 18 04:49:03 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Sep 18 04:27:56 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> References: <200909172201.01878.daniel.is.fischer@web.de> <200909180041.26241.daniel.is.fischer@web.de> <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> Message-ID: On Fri, Sep 18, 2009 at 4:06 AM, Ryan Ingram wrote: > I am confused about why this thread is talking about unsafePerformIO at > all.? It seems like everything you all want to do can be accomplished with > the much less evil unsafeInterleaveIO instead.? (Which is still a bit evil; > but it's the difference between stealing cookies from the cookie jar and > committing genocide) I didn't read about unsafeIntervleaveIO but yesterday I rewrote my code exactly as you did here, and it allowed me to use the applicative style... Cristiano From frodo at theshire.org Fri Sep 18 04:56:08 2009 From: frodo at theshire.org (Cristiano Paris) Date: Fri Sep 18 04:35:01 2009 Subject: [Haskell-cafe] Is it safe to use unsafePerformIO here? In-Reply-To: <200909180515.12969.daniel.is.fischer@web.de> References: <200909180041.26241.daniel.is.fischer@web.de> <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> <200909180515.12969.daniel.is.fischer@web.de> Message-ID: On Fri, Sep 18, 2009 at 5:15 AM, Daniel Fischer wrote: > ... > But that does something completely different from what Cristiano wants to do. > He wants to read many files files quasi-parallel. > As far as I can tell, he needs to read a small chunk from the beginning of every file, > then, depending on what he got from that, he needs to read the rest of some files. > If he reads all the files lazily, he (maybe) runs into the open file limit (a semi-closed > handle is still open from the OS' point of view, isn't it?). Not quite. In one case I want to dumbly read all the files' metadata and printing them out sorted: reading the next file doesn't depend on what happened previously so they could be read in parallel indeed. In the other case, it reads a specific file completely and print everything out. In both cases, I want to use the same code for reading, exploiting laziness in order not to read the body of files if only metadata are requested. > I would separate the reading of headers and bodies, reopening the files whose body is > needed, for some (maybe compelling) reason he wants to do it differently. Yes, that's the way Haskell forces you to do that as it's the only way for you to go safe. But, if you know more about your code, you can use unsafe(Perform|Interleave)IO to assure the compiler that everything's right. Cristiano From cristiano.paris at gmail.com Fri Sep 18 05:03:03 2009 From: cristiano.paris at gmail.com (Cristiano Paris) Date: Fri Sep 18 04:41:56 2009 Subject: [Haskell-cafe] Thank you guys Message-ID: I wish to thank Caf?'s people for their great support in understanding Haskell. Thank you all! Cristiano From jon.fairbairn at cl.cam.ac.uk Fri Sep 18 05:09:39 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Fri Sep 18 04:48:38 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question References: <304845.54987.qm@web112208.mail.gq1.yahoo.com> <87y6oc933p.fsf@malde.org> Message-ID: Ketil Malde writes: > Gregory Propf writes: > >> Heh, perhaps we should petition to have a new computer key and symbol >> added to the world's way of writing maths, something like maybe a >> downward angled slash to mean prefix (-) > > Or just use 'negate' and 'subtract'? Well, now that ghc accepts unicode characters in programme source, we could ask that ? (NOT SIGN, U+00AC) be recategorised as an identifier character and use that (as a simple function name) for negation and lose the wart altogether. class Negatable t where ? :: t -> t (and as a side effect we could have identifiers like slightly?dodgy). Or, if we want to make things look even nicer, make ? (HYPHEN, U+2010) an identifier character and use ? (MINUS SIGN, U+2212) for the infix operator. Now we could have hyphenated?identifiers too. I think this second option would be the ? (CORRECT, U+32A3) thing to do, though editors and so on would have to be changed to make the distinction readily visible. I think it's Friday, but I'm not entirely sure this is silly. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk From tom.davie at gmail.com Fri Sep 18 05:14:02 2009 From: tom.davie at gmail.com (Thomas Davie) Date: Fri Sep 18 04:52:38 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: <304845.54987.qm@web112208.mail.gq1.yahoo.com> References: <304845.54987.qm@web112208.mail.gq1.yahoo.com> Message-ID: <12490B42-6C54-42AB-9CFD-EA6C56498CFA@gmail.com> On 18 Sep 2009, at 04:32, Gregory Propf wrote: > Heh, perhaps we should petition to have a new computer key and > symbol added to the world's way of writing maths, something like > maybe a downward angled slash to mean prefix (-) Such a symbol already exists, but isn't in the ASCII set: (-) (unicode 0x2D) "hyphen minus" and (?) (unicode 0x2010) "hyphen" are not the same as (?) (unicode 0x2200) "minus sign" notably also, not the same as ?, ?, ? and ? (figure dash, en- dash, em-dash and horizontal bar). Bob From bugfact at gmail.com Fri Sep 18 07:56:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Sep 18 07:34:45 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: <20090917173901.47cbe3a9@jabber.aur.us.ray.com> References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> <20090916144839.34273cb1@jabber.aur.us.ray.com> <20090917173901.47cbe3a9@jabber.aur.us.ray.com> Message-ID: I would also like to see a solution for problems like these. Haskell provides a lot of nice memoizing / caching data structures - like a trie - but the ones I know indeed keep growing, so no garbage collection takes place? It would be nice to have a data structure that performs caching but does not grow unlimited. I had a similar problem with stable names; it is not possible to check if a stable name is still "alive". On Fri, Sep 18, 2009 at 1:39 AM, Rodney Price wrote: > In my case, the results of each computation are used to generate a node > in a graph structure (dag). ?The key, oddly, is a hash of a two-tuple > that gets stored in the data structure after the computation of the > node finishes. ?If I don't memoize the function to build a node, the > cost of generating the tree is exponential; if I do, it's somewhere > between linear and quadratic. > > Another process prunes parts of this graph structure as time goes on. > The entire data structure is intended to be persistent, lasting for > days at a time in a server-like application. ?If the parts pruned > aren't garbage collected, the space leak will eventually be > catastrophic. ?Either the memo table or the graph structure itself will > outgrow available memory. > > -Rod > > > On Thu, 17 Sep 2009 13:32:13 -0400 > Job Vranish wrote: > >> What are you trying to use this for? It seems to me that for memo >> tables you almost never have references to they keys outside the >> lookup table since the keys are usually computed right at the last >> minute, and then discarded (otherwise it might be easier to just >> cache stuff outside the function). >> >> For example with a naive fibs, the values you are passing in are >> computed, and probably don't exist before you do the recursive call, >> and then are discarded shortly afterward. >> >> It seems like putting a cap on the cache size, and then just >> overwriting old entries would be better. >> Am I missing something? >> >> - Job >> >> >> >> On Wed, Sep 16, 2009 at 4:48 PM, Rodney Price >> wrote: >> >> > How does garbage collection work in an example like the one below? >> > You memoize a function with some sort of lookup table, which stores >> > function arguments as keys and function results as values. ?As long >> > as the function remains in scope, the keys in the lookup table >> > remain in memory, which means that the keys themselves always >> > remain reachable and they cannot be garbage collected. ?Right? >> > >> > So what do you do in the case where you know that, after some >> > period of time, some entries in the lookup table will never be >> > accessed? ?That is, there are no references to the keys for some >> > entries remaining, except for the references in the lookup table >> > itself. ?You'd like to allow the memory occupied by the keys to be >> > garbage collected. ?Otherwise, if the function stays around for a >> > long time, the size of the lookup table always grows. ?How do you >> > avoid the space leak? >> > >> > I notice that there is a function in Data.IORef, >> > >> > mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) >> > >> > which looks promising. ?In the code below, however, there's only one >> > IORef, so either the entire table gets garbage collected or none of >> > it does. >> > >> > I've been reading the paper "Stretching the storage manager: weak >> > pointers and stable names in Haskell," which seems to answer my >> > question. ?When I attempt to run the memoization code in the paper >> > on the simple fib example, I find that -- apparently due to lazy >> > evaluation -- no new entries are entered into the lookup table, and >> > therefore no lookups are ever successful! >> > >> > So apparently there is some interaction between lazy evaluation and >> > garbage collection that I don't understand. ?My head hurts. ?Is it >> > necessary to make the table lookup operation strict? ?Or is it >> > something entirely different that I am missing? >> > >> > -Rod >> > >> > >> > On Thu, 10 Sep 2009 18:33:47 -0700 >> > Ryan Ingram wrote: >> > >> > > >> > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) >> > > memoIO f = do >> > > ? ?cache <- newIORef M.empty >> > > ? ?return $ \x -> do >> > > ? ? ? ?m <- readIORef cache >> > > ? ? ? ?case M.lookup x m of >> > > ? ? ? ? ? ?Just y -> return y >> > > ? ? ? ? ? ?Nothing -> do let res = f x >> > > ? ? ? ? ? ? ? ? ? ? ? ? ?writeIORef cache $ M.insert x res m >> > > ? ? ? ? ? ? ? ? ? ? ? ? ?return res >> > > >> > > memo :: Ord a => (a -> b) -> (a -> b) >> > > memo f = unsafePerformIO $ do >> > > ? ? fmemo <- memoIO f >> > > ? ? return (unsafePerformIO . fmemo) >> > > >> > > I don't think there is any valid transformation that breaks this, >> > > since the compiler can't lift anything through unsafePerformIO. >> > > Am I mistaken? >> > > >> > > ? -- ryan >> > >> > _______________________________________________ >> > 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 > From seanmcl at gmail.com Fri Sep 18 08:34:15 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Fri Sep 18 08:12:48 2009 Subject: =?UTF-8?Q?Re=3A_=5BHaskell=2Dcafe=5D_=E2=88=80_lexing_in_ghc_and_ghci?= In-Reply-To: <200909180509.15844.daniel.is.fischer@web.de> References: <6579f8680909171831j5cc6de9w8e2e639393910a3a@mail.gmail.com> <200909180400.31264.daniel.is.fischer@web.de> <6579f8680909171941g213bf1c5w5d49bc9f4a6c939@mail.gmail.com> <200909180509.15844.daniel.is.fischer@web.de> Message-ID: <6579f8680909180534m5743bb47g692425221c1994a3@mail.gmail.com> Hi Daniel, Prelude> Data.Char.isSymbol (toEnum 8704) True On Thu, Sep 17, 2009 at 11:09 PM, Daniel Fischer wrote: > Am Friday 18 September 2009 04:41:13 schrieben Sie: > > Weird. OK, thanks a lot! I'm switching to ? until I get this figured > > out. Sean > > > > What does your ghci say for > > Data.Char.isSymbol (toEnum 8704) ? > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090918/e554e96b/attachment.html From jvranish at gmail.com Fri Sep 18 10:19:54 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Sep 18 09:58:27 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: References: <25306687.post@talk.nabble.com> <25381881.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> <20090916144839.34273cb1@jabber.aur.us.ray.com> <20090917173901.47cbe3a9@jabber.aur.us.ray.com> Message-ID: Yeah it seems like the general solution to the problem would be some sort of map-like datastructure that you add items via a key/value pair, and if the key gets GC'd, that entry gets removed from the structure. I've been wanting something like this as well, but didn't know about weak references so I didn't know if it was possible, but I think I could make something like this now. I'll give it a shot and let you guys know how it goes. Rodney could you post your memo code that uses the weak references? - Job On Fri, Sep 18, 2009 at 7:56 AM, Peter Verswyvelen wrote: > I would also like to see a solution for problems like these. > > Haskell provides a lot of nice memoizing / caching data structures - > like a trie - but the ones I know indeed keep growing, so no garbage > collection takes place? > > It would be nice to have a data structure that performs caching but > does not grow unlimited. > > I had a similar problem with stable names; it is not possible to check > if a stable name is still "alive". > > On Fri, Sep 18, 2009 at 1:39 AM, Rodney Price > wrote: > > In my case, the results of each computation are used to generate a node > > in a graph structure (dag). The key, oddly, is a hash of a two-tuple > > that gets stored in the data structure after the computation of the > > node finishes. If I don't memoize the function to build a node, the > > cost of generating the tree is exponential; if I do, it's somewhere > > between linear and quadratic. > > > > Another process prunes parts of this graph structure as time goes on. > > The entire data structure is intended to be persistent, lasting for > > days at a time in a server-like application. If the parts pruned > > aren't garbage collected, the space leak will eventually be > > catastrophic. Either the memo table or the graph structure itself will > > outgrow available memory. > > > > -Rod > > > > > > On Thu, 17 Sep 2009 13:32:13 -0400 > > Job Vranish wrote: > > > >> What are you trying to use this for? It seems to me that for memo > >> tables you almost never have references to they keys outside the > >> lookup table since the keys are usually computed right at the last > >> minute, and then discarded (otherwise it might be easier to just > >> cache stuff outside the function). > >> > >> For example with a naive fibs, the values you are passing in are > >> computed, and probably don't exist before you do the recursive call, > >> and then are discarded shortly afterward. > >> > >> It seems like putting a cap on the cache size, and then just > >> overwriting old entries would be better. > >> Am I missing something? > >> > >> - Job > >> > >> > >> > >> On Wed, Sep 16, 2009 at 4:48 PM, Rodney Price > >> wrote: > >> > >> > How does garbage collection work in an example like the one below? > >> > You memoize a function with some sort of lookup table, which stores > >> > function arguments as keys and function results as values. As long > >> > as the function remains in scope, the keys in the lookup table > >> > remain in memory, which means that the keys themselves always > >> > remain reachable and they cannot be garbage collected. Right? > >> > > >> > So what do you do in the case where you know that, after some > >> > period of time, some entries in the lookup table will never be > >> > accessed? That is, there are no references to the keys for some > >> > entries remaining, except for the references in the lookup table > >> > itself. You'd like to allow the memory occupied by the keys to be > >> > garbage collected. Otherwise, if the function stays around for a > >> > long time, the size of the lookup table always grows. How do you > >> > avoid the space leak? > >> > > >> > I notice that there is a function in Data.IORef, > >> > > >> > mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) > >> > > >> > which looks promising. In the code below, however, there's only one > >> > IORef, so either the entire table gets garbage collected or none of > >> > it does. > >> > > >> > I've been reading the paper "Stretching the storage manager: weak > >> > pointers and stable names in Haskell," which seems to answer my > >> > question. When I attempt to run the memoization code in the paper > >> > on the simple fib example, I find that -- apparently due to lazy > >> > evaluation -- no new entries are entered into the lookup table, and > >> > therefore no lookups are ever successful! > >> > > >> > So apparently there is some interaction between lazy evaluation and > >> > garbage collection that I don't understand. My head hurts. Is it > >> > necessary to make the table lookup operation strict? Or is it > >> > something entirely different that I am missing? > >> > > >> > -Rod > >> > > >> > > >> > On Thu, 10 Sep 2009 18:33:47 -0700 > >> > Ryan Ingram wrote: > >> > > >> > > > >> > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) > >> > > memoIO f = do > >> > > cache <- newIORef M.empty > >> > > return $ \x -> do > >> > > m <- readIORef cache > >> > > case M.lookup x m of > >> > > Just y -> return y > >> > > Nothing -> do let res = f x > >> > > writeIORef cache $ M.insert x res m > >> > > return res > >> > > > >> > > memo :: Ord a => (a -> b) -> (a -> b) > >> > > memo f = unsafePerformIO $ do > >> > > fmemo <- memoIO f > >> > > return (unsafePerformIO . fmemo) > >> > > > >> > > I don't think there is any valid transformation that breaks this, > >> > > since the compiler can't lift anything through unsafePerformIO. > >> > > Am I mistaken? > >> > > > >> > > -- ryan > >> > > >> > _______________________________________________ > >> > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090918/4d072db5/attachment.html From jvranish at gmail.com Fri Sep 18 11:24:37 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Sep 18 11:03:13 2009 Subject: [Haskell-cafe] weak pointers and memoization (was Re: memoization) In-Reply-To: References: <25306687.post@talk.nabble.com> <851558299.20090910160754@gmail.com> <7ca3f0160909101746k43493223g8a00bb48d32fc1e1@mail.gmail.com> <2f9b2d30909101833r205df2bejea297a5b57ec2dd@mail.gmail.com> <20090916144839.34273cb1@jabber.aur.us.ray.com> <20090917173901.47cbe3a9@jabber.aur.us.ray.com> Message-ID: Hey it works :D Here is a proof of concept: http://gist.github.com/189104 Maybe later today I'll try to make a version that can be safely used outside IO. - Job On Fri, Sep 18, 2009 at 10:19 AM, Job Vranish wrote: > Yeah it seems like the general solution to the problem would be some sort > of map-like datastructure that you add items via a key/value pair, and if > the key gets GC'd, that entry gets removed from the structure. > > I've been wanting something like this as well, but didn't know about weak > references so I didn't know if it was possible, but I think I could make > something like this now. I'll give it a shot and let you guys know how it > goes. > > Rodney could you post your memo code that uses the weak references? > > - Job > > > On Fri, Sep 18, 2009 at 7:56 AM, Peter Verswyvelen wrote: > >> I would also like to see a solution for problems like these. >> >> Haskell provides a lot of nice memoizing / caching data structures - >> like a trie - but the ones I know indeed keep growing, so no garbage >> collection takes place? >> >> It would be nice to have a data structure that performs caching but >> does not grow unlimited. >> >> I had a similar problem with stable names; it is not possible to check >> if a stable name is still "alive". >> >> On Fri, Sep 18, 2009 at 1:39 AM, Rodney Price >> wrote: >> > In my case, the results of each computation are used to generate a node >> > in a graph structure (dag). The key, oddly, is a hash of a two-tuple >> > that gets stored in the data structure after the computation of the >> > node finishes. If I don't memoize the function to build a node, the >> > cost of generating the tree is exponential; if I do, it's somewhere >> > between linear and quadratic. >> > >> > Another process prunes parts of this graph structure as time goes on. >> > The entire data structure is intended to be persistent, lasting for >> > days at a time in a server-like application. If the parts pruned >> > aren't garbage collected, the space leak will eventually be >> > catastrophic. Either the memo table or the graph structure itself will >> > outgrow available memory. >> > >> > -Rod >> > >> > >> > On Thu, 17 Sep 2009 13:32:13 -0400 >> > Job Vranish wrote: >> > >> >> What are you trying to use this for? It seems to me that for memo >> >> tables you almost never have references to they keys outside the >> >> lookup table since the keys are usually computed right at the last >> >> minute, and then discarded (otherwise it might be easier to just >> >> cache stuff outside the function). >> >> >> >> For example with a naive fibs, the values you are passing in are >> >> computed, and probably don't exist before you do the recursive call, >> >> and then are discarded shortly afterward. >> >> >> >> It seems like putting a cap on the cache size, and then just >> >> overwriting old entries would be better. >> >> Am I missing something? >> >> >> >> - Job >> >> >> >> >> >> >> >> On Wed, Sep 16, 2009 at 4:48 PM, Rodney Price >> >> wrote: >> >> >> >> > How does garbage collection work in an example like the one below? >> >> > You memoize a function with some sort of lookup table, which stores >> >> > function arguments as keys and function results as values. As long >> >> > as the function remains in scope, the keys in the lookup table >> >> > remain in memory, which means that the keys themselves always >> >> > remain reachable and they cannot be garbage collected. Right? >> >> > >> >> > So what do you do in the case where you know that, after some >> >> > period of time, some entries in the lookup table will never be >> >> > accessed? That is, there are no references to the keys for some >> >> > entries remaining, except for the references in the lookup table >> >> > itself. You'd like to allow the memory occupied by the keys to be >> >> > garbage collected. Otherwise, if the function stays around for a >> >> > long time, the size of the lookup table always grows. How do you >> >> > avoid the space leak? >> >> > >> >> > I notice that there is a function in Data.IORef, >> >> > >> >> > mkWeakIORef :: IORef a -> IO () -> IO (Weak (IORef a)) >> >> > >> >> > which looks promising. In the code below, however, there's only one >> >> > IORef, so either the entire table gets garbage collected or none of >> >> > it does. >> >> > >> >> > I've been reading the paper "Stretching the storage manager: weak >> >> > pointers and stable names in Haskell," which seems to answer my >> >> > question. When I attempt to run the memoization code in the paper >> >> > on the simple fib example, I find that -- apparently due to lazy >> >> > evaluation -- no new entries are entered into the lookup table, and >> >> > therefore no lookups are ever successful! >> >> > >> >> > So apparently there is some interaction between lazy evaluation and >> >> > garbage collection that I don't understand. My head hurts. Is it >> >> > necessary to make the table lookup operation strict? Or is it >> >> > something entirely different that I am missing? >> >> > >> >> > -Rod >> >> > >> >> > >> >> > On Thu, 10 Sep 2009 18:33:47 -0700 >> >> > Ryan Ingram wrote: >> >> > >> >> > > >> >> > > memoIO :: Ord a => (a -> b) -> IO (a -> IO b) >> >> > > memoIO f = do >> >> > > cache <- newIORef M.empty >> >> > > return $ \x -> do >> >> > > m <- readIORef cache >> >> > > case M.lookup x m of >> >> > > Just y -> return y >> >> > > Nothing -> do let res = f x >> >> > > writeIORef cache $ M.insert x res m >> >> > > return res >> >> > > >> >> > > memo :: Ord a => (a -> b) -> (a -> b) >> >> > > memo f = unsafePerformIO $ do >> >> > > fmemo <- memoIO f >> >> > > return (unsafePerformIO . fmemo) >> >> > > >> >> > > I don't think there is any valid transformation that breaks this, >> >> > > since the compiler can't lift anything through unsafePerformIO. >> >> > > Am I mistaken? >> >> > > >> >> > > -- ryan >> >> > >> >> > _______________________________________________ >> >> > 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090918/315d71ac/attachment-0001.html From jvranish at gmail.com Fri Sep 18 11:43:11 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Sep 18 11:21:43 2009 Subject: [Haskell-cafe] code-build-test cycle In-Reply-To: <974426058.20090918083416@gmail.com> References: <4AB2F398.7060703@alumni.caltech.edu> <974426058.20090918083416@gmail.com> Message-ID: Yeah linking in windows is _very_ slow. Supposedly this is because the linker forks a lot of processes. In linux this is fine as forking is dirt cheap, but in windows (at least older versions, not completely sure about vista or 7) forking is expensive. Building a Qt app on my EEE in linux only takes a couple seconds. Building in windows on my dual core 3.2Ghz machine takes 15-30 seconds. It's pretty sad. I second Bulat's suggestion. If you can compile everything and just use ghci to avoid the link you should be able to get the best of both works. - Job On Fri, Sep 18, 2009 at 12:34 AM, Bulat Ziganshin wrote: > Hello Michael, > > Friday, September 18, 2009, 6:42:32 AM, you wrote: > > > Now I'm wondering if Hugs is a faster interpreter. > > 2x slower, and incompatib;e with qtHaskell > > > meaningful way without compilation. Any advice welcome. Maybe there is a > > way to speed up the interpretation. > > if compilation is fast and only linking is slow, you may recompile > haskell modules every time but use ghci to omit linking. just execute ghc > compilation command inside ghci before running your app > > > -- > Best regards, > Bulat mailto:Bulat.Ziganshin@gmail.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090918/c048af57/attachment.html From linusoleander at gmail.com Fri Sep 18 13:14:53 2009 From: linusoleander at gmail.com (Snouser) Date: Fri Sep 18 12:53:24 2009 Subject: [Haskell-cafe] How to generate random string? In-Reply-To: <25512293.post@talk.nabble.com> References: <25512293.post@talk.nabble.com> Message-ID: <25512298.post@talk.nabble.com> Snouser wrote: > > I need to generate a random string from 1 to 30. > > This is the parts I've done so far. > > unikString xs | let x = unsafePerformIO (randomRIO (1,30)) elem x xs = x : > unikString xs > | otherwise = unikString xs > > How do I proceed? > > I need the string/list to look like this: > > [1,9,3,6,2] et.c with only unik numbers. > > Thanks! > I wasnt added to the mailinglist, but now I'm. -- View this message in context: http://www.nabble.com/How-to-generate-random-string--tp25512293p25512298.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From gregorypropf at yahoo.com Fri Sep 18 13:41:14 2009 From: gregorypropf at yahoo.com (Gregory Propf) Date: Fri Sep 18 13:19:47 2009 Subject: [Haskell-cafe] Re: [Haskell-beginners] map question In-Reply-To: Message-ID: <338166.65683.qm@web112202.mail.gq1.yahoo.com> I actually meant it as sort of a joke but maybe it's not after all.? Among the many benefits, think of all the delightful conspiracy theories such a change would spawn - "even our math isn't safe now!", "Save the minus sign!". --- On Fri, 9/18/09, Jon Fairbairn wrote: From: Jon Fairbairn Subject: [Haskell-cafe] Re: [Haskell-beginners] map question To: haskell-cafe@haskell.org Date: Friday, September 18, 2009, 2:09 AM Ketil Malde writes: > Gregory Propf writes: > >> Heh, perhaps we should petition to have a new computer key and symbol >> added to the world's way of writing maths, something like maybe a >> downward angled slash to mean prefix (-)? > > Or just use 'negate' and 'subtract'? Well, now that ghc accepts unicode characters in programme source, we could ask that ? (NOT SIGN, U+00AC) be recategorised as an identifier character and use that (as a simple function name) for negation and lose the wart altogether. class Negatable t where ? ? ? ? :: t -> t (and as a side effect we could have identifiers like slightly?dodgy). Or, if we want to make things look even nicer, make ? (HYPHEN, U+2010) an identifier character and use ? (MINUS SIGN, U+2212) for the infix operator. Now we could have hyphenated?identifiers too. I think this second option would be the ? (CORRECT, U+32A3) thing to do, though editors and so on would have to be changed to make the distinction readily visible. I think it's Friday, but I'm not entirely sure this is silly. -- J?n Fairbairn? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ???Jon.Fairbairn@cl.cam.ac.uk _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090918/a44f6e06/attachment.html From ndmitchell at gmail.com Fri Sep 18 14:29:44 2009 From: ndmitchell at gmail.com (Neil Mitchell) Date: Fri Sep 18 14:08:17 2009 Subject: [Haskell-cafe] Re: Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <4AB20848.1030505@gabriel.name> References: <4AB20848.1030505@gabriel.name> Message-ID: <404396ef0909181129v3bd2feapef5a29064339335b@mail.gmail.com> Hi Marcus, Thanks for your suggestions. I'm a Windows user so aren't really qualified to comment on these suggestions - it depends what Posix users would like. I suggest you follow the Library Submission Process - filepath is now a core library, and as such I don't have the freedom/power to change it as I like, and it's generally something lots of people should think about. http://www.haskell.org/haskellwiki/Library_submissions Thanks Neil PS. I'm off for 3 weeks starting very soon, so will be unlikely to reply to any email thread for a long time :-) On Thu, Sep 17, 2009 at 10:58 AM, Marcus D. Gabriel wrote: > Hello Neil > > I used System.FilePath.Posix quite extensively recently, and I thank > you for the package filepath. ?There were however two words that I > needed which I could not construct from those in > System.FilePath.Posix. ?They are maybe of interest to you and others. > > I submit these two words to you for consideration for inclusion in > System.FilePath.Posix. ?Please change the names as you see fit. > > I do not know if they make sense for System.FilePath.Windows. ?If > the do not make sense, then please feel free to drop them so as to > preserve the interface. > > As requested, I Cc'ed the haskell-cafe, but I am not at the moment > following these threads, so if anyone else responds, please Cc me > if you wish. > > Thanks again and cheers, > - Marcus > > P.S. Here they are. ?Although I use ksh(1) as an example, this is a > feature of POSIX shells. > >> -- | 'reduceFilePath' returns a pathname that is reduced to canonical >> -- form equivalent to that of ksh(1), that is, symbolic link names are >> -- treated literally when finding the directory name. ?See @cd -L@ of >> -- ksh(1). ?Specifically, extraneous separators @(\"/\")@, dot >> -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. >> >> reduceFilePath :: FilePath -> FilePath >> reduceFilePath = joinPath . filePathComponents > > This is in turn built on filePathComponents that does all the work. > >> filePathComponents :: FilePath -> [FilePath] >> filePathComponents "" ? ? = [] >> filePathComponents (c:cs) = >> ? ? reverse $ snd $ foldl accumulate >> ? ? ? ? ? ? ? ? ? ? ? ? ? (if c == pathSeparator then ([],["/"]) else >> ([c],[])) >> ? ? ? ? ? ? ? ? ? ? ? ? ? (cs++[pathSeparator]) >> ? ? where >> ? ? accumulate :: (String,[String]) -> Char -> (String,[String]) >> ? ? accumulate (cs, css) c = >> ? ? ? ? if c == pathSeparator >> ? ? ? ? then ([],(if null cs then id else cons cs) css) >> ? ? ? ? else (cs++[c],css) >> ? ? cons :: String -> [String] -> [String] >> ? ? cons cs css >> ? ? ? ? | cs == "." = css >> ? ? ? ? | cs /= ".." || null css = cs : css >> ? ? ? ? | otherwise = >> ? ? ? ? ? let hd = head css >> ? ? ? ? ? ? ? tl = tail css >> ? ? ? ? ? in if hd == [pathSeparator] >> ? ? ? ? ? ? ?then css >> ? ? ? ? ? ? ?else if hd == ".." >> ? ? ? ? ? ? ? ? ? then cs : css >> ? ? ? ? ? ? ? ? ? else if null tl >> ? ? ? ? ? ? ? ? ? ? ? ?then ["."] >> ? ? ? ? ? ? ? ? ? ? ? ?else tl > > // > > -- > ?Marcus D. Gabriel, Ph.D. ? ? ? ? ? ? ? ? ? ? ? ? Saint Louis, FRANCE > ?http://www.marcus.gabriel.name ? ? ? ? ? ?mailto:marcus@gabriel.name > ?Tel: +33.3.89.69.05.06 ? ? ? ? ? ? ? ? ? Portable: +33.6.34.56.07.75 > > > From alexey.skladnoy at gmail.com Fri Sep 18 16:36:10 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Fri Sep 18 16:08:33 2009 Subject: [Haskell-cafe] Too much strictness in binary-0.5.0.2 Message-ID: <200909190036.10694.alexey.skladnoy@gmail.com> Hello I run into problems with new binary package. Following function reads a list of elements one by one until end of stream. List is very long (won't fit into memory). In binary-0.5.0.1 and earlier it read list lazily. Now it seems that it tries to read whole list to memory. Program does not produce any output and memory usage steadily grows. > getStream :: Get a -> Get [a] > getStream getter = do > empty <- isEmpty > if empty > then return [] > else do x <- getter > xs <- getStream getter > return (x:xs) How could I add laziness to this function to revert to old behavior. -- Khudyakov Alexey From marcus at gabriel.name Fri Sep 18 17:43:46 2009 From: marcus at gabriel.name (Marcus D. Gabriel) Date: Fri Sep 18 17:22:19 2009 Subject: [Haskell-cafe] Re: Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <404396ef0909181129v3bd2feapef5a29064339335b@mail.gmail.com> References: <4AB20848.1030505@gabriel.name> <404396ef0909181129v3bd2feapef5a29064339335b@mail.gmail.com> Message-ID: <4AB3FF12.1050409@gabriel.name> Hello Neil, Thanks for the pointer Neil. I will read the site. Besides, it allows me to submit a fixed version since I just found a bug! Cheers, - Marcus P.S. 452 black box tests of my little command utility, and I still forgot about a corner case. Now there are 454 black box test cases :). Neil Mitchell wrote: > Hi Marcus, > > Thanks for your suggestions. I'm a Windows user so aren't really > qualified to comment on these suggestions - it depends what Posix > users would like. I suggest you follow the Library Submission Process > - filepath is now a core library, and as such I don't have the > freedom/power to change it as I like, and it's generally something > lots of people should think about. > > http://www.haskell.org/haskellwiki/Library_submissions > > Thanks > > Neil > > PS. I'm off for 3 weeks starting very soon, so will be unlikely to > reply to any email thread for a long time :-) > > > On Thu, Sep 17, 2009 at 10:58 AM, Marcus D. Gabriel wrote: > >> Hello Neil >> >> I used System.FilePath.Posix quite extensively recently, and I thank >> you for the package filepath. There were however two words that I >> needed which I could not construct from those in >> System.FilePath.Posix. They are maybe of interest to you and others. >> >> I submit these two words to you for consideration for inclusion in >> System.FilePath.Posix. Please change the names as you see fit. >> >> I do not know if they make sense for System.FilePath.Windows. If >> the do not make sense, then please feel free to drop them so as to >> preserve the interface. >> >> As requested, I Cc'ed the haskell-cafe, but I am not at the moment >> following these threads, so if anyone else responds, please Cc me >> if you wish. >> >> Thanks again and cheers, >> - Marcus >> >> P.S. Here they are. Although I use ksh(1) as an example, this is a >> feature of POSIX shells. >> >> >>> -- | 'reduceFilePath' returns a pathname that is reduced to canonical >>> -- form equivalent to that of ksh(1), that is, symbolic link names are >>> -- treated literally when finding the directory name. See @cd -L@ of >>> -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot >>> -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. >>> >>> reduceFilePath :: FilePath -> FilePath >>> reduceFilePath = joinPath . filePathComponents >>> >> This is in turn built on filePathComponents that does all the work. >> >> >>> filePathComponents :: FilePath -> [FilePath] >>> filePathComponents "" = [] >>> filePathComponents (c:cs) = >>> reverse $ snd $ foldl accumulate >>> (if c == pathSeparator then ([],["/"]) else >>> ([c],[])) >>> (cs++[pathSeparator]) >>> where >>> accumulate :: (String,[String]) -> Char -> (String,[String]) >>> accumulate (cs, css) c = >>> if c == pathSeparator >>> then ([],(if null cs then id else cons cs) css) >>> else (cs++[c],css) >>> cons :: String -> [String] -> [String] >>> cons cs css >>> | cs == "." = css >>> | cs /= ".." || null css = cs : css >>> | otherwise = >>> let hd = head css >>> tl = tail css >>> in if hd == [pathSeparator] >>> then css >>> else if hd == ".." >>> then cs : css >>> else if null tl >>> then ["."] >>> else tl -- Marcus D. Gabriel, Ph.D. Saint Louis, FRANCE http://www.marcus.gabriel.name mailto:marcus@gabriel.name Tel: +33.3.89.69.05.06 Portable: +33.6.34.56.07.75 From ninegua at gmail.com Fri Sep 18 20:06:22 2009 From: ninegua at gmail.com (Paul L) Date: Fri Sep 18 19:44:52 2009 Subject: [Haskell-cafe] big array allocation too slow? Message-ID: <856033f20909181706j5bf3d83atc60c86bf19d77d81@mail.gmail.com> I'm trying to use newArray to allocate something that has 100M unboxed doubles. It takes quite a few seconds to do so on GHC 6.10.2. But doing the same thing (and initialize all to 0) in C returns immediately. Setting RTS heap size doesn't help. Does anybody happen to know why? -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From dons at galois.com Fri Sep 18 20:04:56 2009 From: dons at galois.com (Don Stewart) Date: Fri Sep 18 19:45:39 2009 Subject: [Haskell-cafe] big array allocation too slow? In-Reply-To: <856033f20909181706j5bf3d83atc60c86bf19d77d81@mail.gmail.com> References: <856033f20909181706j5bf3d83atc60c86bf19d77d81@mail.gmail.com> Message-ID: <20090919000456.GQ29750@whirlpool.galois.com> ninegua: > I'm trying to use newArray to allocate something that has 100M unboxed > doubles. It takes quite a few seconds to do so on GHC 6.10.2. But > doing the same thing (and initialize all to 0) in C returns > immediately. Setting RTS heap size doesn't help. Does anybody happen > to know why? Use newArray_ to avoid initialising it. From ninegua at gmail.com Fri Sep 18 20:13:22 2009 From: ninegua at gmail.com (Paul L) Date: Fri Sep 18 19:51:52 2009 Subject: [Haskell-cafe] big array allocation too slow? In-Reply-To: <20090919000456.GQ29750@whirlpool.galois.com> References: <856033f20909181706j5bf3d83atc60c86bf19d77d81@mail.gmail.com> <20090919000456.GQ29750@whirlpool.galois.com> Message-ID: <856033f20909181713j1c92f7d0l946fd5e7e2de255d@mail.gmail.com> wow, using newArray_ and initialize the whole thing myself is much faster than newArray. But why? On 9/18/09, Don Stewart wrote: > ninegua: >> I'm trying to use newArray to allocate something that has 100M unboxed >> doubles. It takes quite a few seconds to do so on GHC 6.10.2. But >> doing the same thing (and initialize all to 0) in C returns >> immediately. Setting RTS heap size doesn't help. Does anybody happen >> to know why? > > Use newArray_ to avoid initialising it. > -- Regards, Paul Liu Yale Haskell Group http://www.haskell.org/yale From jeff at nokrev.com Sat Sep 19 00:46:49 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Sat Sep 19 00:25:39 2009 Subject: [Haskell-cafe] Compiling Yi's Dependencies on Windows Message-ID: <50c1e0910909182146t68e11559re4f96a1c866b569d@mail.gmail.com> Hey all, Yi has a lot of dependencies that currently make it a pain to install on Windows, so I'm wondering which of those can be streamlined for easier install on Windows. So far, I haven't succeeded at getting them to work on my own machine, and I've already spent a lot of time on it. The first major impediment is Gtk2Hs. Duncan has mostly resolved this issue with a minimal build that works on 6.10.4 [1], but I think that this should at least be mentioned on the Gtk2Hs site if it is impossible for now to get cabal-install to work by itself. Then comes bindings for things like curl (this may only be needed for Darcs, I don't remember), zlib, and regex (POSIX). If I remember correctly, zlib, or some other library, is able to ship with its *.c/*.h files and compile them as necessary on Windows. Can this be done for regex-posix and curl, too? On my system now, I've got both GnuWin32 and MSYS (MinGW) installed in attempts to get regex headers that work with regex-posix, but, at the moment, I've run into a wall, in which I get this error when loading or linking to regex-posix (it compiles fine itself): ghc.exe: C:\...\cabal\regex-posix-0.94.1\ghc-6.10.4\HSregex-posix-0.94.1.o: unknown symbol `_regerror' Loading package regex-posix-0.94.1 ... linking ... ghc.exe: unable to load package `regex-posix-0.94.1' I doubt most of these changes are significant (like linking on the gtk2hs site to the 6.10.4 build), but changing them could make many apps easier to install on Windows, not just Yi. Are there any other dependencies that have trouble on Windows which I haven't run into yet? If they're library dependencies, can the headers be included in the Hackage tarball? Jeff Wheeler From andrewcoppin at btinternet.com Sat Sep 19 03:52:14 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sat Sep 19 03:30:45 2009 Subject: [Haskell-cafe] Win32 API Message-ID: <4AB48DAE.9050209@btinternet.com> Hi guys. Last time I looked at the Win32 bindings, it covered a few basic file I/O things (e.g., special access modes, file permissions, etc.), registry editing, and that was about it. Yesterday I took another look, and was pleasently surprised to find that GDI is now covered. Suffice it to say, yesterday I wrote my very first ever program using the Win32 API directly. (Who'd have thought Haskell would be the place to do that?) This was complicated by a small glitch: Graphics.Win32.Window exposes SendMessage() but does not expose PostMessage(). Kind of an important difference there. Fortunately, it's not actually especially hard to fix this deficiency. (Basically few the source code for the module, copy and paste the line for SendMessage(), and edit it to say PostMessage(). The type signature just happens to be identical.) Is there a reason why this is missing to start with? What other functions are missing? (I didn't see PostQuitMessage() anywhere...) Still, 85 lines of code to make a working, native-looking Windows program isn't too shabby, really... (Not that any sane person writes nontrivial programs directly like this of course.) From g.c.stavenga at uu.nl Sat Sep 19 06:37:41 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Sat Sep 19 06:16:11 2009 Subject: [Haskell-cafe] Why the stack overflow? Message-ID: <25520431.post@talk.nabble.com> Hi haskell-cafe, Why does rlist 100000 [] gives stack overflow in ghci? rlist 0 l = return l rlist n l = do {x <- randomRIO (1,maxBound::Int); let nl = x:l in nl `seq` rlist (n-1) nl} I first uses replicateM then foldM and finally an explicit function. But they give all stack overflow I don't know why 100000 is not absurd and it is tail recursive. Or is it not, due to the monad structure? greetings Gerben -- View this message in context: http://www.nabble.com/Why-the-stack-overflow--tp25520431p25520431.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From daniel.is.fischer at web.de Sat Sep 19 07:54:05 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Sep 19 07:33:47 2009 Subject: [Haskell-cafe] Why the stack overflow? In-Reply-To: <25520431.post@talk.nabble.com> References: <25520431.post@talk.nabble.com> Message-ID: <200909191354.05700.daniel.is.fischer@web.de> Am Samstag 19 September 2009 12:37:41 schrieb staafmeister: > Hi haskell-cafe, > > Why does rlist 100000 [] gives stack overflow in ghci? > > rlist 0 l = return l > rlist n l = do {x <- randomRIO (1,maxBound::Int); let nl = x:l in nl `seq` > rlist (n-1) nl} > > I first uses replicateM then foldM and finally an explicit function. But > they give all stack overflow > I don't know why 100000 is not absurd and it is tail recursive. Or is it > not, due to the monad structure? Prelude System.Random> :set -XBangPatterns Prelude System.Random> let rlist2 0 l = return l; rlist2 n l = do { !x <- randomRIO (1,maxBound :: Int); let {nl = x:l}; nl `seq` rlist2 (n-1) nl } Prelude System.Random> rlist2 10 [] >>= \l -> print (take 3 l) >> print (last l) [800589677,541186119,1521221143] 1279766979 Prelude System.Random> rlist2 1000 [] >>= \l -> print (take 3 l) >> print (last l) [655069099,324945664,2137996923] 1108985638 Prelude System.Random> rlist2 10000 [] >>= \l -> print (take 3 l) >> print (last l) [286279491,666663955,2118785404] 315689721 Prelude System.Random> rlist2 100000 [] >>= \l -> print (take 3 l) >> print (last l) [862262999,947331403,790576391] 1250271938 Prelude System.Random> rlist2 1000000 [] >>= \l -> print (take 3 l) >> print (last l) [681201080,627349875,484483111] 1048225698 Prelude System.Random> rlist2 10000000 [] >>= \l -> print (take 3 l) >> print (last l) [1247387053,690485134,1924757191] 1637122415 The problem is that randomRIO doesn't evaluate its result, so you build a long chain of calls to randomR, which isn't evaluated until the count reaches 0, hence the stack overflow. Forcing x prevents the long chain from being built. But better don't use randomRIO, make it a pure function with the PRNG as an argument. > > greetings > Gerben From duncan.coutts at worc.ox.ac.uk Sat Sep 19 07:36:12 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Sep 19 08:11:04 2009 Subject: [Haskell-cafe] Win32 API In-Reply-To: <4AB48DAE.9050209@btinternet.com> References: <4AB48DAE.9050209@btinternet.com> Message-ID: <1253360172.32005.1116.camel@localhost> On Sat, 2009-09-19 at 08:52 +0100, Andrew Coppin wrote: > This was complicated by a small glitch: Graphics.Win32.Window exposes > SendMessage() but does not expose PostMessage(). Kind of an important > difference there. Fortunately, it's not actually especially hard to fix > this deficiency. (Basically few the source code for the module, copy and > paste the line for SendMessage(), and edit it to say PostMessage(). The > type signature just happens to be identical.) Is there a reason why this > is missing to start with? What other functions are missing? (I didn't > see PostQuitMessage() anywhere...) I doubt there's any reason it was not bound except that it was not needed by the person who bound the related ones. Send in your patch. Duncan From duncan.coutts at worc.ox.ac.uk Sat Sep 19 07:45:00 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Sat Sep 19 08:11:09 2009 Subject: [Haskell-cafe] Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <4AB20848.1030505@gabriel.name> References: <4AB20848.1030505@gabriel.name> Message-ID: <1253360700.32005.1133.camel@localhost> On Thu, 2009-09-17 at 11:58 +0200, Marcus D. Gabriel wrote: > > -- | 'reduceFilePath' returns a pathname that is reduced to canonical > > -- form equivalent to that of ksh(1), that is, symbolic link names are > > -- treated literally when finding the directory name. See @cd -L@ of > > -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot > > -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. > > > > reduceFilePath :: FilePath -> FilePath > > reduceFilePath = joinPath . filePathComponents So it's like the existing System.Directory.canonicalizePath but it's pure and it does not do anything with symlinks. On the other hand because it's pure it can do something with non-local paths. Is there anything POSIX-specific about this? I don't see it. Duncan From leather at cs.uu.nl Sat Sep 19 11:59:38 2009 From: leather at cs.uu.nl (Sean Leather) Date: Sat Sep 19 11:38:27 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: References: Message-ID: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> Hi Daneel, On Sat, Sep 19, 2009 at 13:58, Daneel Yaitskov wrote: > > Recently I've found wonderful thing cabal can install packages itself! It > can even install those packages which need for final one. But I'm disturbed > cabal doesn't create the documentation of a package by default. It manually > makes "runhaskell Setup haddock". > > Who knows? > I believe you can do 'cabal haddock', but I don't know why it doesn't do it by default. BTW, the Haskell Caf? is typically more suitable for questions such as these. The Generics list is more specifically for generic programming discussions while the Haskell Caf? serves a broader audience. I've CC'd haskell-cafe@ to see if anybody there knows the answer to your question. Regards, Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090919/8d177369/attachment.html From gwern0 at gmail.com Sat Sep 19 12:02:10 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sat Sep 19 11:40:38 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> References: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> Message-ID: On Sat, Sep 19, 2009 at 11:59 AM, Sean Leather wrote: > Hi Daneel, > > On Sat, Sep 19, 2009 at 13:58, Daneel Yaitskov wrote: >> >> Recently I've found wonderful thing cabal can install packages itself! It >> can even install those packages which need for final one. But I'm disturbed >> cabal doesn't create the documentation of a package by default. It manually >> makes "runhaskell Setup haddock". >> >> Who knows? > > I believe you can do 'cabal haddock', but I don't know why it doesn't do it > by default. > > BTW, the Haskell Caf? is typically more suitable for questions such as > these. The Generics list is more specifically for generic programming > discussions while the Haskell Caf? serves a broader audience. I've CC'd > haskell-cafe@ to see if anybody there knows the answer to your question. > > Regards, > Sean If you use cabal-install (as you should!), you can have it build haddocks by customizing ~/.cabal/config and adding: documentation: True -- gwern From ben.franksen at online.de Sat Sep 19 12:53:52 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sat Sep 19 12:32:51 2009 Subject: [Haskell-cafe] Re: Is it safe to use unsafePerformIO here? References: <200909180041.26241.daniel.is.fischer@web.de> <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> <200909180515.12969.daniel.is.fischer@web.de> Message-ID: Cristiano Paris wrote: > Daniel Fischer wrote: >> I would separate the reading of headers and bodies, reopening the files >> whose body is needed, for some (maybe compelling) reason he wants to do >> it differently. > > Yes, that's the way Haskell forces you to do that as it's the only way > for you to go safe. I don't think it has anything to do with Haskell. How would you do this in C? You'd pass a flag indicating whether to read the whole file or just the header. You can do the same in Haskell, of course, no lazy IO needed. The body remains undefined if the flag indicates header only. Even better wrap the body in a Maybe. > But, if you know more about your code, you can use > unsafe(Perform|Interleave)IO to assure the compiler that everything's > right. I have a hard time believing this is possible, if you demand that the files should not stay opened indefinitely. How is the runtime supposed to know whether to close the file or not? What you /can/ do is use unsafePerformIO to lazily re-open, read the body, and close the file, as soon as the body gets demanded. However, this is ugly and not advised. Cheers Ben From jfredett at gmail.com Sat Sep 19 13:22:05 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 19 13:02:37 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009 Message-ID: Hopefully the line endings come out okay this week, I did a test before sending it to the list, please let me know if you notice anything awry. Just put a [HWN] in the subject line so my filter's will catch it. --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090918 Issue 131 - September 18, 2009 --------------------------------------------------------------------------- Welcome to issue 131 of HWN, a newsletter covering developments in the [1]Haskell community. Last week, I received an email from Mark Wotton about his project [2]Hubris. I totally forgot to put it in the HWN last week, too busy trying to figure out all the tools. So, I thought I'd make it up and give him some special editorial status this week. Hubris is a bridge between Ruby and Haskell, allowing you to call Haskell from Ruby. It's very cool, I highly suggest playing with it. Also, I've been posting a bit about the new HWN tools (dubbed "HWN2") on my [3]blog, there is also a repo up at [4]patch-tag which will have all the code. If there is some interest in helping me, I'll try to come up with a TODO list/Trac. Announcements hssqlppp, sql parser and type checker, pre-alpha. Jake Wheat [5]announced his parser/type checker for SQL. It currently parses a subset of PostGreSQL and PL/pgSQL, and can type check some statements. LambdaINet-0.1.0, Graphical Interaction Net Evaluator for Optimal Evaluation. Paul L [6]announced a LambdaINet 0.1.0, available on [7]Hackage. LambdaINet implements an interaction net based optimal evaluator. With an interactive graphical interface allowing the user to view and directly manipulate the interaction net. arbtt-0.1. Joachim Breitner [8]announced the Automatic Rule-Based Time Tracking tool on hackage. he has an introduction available [9]here. A statistics library. Bryan O'Sullivan [10]announced the imaginatively named [11]statistics library. Which supports common discrete and continuous probability distributions, Kernel density estimation, Auto-correlation analysis, Functions over sample data, Quantile estimation, and Re-sampling techniques. CFP: JSC Special Issue on Automated Verification and Specification of Web Systems. [12]A Special Issue of the Journal of symbolic computation was announced. This issue is related to the topics of the Automated Specification and Verification of Web Systems Workshop (WWV'09). Read the announcement for more details. Haskeline 0.6.2. Judah Jacobson [13]announced the release of Haskeline 0.6.2, available [14]here. Improvements over the last version include, new emacs and vi bindings, a new preference to remove repeated history entries, recognition of page-up and page-down keys, and more. PEPM'10 - Last CFP (Submission: 6 Oct 09, Notification: 29 Oct 09). Janis Voigtlaender [15]announced the Last Call for Papers for PEPM'10, see the announcement for more details. Videos of HIW 2009. Malcolm Wallace [16]announced videos of all the presentations/discussions at the recent Haskell Implementers Workshop 2009, in Edinburgh, are now [17]online. The program of talks is available [18]here. Unification in a Commutative Monoid (cmu 1.1) and a new release of Abelian group unification and matching (agum 2.2). John D. Ramsdell [19]announced cmu 1.1, which provides unification in a commutative monoid, also know as ACU-unification. The core computation finds the minimal non-zero solutions to homogeneous linear Diophantine equations. The linear equation solver has been place in a separate module so it can be used for other applications. He also announced agum 2.2, which provides unification and matching in an Abelian group, also know as AG-unification and matching. graphviz-2999.5.1.0. Ivan Lazar Miljenovic [20]announced a bug-fix release of the GraphViz package, no major API changes occurred. levmar-0.2, bindings-levmar-0.1.1. Bas van Dijk and Roel van Dijk announced [21]new [22]versions of the levmar and bindings-levmar packages. New features include automatic calculation of the Jacobian via Conal Elliot's automatic differentiation from his vector-space library. CmdArgs - easy command line argument processing. Neil Mitchell [23]announced CmdArgs 0.1. CmdArgs is a library for parsing command-line arguments. It offers several improvements over GetOpts, namely that the Command Line Argument Processors are shorter and CmdArgs can support multiple-mode command lines such as those found in darcs, cabal, hpc, etc. OpenGL 2.4.0.1. Sven Panne [24]announced a new version of the OpenGL package, this version fixes a bug that didn't make it into the previous release. OpenGLRaw 1.1.0.0. Sven Panne [25]announced a new version of the OpenGLRaw package has been uploaded to Hackage. Discussion Thank you guys. Cristiano Paris took some time to thank us all from -Cafe for helping him learn Haskell. You're welcome, Cristiano! Unicode lexing in GHC and GHCi. Sean McLaughlin [26]asked about why certain unicode characters parsed in GHCi without error, but not in compiled code. Help with FFI. Jose Prous [27]asked for some help with the foreign function interface. Ambiguous type variable with subclass instance. Andy Gimblett [28]asked about a particular ambiguous type error Haskell -> .NET. Peter Verswyvelen [29]asked about the possibilities for a .NET version of Haskell. A thought about liberating Haskell's syntax. George Pollard [30]suggested a new way to do templates, so that brace-like syntax could be added without having to seriously hack GHC. Blog noise [31]Haskell news from the [32]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Neil Brown: [33]Concurrent Pearl: The Sort Pump. * Roman Cheplyaka: [34]CCC #6: HWN. A comic revealing the _real_ reason Brent left the HWN to me. * Don Stewart (dons): [35]Data.Binary: performance improvements for Haskell binary parsing. * Thomas M. DuBuisson: [36]Kernel Modules in Haskell. * Neil Brown: [37]Boids Simulation: Part 4. * Edward Kmett: [38]Iteratees, Parsec, and Monoids, Oh My!. * Edward Kmett: [39]Remodeling Precision. * Alex McLean: [40]Hackpact documentation (week 3). The continuation of Alex's series on Hackpact * Luke Palmer: [41]IO-free splittable supply. * Thomas M. DuBuisson: [42]Kernel Modules in Haskell. * Bryan O'Sullivan: [43]A video demo of my Haskell benchmarking framework. * Don Stewart (dons): [44]Haskell for Everyone: Hackage and the Haskell Platform : Haskell Implementers Workshop 2009. * David Sankel: [45]Applied Functional Programming: Part 1. * Neil Brown: [46]Boids Simulation: Part 4. * Darcs: [47]darcs weekly news #40. * Chris Smith: [48]On Inverses of Haskell Functions. * David Amos: [49]Finite geometries, part 1: AG(n,Fq). A multipart series from David, part of his Haskell For Maths project. Quotes of the Week * quicksilver: no, you mispelt >> as ; * dons: Cale's my alter-ego. I talk about applications and benchmarking, he talks about theory and math. We've been doing this for years :) * gwern: #haskell: because none of us are as offtopic as all of us * some-crazy-hwn-editor: A monster! HAH! It will not be a monster, but a god! ALL SHALL BOW BEFORE MY SPAWN AND DESPAIR! ALL HAIL THE PROGRAMMER CHILD! ALL HAIL THE HYPNOTOAD! * AlanJPerlis: Purely applicative languages are poorly applicable. About the Haskell Weekly News New editions are posted to [50]the Haskell mailing list as well as to [51]the Haskell Sequence and [52]Planet Haskell. [53]RSS is also available, and headlines appear on [54]haskell.org. To help create new editions of this newsletter, please see the information on [55]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [56]http://patch-tag.com/r/HWN2/home . References 1. http://haskell.org/ 2. http://github.com/mwotton/Hubris 3. http://lowlymath.net/?p=45 4. http://patch-tag.com/r/HWN2/snapshot/current/content/pretty 5. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63413 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63390 7. http://hackage.haskell.org/package/LambdaINet 8. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63369 9. https://www.joachim-breitner.de/blog/archives/336-The-Automatic-Rule-Based-Time-Tracker.html 10. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63362 11. http://hackage.haskell.org/package/statistics 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17502 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17497 14. http://hackage.haskell.org/package/haskeline 15. http://article.gmane.org/gmane.comp.lang.haskell.general/17496 16. http://article.gmane.org/gmane.comp.lang.haskell.general/17494 17. http://www.vimeo.com/album/126462 18. http://haskell.org/haskellwiki/HaskellImplementorsWorkshop 19. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63572 20. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63542 21. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63499 22. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63498 23. http://article.gmane.org/gmane.comp.lang.haskell.general/17493 24. http://article.gmane.org/gmane.comp.lang.haskell.general/17492 25. http://article.gmane.org/gmane.comp.lang.haskell.general/17490 26. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63580 27. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63574 28. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63545 29. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63512 30. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63492 31. http://planet.haskell.org/ 32. http://haskell.org/haskellwiki/Blog_articles 33. http://chplib.wordpress.com/2009/09/18/the-sort-pump/ 34. http://ro-che.blogspot.com/2009/09/ccc-6-hwn.html 35. http://donsbot.wordpress.com/2009/09/16/data-binary-performance-improvments-for-haskell-binary-parsing/ 36. http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ 37. http://chplib.wordpress.com/2009/09/16/boids-simulation-part-4/ 38. http://comonad.com/reader/2009/iteratees-take-2/ 39. http://comonad.com/reader/2009/remodeling-precision/ 40. http://yaxu.org/hackpact-documentation-week-3/ 41. http://lukepalmer.wordpress.com/2009/09/14/io-free-splittable-supply/ 42. http://tommd.wordpress.com/2009/09/13/kernel-modules-in-haskell/ 43. http://www.serpentine.com/blog/2009/09/14/a-video-demo-of-my-haskell-benchmarking-framework/ 44. http://donsbot.wordpress.com/2009/09/14/haskell-for-everyone-hackage-and-the-haskell-platform-haskell-implementors-workshop-2009/ 45. http://netsuperbrain.com/blog/posts/applied-functional-programming-part-1/ 46. http://chplib.wordpress.com/2009/09/14/boids-simulation-part-4/ 47. http://blog.darcs.net/2009/09/darcs-weekly-news-40.html 48. http://cdsmith.wordpress.com/2009/09/14/on-inverses-of-haskell-functions/ 49. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-1-agnfq.html 50. http://www.haskell.org/mailman/listinfo/haskell 51. http://sequence.complete.org/ 52. http://planet.haskell.org/ 53. http://sequence.complete.org/node/feed 54. http://haskell.org/ 55. http://haskell.org/haskellwiki/HWN 56. http://patch-tag.com/r/HWN2/home From derek.a.elkins at gmail.com Sat Sep 19 13:35:59 2009 From: derek.a.elkins at gmail.com (Derek Elkins) Date: Sat Sep 19 13:14:28 2009 Subject: [Haskell-cafe] Why the stack overflow? In-Reply-To: <200909191354.05700.daniel.is.fischer@web.de> References: <25520431.post@talk.nabble.com> <200909191354.05700.daniel.is.fischer@web.de> Message-ID: <61f84eff0909191035v4246d20dx57be7e6ab09a31cf@mail.gmail.com> On Sat, Sep 19, 2009 at 6:54 AM, Daniel Fischer wrote: > Am Samstag 19 September 2009 12:37:41 schrieb staafmeister: >> Hi haskell-cafe, >> >> Why does rlist 100000 [] gives stack overflow in ghci? >> >> rlist 0 l = return l >> rlist n l = do {x <- randomRIO (1,maxBound::Int); let nl = x:l in nl `seq` >> rlist (n-1) nl} >> >> I first uses replicateM then foldM and finally an explicit function. But >> they give all stack overflow >> I don't know why 100000 is not absurd and it is tail recursive. Or is it >> not, due to the monad structure? > > Prelude System.Random> :set -XBangPatterns > Prelude System.Random> let rlist2 0 l = return l; rlist2 n l = do { !x <- randomRIO > (1,maxBound :: Int); let {nl = x:l}; nl `seq` rlist2 (n-1) nl } > Prelude System.Random> rlist2 10 [] >>= \l -> print (take 3 l) >> print (last l) > [800589677,541186119,1521221143] > 1279766979 > Prelude System.Random> rlist2 1000 [] >>= \l -> print (take 3 l) >> print (last l) > [655069099,324945664,2137996923] > 1108985638 > Prelude System.Random> rlist2 10000 [] >>= \l -> print (take 3 l) >> print (last l) > [286279491,666663955,2118785404] > 315689721 > Prelude System.Random> rlist2 100000 [] >>= \l -> print (take 3 l) >> print (last l) > [862262999,947331403,790576391] > 1250271938 > Prelude System.Random> rlist2 1000000 [] >>= \l -> print (take 3 l) >> print (last l) > [681201080,627349875,484483111] > 1048225698 > Prelude System.Random> rlist2 10000000 [] >>= \l -> print (take 3 l) >> print (last l) > [1247387053,690485134,1924757191] > 1637122415 > > The problem is that randomRIO doesn't evaluate its result, so you build a long chain of > calls to randomR, which isn't evaluated until the count reaches 0, hence the stack > overflow. Forcing x prevents the long chain from being built. Incidentally, nl is already in head normal form so seq nl does nothing. Leading to: rlist 0 l = return l rlist n l = do !x <- randomRIO (1, maxBound :: Int); rlist (n-1) (x:l) From allbery at ece.cmu.edu Sat Sep 19 14:43:24 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Sat Sep 19 14:22:09 2009 Subject: [Haskell-cafe] Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <1253360700.32005.1133.camel@localhost> References: <4AB20848.1030505@gabriel.name> <1253360700.32005.1133.camel@localhost> Message-ID: <29E3E258-6C06-437B-A13A-C7C94575CCED@ece.cmu.edu> On Sep 19, 2009, at 07:45 , Duncan Coutts wrote: > On Thu, 2009-09-17 at 11:58 +0200, Marcus D. Gabriel wrote: >>> -- | 'reduceFilePath' returns a pathname that is reduced to >>> canonical >>> -- form equivalent to that of ksh(1), that is, symbolic link names >>> are >>> -- treated literally when finding the directory name. See @cd -L@ >>> of >>> -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot >>> -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. > > So it's like the existing System.Directory.canonicalizePath but it's > pure and it does not do anything with symlinks. On the other hand > because it's pure it can do something with non-local paths. > > Is there anything POSIX-specific about this? I don't see it. It's making assumptions about the safety of eliding "..". (What does \ \machine\share\..\ do?) On the other hand that's also unsafe on POSIX in the presence of symlinks. In general I consider path cleanup not involving validation against the filesystem to be risky. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090919/26123e19/PGP.bin From haskell at gimbo.org.uk Sat Sep 19 14:55:10 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Sat Sep 19 14:33:50 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <2f9b2d30909171001k6db61cadwf23c1b735bb9e1f3@mail.gmail.com> References: <200909171750.27590.daniel.is.fischer@web.de> <6EBAB11B-886A-4B2A-9367-0A05E85E13A5@gimbo.org.uk> <2f9b2d30909171001k6db61cadwf23c1b735bb9e1f3@mail.gmail.com> Message-ID: <1C6B5E13-D478-4BCC-A460-C291330A7529@gimbo.org.uk> On 17 Sep 2009, at 18:01, Ryan Ingram wrote: > Here's a way that works more closely to your original version: > > instance Enumerated a => Target a where > convert n > | n >= 0 && n < numConstrs = Just (constrs !! n) > | otherwise = Nothing > where > constrs = constructors > numConstrs = length constrs Aha - that's great, and it works without OverlappingInstances (but still with FlexibleInstances and UndecidableInstances - should that worry me?) Just making sure constructors is only referenced once is the key, it seems. Thanks! -Andy From daniel.is.fischer at web.de Sat Sep 19 15:27:31 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sat Sep 19 15:09:13 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: <1C6B5E13-D478-4BCC-A460-C291330A7529@gimbo.org.uk> References: <2f9b2d30909171001k6db61cadwf23c1b735bb9e1f3@mail.gmail.com> <1C6B5E13-D478-4BCC-A460-C291330A7529@gimbo.org.uk> Message-ID: <200909192127.32023.daniel.is.fischer@web.de> Am Samstag 19 September 2009 20:55:10 schrieb Andy Gimblett: > On 17 Sep 2009, at 18:01, Ryan Ingram wrote: > > Here's a way that works more closely to your original version: > > > > instance Enumerated a => Target a where > > convert n > > > > | n >= 0 && n < numConstrs = Just (constrs !! n) > > | otherwise = Nothing > > > > where > > constrs = constructors > > numConstrs = length constrs > > Aha - that's great, and it works without OverlappingInstances (but > still with FlexibleInstances and UndecidableInstances - should that > worry me?) FlexibleInstances need not worry anybody. They just remove a fairly arbitrary restriction of Haskell98 for instance declarations. UndecidableInstances can be dangerous, but there are perfectly safe things which reauire UndecidableInstances, too. > > Just making sure constructors is only referenced once is the key, it > seems. Just making sure that every time it is referenced, it is referenced at the correct type. > > Thanks! > > -Andy From marlowsd at gmail.com Sat Sep 19 16:08:29 2009 From: marlowsd at gmail.com (Simon Marlow) Date: Sat Sep 19 15:47:02 2009 Subject: [Haskell-cafe] Re: Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <29E3E258-6C06-437B-A13A-C7C94575CCED@ece.cmu.edu> References: <4AB20848.1030505@gabriel.name> <1253360700.32005.1133.camel@localhost> <29E3E258-6C06-437B-A13A-C7C94575CCED@ece.cmu.edu> Message-ID: <4AB53A3D.7080406@gmail.com> Brandon S. Allbery KF8NH wrote: > On Sep 19, 2009, at 07:45 , Duncan Coutts wrote: >> On Thu, 2009-09-17 at 11:58 +0200, Marcus D. Gabriel wrote: >>>> -- | 'reduceFilePath' returns a pathname that is reduced to canonical >>>> -- form equivalent to that of ksh(1), that is, symbolic link names are >>>> -- treated literally when finding the directory name. See @cd -L@ of >>>> -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot >>>> -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. >> >> So it's like the existing System.Directory.canonicalizePath but it's >> pure and it does not do anything with symlinks. On the other hand >> because it's pure it can do something with non-local paths. >> >> Is there anything POSIX-specific about this? I don't see it. > > It's making assumptions about the safety of eliding "..". (What does > \\machine\share\..\ do?) On the other hand that's also unsafe on POSIX > in the presence of symlinks. In general I consider path cleanup not > involving validation against the filesystem to be risky. I agree; this came up before during the design of System.FilePath, and it's why the current library doesn't have a way to remove "..". The docs should probably explain this point, because it's non-obvious that you can't just "clean up" a path to remove the ".." and end up with something that means the same thing. Cheers, Simon From ekmett at gmail.com Sat Sep 19 16:56:37 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sat Sep 19 16:35:05 2009 Subject: [Haskell-cafe] Ambiguous type variable with subclass instance (also: is there a better way to do this?) In-Reply-To: References: Message-ID: <7fb8f82f0909191356k35f2db6bgbf17ba87eb7bba6@mail.gmail.com> A few issues, you can remove the overlapping instances by using a newtype wrapper to disambiguate which instance you want. A little alarm bell goes off in my head whenever I read 'instance Foo a'. newtype Wrapped a = Wrapped a instance Target Foo where ... instance Enumerated a => Target (Wrapped a) where ... is probably a better idea over all. As for the use of constructors. your problem is that it is ambiguous which constructors you want to take the list of. Try replacing constructors with a local variable. The choice of constructors then will be fixed by the use of the argument from the Just branch and the monomorphism restriction constraining you so that the list you take the length of has the same type. > instance (Enumerated a) => Target a where > convert n | n `elem` [0..len-1] = Just $ cons !! n > | otherwise = Nothing > where > len = length cons > cons = constructors You could also do it with some sort of asListOf :: [a] -> a -> [a] asListOf = const convert n = result where ... len = length cons ... cons = constructors `asListOf` result if relying on the MR makes you feel dirty. -Edward On Thu, Sep 17, 2009 at 9:40 AM, Andy Gimblett wrote: > Hi all. This email is in literate Haskell; you should be able to load > it into ghci and verify what I'm saying (nb: it won't compile without > alteration: see below). > > I'm trying to do something which may anyway be stupid / not the best > approach to what I'm trying to achieve; however, it's not working and > I can't see why not. So I'm asking for help on two fronts: > > 1) Why is this failing? > > 2) Maybe more usefully, how should I actually be doing this? It seems > an ugly approach; a voice in my head is saying "scrap your > boilerplate", but I've no idea yet if that's actually applicable > here; should I look at it? > > On with the show... > > I need these for "subclass" stuff later on... > > > {-# LANGUAGE FlexibleInstances #-} > > {-# LANGUAGE OverlappingInstances #-} > > {-# LANGUAGE UndecidableInstances #-} > > > module Ambig where > > I wish to define a number of algebraic data types with the ability to > turn Int values into instances of those types. So I define a > typeclass saying this is possible. I use Maybe so I can encode the > existence of out-of-range Int values, which will vary from target type > to target type. > > > class Target a where > > convert :: Int -> Maybe a > > E.g. here's a type Foo which only wants values between 1 and 10: > > > data Foo = Foo Int deriving (Show) > > instance Target Foo where > > convert n | n `elem` [1..10] = Just $ Foo n > > | otherwise = Nothing > > (That's a simple example; some are rather more complex. How to do > this isn't what I'm asking about, really.) > > So we have, for example: > > *Ambig> (convert 1) :: Maybe Foo > Just (Foo 1) > *Ambig> (convert 11) :: Maybe Foo > Nothing > > Now, some of those algebraic data type types happen to be > enumerations; in this case, my idea is to list the constructors, with > the rule that each constructor's position in the list is the Int which > gets converted into that constructor. > > > class Enumerated a where > > constructors :: [a] > > E.g. here's a type Bar with three constructors: > > > data Bar = X | Y | Z deriving (Show) > > instance Enumerated Bar where > > constructors = [X, Y, Z] > > (This is certainly ugly. Any suggestions?) > > Now we get to the crux. If a type is an instance of Enumerated, it > should also be a Target, because we should be able to convert from Int > just by list lookup. But we include a bounds check, naturally... > > > instance (Enumerated a) => Target a where > > convert n | n `elem` [0..len-1] = Just $ constructors !! n > > | otherwise = Nothing > > where len = length constructors > > So I would _hope_ that then, e.g., we'd have: > > *Ambig> (convert 0) :: Maybe Bar > Just X > *Ambig> (convert 1) :: Maybe Bar > Just Y > *Ambig> (convert 3) :: Maybe Bar > Nothing > > Sadly, this function doesn't compile, dying with an "Ambiguous type > variable" error: > > Ambig.lhs:75:29: > Ambiguous type variable `a' in the constraint: > `Enumerated a' > arising from a use of `constructors' at Ambig.lhs:74:29-40 > Probable fix: add a type signature that fixes these type variable(s) > > If we replace "length constructors" with "3" (say), it compiles (but > is useless). Adding a type signature doesn't help: it's "misplaced" > in that context. If I break it out of the instance declaration so I > can add one, I still get the same problem: > > > convert' :: (Enumerated a, Target a) => Int -> Maybe a > > convert' n | n `elem` [0..len-1] = Just $ constructors !! n > > | otherwise = Nothing > > where len = length constructors > > I guess I see roughly what's going on; the question is "which > constructors instance is meant?", right? In the "Just" part it's OK, > because it can be inferred from the function's return type (right?). > But in the guard we don't have that help, so it could be any > Enumerated instance? > > Any advice appreciated! Particularly if this is just a dumb approach. > For context, this is related to deserialisation of binary data (they'll > actually be Word8's, not Int's) into a variety of data structures. > > Hmmm, maybe I should just be using Data.Binary... > > Many thanks, > > -Andy > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090919/95393f21/attachment.html From shulman at ugcs.caltech.edu Sun Sep 20 01:33:33 2009 From: shulman at ugcs.caltech.edu (Michael Shulman) Date: Sun Sep 20 01:12:03 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: References: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> Message-ID: <4AB5BEAD.90001@ugcs.caltech.edu> Gwern Branwen wrote: > If you use cabal-install (as you should!), you can have it build > haddocks by customizing ~/.cabal/config and adding: > > documentation: True Is there a way to make it automatically update a single contents page with links to the documentation of all installed packages? I have been doing this manually every time I cabal-install something, by running a little shell script which looks through all the packages directories for "html" directories and ".haddock" files and compiles them all into a call to "haddock --gen-contents". Mike From veger at cistron.nl Sun Sep 20 03:30:33 2009 From: veger at cistron.nl (Peter J. Veger) Date: Sun Sep 20 03:09:24 2009 Subject: [Haskell-cafe] first the platform, the cabal Message-ID: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> I just installed the Haskell Platform 2009.2.0.2 on Windows. There is no cabal.exe, only Cabal-1.6.0.3 How to continue: build cabal? Then what to download from where and what to execute? greetings, Peter J. Veger, Best Netherlands -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090920/43b69a76/attachment.html From jno at di.uminho.pt Sun Sep 20 04:01:09 2009 From: jno at di.uminho.pt (J.N. Oliveira) Date: Sun Sep 20 03:39:22 2009 Subject: [Haskell-cafe] TFM09: Call for Participation (FMWeek, Eindhoven, November 2009) In-Reply-To: <94BB0D54-2E17-4455-92C7-FCFCEBC5CCC2@di.uminho.pt> References: <6AC8F250-5C3 7-4593-BCBD-144AB137C75D@di.uminho.pt><1FB8BC34-C683-4850-8FA6-DA12D9743D5E @di.uminho.pt><8093D19D- B78D-4D7C-A2FF-FAE182EC67AE@di.uminho.pt><61E3A078-D722-47E9-AC4F-A2610969CE13@di.uminho.pt><485E9D1C-AF99-4B8E-B8DA-F45997 FD26F0@di.uminho.pt><10B841BC-C0B9-4186-A8B4-D3C FFFCB8116@di.uminho.pt>< 5023897F-1EAE-4E3A-95FF-BAB39FAD9445@di.uminho.pt><342EB496-47B1-42EA-B133- 2DBB1BB074F5@di.uminho.pt><45FDA14E-EB10-44BD-980D-2FED948F4C9B@di.uminho.p t><47D23ACA-946B-451C-88D5-D5D2970B32AF@di.uminho.pt> <4AB4C40B.4020001@di.uminho.pt> <5D96C512-8B7B-4EFE-AE37-BC31FFAE1B33@di.uminho.pt> <2B579A1E-6D2E-4B30-AF27-5302F31A21EF@di.uminho.pt> <1A959A6D-ED8C-4231-AEFB-B361827D33D4@di.uminho.pt> <8622B674-62F0-439C-80C5-EE256B716DAC@di.uminho.pt> <4DAEC066-B5BA-45A8-987A-F02AC5B99C19@di.uminho.pt> <94BB0D54-2E17-4455-92C7-FCFCEBC5CCC2@di.uminho.pt> Message-ID: TFM2009 2nd Int. FME Conference on Teaching Formal Methods Friday, November 6th 2009, co-located with FM2009 : 16th Int. Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009 CALL FOR PARTICIPATION (URL: http://www.di.uminho.pt/tfm09) 1. About the conference ----------------------- Ten years after the First World Formal Methods Congress (FM'99) in Toulouse, formal methods communities from all over the world will once again have an opportunity to come together. As part of the First Formal Methods Week event surrounding the FM2009 conference in Eindhoven, Formal Methods Europe will be organizing TFM2009, the Second International Conference on Teaching Formal Methods. The conference will serve as a forum to explore the successes and failures of Formal Methods (FM) education, and to promote cooperative projects to further education and training in FMs. TFM2009 will include a panel discussion on the idea of building a 'Guide to the Formal Methods Body of Knowledge' (FMBoK), inspired by similar efforts for software engineering (SWEBoK) and for project management (PMBoK); such a resource would provide guidance to teachers, managers, and developers on what should be expected from a comprehensive, balanced programme of education in FMs. 2. Invited speaker ------------------ Jeff Kramer (Imperial College London, UK) 3. Accepted papers ------------------ * Teaching Concurrency: Theory in Practice (Luca Aceto, Anna Ingolfsdottir, Kim Guldstrand Larsen, Jiri Srba) * Integrated and Tool-Supported Teaching of Testing, Debugging, and Verification (Wolfgang Ahrendt, Richard Bubel, Reiner Haehnle) * What Top-Level Software Engineers Tackle after Learning Formal Methods - Experiences from the Top SE Project (Fuyuki Ishikawa, Kenji Taguchi, Nobukazu Yoshioka, Shinichi Honiden) * Teaching program specification and verification using JML and ESC/Java2 (Erik Poll) * Chief Chefs of Z to Alloy: Using A Kitchen Example to Teach Alloy with Z (Sureyya Tarkan, Vibha Sazawal) * Teaching Formal Methods based on Rewriting Logic and Maude (Peter Olveczky) * Which Mathematics for the Information Society? (Joao Ferreira, Alexandra Mendes, Roland Backhouse, Luis Barbosa) * How to explain mistakes (Stefan Hallerstede, Michael Leuschel) * On Teaching Formal Methods: Behavior Models and Code Analysis (Jan Kofron, Ondrej Sery, Pavel Parizek) * Teaching Formal Methods for the Unconquered Territory (Nestor Catano, Camilo Rueda) 4. Sponsors -------------- * Formal Methods Europe Association (FME) * Software Improvement Group (SIG) , Amsterdam, Netherlands 5. Programme Committee ---------------------- Izzat Alsmadi (North Dakota State University, USA) Dines Bjorner (IIMM Institute, Denmark) Eerke Boiten (University of Kent, UK) Raymond Boute (Universiteit Gent, Belgium) Andrew Butterfield (Trinity College, Dublin) Jim Davies (University of Oxford, UK) David Duce (Oxford Brookes University, UK) John Fitzgerald (University of Newcastle upon Tyne, UK) Jeremy Gibbons (University of Oxford, UK) Randolph Johnson (National Security Agency, USA) Michael Mac an Airchinnigh (Trinity College, Dublin) Dino Mandrioli (Politecnico di Milano, Italy) Jose Oliveira (Universidade do Minho, Portugal) Kees Pronk (Technische Universiteit Delft, NL) Bernhard Schaetz (Tecnical University of Munique, Germany) Wolfgang Schreiner (Johannes Kepler University Linz, Austria) Simao Melo de Sousa (Universidade da Beira Interior, Portugal) Kenji Taguchi (National Institute of Informatics, Japan) Jeannette Wing (Carnegie-Mellon University, USA) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090920/0300d13c/attachment.html From frodo at theshire.org Sun Sep 20 05:35:47 2009 From: frodo at theshire.org (Cristiano Paris) Date: Sun Sep 20 05:14:16 2009 Subject: [Haskell-cafe] Re: Is it safe to use unsafePerformIO here? In-Reply-To: References: <200909180041.26241.daniel.is.fischer@web.de> <2f9b2d30909171906x52ecc640pfde8958e49d6c9ae@mail.gmail.com> <200909180515.12969.daniel.is.fischer@web.de> Message-ID: On Sat, Sep 19, 2009 at 6:53 PM, Ben Franksen wrote: > Cristiano Paris wrote: >> Daniel Fischer wrote: >>> I would separate the reading of headers and bodies, reopening the files >>> whose body is needed, for some (maybe compelling) reason he wants to do >>> it differently. >> >> Yes, that's the way Haskell forces you to do that as it's the only way >> for you to go safe. > > I don't think it has anything to do with Haskell. My sentence was to be understood in a positive way. I think this has a lot to do with Haskell, as it forbids you to write certain kinds of programs: this is a distinguished feature of all the static typed languages and more specifically in Haskell, which has a very expressive type system. In particular, you can't have a program that runs IO "out-of-order": if you really want to do that, you must use unsafe(Perform|Interleave)IO which is like cheating, in a way. Indeed, the only way to do that not using unsafePerformIO is to have a two stage reading, either making the body an IO action or having an intermediate data structure which represents a file whose body has not been read yet: in general this is safer, unless you know something about your program and can assure the compiler it won't behave badly with respect to side effects. > How would you do this in > C? You'd pass a flag indicating whether to read the whole file or just the > header. You can do the same in Haskell, of course, no lazy IO needed. The > body remains undefined if the flag indicates header only. Even better wrap > the body in a Maybe. The difference is in the expressivity of the type system. In C I may use a NULL pointer indicating the body has not been read yet, but then the compiler won't enforce good uses of that pointer and can't assure you that in no way a NULL pointer would be ever dereferenced, leaving room for untested, uncaught bugs. In Haskell this is simply not possible. >... > I have a hard time believing this is possible, if you demand that the files > should not stay opened indefinitely. How is the runtime supposed to know > whether to close the file or not? What you /can/ do is use unsafePerformIO > to lazily re-open, read the body, and close the file, as soon as the body > gets demanded. However, this is ugly and not advised. Here in Caf? once I had a discussion about when is safe and advisable to use unsafePerformIO. I don't think this function is evil per-se and indeed THERE ARE situations where it's more elegant and clear implementing things using unsafePerformIO. I see it as way to tell the compiler "don't mind: I know what I'm doing". This is certainly true when using FFI to implement in C pure functions, but it's true in other situations, like mine, in which using unsafeInterleaveIO allows me to write my code cleanly and easily, separating IO from processing, and avoid having to read the files in a two-stage way. Of course, I can be wrong and I can't look forward to hearing from the wise people and argument againts my point. > Cheers > Ben Thanks. Cristiano From martin.huschenbett at googlemail.com Sun Sep 20 06:23:17 2009 From: martin.huschenbett at googlemail.com (Martin Huschenbett) Date: Sun Sep 20 06:01:43 2009 Subject: [Haskell-cafe] first the platform, the cabal In-Reply-To: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> References: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> Message-ID: <4AB60295.6050303@googlemail.com> Hello Peter, cabal.exe is locatated in extralibs\bin. On my machine the installer added this directory to the PATH, too. Regards, Martin. Peter J. Veger schrieb: > I just installed the Haskell Platform 2009.2.0.2 on Windows. > > There is no cabal.exe, only Cabal-1.6.0.3 > > How to continue: build cabal? > > Then what to download from where and what to execute? > > > > greetings, > > Peter J. Veger, Best Netherlands > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mf-hcafe-15c311f0c at etc-network.de Sun Sep 20 09:15:07 2009 From: mf-hcafe-15c311f0c at etc-network.de (mf-hcafe-15c311f0c@etc-network.de) Date: Sun Sep 20 08:53:42 2009 Subject: [Haskell-cafe] How to generate random string? In-Reply-To: <25512298.post@talk.nabble.com> References: <25512293.post@talk.nabble.com> <25512298.post@talk.nabble.com> Message-ID: <20090920131507.GE24529@yoyo> does this compile at all? i don't think i understand the first line. anyway, a few hints: - if you want to have all numbers between 0..n in your output for some n, just in random order, google for "permutation". - perhaps you can generate the output in an ordered fashion first, eg. into an array, and then shuffle the list by plucking elements from it at random into a new list. - do not use unsafePerformIO. it may reduce the entropy (randomness) of the results, but even if it doesn't, the code is prettier without. good luck! if you get stuck again, just post more code. matthias On Fri, Sep 18, 2009 at 10:14:53AM -0700, Snouser wrote: > To: haskell-cafe@haskell.org > From: Snouser > Date: Fri, 18 Sep 2009 10:14:53 -0700 (PDT) > Subject: Re: [Haskell-cafe] How to generate random string? > > > > > Snouser wrote: > > > > I need to generate a random string from 1 to 30. > > > > This is the parts I've done so far. > > > > unikString xs | let x = unsafePerformIO (randomRIO (1,30)) elem x xs = x : > > unikString xs > > | otherwise = unikString xs > > > > How do I proceed? > > > > I need the string/list to look like this: > > > > [1,9,3,6,2] et.c with only unik numbers. > > > > Thanks! > > > > I wasnt added to the mailinglist, but now I'm. > > > -- > View this message in context: http://www.nabble.com/How-to-generate-random-string--tp25512293p25512298.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 > > > ** ACCEPT: CRM114 PASS osb unique microgroom Matcher ** > CLASSIFY succeeds; success probability: 1.0000 pR: 6.3668 > Best match to file #0 (nonspam.css) prob: 1.0000 pR: 6.3668 > Total features in input file: 2688 > #0 (nonspam.css): features: 758386, hits: 2881904, prob: 1.00e+00, pR: 6.37 > #1 (spam.css): features: 1686754, hits: 3078784, prob: 4.30e-07, pR: -6.37 > From andrewcoppin at btinternet.com Sun Sep 20 10:45:02 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Sep 20 10:23:26 2009 Subject: [Haskell-cafe] Building com-1.2.3 Message-ID: <4AB63FEE.9070500@btinternet.com> C:\com-1.2.3>runhaskell Setup configure Configuring com-1.2.3... Setup: Missing dependencies on foreign libraries: * Missing header file: include/WideStringSrc.h * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 This problem can usually be solved by installing the system packages that provide these libraries (you may need the "-dev" versions). If the libraries are already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are. Any hints? (It is conspicuous that the "hissing header file" is actually present at the exact path indicated... WTH?) From alexey.skladnoy at gmail.com Sun Sep 20 12:22:51 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sun Sep 20 11:55:18 2009 Subject: [Haskell-cafe] [ANN] histogram-fill, library for creating hitograms Message-ID: <200909202022.51650.alexey.skladnoy@gmail.com> Hello. I'm glad to announce library for filling histograms. Its purpose to provide generic and convenient API and be fast. Features list: * Allows to fill many histograms at once. I used it to fill about hundred. * It provide support for arbitrary binning algorithm. Currently there are integer bins, equal sized floating point bins and generic 2D bins. One however could implement more exotic variants. Bins with variable width for example. * Immutable histograms. It's relatively recent addition so it could have few rough edges. * Histogram serialization to/from human readable text. So data could be used with other tools. -- Khudyakov Alexey From dons at galois.com Sun Sep 20 14:03:42 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 20 13:44:20 2009 Subject: [Haskell-cafe] [ANN] histogram-fill, library for creating hitograms In-Reply-To: <200909202022.51650.alexey.skladnoy@gmail.com> References: <200909202022.51650.alexey.skladnoy@gmail.com> Message-ID: <20090920180342.GB6852@whirlpool.galois.com> alexey.skladnoy: > Hello. > > I'm glad to announce library for filling histograms. Its purpose to provide > generic and convenient API and be fast. > > > Features list: > > * Allows to fill many histograms at once. I used it to fill about hundred. > > * It provide support for arbitrary binning algorithm. Currently there are > integer bins, equal sized floating point bins and generic 2D bins. One however > could implement more exotic variants. Bins with variable width for example. > > * Immutable histograms. It's relatively recent addition so it could have few > rough edges. > > * Histogram serialization to/from human readable text. So data could be used > with other tools. > > Where can we get the code? :) http://hackage.haskell.org/package/histogram-fill-0.1.0 -- Don (who thinks it is interesting that hackage is now implied) From dons at galois.com Sun Sep 20 14:43:21 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 20 14:24:06 2009 Subject: [Haskell-cafe] first the platform, the cabal In-Reply-To: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> References: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> Message-ID: <20090920184321.GD6852@whirlpool.galois.com> veger: > I just installed the Haskell Platform 2009.2.0.2 on Windows. > > There is no cabal.exe, only Cabal-1.6.0.3 > > How to continue: build cabal? > > Then what to download from where and what to execute? > > It does come with the cabal executable. Maybe it isn't in your path? -- Don From andrewcoppin at btinternet.com Sun Sep 20 15:06:28 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Sun Sep 20 14:44:50 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009 In-Reply-To: References: Message-ID: <4AB67D34.5070804@btinternet.com> Joe Fredette wrote: > Haskell Weekly News > http://sequence.complete.org/hwn/20090918 > Issue 131 - September 18, 2009 Does anybody else get "page not found" for this URL? From jfredett at gmail.com Sun Sep 20 15:11:04 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun Sep 20 14:49:32 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009 In-Reply-To: <4AB67D34.5070804@btinternet.com> References: <4AB67D34.5070804@btinternet.com> Message-ID: <6F5E3415-A4B7-484B-93A1-170027307013@gmail.com> Ahh, I found the issue. I generated this on the 18th, the software makes files of the form ., so when Brent uploaded the hwn for me, the link it generates is to the date it was generated on, not the date it was published on. The appropriate link is http://sequence.complete.org/hwn/20090919 In the future, I'll have to make sure to do the `make` on the date of publication, but ATM I don't have access to the sequence.complete.org to post the hwns myself. So I try to get the issue to Brent a day early. It shouldn't happen again, thanks for catching it. /Joe On Sep 20, 2009, at 3:06 PM, Andrew Coppin wrote: >> http://sequence.complete.org/hwn/20090918 From alexey.skladnoy at gmail.com Sun Sep 20 16:23:55 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sun Sep 20 15:56:10 2009 Subject: [Haskell-cafe] [ANN] histogram-fill, library for creating hitograms In-Reply-To: <20090920180342.GB6852@whirlpool.galois.com> References: <200909202022.51650.alexey.skladnoy@gmail.com> <20090920180342.GB6852@whirlpool.galois.com> Message-ID: <200909210023.55699.alexey.skladnoy@gmail.com> ? ????????? ?? ??????????? 20 ???????? 2009 22:03:42 ?? ????????: > alexey.skladnoy: > > Hello. > > > > ... skipped ... > > Where can we get the code? :) > > http://hackage.haskell.org/package/histogram-fill-0.1.0 > > -- Don (who thinks it is interesting that hackage is now implied) > It's so easy something important (-: That's how things become de-facto standard. You wake up one day and find that it's standard. Or someone tell you. From veger at cistron.nl Sun Sep 20 16:42:43 2009 From: veger at cistron.nl (Peter J. Veger) Date: Sun Sep 20 16:21:13 2009 Subject: [Haskell-cafe] first the platform, the cabal In-Reply-To: <20090920184321.GD6852@whirlpool.galois.com> References: <007b01ca39c4$400fc8f0$c02f5ad0$@nl> <20090920184321.GD6852@whirlpool.galois.com> Message-ID: <000f01ca3a32$e795f220$b6c1d660$@nl> Martin Huschenbett told me: cabal.exe is locatated in extralibs\bin. On my machine the installer added this directory to the PATH, too. Thanks you both for your answers greetings, Peter J. Veger, Best Netherlands -----Original Message----- From: Don Stewart [mailto:dons@galois.com] Sent: zondag 20 september 2009 20:43 To: Peter J. Veger Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] first the platform, the cabal veger: > I just installed the Haskell Platform 2009.2.0.2 on Windows. > > There is no cabal.exe, only Cabal-1.6.0.3 > > How to continue: build cabal? > > Then what to download from where and what to execute? > > It does come with the cabal executable. Maybe it isn't in your path? -- Don From jmstephens at remcycle.net Sun Sep 20 17:16:12 2009 From: jmstephens at remcycle.net (James Michael Stephens) Date: Sun Sep 20 16:54:41 2009 Subject: [Haskell-cafe] GHC will not let me install Message-ID: I am trying to install Xmonad on my Mac. I download GHC installer for mac the .dmg from Haskell.org and when I install it gets stuck here [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the install button is grey and will not let me click it. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090920/277ca5be/attachment.html From dons at galois.com Sun Sep 20 17:17:05 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 20 16:57:41 2009 Subject: [Haskell-cafe] GHC will not let me install In-Reply-To: References: Message-ID: <20090920211705.GA7182@whirlpool.galois.com> jmstephens: > I am trying to install Xmonad on my Mac. I download GHC installer for mac the > .dmg from Haskell.org and when I install it gets stuck here > [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the install > button is grey and will not let me click it. Are you running Snow Leopard? If so, you need to build GHC manually first. http://www.reddit.com/r/haskell/comments/9krbo/whats_the_status_of_ghc_on_the_64_bit_mac_osx/ From jason.dusek at gmail.com Sun Sep 20 18:11:37 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Sep 20 17:50:01 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages Message-ID: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> Some day, we're going to need a short, catchy name for Cabal packages. Let's call them cabbages. -- Jason Dusek From jeff at nokrev.com Sun Sep 20 18:12:45 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Sun Sep 20 17:51:30 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> Message-ID: <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> On Sun, Sep 20, 2009 at 5:11 PM, Jason Dusek wrote: > ?Some day, we're going to need a short, catchy name for Cabal > ?packages. Let's call them cabbages. +1 Yes, let's. Jeff Wheeler From jfredett at gmail.com Sun Sep 20 18:20:25 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sun Sep 20 17:59:00 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> Message-ID: <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> I also agree. Hackage should also be renamed to something appropriate. The Cabbage Patch? On Sep 20, 2009, at 6:12 PM, Jeff Wheeler wrote: > On Sun, Sep 20, 2009 at 5:11 PM, Jason Dusek > wrote: > >> Some day, we're going to need a short, catchy name for Cabal >> packages. Let's call them cabbages. > > +1 > > Yes, let's. > > Jeff Wheeler > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From jason.dusek at gmail.com Sun Sep 20 18:22:01 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Sep 20 18:00:29 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> Message-ID: <42784f260909201522h128fa1b1g5a55a4397f12ed63@mail.gmail.com> File extension ideas: .choux -- My favorite. .kohl -- Less characters. .cbz -- More conventional. .cbg.gz, .cbg.bz2 -- Allows one to be specific about -- compression. The last one can be extended to the other ones, at the cost of a few characters. -- Jason Dusek From jason.dusek at gmail.com Sun Sep 20 18:23:51 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Sun Sep 20 18:02:15 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> Message-ID: <42784f260909201523o6d32c57fuc62371cc50cd3d1a@mail.gmail.com> 2009/09/20 Joe Fredette : > I also agree. Hackage should also be renamed to something appropriate. > > The Cabbage Patch? +1 -- Jason Dusek From jeff at nokrev.com Sun Sep 20 20:10:48 2009 From: jeff at nokrev.com (Jeff Wheeler) Date: Sun Sep 20 19:49:32 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> Message-ID: <50c1e0910909201710l1808456fhe37ec5b9f3803f1@mail.gmail.com> On Sun, Sep 20, 2009 at 5:20 PM, Joe Fredette wrote: > The Cabbage Patch? 'Patch' is pretty well defined, so using it here seems somewhat awkward and confused to me. Plus, I don't think we really want to sound childish, and the first thing I think of is the cabbage patch kid dolls. The original idea, cabbage, doesn't seem silly to me. Jeff Wheeler From dons at galois.com Sun Sep 20 21:27:40 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 20 21:08:17 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <50c1e0910909201710l1808456fhe37ec5b9f3803f1@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <50c1e0910909201512w5b42a47arf287a34990071fef@mail.gmail.com> <182014B4-9DCF-4312-BBBE-BE7090581A20@gmail.com> <50c1e0910909201710l1808456fhe37ec5b9f3803f1@mail.gmail.com> Message-ID: <20090921012739.GA8240@whirlpool.galois.com> jeff: > On Sun, Sep 20, 2009 at 5:20 PM, Joe Fredette wrote: > > > The Cabbage Patch? > > 'Patch' is pretty well defined, so using it here seems somewhat > awkward and confused to me. > > Plus, I don't think we really want to sound childish, and the first > thing I think of is the cabbage patch kid dolls. The original idea, > cabbage, doesn't seem silly to me. Cabbage patches would be tweaks and fixes you upload to Hackage. Hackage is more of a cabbage farm. -- Don From ajs at 2piix.com Sun Sep 20 21:43:53 2009 From: ajs at 2piix.com (Alexander Solla) Date: Sun Sep 20 21:22:19 2009 Subject: [Haskell-cafe] Type Families Message-ID: (I'm using a fixed width font, so if you don't see nice formatting, you need to use a fixed width font. This is literate Haskell, but I copied and pasted the code. YMMV) Hi Everybody! (Hi Dr. Nick) I've been looking for a good way to use some richer notions of polymorphism than Haskell98 allows. First, I tried to define a monad "of" the things I want to quantify over (so each "type of view" or "type of evaluable thing" would be a constructor in a monadic type.) But that didn't seem to offer the kind of extensibility I wanted, since I basically want to join several types together. I tried FunDeps next, and that worked okay, but it was a bit difficult to keep track of what was "meant" to do what. I guess I could have plowed through the work, but it wasn't any fun. I finally heard about TypeFamilies, and they seem to give me the kind of extensibility I want, while keeping the theoretical foundations relatively clean. But I am not so sure I understand them. Let us consider the code: > type AbstractValue = Int > class Evaluate asset where > data Value asset :: * > value :: (Value asset) -> AbstractValue That's easy enough. "Value asset" is an indexed type. That is reflected in the instance declaration: > instance Evaluate Abstract where > data Value Abstract = AbstractValue Abstract > value (AbstractValue int) = int Okay, easy enough. But what happens when we want to "add" Evaluate instances? > data Add a b = Add a b > instance ( Evaluate a > , Evaluate b > ) => Evaluate (Add a b) where > data Value (Sum a b) = SumValue (Sum a b) Even this much is straightforward. We require a and b to be Evaluate'able before we can find the sum of a and b as "values". Now I want to write my definition for the "value" function. But... how is that supposed to work? My first guess is value (SumValue (Sum a b)) = (value a) + (value b) But I more-or-less expected that to fail. I realize I need some more typing information. What am I supposed to fill in? My next guess was > value (SumValue (Sum a b)) = (value $ Value a) + (value $ Value b) But Value doesn't exist as a type constructor. So now that I am starting to "get" what's going on, I wonder why I don't get what's going on. Since I need to use a type constructor for the (Value a) and (Value b) "things", it kind of defeats the point. (I hesitate to say "value", since I have been using "value" to mean the result/blah of an Evaluate instance) Speaking of which, I am still not sure what the difference between associate data type families and associated type constructor families are. The former use the data keyword in class declarations, and the latter use type keywords. What can I do with one and not the other? I would really appreciate some guidance. Thanks! Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090920/82efdd64/attachment.html From dan.doel at gmail.com Sun Sep 20 22:16:58 2009 From: dan.doel at gmail.com (Dan Doel) Date: Sun Sep 20 21:55:26 2009 Subject: [Haskell-cafe] Type Families In-Reply-To: References: Message-ID: <200909202216.59012.dan.doel@gmail.com> On Sunday 20 September 2009 9:43:53 pm Alexander Solla wrote: > But I more-or-less expected that to fail. I realize I need some more > typing information. What am I supposed to fill in? My next guess was > > > value (SumValue (Sum a b)) = (value $ Value a) + (value $ Value > > b) > > But Value doesn't exist as a type constructor. So now that I am > starting to "get" what's going on, I wonder why I don't get what's > going on. Since I need to use a type constructor for the (Value a) > and (Value b) "things", it kind of defeats the point. (I hesitate to > say "value", since I have been using "value" to mean the result/blah > of an Evaluate instance) Well, the obvious answer is that you should instead write data Value (Add a b) = SumValue (Sum (Value a) (Value b)) So that they are already Values, and value can be called on them. I don't really understand what you're using the data families for, though. Value looks like sort of an identity wrapper around its argument. > Speaking of which, I am still not sure what the difference between > associate data type families and associated type constructor families > are. The former use the data keyword in class declarations, and the > latter use type keywords. What can I do with one and not the other? Type families (as far as their use in classes goes) are for when the associated type already exists. For instance, in a collection class: class Collection c where type Elem c :: * ... You'll have instances: instance Collection [a] where type Elem [a] = a ... By contrast, data families are for when you want to define new data types indexed by the type. For instance, if you're doing generalized tries: class Key k where data Trie k :: * -> * ... Then: instance (Key k) => Key [k] where data Trie [k] a = ListTrie (Maybe a) (Trie k (Trie [k] a)) ... You can, of course, approximate one with the other. If you use a data family, you can use newtypes so there's no additional overhead (but you'll have to sprinkle constructors in your code). And data families can be simulated like (using the Trie example): class Key k where type Trie k :: * -> * ... data ListTrie k a = ListTrie (Maybe a) (Trie k (ListTrie k a)) instance Key k => Key [k] where type Trie [k] = ListTrie k ... But in cases where you're writing lots of new data/newtype declarations, just to refer to them with an associated type, you may was well use associated data instead and remove the middle man. Of course, sometimes you may not be clearly in either situation, so it may be a judgment call. Type families are also useful if you want to do computation at the type level. In that sense, type families are like (value-level) functions, and data families are like (value-level) constructors (I think that's accurate). Hope that helped a bit, -- Dan From felipe.lessa at gmail.com Sun Sep 20 22:19:17 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Sun Sep 20 21:57:50 2009 Subject: [Haskell-cafe] Type Families In-Reply-To: References: Message-ID: <20090921021917.GA20953@kira.casa> On Sun, Sep 20, 2009 at 06:43:53PM -0700, Alexander Solla wrote: > > data Add a b = Add a b > > instance ( Evaluate a > > , Evaluate b > > ) => Evaluate (Add a b) where Okay. > > data Value (Sum a b) = SumValue (Sum a b) Hmmm, have you tried > data Value (Add a b) = AddValue (Value a) (Value b) Now your 'value' function would be > value (AddValue va vb) = value va + value vb because you're holding 'Value a' and 'Value b', not 'a' and 'b'. It may help to think as if this class represented a container. For value, do you need the whole container or just one of its elements? I know other will give a better explanation, but maybe this is enough to get you in the right track :). HTH, -- Felipe. From greg at gregorycollins.net Sun Sep 20 22:32:51 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Sun Sep 20 22:11:16 2009 Subject: [Haskell-cafe] GHC will not let me install In-Reply-To: <20090920211705.GA7182@whirlpool.galois.com> (Don Stewart's message of "Sun, 20 Sep 2009 14:17:05 -0700") References: <20090920211705.GA7182@whirlpool.galois.com> Message-ID: <87eiq1hvsc.fsf@gregorycollins.net> Don Stewart writes: > jmstephens: >> I am trying to install Xmonad on my Mac. I download GHC installer for mac the >> .dmg from Haskell.org and when I install it gets stuck here >> [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the install >> button is grey and will not let me click it. > > > Are you running Snow Leopard? If so, you need to build GHC manually > first. > > http://www.reddit.com/r/haskell/comments/9krbo/whats_the_status_of_ghc_on_the_64_bit_mac_osx/ Also you need to download and install XCode from Apple before the GHC installer will run. G -- Gregory Collins From dave at zednenem.com Mon Sep 21 02:37:28 2009 From: dave at zednenem.com (David Menendez) Date: Mon Sep 21 02:15:52 2009 Subject: [Haskell-cafe] GHC will not let me install In-Reply-To: <20090920211705.GA7182@whirlpool.galois.com> References: <20090920211705.GA7182@whirlpool.galois.com> Message-ID: <49a77b7a0909202337n6f08b7bcw477f9fc8ff17cf57@mail.gmail.com> On Sun, Sep 20, 2009 at 5:17 PM, Don Stewart wrote: > jmstephens: >> I am trying to install Xmonad on my Mac. I download GHC installer for mac the >> .dmg from Haskell.org and when I install it gets stuck here >> [img]http://www.jmstephens.99k.org/picture.png[/img] As you can see the install >> button is grey and will not let me click it. > > > Are you running Snow Leopard? If so, you need to build GHC manually > first. > > ? ?http://www.reddit.com/r/haskell/comments/9krbo/whats_the_status_of_ghc_on_the_64_bit_mac_osx/ I was able to install GHC on Snow Leopard using the Haskell Platform installer. All that was required was (1) to install Xcode first, and (2) to modify /usr/bin/ghc to include the flags -optc-m32 -opta-m32 -optl-m32. -- Dave Menendez From martijn at van.steenbergen.nl Mon Sep 21 04:14:38 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Sep 21 03:53:13 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: <4AB5BEAD.90001@ugcs.caltech.edu> References: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> <4AB5BEAD.90001@ugcs.caltech.edu> Message-ID: <4AB735EE.1050103@van.steenbergen.nl> Hi Michael, Michael Shulman wrote: > Is there a way to make it automatically update a single contents page > with links to the documentation of all installed packages? See: http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/focus=53560 http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/focus=53572 HTH, Martijn. From conor at strictlypositive.org Mon Sep 21 05:04:11 2009 From: conor at strictlypositive.org (Conor McBride) Date: Mon Sep 21 04:42:37 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> Message-ID: <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> On 20 Sep 2009, at 23:11, Jason Dusek wrote: > Some day, we're going to need a short, catchy name for Cabal > packages. Let's call them cabbages. Not that this is a good reason to change your mind, but some sufficiently ancient Brits may remember a televisual entertainment programme in which kids competed to win prizes by answering questions (one prize per answer) until their arms could no longer contain the prizes and they dropped one. The prize for an incorrect answer was, of course, a cabbage (large, hard to hold on to, symbolic of failed social mobility). Probably the people who associate cabbages with error in this way are few in number. Perhaps larger in number are those who simply fear vegetables, or have unpleasant memories of being made to eat sulphurous overboiled cabbage on pain of no pudding. Cabbage is regarded by many as a punishment, compared to, say, an enviably juicy sheep. It's a mark of inability to afford the aforementioned sheep, or of a kind of holier-than-thou middle class faux-puritanism with pretentions to virtue. +1 Conor From jon.fairbairn at cl.cam.ac.uk Mon Sep 21 05:23:51 2009 From: jon.fairbairn at cl.cam.ac.uk (Jon Fairbairn) Date: Mon Sep 21 05:02:44 2009 Subject: [Haskell-cafe] Re: Cabal packages -> cabbages References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> Message-ID: Conor McBride writes: > On 20 Sep 2009, at 23:11, Jason Dusek wrote: > >> Some day, we're going to need a short, catchy name for Cabal >> packages. Let's call them cabbages. > > Not that this is a good reason to change your mind, but some > sufficiently ancient Brits may remember a televisual Speaking of ancient Brits, the Finns used to call Britain cabbage-land, in case that alters anyone's opinion. -- J?n Fairbairn Jon.Fairbairn@cl.cam.ac.uk http://www.chaos.org.uk/~jf/Stuff-I-dont-want.html (updated 2009-01-31) From conor at strictlypositive.org Mon Sep 21 05:40:05 2009 From: conor at strictlypositive.org (Conor McBride) Date: Mon Sep 21 05:18:32 2009 Subject: [Haskell-cafe] Re: Cabal packages -> cabbages In-Reply-To: References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> Message-ID: <0CBB356C-A2B5-4DC6-A850-2C77BA059A65@strictlypositive.org> Hi J?n On 21 Sep 2009, at 10:23, Jon Fairbairn wrote: > Conor McBride writes: > >> On 20 Sep 2009, at 23:11, Jason Dusek wrote: >> >>> Some day, we're going to need a short, catchy name for Cabal >>> packages. Let's call them cabbages. >> >> Not that this is a good reason to change your mind, but some >> sufficiently ancient Brits may remember a televisual > > Speaking of ancient Brits, the Finns used to call Britain > cabbage-land, in case that alters anyone's opinion. It's always somewhere else, isn't it? Somehow, a vision of Michael Palin bursting into the RAF officers' mess shouting "cabbage crates over the briny!" springs to mind. When faced with blank incomprehension and a request to speak English, he replies "but I've got to use banter!". Seems that goes for us too. TTFN Conor From deduktionstheorem at web.de Mon Sep 21 06:08:29 2009 From: deduktionstheorem at web.de (Stephan Friedrichs) Date: Mon Sep 21 05:46:58 2009 Subject: [Haskell-cafe] Re: Cabal packages -> cabbages In-Reply-To: References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> Message-ID: <4AB7509D.20008@web.de> Jon Fairbairn wrote: > Conor McBride writes: > >> On 20 Sep 2009, at 23:11, Jason Dusek wrote: >> >>> Some day, we're going to need a short, catchy name for Cabal >>> packages. Let's call them cabbages. >> Not that this is a good reason to change your mind, but some >> sufficiently ancient Brits may remember a televisual > > Speaking of ancient Brits, the Finns used to call Britain > cabbage-land, in case that alters anyone's opinion. > Speaking of ambiguities: http://en.wikipedia.org/wiki/Cabbage_%28disambiguation%29 CABG is especially interesting :) //Stephan -- Fr?her hie? es ja: Ich denke, also bin ich. Heute wei? man: Es geht auch so. - Dieter Nuhr From colinpauladams at googlemail.com Mon Sep 21 08:20:59 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Mon Sep 21 07:59:22 2009 Subject: [Haskell-cafe] Multiple-selection formlet? Message-ID: <1afdeaec0909210520u77f3b930s4bd1ab157e63fd62@mail.gmail.com> I can't work out how to get multiple selections delivered from a formlet. I can add the multiple attribute to get the formlet to allow the user to make multiple selections, but I only get a single answer back. This seems inevitable from the type of rawSelect (or select) - since the list of values to select from is of type [(a, h)] and the result type is a. Am I missing something? -- Colin Adams Preston, Lancashire, ENGLAND From g.c.stavenga at uu.nl Mon Sep 21 08:32:34 2009 From: g.c.stavenga at uu.nl (staafmeister) Date: Mon Sep 21 08:10:57 2009 Subject: [Haskell-cafe] line intersection code Message-ID: <25530313.post@talk.nabble.com> Hi, I wrote a O(n log n) line segment intersection code. Couple of questions 1) I did not find such a library on hackage (at least google gave no results:)), and I notice a lot of people submit packages. Would there be any interest to submit this code (would give incentive to make the code cleaner) 2) In the algo I needed a balanced binary tree, but with a compare function that changes with each iteration. Is there a balanced binary tree available that give more freedom in specifying the compare function. Data.Set does not have this option (I think). Using unsafePerformIO to change the compare function seemed a little bit ugly. -- View this message in context: http://www.nabble.com/line-intersection-code-tp25530313p25530313.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From ekirpichov at gmail.com Mon Sep 21 08:50:48 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Mon Sep 21 08:29:10 2009 Subject: [Haskell-cafe] line intersection code In-Reply-To: <25530313.post@talk.nabble.com> References: <25530313.post@talk.nabble.com> Message-ID: <5e0214850909210550j6bfb2d5cp118d2c5d6882d143@mail.gmail.com> 1) I didn't find one, either :) I Ctrl+F-ed hackage for "geometry", "segment" and "range". 2) btw, that's yet another good reason to have reified typeclass dictionaries. I wonder why Haskell does not support them yet. Looks like http://hackage.haskell.org/package/AvlTree might fit your need, or probably a variation on http://hackage.haskell.org/package/fingertree . 2009/9/21 staafmeister : > > > Hi, > > I wrote a O(n log n) line segment intersection code. Couple of questions > > 1) I did not find such a library on hackage (at least google gave no > results:)), > and I notice a lot of people submit packages. Would there be any interest > to submit this code (would give incentive to make the code cleaner) > > 2) In the algo I needed a balanced binary tree, but with a compare function > that changes with each iteration. Is there a balanced binary tree available > that give more freedom in specifying the compare function. Data.Set does > not have this option (I think). Using unsafePerformIO to change the compare > function seemed a little bit ugly. > > > -- > View this message in context: http://www.nabble.com/line-intersection-code-tp25530313p25530313.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 > -- Eugene Kirpichov Web IR developer, market.yandex.ru From byorgey at seas.upenn.edu Mon Sep 21 10:02:55 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon Sep 21 09:41:19 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - September 19, 2009 In-Reply-To: <6F5E3415-A4B7-484B-93A1-170027307013@gmail.com> References: <4AB67D34.5070804@btinternet.com> <6F5E3415-A4B7-484B-93A1-170027307013@gmail.com> Message-ID: <20090921140254.GA17514@seas.upenn.edu> On Sun, Sep 20, 2009 at 03:11:04PM -0400, Joe Fredette wrote: > Ahh, I found the issue. I generated this on the 18th, the software makes > files of the form ., so when Brent uploaded the hwn > for me, the link it generates is to the date it was generated on, not the > date it was published on. Actually, it's even simpler than that, the sequence.complete.org/hwn/xxxx URL is actually something you choose when you post it, so this is my fault for giving it the wrong date. You can generate it on whatever day you like, and until you can post them yourself I'll just be careful about matching the URL to the date it was generated. -Brent From relapse.dev at gmx.com Mon Sep 21 13:11:33 2009 From: relapse.dev at gmx.com (Neal Alexander) Date: Mon Sep 21 12:50:19 2009 Subject: [Haskell-cafe] Re: line intersection code In-Reply-To: <25530313.post@talk.nabble.com> References: <25530313.post@talk.nabble.com> Message-ID: staafmeister wrote: > > Hi, > > I wrote a O(n log n) line segment intersection code. Couple of questions > > 1) I did not find such a library on hackage (at least google gave no > results:)), > and I notice a lot of people submit packages. Would there be any interest > to submit this code (would give incentive to make the code cleaner) > > Yea I'd probably use it. Small packages like that are kinda nice. From caseyh at istar.ca Mon Sep 21 13:57:56 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 21 13:36:21 2009 Subject: [Haskell-cafe] line intersection code In-Reply-To: <25530313.post@talk.nabble.com> References: <25530313.post@talk.nabble.com> Message-ID: <6fffb5tu773cn9m7td4uo50f8ecpesf9j6@4ax.com> Posting small packages like that on Hackage is a good way for others to learn Haskell. Is a record kept of suggested changes on Hackage? -- Regards, Casey From andrewcoppin at btinternet.com Mon Sep 21 14:28:36 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 21 14:06:56 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <4AB63FEE.9070500@btinternet.com> References: <4AB63FEE.9070500@btinternet.com> Message-ID: <4AB7C5D4.7010409@btinternet.com> Andrew Coppin wrote: > C:\com-1.2.3>runhaskell Setup configure > Configuring com-1.2.3... > Setup: Missing dependencies on foreign libraries: > * Missing header file: include/WideStringSrc.h > * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 > > Any hints? Maybe I should try the method listed in http://www.bash.org/?152037 But I'm not that much of a troll... I'm just slightly frustrated because this package looks potentially very useful, but I can't actually use it. :-( From dons at galois.com Mon Sep 21 14:28:16 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 21 14:08:55 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <4AB7C5D4.7010409@btinternet.com> References: <4AB63FEE.9070500@btinternet.com> <4AB7C5D4.7010409@btinternet.com> Message-ID: <20090921182816.GI11518@whirlpool.galois.com> andrewcoppin: > Andrew Coppin wrote: >> C:\com-1.2.3>runhaskell Setup configure >> Configuring com-1.2.3... >> Setup: Missing dependencies on foreign libraries: >> * Missing header file: include/WideStringSrc.h >> * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 >> >> Any hints? > > Maybe I should try the method listed in > > http://www.bash.org/?152037 > > But I'm not that much of a troll... > > I'm just slightly frustrated because this package looks potentially very > useful, but I can't actually use it. :-( Have you tried installing the C libraries it requests? -- Don From andrewcoppin at btinternet.com Mon Sep 21 14:37:26 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 21 14:15:47 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <20090921182816.GI11518@whirlpool.galois.com> References: <4AB63FEE.9070500@btinternet.com> <4AB7C5D4.7010409@btinternet.com> <20090921182816.GI11518@whirlpool.galois.com> Message-ID: <4AB7C7E6.5090505@btinternet.com> Don Stewart wrote: > andrewcoppin: > >> Andrew Coppin wrote: >> >>> C:\com-1.2.3>runhaskell Setup configure >>> Configuring com-1.2.3... >>> Setup: Missing dependencies on foreign libraries: >>> * Missing header file: include/WideStringSrc.h >>> * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 >>> >>> Any hints? >>> >> > > > Have you tried installing the C libraries it requests? > kernel32.dll, user32.dll, etc. are all standard DLL files present in C:\WINDOWS\system32. I was hoping that saying --extra-lib-dirs=C:\WINDOWS\system32 like the error message suggests would magically fix the problem... but no. I guess that would be too easy. It also doesn't explain why Cabal isn't finding include/WideStringSrc.h, even though that's the correct relative path to the file. I checked six times; it's definitely there. I also had a look around to see if there's any readme files in the Cabal package or any helpful hints on the package website. I found some example code, but nothing about how to get it to compile. :-( [Presumably because for the author it worked without doing anything special.] From dons at galois.com Mon Sep 21 14:37:20 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 21 14:17:56 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <4AB7C7E6.5090505@btinternet.com> References: <4AB63FEE.9070500@btinternet.com> <4AB7C5D4.7010409@btinternet.com> <20090921182816.GI11518@whirlpool.galois.com> <4AB7C7E6.5090505@btinternet.com> Message-ID: <20090921183720.GL11518@whirlpool.galois.com> andrewcoppin: > Don Stewart wrote: >> andrewcoppin: >> >>> Andrew Coppin wrote: >>> >>>> C:\com-1.2.3>runhaskell Setup configure >>>> Configuring com-1.2.3... >>>> Setup: Missing dependencies on foreign libraries: >>>> * Missing header file: include/WideStringSrc.h >>>> * Missing C libraries: kernel32, user32, ole32, oleaut32, advapi32 >>>> >>>> Any hints? >>>> >>> >> >> >> Have you tried installing the C libraries it requests? >> > > kernel32.dll, user32.dll, etc. are all standard DLL files present in > C:\WINDOWS\system32. > > I was hoping that saying --extra-lib-dirs=C:\WINDOWS\system32 like the > error message suggests would magically fix the problem... but no. I > guess that would be too easy. > > It also doesn't explain why Cabal isn't finding include/WideStringSrc.h, > even though that's the correct relative path to the file. I checked six > times; it's definitely there. > > I also had a look around to see if there's any readme files in the Cabal > package or any helpful hints on the package website. I found some > example code, but nothing about how to get it to compile. :-( > [Presumably because for the author it worked without doing anything > special.] Compile with -v3 or so, to get full debugging output on the PATH and explicit paths being used. Have you contacted the author? -- Don From marcus at gabriel.name Mon Sep 21 14:45:19 2009 From: marcus at gabriel.name (Marcus D. Gabriel) Date: Mon Sep 21 14:23:43 2009 Subject: [Haskell-cafe] Re: Suggested additions to System.FilePath.Posix/Windows In-Reply-To: <4AB53A3D.7080406@gmail.com> References: <4AB20848.1030505@gabriel.name> <1253360700.32005.1133.camel@localhost> <29E3E258-6C06-437B-A13A-C7C94575CCED@ece.cmu.edu> <4AB53A3D.7080406@gmail.com> Message-ID: <4AB7C9BF.3010700@gabriel.name> Simon Marlow wrote: > Brandon S. Allbery KF8NH wrote: >> On Sep 19, 2009, at 07:45 , Duncan Coutts wrote: >>> On Thu, 2009-09-17 at 11:58 +0200, Marcus D. Gabriel wrote: >>>>> -- | 'reduceFilePath' returns a pathname that is reduced to canonical >>>>> -- form equivalent to that of ksh(1), that is, symbolic link names >>>>> are >>>>> -- treated literally when finding the directory name. See @cd -L@ of >>>>> -- ksh(1). Specifically, extraneous separators @(\"/\")@, dot >>>>> -- @(\".\")@, and double-dot @(\"..\")@ directories are removed. >>> >>> So it's like the existing System.Directory.canonicalizePath but it's >>> pure and it does not do anything with symlinks. On the other hand >>> because it's pure it can do something with non-local paths. >>> >>> Is there anything POSIX-specific about this? I don't see it. >> >> It's making assumptions about the safety of eliding "..". (What does >> \\machine\share\..\ do?) On the other hand that's also unsafe on >> POSIX in the presence of symlinks. In general I consider path >> cleanup not involving validation against the filesystem to be risky. > > I agree; this came up before during the design of System.FilePath, and > it's why the current library doesn't have a way to remove "..". The > docs should probably explain this point, because it's non-obvious that > you can't just "clean up" a path to remove the ".." and end up with > something that means the same thing. > > Cheers, > Simon A few points to explain my point of view. It's a little long. Yes, reduceFilePath is pure and not an IO action, but this was not important for my application. What counted is the preservation of the logical structure of the path which was a design choice and that the paths in question may no longer exist in the file system. Thus canonicalizePath could not help me. These are the most important points. For me, if these two points are not of generally interest, than there should be no System.FilePath.reduceFilePath or equivalent. The essential POSIX standard (IEEE Std 1003.1) can be found at , that is, cd - change the working directory. The key points are in the OPTIONS section and steps 8 and 9 of the DESCRIPTIONS section. I used ksh(1) as my guide, but bash(1) or dash(1) work also. See also , that is, section 4.11 Pathname Resolution. So, the function reduceFilePath does not make any assumptions about eliding of "..", it simple attempts to implement the behaviour of cd -L of a POSIX shell consistent with Path Resolution of section 4.11 minus the dereferencing of symbolic links. Whether reduceFilePath does this correctly or not is another question. (It does not, sorry about that, but I have an older version that does minus the leading double slash rule.) Although it is true that if you just clean up the path it may no longer resolve to the same object in the file system as would the result of a call to canonicalizePath, Python has a library function whose name I cannot remember in which the documentation just states that this may change the meaning of the path, that is, let the programmer beware. In my case, I verified and resolved the initial inputs from the user so that either an error message occurred or I could use reduceFilePath in confidence during processing. That is to say, the file system validation was done upfront so that I could safely maintain the logical structure which was the design choice and in certain cases continue processing even if the pathnames no longer referred to anything. This means that \\machine\share\..\ is \\machine\ logically. Thus, the application should either not use reduceFilePath or it should set up conditions to avoid or catch this case. The blind or unthinking use of reduceFilePath is not only risky, it's a mistake. Just like unsafePerformIO, let the programmer beware. If reduceFilePath is useless under Windows but at least makes some kind of sense, then for me, a debugged, POSIX compliant System.FilePath.reduceFilePath would have been nice. So I propose it. If it makes absolutely no sense under Windows, then drop it so as to maintain the interface which I used wherever I could and appreciated greatly. Cheers, - Marcus From slyich at gmail.com Mon Sep 21 14:58:01 2009 From: slyich at gmail.com (Sergei Trofimovich) Date: Mon Sep 21 14:36:24 2009 Subject: [Haskell-cafe] readline does not work on gentoo amd64 (ghc-6.10.4) Message-ID: <20090921215801.3f63edb0@mosly> Hi, dear list! libraries@haskell.org treats me as a spammer, so I'm writing here. Today I've stuck with following problems: 1. After recent readline upgrade (5 -> 6) in my distro I got unbuildable lambdabot. After investigating a little I've noticed I'm having broken readline: //===-------------------- $cabal install readline ... $ ghci -package readline GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Loading package syb ... linking ... done. Loading package base-3.0.3.1 ... linking ... done. Loading package filepath-1.1.0.2 ... linking ... done. Loading package old-locale-1.0.0.1 ... linking ... done. Loading package old-time-1.0.0.2 ... linking ... done. Loading package unix-2.3.2.0 ... linking ... done. Loading package directory-1.0.0.3 ... linking ... done. Loading package process-1.0.1.1 ... linking ... done. Loading package readline-1.0.1.0 ... : can't load .so/.DLL for: readline (/usr/lib64/libreadline.so: invalid ELF header) //===-------------------- It's true, there is no real ELF library, but none of packages complained before. //===-------------------- $ cat /usr/lib64/libreadline.so /* GNU ld script Since Gentoo has critical dynamic libraries in /lib, and the static versions in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we run into linking problems. This "fake" dynamic lib is a linker script that redirects the linker to the real lib. And yes, this works in the cross- compiling scenario as the sysroot-ed linker will prepend the real path. See bug http://bugs.gentoo.org/4411 for more info. */ OUTPUT_FORMAT ( elf64-x86-64 ) GROUP ( /lib64/libreadline.so.6 ) //===-------------------- Looks like readline package can't resolve real ELF library path to readline in readline.buildinfo (right after cabal configure): //===-------------------- $ cat readline.buildinfo buildable: True cc-options: ld-options: extra-libraries: readline ncurses frameworks: //===-------------------- And second minor nit: readline tarball is unusable after issuing 'cabal clean': //===-------------------- $ cabal clean && cabal configure cleaning... Resolving dependencies... Configuring readline-1.0.1.0... configure: error: cannot find sources (include/HsReadline.h) in . or .. //===-------------------- Practically these issues can be solved by moving lambdabot to haskeline tracks. Thanks! -- Sergei -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: not available Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090921/d68236d7/signature.bin From andrewcoppin at btinternet.com Mon Sep 21 14:59:33 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 21 14:37:52 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <20090921183720.GL11518@whirlpool.galois.com> References: <4AB63FEE.9070500@btinternet.com> <4AB7C5D4.7010409@btinternet.com> <20090921182816.GI11518@whirlpool.galois.com> <4AB7C7E6.5090505@btinternet.com> <20090921183720.GL11518@whirlpool.galois.com> Message-ID: <4AB7CD15.2070409@btinternet.com> Don Stewart wrote: > andrewcoppin: > >> Don Stewart wrote: >> >>> Have you tried installing the C libraries it requests? >>> >>> >> kernel32.dll, user32.dll, etc. are all standard DLL files present in >> C:\WINDOWS\system32. >> >> I was hoping that saying --extra-lib-dirs=C:\WINDOWS\system32 like the >> error message suggests would magically fix the problem... but no. I >> guess that would be too easy. >> >> It also doesn't explain why Cabal isn't finding include/WideStringSrc.h, >> even though that's the correct relative path to the file. I checked six >> times; it's definitely there. >> >> I also had a look around to see if there's any readme files in the Cabal >> package or any helpful hints on the package website. I found some >> example code, but nothing about how to get it to compile. :-( >> [Presumably because for the author it worked without doing anything >> special.] >> > > Compile with -v3 or so, to get full debugging output on the PATH and > explicit paths being used. > I see several dozen lines like this: ("D:\\ghc\\ghc-6.10.3\\gcc.exe",["-BD:\\ghc\\ghc-6.10.3\\gcc-lib","-ID:\\ghc\\ghc-6.10.3\\include\\mingw","D:\\DOCUME~1\\Orphi\\LOCALS~1\\Temp\\3192.c","-o","D:\\DOCUME~1\\Orphi\\LOCALS~1\\Temp\\3192","-lole32","--enable-stdcall-fixup","--disable-stdcall-fixup"]) D:\ghc\ghc-6.10.3\gcc.exe returned ExitFailure 1 with error message: cc1.exe: error: unrecognized command line option "-fenable-stdcall-fixup" cc1.exe: error: unrecognized command line option "-fdisable-stdcall-fixup" So perhaps it's not that it can't find stuff, it's that it doesn't like the strange options inserted from the Cabal file? It contains the following gem: -- I can't seem to feed this into the 'ld' invocation that creates the -- relocatable object file. Ld-options: --enable-stdcall-fixup --disable-stdcall-fixup Presumably the author did this for some sort of specific reason. I have no clue what though. > Have you contacted the author? > No, I hadn't actually thought of that... From asviraspossible at gmail.com Mon Sep 21 17:15:48 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Mon Sep 21 16:54:11 2009 Subject: [Haskell-cafe] Problem with type families Message-ID: I've tried to reimplement code presented in the following blog post: http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ But I've got stuck with the following error: Triangulable.hs:41:8: `addRows' is not a (visible) method of class `Triangulable' Triangulable.hs:43:8: `addCols' is not a (visible) method of class `Triangulable' I think the minimal example to reproduce this error is the following: ... class Triangulable m where type Elem m (@@) :: m -> (Int, Int) -> Elem size :: m -> Int swapRows :: Int -> Int -> m -> m swapCols :: Int -> Int -> m -> m addRow :: (Num Elem) => Elem -> Int -> Int -> m -> m addCol :: (Num Elem) => Elem -> Int -> Int -> m -> m newtype ListMatrix a = ListMatrix [[a]] instance Num a => Triangulable (ListMatrix a) where type Elem (ListMatrix a) = a (ListMatrix xs) @@ (i, j) = xs !! i !! j size (ListMatrix xs) = size xs swapRows m n (ListMatrix xs) = ListMatrix $ swap m n xs swapCols m n (ListMatrix xs) = ListMatrix $ map (swap m n) xs addRows q m n (ListMatrix xs) = ListMatrix $ modifyNth n (zipWith comb (xs !! m)) where comb a b = q * a + b addCols q m n (LisMatrix xs) = ListMatrix $ map (\row -> modifyNth n (comb (row !! m)) row) where comb a b = q * a + b ... How can I fix this? -- Victor Nazarov From daniel.is.fischer at web.de Mon Sep 21 17:31:55 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Sep 21 17:14:26 2009 Subject: [Haskell-cafe] Problem with type families In-Reply-To: References: Message-ID: <200909212331.55526.daniel.is.fischer@web.de> Am Montag 21 September 2009 23:15:48 schrieb Victor Nazarov: > I've tried to reimplement code presented in the following blog post: > http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ > > But I've got stuck with the following error: > > Triangulable.hs:41:8: > `addRows' is not a (visible) method of class `Triangulable' > > Triangulable.hs:43:8: > `addCols' is not a (visible) method of class `Triangulable' > > I think the minimal example to reproduce this error is the following: > > ... > class Triangulable m > where type Elem m > (@@) :: m -> (Int, Int) -> Elem > size :: m -> Int > swapRows :: Int -> Int -> m -> m > swapCols :: Int -> Int -> m -> m > addRow :: (Num Elem) => Elem -> Int -> Int -> m -> m > addCol :: (Num Elem) => Elem -> Int -> Int -> m -> m > > newtype ListMatrix a = ListMatrix [[a]] > > instance Num a => Triangulable (ListMatrix a) > where type Elem (ListMatrix a) = a > (ListMatrix xs) @@ (i, j) = xs !! i !! j > size (ListMatrix xs) = size xs > swapRows m n (ListMatrix xs) = ListMatrix $ swap m n xs > swapCols m n (ListMatrix xs) = ListMatrix $ map (swap m n) xs > addRows q m n (ListMatrix xs) = ListMatrix $ modifyNth n > (zipWith comb (xs !! m)) > where comb a b = q * a + b > addCols q m n (LisMatrix xs) = ListMatrix $ map (\row -> > modifyNth n (comb (row !! m)) row) > where comb a b = q * a + b > ... > > How can I fix this? Shouldn't the methods be called the same in the class definition and instance declaration? So instance ... where ... addRow q m n (ListMatrix xs) = ... addCol q m n (ListMatrix xs) = .. > > -- > Victor Nazarov From asviraspossible at gmail.com Mon Sep 21 18:06:05 2009 From: asviraspossible at gmail.com (Victor Nazarov) Date: Mon Sep 21 17:44:29 2009 Subject: [Haskell-cafe] Problem with type families In-Reply-To: <200909212331.55526.daniel.is.fischer@web.de> References: <200909212331.55526.daniel.is.fischer@web.de> Message-ID: On Tue, Sep 22, 2009 at 1:31 AM, Daniel Fischer wrote: > Am Montag 21 September 2009 23:15:48 schrieb Victor Nazarov: >> I've tried to reimplement code presented in the following blog post: >> http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ >> >> But I've got stuck with the following error: >> >> Triangulable.hs:41:8: >> ? ? `addRows' is not a (visible) method of class `Triangulable' >> >> Triangulable.hs:43:8: >> ? ? `addCols' is not a (visible) method of class `Triangulable' >> >> I think the minimal example to reproduce this error is the following: >> >> ... >> class Triangulable m >> ? where type Elem m >> ? ? ? ? (@@) ? ? :: m -> (Int, Int) -> Elem >> ? ? ? ? size ? ? :: m -> Int >> ? ? ? ? swapRows :: Int -> Int -> m -> m >> ? ? ? ? swapCols :: Int -> Int -> m -> m >> ? ? ? ? addRow ? :: (Num Elem) => Elem -> Int -> Int -> m -> m >> ? ? ? ? addCol ? :: (Num Elem) => Elem -> Int -> Int -> m -> m >> >> newtype ListMatrix a = ListMatrix [[a]] >> >> instance Num a => Triangulable (ListMatrix a) >> ? where type Elem (ListMatrix a) = a >> ? ? ? ? (ListMatrix xs) @@ (i, j) = xs !! i !! j >> ? ? ? ? size (ListMatrix xs) = size xs >> ? ? ? ? swapRows m n (ListMatrix xs) = ListMatrix $ swap m n xs >> ? ? ? ? swapCols m n (ListMatrix xs) = ListMatrix $ map (swap m n) xs >> ? ? ? ? addRows q m n (ListMatrix xs) = ListMatrix $ modifyNth n >> (zipWith comb (xs !! m)) >> ? ? ? ? ? where comb a b = q * a + b >> ? ? ? ? addCols q m n (LisMatrix xs) = ListMatrix $ map (\row -> >> modifyNth n (comb (row !! m)) row) >> ? ? ? ? ? where comb a b = q * a + b >> ... >> >> How can I fix this? > > Shouldn't the methods be called the same in the class definition and instance declaration? > > So > > instance ... > ? ?where > ? ... > ? ?addRow q m n (ListMatrix xs) = ... > ? ?addCol q m n (ListMatrix xs) = .. > Yes that's right. My fault, I was too conserned with Fractional context in addRow and addCol function that I failed to see a simple bug. Here is working code for those who is interested: http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=9676#a9676 -- Victor Nazarov From colinpauladams at googlemail.com Tue Sep 22 02:56:30 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Tue Sep 22 02:34:51 2009 Subject: [Haskell-cafe] Problem with Text.XHtml.Strict.Formlets.file on Mac OSX Message-ID: <1afdeaec0909212356s7c5c8b99g3c553e0836c728ce@mail.gmail.com> I'm writing a form that involves picking a file to upload, and so uses Text.XHtml.Strict.Formlets.file. The form displays OK, but when I click the Browse button, and select a file from the dialog (no matter what the file type), and then click on the Submit button, I get an error: "fval[2] is not a file" I haven't added any validation yet. The generated html looks ok to me: This is on my laptop running Mac OSX. I can't test it on Linux until I get home at the weekend, so I don't know if I've made a silly error in my coding, but it is very simple: imageInputForm = F.plug (\xhtml -> X.p << (X.label << "Image file:") +++ xhtml) F.file Are there any known problems with the file formlet? Might it be OSX specific? -- Colin Adams Preston, Lancashire, ENGLAND From dav.vire+haskell at gmail.com Tue Sep 22 03:44:13 2009 From: dav.vire+haskell at gmail.com (david48) Date: Tue Sep 22 03:22:34 2009 Subject: [Haskell-cafe] Building com-1.2.3 In-Reply-To: <4AB7C7E6.5090505@btinternet.com> References: <4AB63FEE.9070500@btinternet.com> <4AB7C5D4.7010409@btinternet.com> <20090921182816.GI11518@whirlpool.galois.com> <4AB7C7E6.5090505@btinternet.com> Message-ID: <4c88418c0909220044x443df13dq6a7d8c0e1587d9b4@mail.gmail.com> On Mon, Sep 21, 2009 at 8:37 PM, Andrew Coppin wrote: > It also doesn't explain why Cabal isn't finding include/WideStringSrc.h, > even though that's the correct relative path to the file. I checked six > times; it's definitely there. include/WideStringSrc.h is a relative path, maybe cabal gets the base path for the include files wrong ? From jim at shareyourgifts.net Tue Sep 22 04:01:45 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 22 03:40:06 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> I am in love with this proposal: http://www.haskell.org/haskellwiki/Accessible_layout_proposal However, after some Google searching and contacting its original author, I have still not found any implementation or project to implement it. Are there any I'm missing? And, if not, who would be willing to help undertake a project to patch ghc to support it? Alternatively, you can try to talk me out of liking the proposal so much, but that is much less likely to work. Jimmy Hartzell From jason.dusek at gmail.com Tue Sep 22 05:04:08 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Tue Sep 22 04:42:28 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> Message-ID: <42784f260909220204r5f1ba6e9q5c6c2355dae90558@mail.gmail.com> 2009/09/21 Conor McBride : > ...or have unpleasant memories of being made to eat sulphurous > overboiled cabbage on pain of no pudding. Well, maybe the Cabal cabbages are Napa cabbages or red cabbages or pickled cabbages or Savoy cabbages? It is too bad, really, that a wholesome vegetable -- good raw or pickled or in little salady things like coleslaw -- finds itself used as a disincentive. -- Jason Dusek From dav.vire+haskell at gmail.com Tue Sep 22 05:29:19 2009 From: dav.vire+haskell at gmail.com (david48) Date: Tue Sep 22 05:07:40 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> Message-ID: <4c88418c0909220229j3f2a6553la6cdd658c9e0b74@mail.gmail.com> On Mon, Sep 21, 2009 at 12:11 AM, Jason Dusek wrote: > ?Some day, we're going to need a short, catchy name for Cabal > ?packages. Let's call them cabbages. C'est chou ! :-P +1 From conor at strictlypositive.org Tue Sep 22 06:03:47 2009 From: conor at strictlypositive.org (Conor McBride) Date: Tue Sep 22 05:42:12 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <42784f260909220204r5f1ba6e9q5c6c2355dae90558@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> <42784f260909220204r5f1ba6e9q5c6c2355dae90558@mail.gmail.com> Message-ID: <12707B01-1E7C-47B7-9A13-62CED23386F5@strictlypositive.org> Hi Jason On 22 Sep 2009, at 10:04, Jason Dusek wrote: > 2009/09/21 Conor McBride : >> ...or have unpleasant memories of being made to eat sulphurous >> overboiled cabbage on pain of no pudding. > > Well, maybe the Cabal cabbages are Napa cabbages or red > cabbages or pickled cabbages or Savoy cabbages? Mmm. Kimchi! > It is too bad, really, that a wholesome vegetable -- good raw > or pickled or in little salady things like coleslaw -- finds > itself used as a disincentive. I quite agree. Despite the best efforts of school kitchens, I remain stubbornly enthusiastic for the humble cabbage. In fact, I rather think I'll fetch one for my dinner. I'm just suggesting that the marketing department consider the variety of connotations and suggestions the term evokes before adopting it: legendary backfirings abound (the Spanish sales failure of a car called the "nova", for example). And what disturbs me is just how scarily spot-on the wholesome vegetable metaphor turns out to be. The time has come... Conor From djamanning at gmail.com Tue Sep 22 10:25:04 2009 From: djamanning at gmail.com (D. Manning) Date: Tue Sep 22 10:03:24 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <12707B01-1E7C-47B7-9A13-62CED23386F5@strictlypositive.org> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> <42784f260909220204r5f1ba6e9q5c6c2355dae90558@mail.gmail.com> <12707B01-1E7C-47B7-9A13-62CED23386F5@strictlypositive.org> Message-ID: <5c851a440909220725h3b7ed665s7d575f24f2e83063@mail.gmail.com> 2009/9/22 Conor McBride > I'm just suggesting that the marketing department consider the > variety of connotations and suggestions the term evokes before > adopting it: legendary backfirings abound (the Spanish sales > failure of a car called the "nova", for example). > Its not important but the nova story really is legendary: http://www.snopes.com/business/misxlate/nova.asp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090922/43f0e59a/attachment.html From conor at strictlypositive.org Tue Sep 22 10:30:51 2009 From: conor at strictlypositive.org (Conor McBride) Date: Tue Sep 22 10:09:12 2009 Subject: [Haskell-cafe] Cabal packages -> cabbages In-Reply-To: <5c851a440909220725h3b7ed665s7d575f24f2e83063@mail.gmail.com> References: <42784f260909201511s4616e51ag4cfd6411f0d5298d@mail.gmail.com> <54FAB73A-B67A-4C6A-9B34-FF0D2E40AE5C@strictlypositive.org> <42784f260909220204r5f1ba6e9q5c6c2355dae90558@mail.gmail.com> <12707B01-1E7C-47B7-9A13-62CED23386F5@strictlypositive.org> <5c851a440909220725h3b7ed665s7d575f24f2e83063@mail.gmail.com> Message-ID: Hi On 22 Sep 2009, at 15:25, D. Manning wrote: > 2009/9/22 Conor McBride > I'm just suggesting that the marketing department consider the > variety of connotations and suggestions the term evokes before > adopting it: legendary backfirings abound (the Spanish sales > failure of a car called the "nova", for example). > > Its not important but the nova story really is legendary: http://www.snopes.com/business/misxlate/nova.asp I chose my words with caution. Cheers Conor From doaitse at cs.uu.nl Tue Sep 22 11:13:16 2009 From: doaitse at cs.uu.nl (S. Doaitse Swierstra) Date: Tue Sep 22 10:51:37 2009 Subject: [Haskell-cafe] help with cabal; trying to escape from configuration hell Message-ID: I am trying to run happstack on my Mac, but unfortunately I am getting error messages as described in: http://code.google.com/p/happstack/issues/detail?id=88 The cure seems to be to downgrade to network-2.2.0.1, but unfortunately my installed cabal depends on network-2.2.1.4. I tried to re-install happstack using: cabal install happstack --reinstall --constraint="network==2.2.0.2" but unfortunately the ghc happily reports to link against network-2.2.1.4: ... Loading package parsec-2.1.0.1 ... linking ... done. Loading package hsemail-1.3 ... linking ... done. Loading package network-2.2.1.4 ... linking ... done. Loading package SMTPClient-1.0.1 ... linking ... done. Loading package time-1.1.4 ... linking ... done. ... Can someone rescue me? Doaitse From gue.schmidt at web.de Tue Sep 22 11:31:50 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Tue Sep 22 11:10:36 2009 Subject: [Haskell-cafe] gtk2hs and runghc Message-ID: Hi, I'm trying to test some gtk2hs gui code without compiling it first, just by using runghc. Gtk2hs then complains about running in a multithreaded ghc, ie. one with several "real" OS threads. Is it possible to start runghc single-threaded? G?nther From anton at appsolutions.com Tue Sep 22 11:42:41 2009 From: anton at appsolutions.com (Anton van Straaten) Date: Tue Sep 22 11:21:04 2009 Subject: [Haskell-cafe] help with cabal; trying to escape from configuration hell In-Reply-To: References: Message-ID: <4AB8F071.9090007@appsolutions.com> S. Doaitse Swierstra wrote: > I am trying to run happstack on my Mac, but unfortunately I am getting > error messages as described in: > > http://code.google.com/p/happstack/issues/detail?id=88 > > The cure seems to be to downgrade to network-2.2.0.1, but unfortunately > my installed cabal depends on network-2.2.1.4. There's a better cure if you're willing to modify & build Happstack. Gregory Collins describes it in this message: http://groups.google.com/group/HAppS/msg/0c9a0d0fd7c6aff0 It needs to be applied in the following file: happstack-server/src/Happstack/Server/HTTP/Socket.hs Replace the definition of acceptLite with the one in the above email, and rebuild happstack-server. The problem seems to be that on OS X, the Template Haskell code to detect at compile time whether IPv6 support is available is failing and causing the wrong code to get compiled in. Anton From colinpauladams at googlemail.com Tue Sep 22 13:44:04 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Tue Sep 22 13:22:24 2009 Subject: [Haskell-cafe] How to install GD library on Mac OSX? Message-ID: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> It needs some missing C libraries - gd, png, jpeg, fontconfig and freetype. Does anyone know what to do to install these on OSX? -- Colin Adams Preston, Lancashire, ENGLAND From danr at student.chalmers.se Tue Sep 22 15:31:08 2009 From: danr at student.chalmers.se (=?ISO-8859-1?Q?Dan_Ros=E9n?=) Date: Tue Sep 22 15:09:47 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays Message-ID: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> Dear haskell-cafe users, I am constructing a shuffle function: given an StdGen and a list, return the list permuted, with all permutations of equal probability. There is the simlpe recursive definition: generate a number from 1 to length list, take this element out from the list, call the function recursively on the remaining list and then cons the element on the shuffled list. A more imperative approach is to make the list an array, and traverse the array in reverse, swapping the iterated element with an arbitrary element less than or equal to the iterator. These functions are implemented as shuffleRec and shuffleArr, respectively. What complexity does these functions have? I argue that the shuffleArr function should be O(n), since it only contains one loop of n, where each loop does actions that are O(1): generating a random number and swapping two elements in an array. I argue that the shuffleRec function should be O(n^2), since for each call, it creates a new list in O(n), with the drop and take calls, and calls itself recursively. This yields O(n^2). However, they both have the same runnig time (roughly), and through looking at the plot it _very_ much looks quadratic. I am compiling with GHC and I guess there is something in the lazy semantics that confuses me about the complexities, and maybe I have misunderstood how STArrays work. Any pointers to what's going in is greatly appreciated! Best regards, Dan Ros?n, Sweden Here is the code: module Main where import Control.Monad import Control.Monad.ST import Data.Array.ST import Data.STRef import System.Random import Time import CPUTime shuffleArr :: StdGen -> [a] -> [a] shuffleArr g list = runST $ do let n = length list gref <- newSTRef g arr <- listToArray list forM_ [n,n-1..2] $ \p -> do m <- rand (1,p) gref swap arr m p getElems arr where rand range gref = do g <- readSTRef gref let (v,g') = randomR range g writeSTRef gref g' return v swap a n m = do [n',m'] <- mapM (readArray a) [n,m] mapM (uncurry $ writeArray a) [(m,n'),(n,m')] listToArray :: [a] -> ST s (STArray s Int a) listToArray list = let n = length list in newListArray (1,n) list shuffleRec :: StdGen -> [a] -> [a] shuffleRec g list = x:shuffleArr g' xs where (n,g') = randomR (0,length list-1) g (x:xs') = drop n list xs = take n list ++ xs' -- A somewhat lame attempt to derive the complexities through testing, -- prints the times for the different functions in a table main :: IO () main = do let times = take 30 $ iterate (+30000) 10000 answers <- mapM test times sequence_ [ putStrLn $ concatMap ((++ "\t"). show) [toInteger t,arr,rec] | (t,(arr,rec)) <- zip times answers ] -- Perform a test of size n, and return the cycles it took for the different -- algorithms in a pair. Evaluation is enforced by seq on length of the list. test :: Int -> IO (Integer,Integer) test n = do let list = [1..n] [g1,g2] <- replicateM 2 newStdGen length list `seq` do s <- doTime ("shuffleArr " ++ show n) $ (length $ shuffleArr g1 list) `seq` return () s' <- doTime ("shuffleRec " ++ show n) $ (length $ shuffleRec g2 list) `seq` return () return (s,s') -- This is taken from GenUtil from the JHC creator's homepage doTime :: String -> IO a -> IO Integer doTime str action = do start <- getCPUTime x <- action end <- getCPUTime let time = (end - start) `div` 1000000 -- `div` cpuTimePrecision -- putStrLn $ "Timing: " ++ str ++ " " ++ show time return time From polyomino at f2s.com Tue Sep 22 16:01:48 2009 From: polyomino at f2s.com (DavidA) Date: Tue Sep 22 15:44:44 2009 Subject: [Haskell-cafe] What is Message-ID: Hi, When I try to build my HaskellForMaths library (http://hackage.haskell.org/package/HaskellForMaths) using GHC6.10.4 on Mac OS X (Leopard), I get several "ld warning: atom sorting error" (see below). The same code built without problems under GHC6.10.3 on Windows. The code in question is using phantom types to parameterise type constructors. Should I be worried? (It's only a warning - I believe the build is fine.) ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Grevlex_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Lex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Glex_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Grevlex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Elim_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Glex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Grevlex_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Lex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Glex_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Grevlex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o ld warning: atom sorting error for _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Elim_closure_tbl and _HaskellForMathszm0zi1zi8_MathziAlgebrazi CommutativeziMonomial_Glex_closure_tbl in dist/build/Math/Algebra/Commutative/Monomial.o From bos at serpentine.com Tue Sep 22 16:10:11 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Sep 22 15:48:32 2009 Subject: [Haskell-cafe] What is In-Reply-To: References: Message-ID: On Tue, Sep 22, 2009 at 1:01 PM, DavidA wrote: > > When I try to build my HaskellForMaths library > (http://hackage.haskell.org/package/HaskellForMaths) > using GHC6.10.4 on Mac OS X (Leopard), I get several > "ld warning: atom sorting error" (see below). The first rule of weird compiler output: enter the message you get into Google. http://hackage.haskell.org/trac/ghc/ticket/2578 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090922/3b7a17b8/attachment.html From daniel.is.fischer at web.de Tue Sep 22 16:31:48 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 22 16:11:21 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays In-Reply-To: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> References: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> Message-ID: <200909222231.49469.daniel.is.fischer@web.de> Am Dienstag 22 September 2009 21:31:08 schrieb Dan Ros?n: > Dear haskell-cafe users, > > I am constructing a shuffle function: given an StdGen and a list, return > the list permuted, with all permutations of equal probability. > > There is the simlpe recursive definition: generate a number from 1 to > length list, take this element out from the list, call the function > recursively on the remaining list and then cons the element on the shuffled > list. > > A more imperative approach is to make the list an array, and traverse the > array in reverse, swapping the iterated element with an arbitrary element > less than or equal to the iterator. > > These functions are implemented as shuffleRec and shuffleArr, respectively. > > What complexity does these functions have? > > I argue that the shuffleArr function should be O(n), since it only contains > one loop of n, where each loop does actions that are O(1): generating a > random number and swapping two elements in an array. > > I argue that the shuffleRec function should be O(n^2), since for each call, > it creates a new list in O(n), with the drop and take calls, and calls > itself recursively. This yields O(n^2). > > However, they both have the same runnig time (roughly), and through looking > at the plot it _very_ much looks quadratic. Regarding > > shuffleRec :: StdGen -> [a] -> [a] > shuffleRec g list = x:shuffleArr g' xs > where > (n,g') = randomR (0,length list-1) g > (x:xs') = drop n list > xs = take n list ++ xs' it's not surprising they take more or less the same time. Make it shuffleRec g list = x:shuffleRec g' xs and prepare to kill the process pretty soon. That doesn't explain the quadratic behaviour of shuffleArr, though. I suspect it's laziness, things aren't actually done until the result is finally demanded, but I would have to take a closer look to really find out. > > I am compiling with GHC and I guess there is something in the lazy > semantics that confuses me about the complexities, and maybe I have > misunderstood how STArrays work. > > Any pointers to what's going in is greatly appreciated! > > Best regards, > Dan Ros?n, Sweden > > Here is the code: From tobsan at gmail.com Tue Sep 22 16:33:27 2009 From: tobsan at gmail.com (Tobias Olausson) Date: Tue Sep 22 16:11:47 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays In-Reply-To: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> References: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> Message-ID: <65c9dbea0909221333i52fc76dgee2af5c6abe932ac@mail.gmail.com> Hi Dan! You might want to change the following: shuffleRec :: StdGen -> [a] -> [a] shuffleRec g list = x:shuffleArr g' xs where (n,g') = randomR (0,length list-1) g (x:xs') = drop n list xs = take n list ++ xs' into the following: shuffleRec :: StdGen -> [a] -> [a] shuffleRec g list = x:shuffleRec g' xs where (n,g') = randomR (0,length list-1) g (x:xs') = drop n list xs = take n list ++ xs' Since shuffleRec just called shuffleArr, one would expect them to run in approximately the same time :-) //Tobias 2009/9/22 Dan Ros?n : > Dear haskell-cafe users, > > I am constructing a shuffle function: given an StdGen and a list, return the > list permuted, with all permutations of equal probability. > > There is the simlpe recursive definition: generate a number from 1 to length > list, take this element out from the list, call the function recursively on > the remaining list and then cons the element on the shuffled list. > > A more imperative approach is to make the list an array, and traverse the > array in reverse, swapping the iterated element with an arbitrary element > less than or equal to the iterator. > > These functions are implemented as shuffleRec and shuffleArr, respectively. > > What complexity does these functions have? > > I argue that the shuffleArr function should be O(n), since it only contains > one loop of n, where each loop does actions that are O(1): generating a random > number and swapping two elements in an array. > > I argue that the shuffleRec function should be O(n^2), since for each call, > it creates a new list in O(n), with the drop and take calls, and calls itself > recursively. This yields O(n^2). > > However, they both have the same runnig time (roughly), and through looking > at the plot it _very_ much looks quadratic. > > I am compiling with GHC and I guess there is something in the lazy semantics > that confuses me about the complexities, and maybe I have misunderstood how > STArrays work. > > Any pointers to what's going in is greatly appreciated! > > Best regards, > Dan Ros?n, Sweden > > Here is the code: > > module Main where > > import Control.Monad > import Control.Monad.ST > import Data.Array.ST > import Data.STRef > import System.Random > > import Time > import CPUTime > > shuffleArr :: StdGen -> [a] -> [a] > shuffleArr g list = runST $ do > ? ?let n = length list > ? ?gref <- newSTRef g > ? ?arr <- listToArray list > ? ?forM_ [n,n-1..2] $ \p -> do > ? ? ? ?m <- rand (1,p) gref > ? ? ? ?swap arr m p > ? ?getElems arr > ?where > ? ?rand range gref = do > ? ? ? ?g <- readSTRef gref > ? ? ? ?let (v,g') = randomR range g > ? ? ? ?writeSTRef gref g' > ? ? ? ?return v > > ? ?swap a n m = do > ? ? ? ?[n',m'] <- mapM (readArray a) [n,m] > ? ? ? ?mapM (uncurry $ writeArray a) [(m,n'),(n,m')] > > listToArray :: [a] -> ST s (STArray s Int a) > listToArray list = let n = length list > ? ? ? ? ? ? ? ? ? in ?newListArray (1,n) list > > shuffleRec :: StdGen -> [a] -> [a] > shuffleRec g list = x:shuffleArr g' xs > ?where > ? ?(n,g') ?= randomR (0,length list-1) g > ? ?(x:xs') = drop n list > ? ?xs ? ? ?= take n list ++ xs' > > -- A somewhat lame attempt to derive the complexities through testing, > -- prints the times for the different functions in a table > main :: IO () > main = do > ? ?let times = take 30 $ iterate (+30000) 10000 > ? ?answers <- mapM test times > ? ?sequence_ [ putStrLn $ concatMap ((++ "\t"). show) [toInteger t,arr,rec] > ? ? ? ? ? ? ?| (t,(arr,rec)) <- zip times answers > ? ? ? ? ? ? ?] > > -- Perform a test of size n, and return the cycles it took for the different > -- algorithms in a pair. Evaluation is enforced by seq on length of the list. > test :: Int -> IO (Integer,Integer) > test n = do > ? ?let list = [1..n] > ? ?[g1,g2] <- replicateM 2 newStdGen > ? ?length list `seq` do > ? ? ? ?s ?<- doTime ("shuffleArr " ++ show n) $ > ? ? ? ? ? ? ? ? (length $ shuffleArr g1 list) `seq` return () > ? ? ? ?s' <- doTime ("shuffleRec " ++ show n) $ > ? ? ? ? ? ? ? ? (length $ shuffleRec g2 list) `seq` return () > ? ? ? ?return (s,s') > > -- This is taken from GenUtil from the JHC creator's homepage > doTime :: String -> IO a -> IO Integer > doTime str action = do > ? ?start <- getCPUTime > ? ?x <- action > ? ?end <- getCPUTime > ? ?let time = (end - start) `div` 1000000 -- `div` cpuTimePrecision > ? ?-- putStrLn $ "Timing: " ++ str ++ " " ++ show time > ? ?return time > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Tobias Olausson tobsan@gmail.com From daniel.is.fischer at web.de Tue Sep 22 16:57:46 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 22 16:37:15 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays In-Reply-To: <200909222231.49469.daniel.is.fischer@web.de> References: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> <200909222231.49469.daniel.is.fischer@web.de> Message-ID: <200909222257.46673.daniel.is.fischer@web.de> Am Dienstag 22 September 2009 22:31:48 schrieb Daniel Fischer: > That doesn't explain the quadratic behaviour of shuffleArr, though. > I suspect it's laziness, things aren't actually done until the result is > finally demanded, but I would have to take a closer look to really find > out. Yep. Strictifying things gives the expected linear behaviour. In ? ? swap a n m = do ? ? ? ? [n',m'] <- mapM (readArray a) [n,m] ? ? ? ? mapM (uncurry $ writeArray a) [(m,n'),(n,m')] you don't actually read and write values, but ever longer thunks. Changing swap to ? ? swap a m n vm <- readArray a m vn <- readArray a n writeArray a n $! vm writeArray a m $! vn is all you need to do (as long as your values have a simple type). From allbery at ece.cmu.edu Tue Sep 22 17:08:39 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Sep 22 16:47:03 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: References: Message-ID: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sep 22, 2009, at 11:31 , G?nther Schmidt wrote: > Gtk2hs then complains about running in a multithreaded ghc, ie. one > with several "real" OS threads. Is it possible to start runghc > single-threaded? No, but you can unsafeInitGUIForThreadedRTS. - -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) iEYEARECAAYFAkq5PNcACgkQIn7hlCsL25UbYQCfSTz6RgOOB2v2x5aWQl2wTqQ0 5/sAnipoGEOCHn0zXfsx9H3N4ggp/7aJ =Czq6 -----END PGP SIGNATURE----- From sergueyz at gmail.com Tue Sep 22 17:14:10 2009 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Sep 22 16:52:31 2009 Subject: [Haskell-cafe] Strange problem with type classes (ghc 6.8.2 looks allright and ghc 6.10.1 doesn't). Message-ID: <600376290909221414l6a62f60dpcd06f6fa962dfc6e@mail.gmail.com> I try to create yet another hardware description language embedded in Haskell and faced a (perceived) bug in ghc 6.10.1 type checker. In ghc 6.8.2 everything works fine. I need a type class that can express relationship between type and its' "size in wires" (the number of bits needed to represent any value of a type). The type class can be easily generalized to most haskell data types and it's easy to write instance derivation using Template Haskell. I used multiparameter type classes because support for type families in Template Haskell was incomplete in 6.10.1 and prior versions. The source code below. Do not forget to include -fcontext-stack=100 when trying to load the code into ghci. The problem lines are between "THE PROBLEM!!" comments. Please, tell me, is it geniune bug or I misunderstand something about Haskell type checker? How do you solve problems like that? and, btw, you can take a look on how we can describe something MIPS-alike in Haskell here: http://thesz.mskhug.ru/svn/hhdl/MIPS.hs it is not finished by any means, but it gives a feel on how it will look. I head to obtain (pretty) efficient simulation functions on infinite streams (almost done, transformations are very simple) and synthesable VHDL/Verilog description all from the same code that looks like ordinary Haskell code. ----------------------------------------------------------------------------------------------------------------------------- -- "A problem with functional dependencies. -- use -fcontext-stack=100 ghc switch. {-# LANGUAGE GADTs, FunctionalDependencies, MultiParamTypeClasses, TypeSynonymInstances, FlexibleInstances, FlexibleContexts, UndecidableInstances #-} module Problem where import Data.Bits import Data.Word ------------------------------------------------------------------------------- -- Type level arithmetic. data Zero = Zero data Succ n = Succ n type ZERO = Zero type ONE = Succ ZERO type TWO = Succ ONE type THREE = Succ TWO type FOUR = Succ THREE type FIVE = Succ FOUR type SIX = Succ FIVE type SEVEN = Succ SIX type EIGHT = Succ SEVEN type NINE = Succ EIGHT type SIZE10 = Succ NINE type SIZE11 = Succ SIZE10 type SIZE12 = Succ SIZE11 type SIZE13 = Succ SIZE12 type SIZE15 = Succ (Succ SIZE13) type SIZE16 = Succ SIZE15 type SIZE20 = Succ (Succ (Succ (Succ (Succ SIZE15)))) type SIZE25 = Succ (Succ (Succ (Succ (Succ SIZE20)))) type SIZE26 = Succ SIZE25 type SIZE30 = Succ (Succ (Succ (Succ (Succ SIZE25)))) type SIZE32 = Succ (Succ SIZE30) class Nat n where fromNat :: n -> Int instance Nat Zero where fromNat = const 0 instance Nat n => Nat (Succ n) where fromNat ~(Succ n) = 1+fromNat n class (Nat a, Nat b, Nat c) => CPlus a b c | a b -> c, a c -> b --instance Nat a => CPlus a Zero a instance Nat a => CPlus Zero a a instance (CPlus a b c) => CPlus (Succ a) b (Succ c) --instance (CPlus a b c) => CPlus (Succ a) b (Succ c) --instance (CPlus a b c) => CPlus a (Succ b) (Succ c) class (Nat a, Nat b, Nat c) => CMax a b c | a b -> c instance CMax Zero Zero Zero instance Nat a => CMax (Succ a) Zero (Succ a) instance Nat a => CMax Zero (Succ a) (Succ a) instance CMax a b c => CMax (Succ a) (Succ b) (Succ c) class (Nat a, Nat b) => CDbl a b | a -> b instance CPlus a a b => CDbl a b class (Nat a, Nat b) => CPow2 a b | a -> b instance CPow2 Zero (Succ Zero) instance (CPow2 a b, CDbl b b2) => CPow2 (Succ a) b2 ------------------------------------------------------------------------------- -- Sized integer. data IntSz n where IntSz :: Nat sz => Integer -> IntSz sz intSzSizeType :: IntSz n -> n; intSzSizeType _ = undefined intSzSize :: Nat n => IntSz n -> Int; intSzSize n = fromNat $ intSzSizeType n instance Nat sz => Eq (IntSz sz) where (IntSz a) == (IntSz b) = a == b instance Show (IntSz n) where show n@(IntSz x) = show x++"{"++show (intSzSize n)++"}" instance Nat sz => Num (IntSz sz) where fromInteger x = IntSz x (IntSz a) + (IntSz b) = IntSz $ a+b (IntSz a) - (IntSz b) = IntSz $ a-b (IntSz a) * (IntSz b) = IntSz $ a*b abs = error "No abs for IntSz." signum = error "No signum for IntSz." ------------------------------------------------------------------------------- -- ToWires class, the main source of problems. class Nat aSz => ToWires a aSz | a -> aSz where wireSizeType :: a -> aSz wireSizeType _ = undefined -- size of a bus to hold a value in bits. wireSize :: a -> Int wireSize x = fromNat $ wireSizeType x -- 2^wireSize, currently unused. wireMul :: a -> Integer wireMul x = Data.Bits.shiftL 1 (wireSize x) -- selector size for decode (unused). wireSelSize :: a -> Int wireSelSize = const 0 -- Integer should occupy no more than wireSize bits, the remaining bits should be 0 toWires :: a -> Integer -- fromWires should work with integers that have non-zero bits -- above wireSize index. fromWires :: Integer -> a -- enumeration. -- valuesCount of (Maybe a) returns 1+valuesCount (x::a) -- valuesCount of Either a b returns valuesCount (x::a) + valuesCount (yLLb) -- valuesCount of (a,b) returns valuesCoutn (x::a) * valuesCount (y::b) valuesCount :: a -> Integer -- valueIndex. -- get a value and return an index inside enumeration. valueIndex :: a -> Integer ------------------------------------------------------------------------------- -- Instances. instance (ToWires x a,ToWires y b, CPlus a b c) => ToWires (x,y) c where toWires (a,b) = Data.Bits.shiftL (toWires a) (wireSize b) .|. toWires b fromWires x = (a,b) where b = fromWires x a = fromWires $ Data.Bits.shiftR x (wireSize b) valuesCount (a,b) = valuesCount a*valuesCount b valueIndex (a,b) = valueIndex a*valuesCount b + valueIndex b instance (ToWires x1 a,ToWires x2 b,ToWires x3 c, CPlus b c bc, CPlus a bc abc) => ToWires (x1,x2,x3) abc where toWires (a,b,c) = toWires (a,(b,c)) fromWires abc = (a,b,c) where (a,(b,c)) = fromWires abc valuesCount (a,b,c) = valuesCount (a,(b,c)) valueIndex (a,b,c) = valueIndex (a,(b,c)) instance (ToWires x1 a,ToWires x2 b,ToWires x3 c,ToWires x4 d,ToWires x5 e, CPlus d e de, CPlus c de cde, CPlus b cde bcde, CPlus a bcde abcde) => ToWires (x1,x2,x3,x4,x5) abcde where toWires (a,b,c,d,e) = toWires (a,(b,(c,(d,e)))) fromWires abcde = (a,b,c,d,e) where (a,(b,(c,(d,e)))) = fromWires abcde valuesCount (a,b,c,d,e) = valuesCount (a,(b,(c,(d,e)))) valueIndex (a,b,c,d,e) = valueIndex (a,(b,(c,(d,e)))) instance CPow2 FIVE size32 => ToWires Int size32 where toWires n = fromIntegral n .&. 0xffffffff fromWires x = fromIntegral x valuesCount = const (Data.Bits.shiftL (1::Integer) 32) valueIndex = fromIntegral instance CPow2 FIVE size32 => ToWires Word32 size32 where toWires n = fromIntegral n .&. 0xffffffff fromWires x = fromIntegral x valuesCount = const (Data.Bits.shiftL (1::Integer) 32) valueIndex = fromIntegral instance Nat size => ToWires (IntSz size) size where toWires x@(IntSz n) = n .&. (Data.Bits.shiftL 1 (wireSize x) - 1) fromWires x = fromIntegral x valuesCount x = Data.Bits.shiftL (1::Integer) (wireSize x) valueIndex x = toWires x ------------------------------------------------------------------------------- -- Neccessary types for a problem. -- A hack around bugs (??) in ghc 6.10.1. data RI = RI (IntSz FIVE) deriving (Eq,Show) data Imm5 = Imm5 (IntSz FIVE) deriving (Eq,Show) data Imm16 = Imm16 (IntSz SIZE16) deriving (Eq,Show) data Imm26 = Imm26 (IntSz SIZE26) deriving (Eq,Show) instance ToWires RI FIVE where toWires (RI x) = toWires x fromWires x = RI $ fromWires x valuesCount = const 32 valueIndex (RI x) = toWires x instance ToWires Imm5 FIVE where toWires (Imm5 x) = toWires x fromWires x = Imm5 $ fromWires x valuesCount = const 32 valueIndex (Imm5 x) = toWires x instance ToWires Imm16 SIZE16 where toWires (Imm16 x) = toWires x fromWires x = Imm16 $ fromWires x valuesCount (Imm16 x) = valuesCount x valueIndex (Imm16 x) = valueIndex x instance ToWires Imm26 SIZE26 where toWires (Imm26 x) = toWires x fromWires x = Imm26 $ fromWires x valuesCount (Imm26 x) = valuesCount x valueIndex (Imm26 x) = toWires x instance ToWires a sz => ToWires (Maybe a) (Succ sz) where toWires Nothing = 0 toWires (Just x) = shiftL (toWires x) 1 .|. 1 fromWires = undefined valuesCount x = 1+valuesCount y where ~(Just y) = x valueIndex Nothing = 0 valueIndex (Just x) = 1+valueIndex x ------------------------------------------------------------------------------- -- And a problem itself. data Signed = Signed | Unsigned deriving (Eq,Show) data MIPSCmd regv = Nop | Trap -- we mark destination register with RI. It never gets fetched. -- we mark source registers as regv, because they can change their size -- at FETCH stage (became Word32). | AddU regv regv RI | And regv regv RI | Div Signed regv regv deriving (Eq,Show) instance ToWires Signed (Succ Zero) where toWires (Signed) = Data.Bits.shiftL 0 1 .|. 0 toWires (Unsigned) = Data.Bits.shiftL 0 1 .|. 1 fromWires x = undefined valuesCount x = 1 + (1 + 0) where ~(Signed) = x ~(Unsigned) = x valueIndex x = case x of Signed -> 0 + 0 Unsigned -> (0 + 0) + 0 where ~(Signed) = x ~(Unsigned) = x instance (ToWires regv_0 v_1, ToWires RI v_2, CPlus v_1 v_1 vCPlus_3, CPlus vCPlus_3 v_2 vCPlus_4, CPlus v_1 v_1 vCPlus_5, CPlus vCPlus_5 v_2 vCPlus_6, ToWires Signed v_7, CPlus v_7 v_1 vCPlus_8, CPlus vCPlus_8 v_1 vCPlus_9, CMax vCPlus_4 vCPlus_6 vCMax_10, CMax vCMax_10 vCPlus_9 vCMax_11) => ToWires (MIPSCmd regv_0) (Succ (Succ (Succ vCMax_11))) where toWires (Nop) = Data.Bits.shiftL 0 3 .|. 0 toWires (Trap) = Data.Bits.shiftL 0 3 .|. 1 toWires (AddU a_12 a_13 a_14) = Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL 0 (wireSize a_12) .|. toWires a_12) (wireSize a_13) .|. toWires a_13) (wireSize a_14) .|. toWires a_14) 3 .|. 2 toWires (And a_15 a_16 a_17) = Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL 0 (wireSize a_15) .|. toWires a_15) (wireSize a_16) .|. toWires a_16) (wireSize a_17) .|. toWires a_17) 3 .|. 3 toWires (Div a_18 a_19 a_20) = Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL (Data.Bits.shiftL 0 (wireSize a_18) .|. toWires a_18) (wireSize a_19) .|. toWires a_19) (wireSize a_20) .|. toWires a_20) 3 .|. 4 fromWires x = undefined valuesCount x = 1 + (1 + ((valuesCount x_21 * (valuesCount x_22 * (valuesCount x_23 * 1))) + ((valuesCount x_24 * (valuesCount x_25 * (valuesCount x_26 * 1))) + ((valuesCount x_27 * (valuesCount x_28 * (valuesCount x_29 * 1))) + 0)))) where ~(Nop) = x ~(Trap) = x ~(AddU x_21 x_22 x_23) = x ~(And x_24 x_25 x_26) = x ~(Div x_27 x_28 x_29) = x -- Please don't mind that code is wrong, I can't get past typechecker here. valueIndex x = case x of Nop -> 0 + 0 Trap -> (0 + 0) + 0 -- THE PROBLEM!!! AddU ax_30 ax_31 ax_32 -> ((0 + 0) + 0) + valueIndex (ax_32,(ax_30, ax_31)) -- /THE PROBLEM!!! {- And x_33 x_34 x_35 -> (((0 + 0) + 0) + valuesCount (x_32, (x_30, x_31))) + valueIndex (x_35, (x_33, x_34)) Div x_36 x_37 x_38 -> ((((0 + 0) + 0) + valuesCount (x_32, (x_30, x_31))) + valuesCount (x_35, (x_33, x_34))) + valueIndex (x_38, (x_36, x_37)) -} where ~(Nop) = x ~(Trap) = x ~(AddU x_30 x_31 x_32) = x ~(And x_33 x_34 x_35) = x ~(Div x_36 x_37 x_38) = x ----------------------------------------------------------------------------------------------------------------------------- From allbery at ece.cmu.edu Tue Sep 22 17:53:17 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Tue Sep 22 17:31:52 2009 Subject: [Haskell-cafe] How to install GD library on Mac OSX? In-Reply-To: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> References: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sep 22, 2009, at 13:44 , Colin Adams wrote: > It needs some missing C libraries - gd, png, jpeg, fontconfig and > freetype. > Does anyone know what to do to install these on OSX? Customarily, Fink or MacPorts. Several of those *are* installed on OSX by default (at least Leopard and up); if they're not being found, make sure you have installed the latest XCode and Apple's X11 (the latter should only matter for Tiger and earlier). You may also want the latest X11 from http://xquartz.macosforge.org . - -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) iEUEARECAAYFAkq5R1sACgkQIn7hlCsL25VVqgCg024xKkPI4fQcKVz1SZp4ca8Y TmEAkwbId0xKjhL8HmJAIukgVFrTz7E= =fAaa -----END PGP SIGNATURE----- From vasyl.pasternak at gmail.com Tue Sep 22 18:05:38 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Tue Sep 22 17:43:57 2009 Subject: [Haskell-cafe] FFMpeg, SDL and Haskell Message-ID: <8feb08f70909221505p6aa2569frab79d0297353b34@mail.gmail.com> Hi all, Last few days I was playing with FFI, FFMpeg and Haskell. Currently I am trying to make this tutorial http://www.dranger.com/ffmpeg/ on Haskell. Now I have done tutorial 01 and tutorial 02 (show video stream in SDL window). The third tutorial is about audio, and I found that audio doesn't supported in SDL bindings completely. So I'd like to fill this gap, but I don't know where to get latest version and to whom I have to send SDL patches. Anyway, does anybody interested in FFMpeg bindings ? Should I put it on Hackage ? The preliminary version I've put on google code: http://hs-ffmpeg.googlecode.com/files/hs-ffmpeg-0.2.0.tar.gz, but this is "work on my PC" version. Vasyl -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090922/e6fd91d8/attachment.html From sergueyz at gmail.com Tue Sep 22 18:11:11 2009 From: sergueyz at gmail.com (Serguey Zefirov) Date: Tue Sep 22 17:49:30 2009 Subject: [Haskell-cafe] Strange problem with type classes (ghc 6.8.2 looks allright and ghc 6.10.1 doesn't). Message-ID: <600376290909221511x338e94ey56af62e63f6b1668@mail.gmail.com> (followup to my previous letter with the same subject) I found the way to break 6.8.2 type checker. It's as easy as to uncomment Div case alternative in valueIndex. Weird. I found a solution, though. Instead of (valueIndex (x_38,(x_36,x_37))) in that Div alternative I should create expression (valueIndex x_38*valuesCount x_36*valuesCount x_37 + valueIndex x_36 * valuesCount x_37+valueIndex x_37) which is equivalent to above one. Slightly more work. And I still cannot figure why valueIndex (a,(b,c)) works in one type and doesn;t in another. From shinnonoir at gmail.com Tue Sep 22 18:22:08 2009 From: shinnonoir at gmail.com (Raynor Vliegendhart) Date: Tue Sep 22 18:00:27 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> Message-ID: <6d961e560909221522r38e2b0aeke0ffcfa522b2185@mail.gmail.com> On Tue, Sep 22, 2009 at 10:01 AM, Jimmy Hartzell wrote: > I am in love with this proposal: > http://www.haskell.org/haskellwiki/Accessible_layout_proposal I'm not sure whether I like the idea in general or not. It looks a bit odd. The suggestion on the talk page ( http://www.haskell.org/haskellwiki/Talk:Accessible_layout_proposal ) might be preferable, although I wonder about the implications. For example, what should (#) be parsed as? From ok at cs.otago.ac.nz Tue Sep 22 18:49:10 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Sep 22 18:27:39 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> Message-ID: On Sep 22, 2009, at 8:01 PM, Jimmy Hartzell wrote: > I am in love with this proposal: > http://www.haskell.org/haskellwiki/Accessible_layout_proposal I hadn't read it before. Now that I have, I really do not like it. "Syntactic sugar causes cancer of the semicolon" as Alan Perlis once said, and to my taste this proposal definitely counts as cancer of the semicolon. In effect, its purpose is to overload vertical white space. Any time that you have something where you think you need this, it's likely that a better solution is to break what you are doing into smaller pieces. From jim at shareyourgifts.net Tue Sep 22 20:51:59 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 22 20:30:17 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> > > On Sep 22, 2009, at 8:01 PM, Jimmy Hartzell wrote: > >> I am in love with this proposal: >> http://www.haskell.org/haskellwiki/Accessible_layout_proposal > > I hadn't read it before. Now that I have, I really do not like > it. "Syntactic sugar causes cancer of the semicolon" as Alan > Perlis once said, and to my taste this proposal definitely > counts as cancer of the semicolon. In effect, its purpose > is to overload vertical white space. > > Any time that you have something where you think you need > this, it's likely that a better solution is to break what > you are doing into smaller pieces. Well, look at code like this: wrapParens str = concat [ "(", str, ")" ] (And yes, I realize you can do something like this with 'printf "(%s)" str'.) First off, there is a serious issue with the commas. You should at least be allowed to have a comma after the last element, a la Python. Otherwise, the last one is randomly special in this list, and in a format like this, I regularly edit code accidentally leaving off commas, yielding stuff like: concat [ "(", str, ")" -- (oops, no comma!) lineEnd -- forgot I needed this ] which (of course) results in a very confusing type error. Meanwhile, you have to format your code very awkwardly, as the closing bracket can't be in the left-most column, and, all in all, you have lots and lots of commas cluttering up your otherwise clean-looking layout. You get humans reading the code based off of the physical layout, while the computer is interpreting it based on the presence of commas, which the human mind will naturally filter in favor of the layout. And as to the "simplifying your code" idea: however "pure" your code is, you will regularly have to embed lists of things in it (ADTs, export lists, data from the domain). And unless you're claiming it is *almost always bad style to have code looking like (from the proposal): main = do a <- getChar bracket_ (enter a) (exit a) (do putChar a putStrLn "hello") then the same argument holds for $# (which I expect is the most controversial part of the proposal): the humans read the layout, the computers read the parentheses, and there are many opportunities for error. I mean, probably in this case the code could stand to be changed to: with a = bracket_ (enter a) (exit a) main = do a <- getChar with a $ do putChar a putStrLn "hello" But I would *still* rather have: with a = bracket_ $# enter a exit a Layout is easier to read than parentheses. In summary, I have to spend a good portion of my time coding Haskell dealing with the fact that I have a lot of {'s, ['s, and ,'s to keep track of, and they rarely fit on one line (records, ADTs, lists). I have to spend a significant amount of my coding time finagling the layout to look sensible, and I don't think anyone would claim that I just shouldn't use records or ADTs. From daniel.is.fischer at web.de Tue Sep 22 21:32:56 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 22 21:12:24 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> References: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> Message-ID: <200909230332.56203.daniel.is.fischer@web.de> Am Mittwoch 23 September 2009 02:51:59 schrieb Jimmy Hartzell: > > On Sep 22, 2009, at 8:01 PM, Jimmy Hartzell wrote: > >> I am in love with this proposal: > >> http://www.haskell.org/haskellwiki/Accessible_layout_proposal (Richard O'Keefe:) > > > > I hadn't read it before. Now that I have, I really do not like > > it. "Syntactic sugar causes cancer of the semicolon" as Alan > > Perlis once said, and to my taste this proposal definitely > > counts as cancer of the semicolon. In effect, its purpose > > is to overload vertical white space. > > > > Any time that you have something where you think you need > > this, it's likely that a better solution is to break what > > you are doing into smaller pieces. I don't like it either. I have not nearly a s strong feelings as Mr. O'Keefe, but to me it doesn't look right. > > Well, look at code like this: > > wrapParens str = concat [ > "(", > str, > ")" > ] > > (And yes, I realize you can do something like this with 'printf "(%s)" > str'.) Or, what I do: concat [ "(" , str , ")" ] (of course, here I would just write '(' : str ++ ")"). I admit it looked odd for the first couple of hours, but now I find it nice, clean and systematic. > > First off, there is a serious issue with the commas. You should at least > be allowed to have a comma after the last element, a la Python. Otherwise, > the last one is randomly special in this list, and in a format like this, > I regularly edit code accidentally leaving off commas, yielding stuff > like: > > concat [ > "(", > str, > ")" -- (oops, no comma!) > lineEnd -- forgot I needed this > ] And that is avoided, because a missing comma leaps to the eye. > > which (of course) results in a very confusing type error. Meanwhile, you > have to format your code very awkwardly, as the closing bracket can't be > in the left-most column, Which is a good thing in my eyes. > In summary, I have to spend a good portion of my time coding Haskell > dealing with the fact that I have a lot of {'s, ['s, and ,'s to keep track > of, and they rarely fit on one line (records, ADTs, lists). I have to > spend a significant amount of my coding time finagling the layout to look > sensible, and I don't think anyone would claim that I just shouldn't use > records or ADTs. I see your point but remain not liking the proposal. From jim at shareyourgifts.net Tue Sep 22 22:06:11 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 22 21:44:29 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <200909230332.56203.daniel.is.fischer@web.de> References: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> <200909230332.56203.daniel.is.fischer@web.de> Message-ID: <178330b7b968313a3ff0e1f3bea29567.squirrel@mail.shareyourgifts.net> Daniel Fischer wrote: > Or, what I do: > > concat > [ "(" > , str > , ")" > ] This is a lot better, true, but it still takes a lot of typing, and the first element is now special-cased, preventing easy copy-and-paste (although, admittedly, much less opportunity for mistake). On a more philosophical level, the signals used by the humans still are different from the signals used by the computer, which leads me to suspect such a system could still cause confusion. > And that is avoided, because a missing comma leaps to the eye. True. Drawing this much attention to syntax, however, is part of why I find it aesthetically displeasing. > Which is a good thing in my eyes. Well, yes, but it means that when you lay it out the way I was proposing, you had two levels of indentation. With the way you're using, it's a lot cleaner. > I see your point but remain not liking the proposal. Do you mean you see that there is a problem in the language that needs fixing, but you just don't like this fix? Would you be open to a modified version of the proposal? Is it an aesthetic objection, or more philosophical? From ok at cs.otago.ac.nz Tue Sep 22 22:20:53 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Sep 22 21:59:24 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <3303cb473f3ccdc5f54031a4d0582bc9.squirrel@mail.shareyourgifts.net> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> <3303cb473f3ccdc5f54031a4d0582bc9.squirrel@mail.shareyourgifts.net> Message-ID: <49F12E08-0E9E-42C5-832A-03973D3751E6@cs.otago.ac.nz> On Sep 23, 2009, at 12:24 PM, James Hartzell wrote: >> Well, look at code like this: > > wrapParens str = concat [ > "(", > str, > ")" > ] I just did. I'd write it as wrap_parens s = "(" ++ s ++ ")" although I wouldn't use that name, because it's not the parentheses that are wrapped, it's s. > First off, there is a serious issue with the commas. > You should at least > be allowed to have a comma after the last element, a la Python. Oh, I agree about that. I've written an Erlang Extension Proposal for Erlang about that. > concat [ > "(", > str, > ")" -- (oops, no comma!) > lineEnd -- forgot I needed this > ] "(" ++ str ++ ")" ++ line_end I'm actually quite serious here. Using infix ++ we have the SAME problem about missing ++ as we do about mssing , After all, someone might have started with ( "(" ++ str ++ ")" ) and ended up with ( "(" ++ str ++ ")" -- (oops, no ++!) lineEnd -- forgot I needed this ) I asked for the trailing comma in Erlang for _social_ reasons, not because I believed it would fix all problems of this type. > And as to the "simplifying your code" idea: however "pure" your code > is, > you will regularly have to embed lists of things in it (ADTs, export > lists, data from the domain). And unless you're claiming it is *almost > always bad style to have code looking like (from the proposal): > > main = do > a <- getChar > bracket_ > (enter a) > (exit a) > (do > putChar a > putStrLn "hello") The thing about toy examples is that they are toy size. On an example this size, we don't NEED fancy new stuff. Actually, I'd write main = getChar >>= \a -> bracket_ (enter a) (exit a) (putChar a >> putStrLn "hello") so even _with_ this proposal, I'd still need exactly the same parentheses. One thing I might do is this: enter_exit_bracket a body = bracket_ (enter a) (exit a) body and then main = getChar >>= \a -> enter_exit_bracket a (putChar a >> putStrLn "hello") because it looks very much as if enter and exit exist only to be passed (with suitable parameters) to bracket_. > > > But I would *still* rather have: > with a = bracket_ $# > enter a > exit a > > Layout is easier to read than parentheses. It all depends on size (small things being easy pretty much no matter what you do) and tools (tools where you click just inside parentheses and the bracketed thing lights up, like the traditional Smalltalk interface make parentheses very very easy to read). > > In summary, I have to spend a good portion of my time coding Haskell > dealing with the fact that I have a lot of {'s, ['s, and ,'s to keep > track > of, and they rarely fit on one line (records, ADTs, lists). I have to > spend a significant amount of my coding time finagling the layout to > look > sensible, and I don't think anyone would claim that I just shouldn't > use > records or ADTs. For what it's worth, the editor I normally use has an "add new element to list" command. Where I'm coming from is this: I do not find meaningless jumbles of special characters combined with overloaded white space readable. It would be so much better if we could discuss a _real_ example. From qdunkan at gmail.com Tue Sep 22 23:04:49 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Tue Sep 22 22:43:07 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <49F12E08-0E9E-42C5-832A-03973D3751E6@cs.otago.ac.nz> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> <3303cb473f3ccdc5f54031a4d0582bc9.squirrel@mail.shareyourgifts.net> <49F12E08-0E9E-42C5-832A-03973D3751E6@cs.otago.ac.nz> Message-ID: <2518b95d0909222004n1f70ab48h18bb5a7f5af148da@mail.gmail.com> > It would be so much better if we could discuss a _real_ > example. Or implement one. Unlike some proposals, this could be implemented with a preprocessor and -F -pgmF, right? As far as the parsing job, I don't know how hard this would be to plug into the haskell parsing library, but in case it is hard, then improving the library to handle layout extensions would be a nice side-effect even if the preprocessor never became widely popular. From daniel.is.fischer at web.de Tue Sep 22 23:06:25 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 22 22:45:53 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <178330b7b968313a3ff0e1f3bea29567.squirrel@mail.shareyourgifts.net> References: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> <200909230332.56203.daniel.is.fischer@web.de> <178330b7b968313a3ff0e1f3bea29567.squirrel@mail.shareyourgifts.net> Message-ID: <200909230506.25742.daniel.is.fischer@web.de> Am Mittwoch 23 September 2009 04:06:11 schrieb Jimmy Hartzell: > Daniel Fischer wrote: > > Or, what I do: > > > > concat > > [ "(" > > , str > > , ")" > > ] > > This is a lot better, true, but it still takes a lot of typing, and the Huh? Per line it's two keystrokes more than with the accessible layout proposal. That's not a lot. > first element is now special-cased, preventing easy copy-and-paste Making it slightly harder. Copy-Paste-Cursor to beginning-delete-comma. No big deal. Besides, how often does one need to copy the beginning of one list into the middle of another? > (although, admittedly, much less opportunity for mistake). On a more > philosophical level, the signals used by the humans still are different > from the signals used by the computer, which leads me to suspect such a > system could still cause confusion. I don't think so. The dominant factor to the human eye (at least to mine) is the layout. The commas are rather unobtrusive and go almost unnoticed. > > > And that is avoided, because a missing comma leaps to the eye. > > True. Drawing this much attention to syntax, however, is part of why I > find it aesthetically displeasing. To me, it doesn't draw attention to syntax, only to syntax errors. When each line has its comma at the beginning, all is fine. When one line lacks the comma, it looks different and only then spring the commas to attention. Of course, it may be different for you. > > > Which is a good thing in my eyes. > > Well, yes, but it means that when you lay it out the way I was proposing, > you had two levels of indentation. With the way you're using, it's a lot > cleaner. > > > I see your point but remain not liking the proposal. > > Do you mean you see that there is a problem in the language that needs > fixing, but you just don't like this fix? I don't consider it a problem in the language. For me it works fine as is. But I can understand that if > In summary, I have to spend a good portion of my time coding Haskell > dealing with the fact that I have a lot of {'s, ['s, and ,'s to keep track > of, and they rarely fit on one line (records, ADTs, lists). I have to > spend a significant amount of my coding time finagling the layout to look > sensible, there is reason to desire something that would simplify the process. > Would you be open to a modified version of the proposal? Maybe. I haven't formed an opinion yet. > Is it an aesthetic objection, or more philosophical? On an aesthetic level, I find #( and #[ absolutely terrible. Opening a parenthesis (or bracket) and not closing it just screams "WRONG!!!" to me. On the philosophical side, I'm not fundamentally opposed to syntax sugar, but I think it should be added sparingly. I don't think there is sufficient reason to add this sugar, but if many argue that there is, I would accept such an addition (just, please don't use #( and #[). From jim at shareyourgifts.net Tue Sep 22 23:46:47 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 22 23:25:05 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: <30aa6d21fcf46921a08d517ad1c4e55d.squirrel@mail.shareyourgifts.net> Richard O'Keefe wrote: > After all, someone might have started with > ( > "(" ++ > str ++ > ")" > ) > and ended up with > ( > "(" ++ > str ++ > ")" -- (oops, no ++!) > lineEnd -- forgot I needed this > ) > > I asked for the trailing comma in Erlang for _social_ reasons, > not because I believed it would fix all problems of this type. What do you mean, for social reasons? And are there any projects/feature requests to add the trailing comma to ghc? As for "all problems of this type", I agree in theory, but often enough, for an operator @@, you can use foldl1 (@@) [...] and reduce it to the trailing comma problem (notable exceptions include (.) and ($) and other operators where the type is different for the intermediate return values -- and this, I take it, is why '$#' is in the proposal). If I need to use 'a @@ b @@ c' for any operator @@, I rewrite it with a fold (if possible), because I find it more readable to not repeat the operator over and over again. I find lists more semantically appealing in this situation: you really are listing things. > Actually, I'd write > > main = > getChar >>= \a -> > bracket_ (enter a) (exit a) (putChar a >> putStrLn "hello") > > so even _with_ this proposal, I'd still need exactly the same > parentheses. Doing monads without do-notation gets me into precedence trouble pretty quickly -- I find myself adding lots and lots of parentheses, until it ends up looking like Lisp (which I've always found hard on the eyes, keeping track of how many layers you have -- indentation is better for this, in my opinion). The fact that $ can't be used for the last expression of the bracket_ is an example of the precedence trouble I get into. I agree that this proposal makes a lot less sense if you don't also use do-notation. > Where I'm coming from is this: > I do not find meaningless jumbles of special characters > combined with overloaded white space readable. I find the combination of characters very meaningful and intuitive, especially if '(#' is chosen over '#(': use an # if you want to put a list on separate lines (which you'd lay out like that anyway: why not give the compiler some extra knowledge), and don't use it if it fits on the same line. I don't see how this is all that revolutionary, especially as we already have whitespace-significant and non-whitespace-significant versions of 'case', 'do', etc. I don't even see it as syntactic sugar, but more as an alternative syntax -- with the exception of '$#' it parses pretty much directly to the same tree, does it not? It's just changing what's significant. I am not at all committed to the specifics. Would it be better if there were keywords like 'list#', 'tuple#', or maybe '(#)', '[#]' etc? I would suggest using colon like Python, except for it's taken by the (:) operator. I guess where I'm coming from is: I don't like my expressions to be full of parentheses or hard-to-track operator precedences, and find it harder to read, to write, and to maintain, even for toy examples like the ones we've been discussing. From ok at cs.otago.ac.nz Wed Sep 23 00:01:10 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Tue Sep 22 23:39:48 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <2518b95d0909222004n1f70ab48h18bb5a7f5af148da@mail.gmail.com> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> <3303cb473f3ccdc5f54031a4d0582bc9.squirrel@mail.shareyourgifts.net> <49F12E08-0E9E-42C5-832A-03973D3751E6@cs.otago.ac.nz> <2518b95d0909222004n1f70ab48h18bb5a7f5af148da@mail.gmail.com> Message-ID: On Sep 23, 2009, at 3:04 PM, Evan Laforge wrote: >> It would be so much better if we could discuss a _real_ >> example. > > Or implement one. I really did mean EXAMPLES. Examples of code which would be improved *more* by the proposal than by adopting an alternative style within the existing language. Let's not forget what the proposal actually _is_. It is that "#(" "#[" "#$" and "#" should become magic tokens such that #( {a;b;c} is read as (a,b,c) #[ {a;b;c} is read as [a,b,c] f #$ {a;b;c} is read as f (a) (b) (c) # {a;b;c} is read as {a,b,c} [http://www.haskell.org/haskellwiki/Accessible_layout_proposal] Are you not troubled by the inconsistencies here? Why isn't the last case #{ to match #( and #[? Why does #$ add extra parentheses but not the others? Are you not troubled by the fact that it breaks the automatic bracket matching in editors like Vim, Emacs, XCode, ...? I _can_ hack on Emacs if I have to, but I _can't_ hack on XCode. In fact it breaks bracket matching in two ways: - clicking just after #( doesn't select the tuple the way that clicking just after ( does - the excess imbalanced bracket wrecks matching for anything that includes an #( or #[ That's a *lot* to give up for less readable code! In effect, the proposal is that there should be a context- sensitive overloading of to mean - nothing (existing case) - semicolon (existing case) - >> or >>= (existing case) - comma (for #( and #[ and #) - nothing, except parentheses magically go somewhere else That's too many overloadings for me. 'do' was already too many overloadings for me to be comfortable with, which is one reason why I avoid it. On small examples, I find no advantage. Let's see a real medium-size example. The heavy costs that I can see might just be overwhelmed by advantages in real use. From ok at cs.otago.ac.nz Wed Sep 23 00:31:07 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Sep 23 00:09:39 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <4a5b1f2f7b73cddf4866b85d28251a21.squirrel@mail.shareyourgifts.net> References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> <3303cb473f3ccdc5f54031a4d0582bc9.squirrel@mail.shareyourgifts.net> <49F12E08-0E9E-42C5-832A-03973D3751E6@cs.otago.ac.nz> <4a5b1f2f7b73cddf4866b85d28251a21.squirrel@mail.shareyourgifts.net> Message-ID: On Sep 23, 2009, at 3:40 PM, James Hartzell wrote: >> I asked for the trailing comma in Erlang for _social_ reasons, >> not because I believed it would fix all problems of this type. > > What do you mean, for social reasons? The proposal is http://www.erlang.org/eeps/eep-0021.html The abstract says "Allow an extra comma at the end of a list or tuple. Darren New proposed this change; Richard O'Keefe, who doesn't like it very much, wrote it up as an EEP." Later on, we find the text "I don't actually feel any need for this proposal; I believe that the answer is better tool support. However, many people are wedded to their tools, even more than their programming languages. Darren New is not the only one to have asked for it, and with about 1 SLOC in 110 of the Erlang/OTP sources reflecting a list or tuple where this feature could have been used, it's very much a low cost high public appreciation feature." It was a feature that people *wanted* because they were used to in other languages and it could be added at comparatively low cost (there's only one Erlang implementation worth bothering about) without breaking existing tools. Adding it would please many existing and potential Erlang programmers without XXXXing off too many others (you don't _have_ to write the extra comma, and it's not that obtrusive when you read other people's code), and it would remove some complaints and criticisms from the mailing list, so, social reasons. I don't believe it solves any problem that can't be better solved any other way, but at least optional trailing commas don't *hurt* anything. This might actually be different in Haskell, which allows things like (,,). You can't add a trailing comma here without breaking things. The #( #[ #$ # proposal, on the other hand, WOULD break things. "#" is currently an 'ascSymbol', so the character sequences #( and #[ may occur in legal Haskell code. infix # x # y = (x,y) foo x y = x #( y ) bar x z = x #[ z ] > As for "all problems of this type", I agree in theory, but often > enough, > for an operator @@, you can use foldl1 (@@) [...] and reduce it to the > trailing comma problem (notable exceptions include (.) and ($) and > other > operators where the type is different for the intermediate return > values > -- and this, I take it, is why '$#' is in the proposal). I am a bit puzzled here. This seems to mean something like "If you take readable code using an operator you can make it less readable, and when you do that you create another problem as well, and an even less readable hack can fix that." "I know an old lady who swallowed a fly..." > I don't see how this is all that revolutionary, I don't think anyone claims that it is. The claims are that it is - not needed - not pleasant to look at - not good for existing syntax-(semi-)aware tools - not backwards compatible with existing code > I am not at all committed to the specifics. Would it be better if > there > were keywords like 'list#', 'tuple#', or maybe '(#)', '[#]' etc? But of course! > > I guess where I'm coming from is: I don't like my expressions to be > full > of parentheses or hard-to-track operator precedences, and find it > harder > to read, to write, and to maintain, even for toy examples like the > ones > we've been discussing. There's no accounting for taste. I find invisible operators much harder to deal with than parentheses. So we agree to differ. Changing the proposal to something that doesn't spoil bracket matching and doesn't break previously legal Haskell' code (note the prime; I'm not fighting old battles again) would make a huge difference. I still wouldn't _like_ it, but wouldn't have such strong reasons to _oppose_ it. For what it's worth, I've used an experimental language where - immediately after ( [ { or an infix or prefix operator, newlines were treated like any other white space - in other contexts, newlines inside ( [ were treated as commas - in other contexts, newlines were treated as semicolons - trailing commas and semicolons were allowed In Haskell terms, this would mean that ( 1 2 3 ) meant (1,2,3) and [ 1 2 3 ] meant [1,2,3] and 'do' and 'case' worked as now. By adding f $$ (x,y) = f x y f $$ (x,y,z) = f x y z f $$ (x,y,z,a) = f x y z a ... you could also have f $( 1 2 3 ) meaning f 1 2 3. I am aware that this is not backwards compatible with existing code, and I am not proposing this for adoption. From dm.maillists at gmail.com Wed Sep 23 01:02:24 2009 From: dm.maillists at gmail.com (Daniel McAllansmith) Date: Wed Sep 23 00:41:01 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <200909230506.25742.daniel.is.fischer@web.de> References: <12d2ea38a3d0df730a94483015db546d.squirrel@mail.shareyourgifts.net> <178330b7b968313a3ff0e1f3bea29567.squirrel@mail.shareyourgifts.net> <200909230506.25742.daniel.is.fischer@web.de> Message-ID: <200909231702.24545.dm.maillists@gmail.com> On Wed, 23 Sep 2009 15:06:25 Daniel Fischer wrote: > Am Mittwoch 23 September 2009 04:06:11 schrieb Jimmy Hartzell: > > Daniel Fischer wrote: > > > Or, what I do: > > > > > > concat > > > [ "(" > > > , str > > > , ")" > > > ] > > > > This is a lot better, true, but it still takes a lot of typing, and the > > Huh? Per line it's two keystrokes more than with the accessible layout > proposal. That's not a lot. > > > first element is now special-cased, preventing easy copy-and-paste > > Making it slightly harder. Copy-Paste-Cursor to beginning-delete-comma. > No big deal. Besides, how often does one need to copy the beginning of one > list into the middle of another? Or you could use: concat ( : "(" : str : ")" :[]) Though you do sometimes have to bracket an element that you wouldn't otherwise have to, eg concat ( : "(" : str : ('a':'b':[]) : ")" :[]) From jim at shareyourgifts.net Wed Sep 23 01:31:48 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Wed Sep 23 01:10:06 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: > Am Mittwoch 23 September 2009 04:06:11 schrieb Jimmy Hartzell: >> Daniel Fischer wrote: >> > Or, what I do: >> > >> > concat >> > [ "(" >> > , str >> > , ")" >> > ] You're right: my objections to this seem mostly to be matters of taste -- as I think about it, I find fewer and fewer practical reasons for disliking it. I still would prefer it if the proposal were implemented (and I would modify it so brackets weren't mismatched), and I'm still interested in implementing it, if only so I (and others) can do programming projects both ways and see if it actually makes a big difference. From jim at shareyourgifts.net Wed Sep 23 03:11:58 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Wed Sep 23 02:50:16 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: <32e89040b72e9507a59ae35759ac6e0e.squirrel@mail.shareyourgifts.net> > On Sep 23, 2009, at 3:04 PM, Evan Laforge wrote: > Let's not forget what the proposal actually _is_. > It is that "#(" "#[" "#$" and "#" should become magic > tokens such that > > #( {a;b;c} is read as (a,b,c) > #[ {a;b;c} is read as [a,b,c] > f #$ {a;b;c} is read as f (a) (b) (c) > # {a;b;c} is read as {a,b,c} > > [http://www.haskell.org/haskellwiki/Accessible_layout_proposal] > > Are you not troubled by the inconsistencies here? I am indeed. I concede that the proposal in its present form is completely unacceptable. How about this (which I believe to be backwards compatible): * For data-type declarations, simple indentation may be used: data Tree a Leaf a Branch (Tree a) (Tree a) deriving Show -- this bit may be overkill Read * For records, simple indentation is extended: data Tree a = Branch left::a right::a Leaf a * Export lists are similarly without extra symbols: module Foo Zap Con1 Con2 Con3 mkZap count where * [~] and (~) introduce newline-separated lists and tuples, respectively: wrapWithParens str = concat [~] "(" str ")" Ideally, I'd want something even more light-weight, but I can't think of anything backwards-compatible that satisfies the bracket-matching requirement (which I also care about, as I don't particularly want to hack my editor for this layout proposal either). * For the magic uncurried-function operator, I don't want to have the monstrosity of $$(~). A simple ~ should do here: main = between_ ~ enter a exit a body a This is also allowable in data declarations: data Tree a = Branch ~ Tree a Tree a Leaf a I'd also be interested in knowing if any of these seem interesting separately. I would personally use this new layout for virtually all datatypes, records, and long (where long = (> 2) . length) lists and tuples. I would probably use the '~' notation heavily in writing parsec parsers (the following based loosely off of code from a compiler for a toy programming language): classDeclaration = LiftM4 ClassDeclaration ~ scopeDesignator >>~ keyword "class" typeNameDeclaration option rootClass $ parens qualifiedConstantName -- look, no parens list fieldVariable >>~ operator ";" I like how this version allows me to plainly list the components of a ClassDeclaration. Certainly, if I was actually designing a programming language for writing parsers in, I wouldn't require a bunch of parentheses for productions like this. The fact that, with this proposal, Haskell would no longer require them I take as a good sign. (>>~) is defined as per an article I can't seem to find right now: a >>~ b = do res <- a b return res Furthermore, a function 'if_ a b c = if a then b else c' would be a lot more natural to use. I prefer programming languages where an if-function is as natural to use as the programming language's native 'if', especially those that have a function to implement the functionality of 'if', as those languages are usually the most flexible in their control structures (in Haskell, the only awkwardness with 'if_' at present is syntactic): if_ $ a < 3 ~ errorResult "insufficient allocations" Right $ f b c I feel that with the existence of ($), do notation, the significant whitespace for both do-notation and case statements, Haskell already leans in the direction of allowing for minor awkwardness and inconsistency to eliminate parentheses and to make the structure of the program easily visibly accessible. Jimmy Hartzell From colinpauladams at googlemail.com Wed Sep 23 03:23:09 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Wed Sep 23 03:01:28 2009 Subject: [Haskell-cafe] How to install GD library on Mac OSX? In-Reply-To: References: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> Message-ID: <1afdeaec0909230023v3489235es7d0c0062c20d41e3@mail.gmail.com> 2009/9/22 Brandon S. Allbery KF8NH : > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Sep 22, 2009, at 13:44 , Colin Adams wrote: >> >> It needs some missing C libraries - gd, png, jpeg, fontconfig and >> freetype. >> Does anyone know what to do to install these on OSX? > > > Customarily, Fink or MacPorts. > > Several of those *are* installed on OSX by default (at least Leopard and > up); if they're not being found, make sure you have installed the latest > XCode and Apple's X11 (the latter should only matter for Tiger and earlier). > ?You may also want the latest X11 from http://xquartz.macosforge.org. Well I tried using macports to install GD2. That was hard work (it doesn't resolve dependencies for you). But it makes no difference. Cabal install gd still fails saying gd.h is missing, and the libraries gd, png, jpeg, fonconfig and freetype, as before. -- Colin Adams Preston, Lancashire, ENGLAND From bulat.ziganshin at gmail.com Wed Sep 23 03:16:24 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 23 03:02:08 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <32e89040b72e9507a59ae35759ac6e0e.squirrel@mail.shareyourgifts.net> References: <32e89040b72e9507a59ae35759ac6e0e.squirrel@mail.shareyourgifts.net> Message-ID: <204126547.20090923111624@gmail.com> Hello Jimmy, Wednesday, September 23, 2009, 11:11:58 AM, you wrote: > How about this (which I believe to be backwards compatible): brilliant! -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From judah.jacobson at gmail.com Wed Sep 23 03:29:58 2009 From: judah.jacobson at gmail.com (Judah Jacobson) Date: Wed Sep 23 03:08:37 2009 Subject: [Haskell-cafe] How to install GD library on Mac OSX? In-Reply-To: <1afdeaec0909230023v3489235es7d0c0062c20d41e3@mail.gmail.com> References: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> <1afdeaec0909230023v3489235es7d0c0062c20d41e3@mail.gmail.com> Message-ID: <6d74b0d20909230029s30c5cd09h361ca3c3bdc5fb74@mail.gmail.com> On Wed, Sep 23, 2009 at 12:23 AM, Colin Adams wrote: > 2009/9/22 Brandon S. Allbery KF8NH : >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On Sep 22, 2009, at 13:44 , Colin Adams wrote: >>> >>> It needs some missing C libraries - gd, png, jpeg, fontconfig and >>> freetype. >>> Does anyone know what to do to install these on OSX? >> >> >> Customarily, Fink or MacPorts. >> >> Several of those *are* installed on OSX by default (at least Leopard and >> up); if they're not being found, make sure you have installed the latest >> XCode and Apple's X11 (the latter should only matter for Tiger and earlier). >> ?You may also want the latest X11 from http://xquartz.macosforge.org. > > Well I tried using macports to install GD2. That was hard work (it > doesn't resolve dependencies for you). But it makes no difference. > Cabal install gd still fails saying gd.h is missing, and the libraries > gd, png, jpeg, fonconfig and freetype, as before. You probably want to use (if you haven't tried it already): cabal install gd --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib Best, -Judah From colinpauladams at googlemail.com Wed Sep 23 03:37:47 2009 From: colinpauladams at googlemail.com (Colin Adams) Date: Wed Sep 23 03:16:06 2009 Subject: [Haskell-cafe] How to install GD library on Mac OSX? In-Reply-To: <6d74b0d20909230029s30c5cd09h361ca3c3bdc5fb74@mail.gmail.com> References: <1afdeaec0909221044t7eb3e7aat86417250493c46de@mail.gmail.com> <1afdeaec0909230023v3489235es7d0c0062c20d41e3@mail.gmail.com> <6d74b0d20909230029s30c5cd09h361ca3c3bdc5fb74@mail.gmail.com> Message-ID: <1afdeaec0909230037ke2bb7dp8c2c73b3df0feacf@mail.gmail.com> Thanks Judah. That was all it took. :-) 2009/9/23 Judah Jacobson : > On Wed, Sep 23, 2009 at 12:23 AM, Colin Adams > wrote: >> 2009/9/22 Brandon S. Allbery KF8NH : >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> On Sep 22, 2009, at 13:44 , Colin Adams wrote: >>>> >>>> It needs some missing C libraries - gd, png, jpeg, fontconfig and >>>> freetype. >>>> Does anyone know what to do to install these on OSX? >>> >>> >>> Customarily, Fink or MacPorts. >>> >>> Several of those *are* installed on OSX by default (at least Leopard and >>> up); if they're not being found, make sure you have installed the latest >>> XCode and Apple's X11 (the latter should only matter for Tiger and earlier). >>> ?You may also want the latest X11 from http://xquartz.macosforge.org. >> >> Well I tried using macports to install GD2. That was hard work (it >> doesn't resolve dependencies for you). But it makes no difference. >> Cabal install gd still fails saying gd.h is missing, and the libraries >> gd, png, jpeg, fonconfig and freetype, as before. > > You probably want to use (if you haven't tried it already): > > cabal install gd --extra-include-dirs=/opt/local/include > --extra-lib-dirs=/opt/local/lib > > Best, > -Judah > -- Colin Adams Preston, Lancashire, ENGLAND From gue.schmidt at web.de Wed Sep 23 07:29:10 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Sep 23 07:08:02 2009 Subject: [Haskell-cafe] Got it working, now trying to abstract it Message-ID: Hi all, I'm finished with my implementation, an app that analyses financial data for budgeting. But there are no abstractions in my code whatsoever, everything is coded exactly to the point. So now that I'm done I'd like to start it over, this time using far more abstractions than I have, I was thinking along the lines of creating a DSL for it first. The aspects I have to consider are two-fold: ETL-ish - I need to assemble the "records" from a set of csv files BI-ish - I need then to group, filter and aggregate the data. I've come across "How to write a financial contract" S. Peyton Jones in the "fun of programming" and it gives me some ideas on how to go about the BI-ish part of the application. Does anyone know of a DSL example which could fit the bill? G?nther From chris at eidhof.nl Wed Sep 23 08:57:00 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Sep 23 08:35:19 2009 Subject: [Haskell-cafe] Re: Multiple-selection formlet? In-Reply-To: <1afdeaec0909230535r54db4df3w850191424e077b7e@mail.gmail.com> References: <1afdeaec0909210520u77f3b930s4bd1ab157e63fd62@mail.gmail.com> <1afdeaec0909230535r54db4df3w850191424e077b7e@mail.gmail.com> Message-ID: <07D25618-B890-4350-B3AC-9D845E032CE6@eidhof.nl> Hey Colin, Currently, I don't think this is supported. It would help a lot if you could send me a dumbed-down version of your code, I'll file an issue for it on github. Thanks, -chris On 23 sep 2009, at 14:35, Colin Adams wrote: > Just in case you missed it on the cafe. > > ---------- Forwarded message ---------- > From: Colin Adams > Date: 2009/9/21 > Subject: Multiple-selection formlet? > To: Haskell Cafe > > > I can't work out how to get multiple selections delivered from a > formlet. I can add the multiple attribute to get the formlet to allow > the user to make multiple selections, but I only get a single answer > back. This seems inevitable from the type of rawSelect (or select) - > since the list of values to select from is of type [(a, h)] and the > result type is a. > > Am I missing something? > > -- > Colin Adams > Preston, > Lancashire, > ENGLAND > > > > -- > Colin Adams > Preston, > Lancashire, > ENGLAND From chris at eidhof.nl Wed Sep 23 09:06:36 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Sep 23 08:44:55 2009 Subject: [Haskell-cafe] Problem with Text.XHtml.Strict.Formlets.file on Mac OSX In-Reply-To: <1afdeaec0909212356s7c5c8b99g3c553e0836c728ce@mail.gmail.com> References: <1afdeaec0909212356s7c5c8b99g3c553e0836c728ce@mail.gmail.com> Message-ID: Hey Colin, The code looks OK to me. Are you sure you are setting the right method for your form? It's the third component of the tuple returned by the runFormState. Thanks, -chris On 22 sep 2009, at 08:56, Colin Adams wrote: > I'm writing a form that involves picking a file to upload, and so uses > Text.XHtml.Strict.Formlets.file. The form displays OK, but when I > click the Browse button, and select a file from the dialog (no matter > what the file type), and then click on the Submit button, I get an > error: > > "fval[2] is not a file" > > I haven't added any validation yet. > > The generated html looks ok to me: > > > > This is on my laptop running Mac OSX. I can't test it on Linux until I > get home at the weekend, so I don't know if I've made a silly error in > my coding, but it is very simple: > > imageInputForm = F.plug (\xhtml -> X.p << (X.label << "Image file:") > +++ xhtml) F.file > > Are there any known problems with the file formlet? Might it be OSX > specific? > -- > Colin Adams > Preston, > Lancashire, > ENGLAND > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From chris at eidhof.nl Wed Sep 23 09:46:40 2009 From: chris at eidhof.nl (Chris Eidhof) Date: Wed Sep 23 09:24:58 2009 Subject: [Haskell-cafe] Problem with Text.XHtml.Strict.Formlets.file on Mac OSX In-Reply-To: <1afdeaec0909230635r6ac88178l1333241bec942912@mail.gmail.com> References: <1afdeaec0909212356s7c5c8b99g3c553e0836c728ce@mail.gmail.com> <1afdeaec0909230635r6ac88178l1333241bec942912@mail.gmail.com> Message-ID: OK, the trick is to set the attribute enctype="multipart/form-data" on the form whenever your form contains a file upload item. Using the third parameter you can detect if this is the case. This is typical of using file-upload fields in web programming and independent of the formlets. It's also covered in the Happstack tutorial [1] and in the HTML form spec [2]. Good luck, -chris [1] http://tutorial.happstack.com/tutorial/file-uploads [2] http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4 On 23 sep 2009, at 15:35, Colin Adams wrote: > I'm not sure, but the other components of the form work (before I > added the file bit, that is), so they will all be using the same > method. > > I'm using a generic form-handling function named withForm that I got > from one of the examples - this code appears to ignore the third > component of the tuple. > > Note that I don't really understand all of this yet. > > 2009/9/23 Chris Eidhof : >> Hey Colin, >> >> The code looks OK to me. Are you sure you are setting the right >> method for >> your form? It's the third component of the tuple returned by the >> runFormState. >> >> Thanks, >> >> -chris >> >> On 22 sep 2009, at 08:56, Colin Adams wrote: >> >>> I'm writing a form that involves picking a file to upload, and so >>> uses >>> Text.XHtml.Strict.Formlets.file. The form displays OK, but when I >>> click the Browse button, and select a file from the dialog (no >>> matter >>> what the file type), and then click on the Submit button, I get an >>> error: >>> >>> "fval[2] is not a file" >>> >>> I haven't added any validation yet. >>> >>> The generated html looks ok to me: >>> >>> >>> >>> This is on my laptop running Mac OSX. I can't test it on Linux >>> until I >>> get home at the weekend, so I don't know if I've made a silly >>> error in >>> my coding, but it is very simple: >>> >>> imageInputForm = F.plug (\xhtml -> X.p << (X.label << "Image file:") >>> +++ xhtml) F.file >>> >>> Are there any known problems with the file formlet? Might it be OSX >>> specific? >>> -- >>> Colin Adams >>> Preston, >>> Lancashire, >>> ENGLAND >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > > -- > Colin Adams > Preston, > Lancashire, > ENGLAND From ekirpichov at gmail.com Wed Sep 23 09:46:44 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Sep 23 09:25:05 2009 Subject: [Haskell-cafe] An encoding of parametricity in Agda Message-ID: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> Hi, I've discovered the following post on the internets: http://gelisam.blogspot.com/2009/09/samuels-really-straightforward-proof-of.html It contains an ingenious (to my mind) encoding of parametricity in Agda that makes the Free Theorems a trivial consequence. I've tried to formalize it in Coq, but, as of now, with no success. -- Eugene Kirpichov Web IR developer, market.yandex.ru From haskell at gimbo.org.uk Wed Sep 23 09:59:55 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Wed Sep 23 09:38:18 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: <4AB735EE.1050103@van.steenbergen.nl> References: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> <4AB5BEAD.90001@ugcs.caltech.edu> <4AB735EE.1050103@van.steenbergen.nl> Message-ID: <8955AB5E-C667-4115-BA3C-5BBCF83B31C3@gimbo.org.uk> On 21 Sep 2009, at 09:14, Martijn van Steenbergen wrote: > > Michael Shulman wrote: >> Is there a way to make it automatically update a single contents page >> with links to the documentation of all installed packages? > > See: > http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/ > focus=53560 > http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/ > focus=53572 Seeing this today (I'm catching up on haskell-cafe!) made me want this too, so I rolled my own. Main nice feature: I pointed it at the hackage CSS file, so it's pleasingly familiar/pretty. Anything that doesn't have a 'html/index.html' in it gets indexed separately at the end. I used Python. I was going for quick and dirty. Sorry, Dijkstra! Haskell next time, I promise! :-) More info, screenshots, and code here: http://gimbo.org.uk/blog/2009/09/23/generating-an-index-of-haskell-haddock-docs-automatically/ Best, -Andy From monnier at iro.umontreal.ca Wed Sep 23 11:09:27 2009 From: monnier at iro.umontreal.ca (Stefan Monnier) Date: Wed Sep 23 10:48:16 2009 Subject: [Haskell-cafe] Re: accessible layout proposal? References: <9e4537672b00ed99016f9f8a25a34097.squirrel@mail.shareyourgifts.net> Message-ID: > http://www.haskell.org/haskellwiki/Accessible_layout_proposal I see two main problems with such a proposal (other than the particular details of the syntax chosen for it): - layout is not very well supported by most of the text editors, contrary to parens/brackets/braces. - more importantly: it introduces a new syntax that doesn't replace the old one, so it makes the language more complex. Compare that with the layout for `do', `let', `where' and `case' which is fine because it's used 99% of the time and the alternative syntax is the same for each one of them (simply add {;;;}). So I'd be OK with a switch from data foo = Toto | Tata Int | Titi to data foo = { Toto ; Tata Int ; Titi } and data foo = Toto Tata Int Titi and similarly for module import lists, but only if it comes with a deprecation of the current syntax. Stefan From pitekus at gmail.com Wed Sep 23 11:19:59 2009 From: pitekus at gmail.com (=?UTF-8?Q?Grzegorz_Chrupa=C5=82a?=) Date: Wed Sep 23 10:58:15 2009 Subject: [Haskell-cafe] Bug in writeArray? Message-ID: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> Hi all, This seems like a bug in the implementation of writeArray: when passed an out-of-range index it silently writes to an incorrect index in the array. -- import Data.Array.IO import Data.Array.Unboxed main = do let (l,u) = ((0,10),(20,20)) marr <- newArray (l,u) 0 :: IO (IOUArray (Int,Int) Int) let badi = (10,9) print (inRange (l,u) badi) writeArray marr badi 1 arr <- freeze marr :: IO (UArray (Int,Int) Int) print . filter ((/=0) . snd) . assocs $ arr -- Grzegorz From bulat.ziganshin at gmail.com Wed Sep 23 11:36:41 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 23 11:15:09 2009 Subject: [Haskell-cafe] Bug in writeArray? In-Reply-To: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> References: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> Message-ID: <766034098.20090923193641@gmail.com> Hello Grzegorz, Wednesday, September 23, 2009, 7:19:59 PM, you wrote: > This seems like a bug in the implementation of writeArray: when passed > let (l,u) = ((0,10),(20,20)) writeArray computes raw index (from 0 to total number of array elements) and check that this index is correct. with multi-dimensional arrays this approach may lead to wrong results, as you mentioned. it's known problem that isn't fixed for a long time probably due to efficiency cautions. the error is here: data Ix i => Array i e = Array !i -- the lower bound, l !i -- the upper bound, u !Int -- a cache of (rangeSize (l,u)) -- used to make sure an index is -- really in range (Array# e) -- The actual elements (!) :: Ix i => Array i e -> i -> e arr@(Array l u n _) ! i = unsafeAt arr $ safeIndex (l,u) n i safeIndex :: Ix i => (i, i) -> Int -> i -> Int safeIndex (l,u) n i = let i' = unsafeIndex (l,u) i in if (0 <= i') && (i' < n) then i' else error "Error in array index" obviously, safeIndex should use inRange call instead -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From kowey at darcs.net Wed Sep 23 11:36:51 2009 From: kowey at darcs.net (Eric Kow) Date: Wed Sep 23 11:15:17 2009 Subject: [Haskell-cafe] ANNOUNCE: Darcs Hacking Sprint - 14-15 November Vienna Message-ID: <20090923153650.GI11779@brighton.ac.uk> Dear Haskellers, The Darcs Team will soon be hosting its third hacking sprint. Details ------- When : 14-15 November 2009 Where: University of Technology, Vienna, Austria Who : Anybody who wants to hack on Darcs (or Camp, Focal, SO6, etc) Beginners especially welcome! Why : Darcs aims to have bi-annual hacking sprints so that we can get together on a regular basis, hold design discussions, hack up a storm and have a lot fun. What : We plan to put some finishing touches on Darcs-2.4. Darcs 2.4 is a pretty exciting release because we expect it to offer nice performance enhancements from Petr's Google Summer of Code Project, and also a nice new 'hunk splitting' feature. We also intend to set aside at least one Darcs hacker for mentoring beginners, so if you're new to Haskell or to Darcs hacking, here's a good chance to plunge in and start working on a real world project. How: Add yourself to http://wiki.darcs.net/Sprints/2009-11 or email me to let me know you're interested! Thanks ------ Thanks to our local team David Markvica and Benedikt Huber for generously offering to host this event! Thanks also to donors from the last fundraising drive. We'll be using that money to help Darcs hackers get to Vienna. Supporting Darcs ---------------- Darcs is a very happy member of the Software Freedom Conservancy. Among other things, the Software Freedom Conservancy makes it easy for open source projects to raise funds and hold assets (as part of a legal entity). For more information on supporting Darcs, see http://darcs.net/donations.html See you there! -- Eric Kow PGP Key ID: 08AC04F9 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: Digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090923/0392ea77/attachment.bin From taralx at gmail.com Wed Sep 23 12:21:00 2009 From: taralx at gmail.com (Taral) Date: Wed Sep 23 11:59:40 2009 Subject: [Haskell-cafe] Re: [Coq-Club] An encoding of parametricity in Agda In-Reply-To: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> References: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> Message-ID: On Wed, Sep 23, 2009 at 6:46 AM, Eugene Kirpichov wrote: > It contains an ingenious (to my mind) encoding of parametricity in > Agda that makes the Free Theorems a trivial consequence. Perhaps I don't understand Agda very well, but I don't see parametricity here. For one, there's no attempt to prove that: forall (P Q : forall a, a -> a), P = Q. which is what parametricity means to me. -- Taral "Please let me know if there's any further trouble I can give you." -- Unknown From ekirpichov at gmail.com Wed Sep 23 12:30:28 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Wed Sep 23 12:08:44 2009 Subject: [Haskell-cafe] Re: [Coq-Club] An encoding of parametricity in Agda In-Reply-To: References: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> Message-ID: <5e0214850909230930y1a58d721u6c51935f4f9b9db0@mail.gmail.com> Under parametricity, I mean the Reynolds Abstraction Theorem, from which free theorems follow. The encoding allows one to prove the theorem for any particular function by implementing this function in terms of "relativized" types. The type of the relativized function is precisely an instance of Reynolds theorem for it, and its implementation is a proof. 2009/9/23 Taral : > On Wed, Sep 23, 2009 at 6:46 AM, Eugene Kirpichov wrote: >> It contains an ingenious (to my mind) encoding of parametricity in >> Agda that makes the Free Theorems a trivial consequence. > > Perhaps I don't understand Agda very well, but I don't see > parametricity here. For one, there's no attempt to prove that: > > forall (P Q : forall a, a -> a), P = Q. > > which is what parametricity means to me. > > -- > Taral > "Please let me know if there's any further trouble I can give you." > ? ?-- Unknown > -- Eugene Kirpichov Web IR developer, market.yandex.ru From dons at galois.com Wed Sep 23 12:35:50 2009 From: dons at galois.com (Don Stewart) Date: Wed Sep 23 12:16:19 2009 Subject: [Haskell-cafe] FFMpeg, SDL and Haskell In-Reply-To: <8feb08f70909221505p6aa2569frab79d0297353b34@mail.gmail.com> References: <8feb08f70909221505p6aa2569frab79d0297353b34@mail.gmail.com> Message-ID: <20090923163550.GH21213@whirlpool.galois.com> vasyl.pasternak: > Hi all, > > Last few days I was playing with FFI, FFMpeg and Haskell. Currently I am trying > to make this tutorial http://www.dranger.com/ffmpeg/ on Haskell. Now I have > done tutorial 01 and tutorial 02 (show video stream in SDL window). > > The third tutorial is about audio, and I found that audio doesn't supported in > SDL bindings completely. So I'd like to fill this gap, but I don't know where > to get latest version and to whom I have to send SDL patches. > > Anyway, does anybody interested in FFMpeg bindings ? Should I put it on Hackage > ? > > The preliminary version I've put on google code: http:// > hs-ffmpeg.googlecode.com/files/hs-ffmpeg-0.2.0.tar.gz, but this is "work on my > PC" version. This is different to http://hackage.haskell.org/package/SDL-mpeg right? If so, *yes* put it on Hackage! From duncan.coutts at worc.ox.ac.uk Wed Sep 23 13:22:13 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 23 13:00:34 2009 Subject: [Haskell-cafe] help with cabal; trying to escape from configuration hell In-Reply-To: References: Message-ID: <1253726533.18961.4722.camel@localhost> On Tue, 2009-09-22 at 17:13 +0200, S. Doaitse Swierstra wrote: > I am trying to run happstack on my Mac, but unfortunately I am getting > error messages as described in: > > http://code.google.com/p/happstack/issues/detail?id=88 > > The cure seems to be to downgrade to network-2.2.0.1, but > unfortunately my installed cabal depends on network-2.2.1.4. > > I tried to re-install happstack using: > > cabal install happstack --reinstall --constraint="network==2.2.0.2" > > but unfortunately the ghc happily reports to link against > network-2.2.1.4: > > ... > Loading package parsec-2.1.0.1 ... linking ... done. > Loading package hsemail-1.3 ... linking ... done. > Loading package network-2.2.1.4 ... linking ... done. > Loading package SMTPClient-1.0.1 ... linking ... done. > Loading package time-1.1.4 ... linking ... done. > ... > > Can someone rescue me? Is that log output from when you are compiling happstack itself (and that snippet is the template haskell code being loaded) or is it when you are loading the final built package in ghci? If it's the TH bit then it appears to be an instance of this bug: http://hackage.haskell.org/trac/ghc/ticket/2555 The problem appears to be that while we compile happstack against network-2.2.0.2, when it comes to the template haskell stuff, it goes and picks up the latest version of network instead. GHC HQ have not been able to reproduce this so it would be useful if we could have more details on what you are finding. In particular a full log of this command would be useful: $ cabal install happstack -v --reinstall --constraint="network==2.2.0.2" Note the -v so that we will see how cabal invokes ghc. Attach the log to the ghc ticket above. Once you've saved the evidence, the workaround is to unregister the later network version, then ghc cannot possibly pick it. Duncan From duncan.coutts at worc.ox.ac.uk Wed Sep 23 13:29:29 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 23 13:07:47 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> Message-ID: <1253726969.18961.4731.camel@localhost> On Tue, 2009-09-22 at 17:08 -0400, Brandon S. Allbery KF8NH wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Sep 22, 2009, at 11:31 , G?nther Schmidt wrote: > > Gtk2hs then complains about running in a multithreaded ghc, ie. one > > with several "real" OS threads. Is it possible to start runghc > > single-threaded? > > > No, but you can unsafeInitGUIForThreadedRTS. If you observe the foot-shooting restrictions (of which the easiest is to not use forkIO). Duncan From jim at shareyourgifts.net Wed Sep 23 14:15:08 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Wed Sep 23 13:53:24 2009 Subject: [Haskell-cafe] accessible layout proposal? Message-ID: <849e33f830bd58c1de174ede059df533.squirrel@mail.shareyourgifts.net> > I am a bit puzzled here. > This seems to mean something like > "If you take readable code using an operator you can > make it less readable, and when you do that you create > another problem as well, and an even less readable hack > can fix that." > > "I know an old lady who swallowed a fly..." This proposal notwithstanding, I find 'concat [a, b, c]' much more readable than (a) ++ (b) ++ (c), especially since the parentheses in the latter might be necessary (or become necessary unexpectedly upon editing), whereas in the former order of operations is never a concern. Furthermore, why repeat the (++) over and over again, when really you are making a *list* of things to add, and should be using a list? From gue.schmidt at web.de Wed Sep 23 14:24:26 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Sep 23 14:02:44 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: <1253726969.18961.4731.camel@localhost> References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> Message-ID: Am 23.09.2009, 19:29 Uhr, schrieb Duncan Coutts : > On Tue, 2009-09-22 at 17:08 -0400, Brandon S. Allbery KF8NH wrote: >> -----BEGIN PGP SIGNED MESSAGE----- >> Hash: SHA1 >> >> On Sep 22, 2009, at 11:31 , G?nther Schmidt wrote: >> > Gtk2hs then complains about running in a multithreaded ghc, ie. one >> > with several "real" OS threads. Is it possible to start runghc >> > single-threaded? >> >> >> No, but you can unsafeInitGUIForThreadedRTS. > > If you observe the foot-shooting restrictions (of which the easiest is > to not use forkIO). > > > Duncan > And exactly herein lies the problem :) I've seen your response to the recent post about gui state, in which you mention your own prefered solution to the problem, ie. that you "post" your state to a channel which is read in a thread. I'm doing the same thing, but I'm also "calling" gui code from within that thread. I figured since the thread itself isn't a separate OS thread it shouldn't be a problem. It seems to work once the app is compiled, but running the code in either ghci or with runghc it crashes. G?nther From vanenkj at gmail.com Wed Sep 23 14:50:24 2009 From: vanenkj at gmail.com (John Van Enk) Date: Wed Sep 23 14:28:40 2009 Subject: [Haskell-cafe] Status of GHC as a Cross Compiler Message-ID: Hi, This may be more appropriate for a different list, but I'm having a hard time figuring out whether or not we're getting a cross compiler in 6.12 or not. Can some one point me to the correct place in Traq to find this information? /jve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090923/ee745d88/attachment.html From alexey.skladnoy at gmail.com Wed Sep 23 15:04:57 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Wed Sep 23 14:37:00 2009 Subject: [Haskell-cafe] [uvector] derive UA instance for newtype Message-ID: <200909232304.58119.alexey.skladnoy@gmail.com> Hello I want to derive UA instance for newtypes. Say I have following newtype: > newtype Foo a = Foo a Attempts to derive UA automatically fails because it have associated types. It seems that it's not possible to define from outside. However it's possible to derive instance in the uvector's internals. > deriving instance UAE a => UAE (Foo a) > deriving instance UPrim a => UPrim (Foo a) > > instance UPrim a => UA (Foo a) where > newtype UArr (Foo a) = UAFoo (BUArr (Foo a)) > newtype MUArr (Foo a) s = MUFoo (MBUArr s (Foo a)) > > lengthU = primLengthU > indexU = primIndexU > sliceU = primSliceU > lengthMU = primLengthMU > newMU = primNewMU > readMU = primReadMU > writeMU = primWriteMU > copyMU = primCopyMU > unsafeFreezeMU = primUnsafeFreezeMU > > memcpyMU = primMemcpyMU > memcpyOffMU = primMemcpyOffMU > memmoveOffMU = primMemmoveOffMU Am I moving in right direction and are there other/better solutions to problem? -- Khudyakov Alexey From bulat.ziganshin at gmail.com Wed Sep 23 15:10:35 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Wed Sep 23 14:49:06 2009 Subject: [Haskell-cafe] Status of GHC as a Cross Compiler In-Reply-To: References: Message-ID: <771884251.20090923231035@gmail.com> Hello John, Wednesday, September 23, 2009, 10:50:24 PM, you wrote: > This may be more appropriate for a different list, but I'm having a > hard time figuring out whether or not we're getting a cross compiler > in 6.12 or not. Can some one point me to the correct place in Traq to find this information? afaik, ghc never supported and not planned to support cross compiling -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From pumpkingod at gmail.com Wed Sep 23 15:19:22 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Wed Sep 23 14:57:43 2009 Subject: [Haskell-cafe] [uvector] derive UA instance for newtype In-Reply-To: <200909232304.58119.alexey.skladnoy@gmail.com> References: <200909232304.58119.alexey.skladnoy@gmail.com> Message-ID: I believe this is a bug that was introduced in 6.10.2 (it definitely worked in 6.10.1) that has since been fixed in HEAD. This newtype deriving issue also prevents the uvector testsuite from running at the moment. You might want to try a different version of GHC? Dan On Wed, Sep 23, 2009 at 3:04 PM, Khudyakov Alexey wrote: > Hello > > I want to derive UA instance for newtypes. > > Say I have following newtype: >> newtype Foo a = Foo a > > Attempts to derive UA automatically fails because it have associated types. It > seems that it's not possible to define from outside. However it's possible to > derive instance in the uvector's internals. > >> deriving instance UAE a ? => UAE (Foo a) >> deriving instance UPrim a => UPrim (Foo a) >> >> instance UPrim a => UA (Foo a) where >> ? newtype UArr ?(Foo a) ? = UAFoo (BUArr (Foo a)) >> ? newtype MUArr (Foo a) s = MUFoo (MBUArr s (Foo a)) >> >> ? lengthU ? ? ? ?= primLengthU >> ? indexU ? ? ? ? = primIndexU >> ? sliceU ? ? ? ? = primSliceU >> ? lengthMU ? ? ? = primLengthMU >> ? newMU ? ? ? ? ?= primNewMU >> ? readMU ? ? ? ? = primReadMU >> ? writeMU ? ? ? ?= primWriteMU >> ? copyMU ? ? ? ? = primCopyMU >> ? unsafeFreezeMU = primUnsafeFreezeMU >> >> ? memcpyMU ? ? = primMemcpyMU >> ? memcpyOffMU ?= primMemcpyOffMU >> ? memmoveOffMU = primMemmoveOffMU > > Am I moving in right direction and are there other/better solutions to > problem? > > -- > ?Khudyakov Alexey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From donnie at darthik.com Wed Sep 23 15:24:05 2009 From: donnie at darthik.com (Donnie Jones) Date: Wed Sep 23 15:02:23 2009 Subject: [Haskell-cafe] Status of GHC as a Cross Compiler In-Reply-To: References: Message-ID: Hello John, glasgow-haskell-users is a more appropriate list... http://www.haskell.org/mailman/listinfo/glasgow-haskell-users I went ahead and cc'd your message to the list. Any replies please include John's email address as I don't think he is subscribed to the list. Hope that helps... -- Donnie Jones On Wed, Sep 23, 2009 at 1:50 PM, John Van Enk wrote: > Hi, > > This may be more appropriate for a different list, but I'm having a hard > time figuring out whether or not we're getting a cross compiler in 6.12 or > not. Can some one point me to the correct place in Traq to find this > information? > > /jve > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From lurifax at gmail.com Wed Sep 23 15:25:01 2009 From: lurifax at gmail.com (=?ISO-8859-1?Q?Dan_Ros=E9n?=) Date: Wed Sep 23 15:03:37 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays In-Reply-To: <200909222257.46673.daniel.is.fischer@web.de> References: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> <200909222231.49469.daniel.is.fischer@web.de> <200909222257.46673.daniel.is.fischer@web.de> Message-ID: <3defcb4e0909231225x52c63361u6fe3eda435228aa7@mail.gmail.com> Thanks Daniel and Tobias, and sorry for posting something with an obvious miss in it (the function call) It works better with strict evaulation. best regards, Dan From rmm-haskell at z.odi.ac Wed Sep 23 15:52:21 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Wed Sep 23 15:33:32 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> Message-ID: Well, keep in mind forkIO *might* be a different OS thread (unless it's bound, IIRC), depending on the number of workers (with -Nx) and so on. -Ross On Sep 23, 2009, at 2:24 PM, G?nther Schmidt wrote: > Am 23.09.2009, 19:29 Uhr, schrieb Duncan Coutts >: > >> On Tue, 2009-09-22 at 17:08 -0400, Brandon S. Allbery KF8NH wrote: >>> -----BEGIN PGP SIGNED MESSAGE----- >>> Hash: SHA1 >>> >>> On Sep 22, 2009, at 11:31 , G?nther Schmidt wrote: >>> > Gtk2hs then complains about running in a multithreaded ghc, ie. >>> one >>> > with several "real" OS threads. Is it possible to start runghc >>> > single-threaded? >>> >>> >>> No, but you can unsafeInitGUIForThreadedRTS. >> >> If you observe the foot-shooting restrictions (of which the easiest >> is >> to not use forkIO). >> >> >> Duncan >> > > And exactly herein lies the problem :) > > > I've seen your response to the recent post about gui state, in which > you mention your own prefered solution to the problem, ie. that you > "post" your state to a channel which is read in a thread. > > I'm doing the same thing, but I'm also "calling" gui code from > within that thread. I figured since the thread itself isn't a > separate OS thread it shouldn't be a problem. > > It seems to work once the app is compiled, but running the code in > either ghci or with runghc it crashes. > > G?nther > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From duncan.coutts at worc.ox.ac.uk Wed Sep 23 16:12:25 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 23 16:03:45 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> Message-ID: <1253736745.18961.4918.camel@localhost> On Wed, 2009-09-23 at 20:24 +0200, G?nther Schmidt wrote: > >> No, but you can unsafeInitGUIForThreadedRTS. > > > > If you observe the foot-shooting restrictions (of which the easiest is > > to not use forkIO). > > > And exactly herein lies the problem :) > > I've seen your response to the recent post about gui state, in which you > mention your own prefered solution to the problem, ie. that you "post" > your state to a channel which is read in a thread. > > I'm doing the same thing, but I'm also "calling" gui code from within that > thread. > I figured since the thread itself isn't a separate OS thread it > shouldn't be a problem. Stop! You are confused about the relationship between Haskell threads and OS threads. By default you have _no_ control over which OS thread your Haskell threads run on. Using forkIO provides no promises at all about that. Using forkOS provides the opposite guarantee to the one you want. There is no API to launch a Haskell thread and guarantee that runs on the same OS thread as some existing Haskell thread. (One way is to use the single-threaded rts) The documentation for unsafeInitGUIForThreadedRTS states: If you want to use Gtk2Hs and the threaded RTS then it is your obligation to ensure that all calls to Gtk+ happen on a single OS thread. If you want to make calls to Gtk2Hs functions from a Haskell thread other than the one that calls this functions and mainGUI then you will have to 'post' your GUI actions to the main GUI thread. You can do this using postGUISync or postGUIAsync. The postGUI actions do some magic so that your IO actions are run on the same OS thread as the GUI is running on. > It seems to work once the app is compiled, but running the code in either > ghci or with runghc it crashes. Right, because when you compile it you are using the single threaded rts but if you linked using -threaded or if you use ghci or runghc then you are using the threaded rts. There are two solutions: 1. use the single threaded rts 2. annotate all sequences of GUI calls with postGUISync or postGUIAsync so that they get run in the GUI thread and not some random thread. The first is obviously much easier. Only go with the second if for some reason you actually need the -threaded rts. There is no claim that the second option is a good GUI programming model. The Gtk2Hs developers added the possibility of running on the threaded rts due to popular demand but the intention of the reallyLongNamedFunction unsafeInitGUIForThreadedRTS is to make you stop and think about what you are doing :-). Perhaps we should make it even more so, like unsafeInitGUIIHaveReadTheDocsAndIAmSureIAmNotGoingToShootMyselfInTheFoot Duncan From duncan.coutts at worc.ox.ac.uk Wed Sep 23 16:38:21 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Wed Sep 23 16:16:40 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> Message-ID: <1253738301.18961.4958.camel@localhost> On Wed, 2009-09-23 at 15:52 -0400, Ross Mellgren wrote: > Well, keep in mind forkIO *might* be a different OS thread Yes. > (unless it's bound, IIRC) In which case it's guaranteed to be on a different OS thread.. > depending on the number of workers (with -Nx) and so on. The number of capabilities is mostly unrelated. All these problems will happen with -N1 and -N2. Essentially each capability has a pool of OS threads. Only one of these OS threads runs Haskell code at once, but which one it is at any particular time is not defined. The trick that postGUI uses is to arrange for a foreign callback (from C into Haskell) on the OS thread running the GUI. This creates a Haskell thread that runs on that OS thread until the callback returns. Duncan From gue.schmidt at web.de Wed Sep 23 18:10:32 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Wed Sep 23 17:48:51 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: <1253736745.18961.4918.camel@localhost> References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> <1253736745.18961.4918.camel@localhost> Message-ID: Hi Duncan, so ... I have a green light to call gtk from within a forkIO thread for as long as I make sure that the rts is single threaded? BTW: I was already strongly put off using unsafeInitGUIwForThreadedRTS but thanks for the warning. Thus my back to my original question: Can I start either ghci or runghc with a single-threaded rts so I don't have to compile the app every time I want to check my really trick GUI code? G?nther From ok at cs.otago.ac.nz Wed Sep 23 20:11:54 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Wed Sep 23 19:50:14 2009 Subject: [Haskell-cafe] accessible layout proposal? In-Reply-To: <849e33f830bd58c1de174ede059df533.squirrel@mail.shareyourgifts.net> References: <849e33f830bd58c1de174ede059df533.squirrel@mail.shareyourgifts.net> Message-ID: <3559F19C-8318-4A9E-AF7C-00AC3751DA30@cs.otago.ac.nz> > [PPIG: this is the middle of a discussion about style in the programming language Haskell and the degree to which one could improve things by overloading newline.] > This proposal notwithstanding, I find 'concat [a, b, c]' much more > readable than (a) ++ (b) ++ (c), Yes, but now you've changed it again. The parentheses are not needed that often. The thing about concat [a,b,c] is that the operation is HIDDEN. Suppose for the sake of example (and I repeat that non-trivial examples are what we _really_ need) that you have something that needs to be broken across multiple lines, then ( e1 ++ e2 ++ e3 ++ e4 ) tells you on (nearly) *every line* what the ---- is going on, whereas concat [ e1 , e2 , e3 , e4 ] does not. I don't find parentheses a problem. I *do* find lots of code looking identical but meaning very different things to be a problem. > Furthermore, > why repeat the (++) over and over again, (A) To remind the reader over and over again (B) In fact such expressions often mix ++ and : which in concat[] requires you to add square brackets (C) "++" isn't _that_ much harder to type than ",", so there isn't any real downside to making my code clearer. > when really you are making a > *list* of things to add, No, I'm really *NOT*. If I write a++b++c, the list [a,b,c] is *not* what I want to make; it is no interest, it is at best a distraction from what's *really* supposed to be going on. I would find it absurd to write sum [ e1 , e2 , e3 ] instead of e1 + e2 + e3 (and just as concatenations often mix ++ and :, so sums often mix + and -). I'm not worried about efficiency here: perhaps mistakenly I trust the Haskell compiler to unfold "concat [a,b,c]" or "sum [a,b,c]". What bothers me is misleading any human beings who have the misfortune to have to try to read the code. I don't hesitate to use concat [...] or sum [...] or the like when [...] is a list comprehension, because I don't know a clearer way to do that. Turning to the new proposal being developed, suppose one wrote data Tree k v -- V2 Empty Fork key :: k value :: v left :: Tree k v right :: Tree k v instead of data Tree k v -- V1 = Empty | Fork { key :: k , value :: v , left :: Tree k v , right :: Tree k v } This could indeed work. Indeed, I have seen a formal specification language where records were declared using layout (but not sum-of-product types) not unlike this. Here we have newline overloaded to mean "or" (Empty or Fork) and "and" (key and value and left and right). It could *work*, and it would be less typing for the *author*, but what would it do for the *reader*? The leading punctuation marks "=" "|" "," give the reader an immediate and unmistakable clue about what role the rest of the line plays. I'd actually prefer to write data Tree k v -- V3 | Empty | Fork { , key :: k , value :: v , left :: Tree k v , right :: Tree k v } What we really need here is somebody who is willing and able to conduct some experiments to compare the readability of these and other ways of writing data declarations. *I* prefer V3 to V1 to V2, but since my argument is that readers need more help than writers, experimental evidence that V2 is better for others than V1 or V3 would persuade me to adopt it. For this reason I've cc'ed this message to the psychology of programming interest group mailing list. From brad.larsen at gmail.com Wed Sep 23 21:59:49 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Wed Sep 23 21:38:04 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition Message-ID: I seem to have run into an instance of the expression problem [1], or something very similar, when experimenting with ``finally tagless'' EDSLs, and don't see a good way to work around it. I have been experimenting with embedded DSLs, using the techniques described in a couple recent papers [2,3]. The idea is this: implement an embedded DSL using type classes, rather than ADTs or GADTs. This allows one to define analyses, queries, and manipulations of EDSL programs independently, as class instances. Furthermore, by using type classes rather than data types, there is no interpretive overhead in the analyses, queries, and manipulations on the EDSL programs. Finally, using type classes permits greater modularity, as an EDSL can be defined as the combination of several simpler EDSLs [3]. Suppose we have a type class for simple integer arithmetic expressions: > class IntArithExpr exp where > integer :: Integer -> exp Integer > add :: exp Integer -> exp Integer -> exp Integer We can write an evaluator for these expressions like this: > newtype E a = E { eval :: a } > > instance IntArithExpr E where > integer = E > add e1 e2 = E (eval e1 + eval e2) > > -- eval $ add (integer 20) (integer 22) <==> 42 The trouble comes in when defining a more general arithmetic expression type class. Suppose we want polymorphic arithmetic expressions: > class PolyArithExpr exp where > constant :: a -> exp a > addP :: exp a -> exp a -> exp a We then try to define an evaluator: > -- instance PolyArithExpr E where > -- constant = E > -- addP e1 e2 = E (eval e1 + eval e2) -- bzzt! The instance definition for `addP' is not type correct: Could not deduce (Num a) from the context () arising from a use of `+' at /home/blarsen/mail.lhs:42:20-36 One way to remedy this is to change the class definition of PolyArithExpr so that `addP' has a Num constraint on `a': > class PolyArithExprFixed exp where > pae_constant :: a -> exp a > pae_add :: Num a => exp a -> exp a -> exp a which allows us to define an evaluator: > instance PolyArithExprFixed E where > pae_constant = E > pae_add e1 e2 = E (eval e1 + eval e2) I find this ``fix'' lacking, however: to define a new interpretation of the EDSL, we may be forced to change the DSL definition. This is non-modular, and seems like an instance of the expression problem. (There may be a multiparameter type class solution for this.) How can one define the polymorphic arithmetic EDSL without cluttering up the class definitions with interpretation-specific constraints, and still write the desired interpretations? Sincerely, Bradford Larsen References: [1] Philip Wadler. The Expression Problem. November 12, 1998. http://www.daimi.au.dk/~madst/tool/papers/expression.txt. [2] Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages. APLAS 2007. [3] Robert Atkey, Sam Lindley, and Jeremy Yallop. Unembedding Domain-Specific Languages. ICFP Haskell Symposium 2009. From dan.doel at gmail.com Wed Sep 23 23:03:09 2009 From: dan.doel at gmail.com (Dan Doel) Date: Wed Sep 23 22:41:30 2009 Subject: [Haskell-cafe] Re: [Coq-Club] An encoding of parametricity in Agda In-Reply-To: References: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> Message-ID: <200909232303.09517.dan.doel@gmail.com> On Wednesday 23 September 2009 12:21:00 pm Taral wrote: > On Wed, Sep 23, 2009 at 6:46 AM, Eugene Kirpichov wrote: > > It contains an ingenious (to my mind) encoding of parametricity in > > Agda that makes the Free Theorems a trivial consequence. > > Perhaps I don't understand Agda very well, but I don't see > parametricity here. For one, there's no attempt to prove that: > > forall (P Q : forall a, a -> a), P = Q. > > which is what parametricity means to me. I've been playing with this, and the stuff in the post takes a bit of work to fully tease out. Working through the Theorems for Free paper along side the blog post should be helpful, but here's a fast version: ? A. A ? A goes like: From a function from relations to relations ? we get relations ??. ?(?) where (?, ?') ? ??. ?(?) iff (A, A') ? ? ? (?(A) , ?'(A')) ? ?(R_A) or something close to that. And (f, f') ? ? ? ? iff (x,x') ? ? ? (f x, f' x') ? ? Parametricity states that: if f : ?A. A ? A then (f,f) ? ??. ? ? ? And Theorems for Free goes on to suggest that using functions as the relations between two types gives us useful theorems. All together, this looks like: id : ?A. A ? A (id,id) ? ??. ? ? ? (parametricity) suppose f : B ? C (id_B, id_C) ? f ? f (definition of the ? relation above) (x,f x) ? f (functions as a relation) (id_B x, id_C (f x)) ? f (definition of the ? relation above) f (id_B x) ? id_C (f x) (functions as a relation) which, cleaning up a bit gives: f ? id ? id ? f the free theorem for id : ?A. A ? A So, that's how things are supposed to go (hopefully I got that roughly correct. I get a bit muddled with the types vs. relations on types and functions on both and whatnot). However, I don't think that Agda quite allows us to do all this. We can lift a function to one of these relations fine: record Set# : Set? where field A : Set A' : Set A~ : A ? A' ? Set record value# (A# : Set#) : Set where open Set# A# field x : A x' : A' x~ : A~ x x' Rel : ?{A B : Set} ? (f : A ? B) ? A ? B ? Set Rel f x y = f x ? y infix 40 _# _# : ?{A B} ? (A ? B) ? Set# _# {A} {B} f = record { A = A ; A' = B ; A~ = Rel f } _#'_ : ?{A B} (f : A ? B) ? A ? value# (f #) f #' x = record { x = x ; x' = f x ; x~ = refl } But, what about parametricity? I'll define an alias for the relation of the type for identity: ?A,A?A# : Set? ?A,A?A# = (A# : Set#) ? value# A# ? value# A# parametricity : (?(A : Set) ? A ? A) ? ?A,A?A# parametricity id A# x# = record { x = id (Set#.A A#) (value#.x x#) ; x' = id (Set#.A' A#) (value#.x' x#) ; x~ = ? } I don't think there's anything to be filled in for that ? unless we use some postulates. We can do it for 'id A x = x', but that's a specific function (which happens to be the only function with that type, but I don't think we can prove that), and the point of parametricity (I think) is that it gives us this fact for every function, based only on the type. However, if we do take it as a postulate, we seem to be good to go: postulate param : ?{B C} {x : B} {y : C} (_~_ : B ? C ? Set) ? (id : (A : Set) ? A ? A) ? x ~ y ? id B x ~ id C y parametricity : (?(A : Set) ? A ? A) ? ?A,A?A# parametricity id A# x# = record { x = id (Set#.A A#) (value#.x x#) ; x' = id (Set#.A' A#) (value#.x' x#) ; x~ = param (Set#.A~ A#) id (value#.x~ x#) } module Free-id {A B : Set} (id# : ?A,A?A#) (f : A ? B) where -- (id,id') ? ??. ? ? ? -- (x,y) ? f : A ? B f x ? y -- (id A x, id' B y) ? f f (id x) ? id' (f x) -- id# = (id,id') -- f #' x = (x, y) -- id# (f #' x) = (id A x, id' B y) free : A ? value# (f #) free x = id# (f #) (f #' x) free' : (x : A) ? _ free' x = value#.x~ (free x) free : ?{B C} (f : B ? C) (id : ? A ? A ? A) ? (x : B) ? f (id B x) ? id C (f x) free f id x = Free-id.free' id# f x where id# : ?A,A?A# id# = parametricity id voila! Of course, I took parametricity for only one fairly specific type. I'm not sure how to make it much more general, so one may have to end up taking quite a lot of postulates if one wants to work this way (or work in a language that actually has/lets you prove parametricity). Hopefully I didn't steal the author's thunder too much. Cheers, -- Dan From lrpalmer at gmail.com Wed Sep 23 23:12:42 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Wed Sep 23 22:50:57 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: Message-ID: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> On Wed, Sep 23, 2009 at 7:59 PM, Brad Larsen wrote: > The trouble comes in when defining a more general arithmetic > expression type class. ?Suppose we want polymorphic arithmetic > expressions: > >> class PolyArithExpr exp where >> ? constant :: a ? ? -> exp a >> ? addP ? ? :: exp a -> exp a -> exp a > > We then try to define an evaluator: > >> -- instance PolyArithExpr E where >> -- ? constant ? = E >> -- ? addP e1 e2 = E (eval e1 + eval e2) ?-- bzzt! > > The instance definition for `addP' is not type correct: > ? ?Could not deduce (Num a) from the context () > ? ? ?arising from a use of `+' at /home/blarsen/mail.lhs:42:20-36 > > One way to remedy this is to change the class definition of > PolyArithExpr so that `addP' has a Num constraint on `a': > >> class PolyArithExprFixed exp where >> ? pae_constant :: a -> exp a >> ? pae_add ? ? ?:: Num a => exp a -> exp a -> exp a > > which allows us to define an evaluator: > >> instance PolyArithExprFixed E where >> ? pae_constant = E >> ? pae_add e1 e2 = E (eval e1 + eval e2) > > I find this ``fix'' lacking, however: to define a new interpretation > of the EDSL, we may be forced to change the DSL definition. ?This is > non-modular, and seems like an instance of the expression > problem. (There may be a multiparameter type class solution for this.) I don't know what you expect from pae_add, such that it could "add" a couple of a's without knowing anything about them. Don't think of Num as a implementation detail, think of it as information about that a. An implementation which adds another typeclass constraint is requiring too much information, and either the implementation is undefinable (that happens, but it's always for a good reason), or the interface is weaker than you wrote. I don't know what kind of implementation would add another constraint on a. Are you referring maybe to a specialized interpreter for Integer math? Well, if this is truly a polymorphic type that needs a constructor class, there could be some non-Integer math in the middle somewhere, and your interpreter would be incorrect. I would like to see an example of this unmodularity, making use of the polymorphism, so I can understand what you're asking better. Luke From claudiusmaximus at goto10.org Wed Sep 23 23:32:45 2009 From: claudiusmaximus at goto10.org (Claude Heiland-Allen) Date: Wed Sep 23 23:11:03 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: <4AAF7EF2.9050203@btinternet.com> References: <4AAF7EF2.9050203@btinternet.com> Message-ID: <4ABAE85D.4080304@goto10.org> Andrew Coppin wrote: > (OK, well the *best* way is to use the GPU. But AFAIK that's still a > theoretical research project, so we'll leave that for now.) Works for me :-) http://claudiusmaximus.goto10.org/cm/2009-09-24_fl4m6e_in_haskell.html There doesn't need to be a sound theoretical foundation for everything, sometimes sufficient ugly hackery will make pretty pretty pictures... Claude -- http://claudiusmaximus.goto10.org From brad.larsen at gmail.com Thu Sep 24 00:00:16 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Wed Sep 23 23:38:32 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> Message-ID: Luke, On Wed, Sep 23, 2009 at 11:12 PM, Luke Palmer wrote: > On Wed, Sep 23, 2009 at 7:59 PM, Brad Larsen wrote: >> The trouble comes in when defining a more general arithmetic >> expression type class. Suppose we want polymorphic arithmetic >> expressions: >> >>> class PolyArithExpr exp where >>> constant :: a -> exp a >>> addP :: exp a -> exp a -> exp a >> >> We then try to define an evaluator: >> >>> -- instance PolyArithExpr E where >>> -- constant = E >>> -- addP e1 e2 = E (eval e1 + eval e2) -- bzzt! >> >> The instance definition for `addP' is not type correct: >> Could not deduce (Num a) from the context () >> arising from a use of `+' at /home/blarsen/mail.lhs:42:20-36 >> >> One way to remedy this is to change the class definition of >> PolyArithExpr so that `addP' has a Num constraint on `a': >> >>> class PolyArithExprFixed exp where >>> pae_constant :: a -> exp a >>> pae_add :: Num a => exp a -> exp a -> exp a >> >> which allows us to define an evaluator: >> >>> instance PolyArithExprFixed E where >>> pae_constant = E >>> pae_add e1 e2 = E (eval e1 + eval e2) >> >> I find this ``fix'' lacking, however: to define a new interpretation >> of the EDSL, we may be forced to change the DSL definition. This is >> non-modular, and seems like an instance of the expression >> problem. (There may be a multiparameter type class solution for this.) > > I don't know what you expect from pae_add, such that it could "add" a > couple of a's without knowing anything about them. Don't think of Num > as a implementation detail, think of it as information about that a. > An implementation which adds another typeclass constraint is requiring > too much information, and either the implementation is undefinable > (that happens, but it's always for a good reason), or the interface is > weaker than you wrote. > > I don't know what kind of implementation would add another constraint > on a. Are you referring maybe to a specialized interpreter for > Integer math? Well, if this is truly a polymorphic type that needs a > constructor class, there could be some non-Integer math in the middle > somewhere, and your interpreter would be incorrect. > > I would like to see an example of this unmodularity, making use of the > polymorphism, so I can understand what you're asking better. > > Luke The idea with these type classes is that an EDSL can be defined, separately from any interpretation of its programs. Instead of evaluating an EDSL program, suppose you want to pretty-print it, using some pretty-printing type class, along the lines of this: import Text.PrettyPrint class PrettyPrintable a where pretty :: a -> Doc newtype P = P { unP :: Doc } instance PolyArithExpr P where constant = P . pretty -- bzzt! Cannot deduce (PrettyPrintable a) add e1 e2 = P (pretty e1 <+> text "+" <+> pretty e2) -- bzzt! Cannot deduce (PrettyPrintable a) To write a pretty-printing interpretation for polymorphic arithmetic expressions, we do not need a Num constraint, but we do need a PrettyPrintable constraint. So, we might ``remedy'' the definition of PolyArithExpr so that we could write the evaluator and pretty-printer: class PolyArithExprFixedAgain exp where constant_fixed_again :: (Num a, PrettyPrintable a) => a -> exp a add_fixed_again :: (Num a, PrettyPrintable a) => a -> exp a Similarly, if we wanted to marshall an EDSL program over the network or to disk, we would have to modify PolyArithExprFixedAgain to add another constraint. Such modification would be necessary for other interesting interpretations, such as compilation to native code. Perhaps the problem I have encountered is more clear now. With my current approach, the EDSL ``language definition'' and interpretations of EDSL programs are intertwined. Hence, this is a close relative of the ``expression problem''. I want language definition and language interpretations to be decoupled. Sincerely, Brad Larsen From peteg42 at gmail.com Thu Sep 24 00:22:49 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Thu Sep 24 00:01:10 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: Message-ID: <5FE6A764-0817-4E2F-B20D-064960A82765@gmail.com> Brad: On 24/09/2009, at 11:59 AM, excerpts of what Brad Larsen wrote: > We then try to define an evaluator: > >> -- instance PolyArithExpr E where >> -- constant = E >> -- addP e1 e2 = E (eval e1 + eval e2) -- bzzt! > > The instance definition for `addP' is not type correct: > Could not deduce (Num a) from the context () > arising from a use of `+' at /home/blarsen/mail.lhs:42:20-36 > > One way to remedy this is to change the class definition of > PolyArithExpr so that `addP' has a Num constraint on `a': > >> class PolyArithExprFixed exp where >> pae_constant :: a -> exp a >> pae_add :: Num a => exp a -> exp a -> exp a > > which allows us to define an evaluator: > >> instance PolyArithExprFixed E where >> pae_constant = E >> pae_add e1 e2 = E (eval e1 + eval e2) > > I find this ``fix'' lacking, however: to define a new interpretation > of the EDSL, we may be forced to change the DSL definition. This is > non-modular, and seems like an instance of the expression > problem. (There may be a multiparameter type class solution for this.) A better fix is to shift the type constraint to the class head, e.g.: class PolyArithExprFixed exp a where pae_constant :: a -> exp a pae_add :: exp a -> exp a -> exp a then: instance PolyArithExprFixed E Integer where ... or if you want to be more general: instance Num n => PolyArithExprFixed E n where ... but note that this instance precludes any other ones for PolyArithExprFixed without allowing overlapping instances and hence some Olegs / Olegging. See, e.g.: http://www.soi.city.ac.uk/~ross/papers/fop.html (the slides link) Ambiguity is IMHO best handled with a judicious application of type (or data) families, but you can get surprisingly far by simply requiring that every class member mention all type variables in the class head. YMMV of course. cheers peter From brad.larsen at gmail.com Thu Sep 24 00:24:52 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Sep 24 00:03:07 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> Message-ID: Luke, On Wed, Sep 23, 2009 at 11:12 PM, Luke Palmer wrote: > On Wed, Sep 23, 2009 at 7:59 PM, Brad Larsen wrote: >> The trouble comes in when defining a more general arithmetic >> expression type class. Suppose we want polymorphic arithmetic >> expressions: >> >>> class PolyArithExpr exp where >>> constant :: a -> exp a >>> addP :: exp a -> exp a -> exp a >> >> We then try to define an evaluator: >> >>> -- instance PolyArithExpr E where >>> -- constant = E >>> -- addP e1 e2 = E (eval e1 + eval e2) -- bzzt! >> >> The instance definition for `addP' is not type correct: >> Could not deduce (Num a) from the context () >> arising from a use of `+' at /home/blarsen/mail.lhs:42:20-36 >> >> One way to remedy this is to change the class definition of >> PolyArithExpr so that `addP' has a Num constraint on `a': >> >>> class PolyArithExprFixed exp where >>> pae_constant :: a -> exp a >>> pae_add :: Num a => exp a -> exp a -> exp a >> >> which allows us to define an evaluator: >> >>> instance PolyArithExprFixed E where >>> pae_constant = E >>> pae_add e1 e2 = E (eval e1 + eval e2) >> >> I find this ``fix'' lacking, however: to define a new interpretation >> of the EDSL, we may be forced to change the DSL definition. This is >> non-modular, and seems like an instance of the expression >> problem. (There may be a multiparameter type class solution for this.) > > I don't know what you expect from pae_add, such that it could "add" a > couple of a's without knowing anything about them. Don't think of Num > as a implementation detail, think of it as information about that a. > An implementation which adds another typeclass constraint is requiring > too much information, and either the implementation is undefinable > (that happens, but it's always for a good reason), or the interface is > weaker than you wrote. > > I don't know what kind of implementation would add another constraint > on a. Are you referring maybe to a specialized interpreter for > Integer math? Well, if this is truly a polymorphic type that needs a > constructor class, there could be some non-Integer math in the middle > somewhere, and your interpreter would be incorrect. > > I would like to see an example of this unmodularity, making use of the > polymorphism, so I can understand what you're asking better. > > Luke > To elaborate a point I mentioned in my original email, and discussed in ``Unembedding Domain-Specific Languages'' by Atkey, Lindley, and Yallop: EDSLs defined using type classes in this way can be freely combined, and so you can cobble together an EDSL from several smaller EDSLs. For example, we can define an EDSL for boolean expressions: class BooleanExpr exp where true :: exp Bool false :: exp Bool cond :: exp Bool -> exp a -> exp a -> exp a (&&*) :: exp Bool -> exp Bool -> exp Bool (||*) :: exp Bool -> exp Bool -> exp Bool infixr 3 (&&*) infixr 2 (||*) Then, combined with PolyArithExprFixed, we can define an EDSL supporting polymorphic arithmetic and boolean expressions, as well as an evaluator for this language. (I've repeated the PolyArithExprFixed and previous evaluator stuff for reference.) class PolyArithExprFixed exp where pae_constant :: a -> exp a pae_add :: Num a => exp a -> exp a -> exp a class (BooleanExpr exp, PolyArithExprFixed exp) => BoolArithExpr exp -- a well-typed evaluator newtype E a = E { unE :: a } instance BooleanExpr E where true = E True false = E False cond p t f = if unE p then t else f e1 &&* e2 = E (unE e1 && unE e2) e1 ||* e2 = E (unE e1 || unE e2) instance PolyArithExprFixed E where pae_constant = E pae_add e1 e2 = E (unE e1 + unE e2) A simple test case, combining boolean expressions and arithmetic expressions: test1 = cond (true &&* false) (pae_constant 0) (pae_add (pae_constant 22) (pae_constant 20)) -- unE test1 <===> 42 Sincerely, Brad Larsen From brad.larsen at gmail.com Thu Sep 24 00:45:20 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Sep 24 00:23:34 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <5FE6A764-0817-4E2F-B20D-064960A82765@gmail.com> References: <5FE6A764-0817-4E2F-B20D-064960A82765@gmail.com> Message-ID: Peter, On Thu, Sep 24, 2009 at 12:22 AM, Peter Gammie wrote: [...] > Ambiguity is IMHO best handled with a judicious application of type (or > data) families, but you can get surprisingly far by simply requiring that > every class member mention all type variables in the class head. YMMV of > course. > > cheers > peter Can you say more about the use of type/data families? Sincerely, Brad From peteg42 at gmail.com Thu Sep 24 01:10:03 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Thu Sep 24 00:48:23 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: <5FE6A764-0817-4E2F-B20D-064960A82765@gmail.com> Message-ID: Brad, On 24/09/2009, at 2:45 PM, Brad Larsen wrote: > On Thu, Sep 24, 2009 at 12:22 AM, Peter Gammie > wrote: > [...] > >> Ambiguity is IMHO best handled with a judicious application of type >> (or >> data) families, but you can get surprisingly far by simply >> requiring that >> every class member mention all type variables in the class head. >> YMMV of >> course. > > Can you say more about the use of type/data families? Multi-parameter type classes generally lead to ambiguity - see the classic paper(s) by Simon PJ et al for some good examples. In the context of Arrows, I used type/data families to make the representation type (e.g. Integer) a function of the arrow (e.g. a direct semantics), which makes life a bit easier for using this stuff but is not completely faithful to what I wanted. (Imagine you want to mix Integer and Double in the same expression.) Hope this helps! cheers peter -- http://peteg.org/ From qdunkan at gmail.com Thu Sep 24 01:13:56 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Sep 24 00:52:16 2009 Subject: [Haskell-cafe] best practices for monad transformers and exceptions? Message-ID: <2518b95d0909232213i54722e16pb1eb2f9811647057@mail.gmail.com> I don't have an especially deep understanding of monad transformers... basically, I asked around (thanks #haskell!) and struggled and with helpful advice came up with something that seemed to work for me, only now I'm having trouble. What I'm trying to do is hardly revolutionary or even advanced, so I'd like to come up with some kind of standard best practices way to do this. Basically, the question is, "how do you combine multiple sets of monad transformers, each of which may contain their own exception mechanism, and throw and catch exceptions for each one?" This seems like a perfectly normal thing to want to do, so someone must have figured this out. For more details: I have several subsystems, each of which runs in its own monad. For instance, the Ui level has a monad that provides state, logging of updates, and an exception (LoggerT is simply a type alias for a WriterT with DList): module Ui.State where type StateStack m = State.StateT State (Logger.LoggerT Update.Update (Error.ErrorT StateError m)) newtype StateT m a = StateT (StateStack m a) deriving (Functor, Monad, Trans.MonadIO, Error.MonadError StateError) I wished to wrap up this Ui.StateT as its own transformer that can be reused inside other transformers.... because another subsystem has its own set of needs, including its own logging, state, and exception, in addition to Ui.StateT: module Cmd.Cmd where type CmdStack m = Ui.State.StateT (Monad.State.StateT State (Error.ErrorT Abort (Log.LogT m))) newtype CmdT m a = CmdT (CmdStack m a) deriving (Functor, Monad, Trans.MonadIO) I want to provide unlifted access to Ui.State operations, so I have: class (Monad m, Functor m) => UiStateMonad m where get :: m State put :: State -> m () modify :: (State -> State) -> m () update :: Update.Update -> m () throw :: String -> m a Along with instances for Ui.StateT and Cmd.CmdT where Ui.StateT does the appropriate lifting and CmdT just "delegates": 'put st = CmdT (State.put st)' etc. So now I can throw a StateError within Ui.State by calling State.throw. I can throw the error within Cmd with: abort = (CmdT . lift . lift . lift) (Error.throwError Abort) So this all works fine and each "level" of transformers can provide access to its throw by exporting a 'throw' with the appropriate lifts already applied. But then I want to catch an exception, and there's a problem because catchException takes a monadic argument in addition to having a monadic result. I can easily lift the result into the proper layer, but I can't so easily "lower" the result of the monadic argument back down to the StateT or CmdT or whatever. I can use fancy newtype deriving to put Ui.StateT into MonadError and get catchError for free, but if I try to do the same with CmdT then I get: Couldn't match expected type `Abort' against inferred type `State.StateError' When using functional dependencies to combine Error.MonadError State.StateError (State.StateT m), arising from the dependency `m -> e' So evidentally they are not co-existing. In any case, I would need different names for the throw and catch in the different monads. So all I want to do is to be able to catch an Abort. The closest I can think of is something vaguely like: catch_abort :: (Monad m) => CmdT m a -> CmdT m (Maybe a) catch_abort cmd = do ustate <- State.get cstate <- get_state (cmd_result, logs) <- run_cmd ustate cstate mapM_ Log.record logs case cmd_result of Left Abort -> return Nothing Right ui_result -> case ui_result of Left ui_err -> State.throw ui_err Right (val, ustate, updates) -> do State.put ustate mapM_ State.update updates return (Just val) All of this manual "unlifting" is quite ugly and clearly doesn't scale... and it's quite easy to introduce a subtle bug by forgetting to merge one of the many results that come out. So... what should I have done? What do other people who have a project with >1 kind of exception do? Is there an easier way to write 'catch_abort'? Should I break modularity by making a global exception type and putting them all in StateError? Then (I think) I could use catchError directly since I'd only have one occurrance of ErrorT in any transformer stack. From oleg at okmij.org Thu Sep 24 01:54:38 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Thu Sep 24 01:36:18 2009 Subject: [Haskell-cafe] Beginning of a meta-Haskell [was: An issue with the ``finally tagless'' tradition] Message-ID: <20090924055438.C9973176DC@Adric.metnet.navy.mil> The topic of an extensible, modular interpreter in the tagless final style has come up before. A bit more than a year ago, on a flight from Frankfurt to San Francisco I wrote two interpreters for a trivial subset of Haskell or ML (PCF actually), just big enough for Power, Fibonacci and other classic functions. The following code is a fragment of meta-Haskell. It defines the object language and two interpreters: one is the typed meta-circular interpreter, and the other is a non-too-pretty printer. We can write the expression once: > power = > fix $ \self -> > lam $ \x -> lam $ \n -> > if_ (n <= 0) 1 > (x * ((self $$ x) $$ (n - 1))) and interpret it several times, as an integer > -- testpw :: Int > testpw = (unR power) (unR 2) ((unR 7)::Int) > -- 128 or as a string > -- testpwc :: P.String > testpwc = showQC power {- "(let self0 = (\\t1 -> (\\t2 -> (if (t2 <= 0) then 1 else (t1 * ((self0 t1) (t2 - 1)))))) in self0)" -} The code follows. It is essentially Haskell98, with the exception of multi-parameter type classes (but no functional dependencies, let alone overlapping instances). {-# LANGUAGE NoMonomorphismRestriction, NoImplicitPrelude #-} {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} -- A trivial introduction to `meta-Haskell', just enough to give a taste -- Please see the tests at the end of the file module Intro where import qualified Prelude as P import Prelude (Monad(..), (.), putStrLn, IO, Integer, Int, ($), (++), (=<<), Bool(..)) import Control.Monad (ap) import qualified Control.Monad.State as S -- Definition of our object language -- Unlike that in the tagless final paper, the definition here is spread -- across several type classes for modularity class QNum repr a where (+) :: repr a -> repr a -> repr a (-) :: repr a -> repr a -> repr a (*) :: repr a -> repr a -> repr a negate :: repr a -> repr a fromInteger :: Integer -> repr a infixl 6 +, - infixl 7 * class QBool repr where true, false :: repr Bool if_ :: repr Bool -> repr w -> repr w -> repr w class QBool repr => QLeq repr a where (<=) :: repr a -> repr a -> repr Bool infix 4 <= -- Higher-order fragment of the language class QHO repr where lam :: (repr a -> repr r) -> repr (a -> r) ($$) :: repr (a -> r) -> (repr a -> repr r) fix :: (repr a -> repr a) -> repr a infixr 0 $$ -- The first interpreter R -- which embeds the object language in -- Haskell. It is a meta-circular interpreter, and so is trivial. -- It still could be useful if we wish just to see the result -- of our expressions, quickly newtype R a = R{unR :: a} instance P.Num a => QNum R a where R x + R y = R $ x P.+ y R x - R y = R $ x P.- y R x * R y = R $ x P.* y negate = R . P.negate . unR fromInteger = R . P.fromInteger instance QBool R where true = R True false = R False if_ (R True) x y = x if_ (R False) x y = y instance QLeq R Int where R x <= R y = R $ x P.<= y instance QHO R where lam f = R $ unR . f . R R f $$ R x = R $ f x fix f = f (fix f) -- The second interpreter: pretty-printer -- Actually, it is not pretty, but sufficient newtype S a = S{unS :: S.State Int P.String} instance QNum S a where S x + S y = S $ app_infix "+" x y S x - S y = S $ app_infix "-" x y S x * S y = S $ app_infix "*" x y negate (S x) = S $ (return $ \xc -> "(negate " ++ xc ++ ")") `ap` x fromInteger = S . return . P.show app_infix op x y = do xc <- x yc <- y return $ "(" ++ xc ++ " " ++ op ++ " " ++ yc ++ ")" instance QBool S where true = S $ return "True" false = S $ return "False" if_ (S b) (S x) (S y) = S $ do bc <- b xc <- x yc <- y return $ "(if " ++ bc ++ " then " ++ xc ++ " else " ++ yc ++ ")" instance QLeq S a where S x <= S y = S $ app_infix "<=" x y newName stem = do cnt <- S.get S.put (P.succ cnt) return $ stem ++ P.show cnt instance QHO S where S x $$ S y = S $ app_infix "" x y lam f = S $ do name <- newName "t" let xc = name bc <- unS . f . S $ return xc return $ "(\\" ++ xc ++ " -> " ++ bc ++ ")" fix f = S $ do self <- newName "self" let sc = self bc <- unS . f . S $ return sc return $ "(let " ++ self ++ " = " ++ bc ++ " in " ++ sc ++ ")" showQC :: S a -> P.String showQC (S m) = S.evalState m (unR 0) -- ------------------------------------------------------------------------ -- Tests -- Perhaps the first test should be the power function... -- The following code can be interpreted and compiled just as it is... power = fix $ \self -> lam $ \x -> lam $ \n -> if_ (n <= 0) 1 (x * ((self $$ x) $$ (n - 1))) -- The interpreted result -- testpw :: Int testpw = (unR power) (unR 2) ((unR 7)::Int) -- 128 -- The result of compilation. -- testpwc :: P.String testpwc = showQC power {- "(let self0 = (\\t1 -> (\\t2 -> (if (t2 <= 0) then 1 else (t1 * ((self0 t1) (t2 - 1)))))) in self0)" -} From lrpalmer at gmail.com Thu Sep 24 02:15:25 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Thu Sep 24 01:53:40 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> Message-ID: <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> On Wed, Sep 23, 2009 at 10:24 PM, Brad Larsen wrote: > On Wed, Sep 23, 2009 at 11:12 PM, Luke Palmer wrote: >> I would like to see an example of this unmodularity, making use of the >> polymorphism, so I can understand what you're asking better. >> >> Luke > > [...] > > A simple test case, combining boolean expressions and arithmetic expressions: > > ? ?test1 = cond (true &&* false) > ? ? ? ? ? ? ? ? (pae_constant 0) > ? ? ? ? ? ? ? ? (pae_add (pae_constant 22) (pae_constant 20)) > ? ?-- unE test1 <===> 42 Looks great! So, where is the modularity problem? Luke From peteg42 at gmail.com Thu Sep 24 02:39:29 2009 From: peteg42 at gmail.com (Peter Gammie) Date: Thu Sep 24 02:17:49 2009 Subject: [Haskell-cafe] Beginning of a meta-Haskell [was: An issue with the ``finally tagless'' tradition] In-Reply-To: <20090924055438.C9973176DC@Adric.metnet.navy.mil> References: <20090924055438.C9973176DC@Adric.metnet.navy.mil> Message-ID: <1924E64B-4E41-4A2E-A391-126C4DA42637@gmail.com> Thanks Oleg! Brad: On 24/09/2009, at 3:54 PM, oleg@okmij.org wrote: > and interpret it several times, as an integer > >> -- testpw :: Int >> testpw = (unR power) (unR 2) ((unR 7)::Int) >> -- 128 My type function allows one to remove the '::Int' annotation, which is especially useful in situations where you cannot give an annotation due to 'show . read'-style ambiguity. Conversely one gives up some useful polymorphism (in my case, sometimes it would be nice to have multiple boolean types). Another nit with Oleg's code is that you can only interpret Bool with Bool, in the interpreter: > class QBool repr where > true, false :: repr Bool > if_ :: repr Bool -> repr w -> repr w -> repr w If 'repr' is merely a Haskell98-style type constructor, it cannot analyse its argument. Hence there are two choices: use the argument (Bool) or don't (see the pretty printer). I doubt you could implement a very pleasant interpreter using the latter option, but see http://web.cecs.pdx.edu/~brianh/talks/talk20081010.pdf if you want to try. Again, using a type function here allows you to choose an arbitrary type to represent Bool (and so forth). Trying to do this with fundeps is possible but syntactically heavy. cheers peter From bugfact at gmail.com Thu Sep 24 02:47:11 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Thu Sep 24 02:25:26 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: <4ABAE85D.4080304@goto10.org> References: <4AAF7EF2.9050203@btinternet.com> <4ABAE85D.4080304@goto10.org> Message-ID: This is seriously cool stuff!!! Maybe it's time to start a "Haskell Demo Scene" :-) (what's a "demo scene"? See http://en.wikipedia.org/wiki/Demoscene ) PS: Note that Conal Elliott also was generating GPU code using Haskell with Vertigo back in 2004: http://conal.net/papers/Vertigo/ On Thu, Sep 24, 2009 at 5:32 AM, Claude Heiland-Allen wrote: > Andrew Coppin wrote: >> >> (OK, well the *best* way is to use the GPU. But AFAIK that's still a >> theoretical research project, so we'll leave that for now.) > > Works for me :-) > > http://claudiusmaximus.goto10.org/cm/2009-09-24_fl4m6e_in_haskell.html > > There doesn't need to be a sound theoretical foundation for everything, > sometimes sufficient ugly hackery will make pretty pretty pictures... > > > Claude > -- > http://claudiusmaximus.goto10.org > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From vasyl.pasternak at gmail.com Thu Sep 24 05:30:46 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Thu Sep 24 05:09:00 2009 Subject: [Haskell-cafe] Ctrl-C handling in Haskell with curl on Linux Message-ID: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> Hi, Yesterday I tried to implement simple tool to download pages, and wanted catch Ctrl-C (and other 'killing' messages) from haskell to handle state saving. Without curl (when I perform some long operation) haskell throws UserInterrupt exception immediately, but if I put long operation, which downloads page from the WEB (from the far-far-away server :) ) than I noticed following issues: - to break my program I have to press Ctrl-C twice - haskell doesn't throw an exception - when I rewrite this code to use signals, haskell, after I press Ctrl-C several times exits with error "too many pending signals" I put the test code in the end of the letter. Shortly the longTask doesn't handle Ctrl-C and longTask' handles it. I couldn't find any solutions to this problem, I am afraid that this problem could occur in other non-native haskell modules (bindings to C libraries) Many thanks in advance, Vasyl pasternak ------------------------------------------ Test code: module Main where import Prelude hiding (catch) import Network.Curl import Control.Exception import Control.Monad import System.IO errorHandler defVal e = do putStrLn $ "Error: " ++ (show (e :: ErrorCall)) return defVal link = "far-far-away-site.com.net" getSite curl l = do r <- do_curl_ curl l method_GET :: IO (CurlResponse) if respCurlCode r /= CurlOK then error "get page failed" else return $ respBody r -- this long task doesn't throw user interrupts longTask = do putStrLn "Long task started" curl <- initialize setopts curl [CurlCookieJar "cookies"] handle (errorHandler ()) $ mapM_ (\_ -> getSite curl link >> return ()) [0..100] return () -- this trows longTask' = do putStrLn "long task started" let fib n = foldr (*) 1 [1..n] h <- openFile "/dev/null" WriteMode -- never ends mapM_ (hPutStr h . show . fib) [1..] return () onAbort e = do let x = show (e :: AsyncException) putStrLn $ "Aborted: " ++ x return () main :: IO () main = do handle onAbort longTask putStrLn "Exiting" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/8f123702/attachment.html From alexey.skladnoy at gmail.com Thu Sep 24 05:40:57 2009 From: alexey.skladnoy at gmail.com (Alexey Khudyakov) Date: Thu Sep 24 05:19:11 2009 Subject: [Haskell-cafe] [uvector] derive UA instance for newtype In-Reply-To: References: <200909232304.58119.alexey.skladnoy@gmail.com> Message-ID: <8425cc0e0909240240u4a5f6673gba6f897c62337361@mail.gmail.com> On Wed, Sep 23, 2009 at 11:19 PM, Daniel Peebles wrote: > I believe this is a bug that was introduced in 6.10.2 (it definitely > worked in 6.10.1) that has since been fixed in HEAD. This newtype > deriving issue also prevents the uvector testsuite from running at the > moment. > Yes. It works in 6.10.1 From bulat.ziganshin at gmail.com Thu Sep 24 05:45:58 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Thu Sep 24 05:24:19 2009 Subject: [Haskell-cafe] Ctrl-C handling in Haskell with curl on Linux In-Reply-To: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> References: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> Message-ID: <79331623.20090924134558@gmail.com> Hello Vasyl, Thursday, September 24, 2009, 1:30:46 PM, you wrote: > I couldn't find any solutions to this problem, I am afraid that > this problem could occur in other non-native haskell modules (bindings to C libraries) look at GHC.ConsoleHandler module -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From allbery at ece.cmu.edu Thu Sep 24 06:20:02 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Sep 24 05:58:28 2009 Subject: [Haskell-cafe] Ctrl-C handling in Haskell with curl on Linux In-Reply-To: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> References: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> Message-ID: <35A18675-1CE8-4997-B1A9-826478B80189@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/b68423ff/PGP.bin From allbery at ece.cmu.edu Thu Sep 24 06:27:29 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Thu Sep 24 06:05:46 2009 Subject: [Haskell-cafe] Ctrl-C handling in Haskell with curl on Linux In-Reply-To: <35A18675-1CE8-4997-B1A9-826478B80189@ece.cmu.edu> References: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> <35A18675-1CE8-4997-B1A9-826478B80189@ece.cmu.edu> Message-ID: <15926D00-18F9-4878-A367-9B752C5AEBA7@ece.cmu.edu> Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/ad1b697f/PGP.bin From ivan.miljenovic at gmail.com Thu Sep 24 06:28:23 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu Sep 24 06:06:43 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.5.1.1 Message-ID: <87ocp0d4c8.fsf@gmail.com> I'm pleased to announce version 2999.5.1.1 [1] of the graphviz library, which provides bindings to the GraphViz [2] suite of tools for drawing graphs. [1] http://hackage.haskell.org/package/graphviz-2999.5.1.1 [2] http://www.graphviz.org/ This is yet another bugfix release, fixing the problem spotted by Kathleen Fisher where Dot keywords need to be explicitly quoted if used as labels, etc. Once again, this is done automagically with no change to the API. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From hoknamahn at gmail.com Thu Sep 24 07:02:44 2009 From: hoknamahn at gmail.com (Olex P) Date: Thu Sep 24 06:41:00 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: References: <4AAF7EF2.9050203@btinternet.com> <4ABAE85D.4080304@goto10.org> Message-ID: Awesome! On Thu, Sep 24, 2009 at 7:47 AM, Peter Verswyvelen wrote: > This is seriously cool stuff!!! > > Maybe it's time to start a "Haskell Demo Scene" :-) > > (what's a "demo scene"? See http://en.wikipedia.org/wiki/Demoscene ) > > PS: Note that Conal Elliott also was generating GPU code using Haskell > with Vertigo back in 2004: http://conal.net/papers/Vertigo/ > > > > > > On Thu, Sep 24, 2009 at 5:32 AM, Claude Heiland-Allen > wrote: > > Andrew Coppin wrote: > >> > >> (OK, well the *best* way is to use the GPU. But AFAIK that's still a > >> theoretical research project, so we'll leave that for now.) > > > > Works for me :-) > > > > http://claudiusmaximus.goto10.org/cm/2009-09-24_fl4m6e_in_haskell.html > > > > There doesn't need to be a sound theoretical foundation for everything, > > sometimes sufficient ugly hackery will make pretty pretty pictures... > > > > > > Claude > > -- > > http://claudiusmaximus.goto10.org > > _______________________________________________ > > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/ff3df8cd/attachment.html From alp at mestan.fr Thu Sep 24 07:09:34 2009 From: alp at mestan.fr (Alp Mestan) Date: Thu Sep 24 06:47:49 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: References: <4AAF7EF2.9050203@btinternet.com> <4ABAE85D.4080304@goto10.org> Message-ID: This is just awesome indeed. You should create a haskell wiki page about that, so that "beginners" could see Haskell can do that (TM) (yeah, some beginners doubt of it). On Thu, Sep 24, 2009 at 1:02 PM, Olex P wrote: > Awesome! > > > On Thu, Sep 24, 2009 at 7:47 AM, Peter Verswyvelen wrote: > >> This is seriously cool stuff!!! >> >> Maybe it's time to start a "Haskell Demo Scene" :-) >> >> (what's a "demo scene"? See http://en.wikipedia.org/wiki/Demoscene ) >> >> PS: Note that Conal Elliott also was generating GPU code using Haskell >> with Vertigo back in 2004: http://conal.net/papers/Vertigo/ >> >> >> >> >> >> On Thu, Sep 24, 2009 at 5:32 AM, Claude Heiland-Allen >> wrote: >> > Andrew Coppin wrote: >> >> >> >> (OK, well the *best* way is to use the GPU. But AFAIK that's still a >> >> theoretical research project, so we'll leave that for now.) >> > >> > Works for me :-) >> > >> > http://claudiusmaximus.goto10.org/cm/2009-09-24_fl4m6e_in_haskell.html >> > >> > There doesn't need to be a sound theoretical foundation for everything, >> > sometimes sufficient ugly hackery will make pretty pretty pictures... >> > >> > >> > Claude >> > -- >> > http://claudiusmaximus.goto10.org >> > _______________________________________________ >> > 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 > > -- Alp Mestan http://blog.mestan.fr/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/b0c12707/attachment.html From pitekus at gmail.com Thu Sep 24 07:53:51 2009 From: pitekus at gmail.com (=?UTF-8?Q?Grzegorz_Chrupa=C5=82a?=) Date: Thu Sep 24 07:32:05 2009 Subject: [Haskell-cafe] Bug in writeArray? In-Reply-To: <766034098.20090923193641@gmail.com> References: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> <766034098.20090923193641@gmail.com> Message-ID: <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> 2009/9/23 Bulat Ziganshin : > Hello Grzegorz, > > Wednesday, September 23, 2009, 7:19:59 PM, you wrote: > >> This seems like a bug in the implementation of writeArray: when passed >> ? let (l,u) = ((0,10),(20,20)) > > writeArray computes raw index (from 0 to total number of array > elements) and check that this index is correct. with multi-dimensional > arrays this approach may lead to wrong results, as you mentioned. it's > known problem that isn't fixed for a long time probably due to > efficiency cautions. Hmm, I understand that efficiency is an issue, but in that case shouldn't unsafe writing be provided by and unsafeWriteArray function, while writeArray does proper range checking? Or at least this problem with writeArray should be clearly indicated in the documentation. I for one spent several hours debugging before finding out about this lack of proper range checks so it's not an imaginary problem. -- Grzegorz From vasyl.pasternak at gmail.com Thu Sep 24 08:24:16 2009 From: vasyl.pasternak at gmail.com (Vasyl Pasternak) Date: Thu Sep 24 08:02:32 2009 Subject: [Haskell-cafe] Ctrl-C handling in Haskell with curl on Linux In-Reply-To: <15926D00-18F9-4878-A367-9B752C5AEBA7@ece.cmu.edu> References: <8feb08f70909240230l4226c33r9d9b594c95723b11@mail.gmail.com> <35A18675-1CE8-4997-B1A9-826478B80189@ece.cmu.edu> <15926D00-18F9-4878-A367-9B752C5AEBA7@ece.cmu.edu> Message-ID: <8feb08f70909240524ga552b75wb866ec44fd7e810d@mail.gmail.com> Thank you, You give me and idea, and I fixed this annoying bug - we should only wrap all curl code into withCurlDo function, so the longTask function should be following: longTask = do putStrLn "Long task started (curl)" withCurlDo $ do curl <- initialize setopts curl [CurlCookieJar "cookies"] handle (errorHandler ()) $ mapM_ (\_ -> getSite curl link >> return ()) [0..100] return () Now it works fine and handles interrupts correctly. Best regards, Vasyl Pasternak 2009/9/24 Brandon S. Allbery KF8NH > On Sep 24, 2009, at 06:20 , Brandon S. Allbery KF8NH wrote: > > On Sep 24, 2009, at 05:30 , Vasyl Pasternak wrote: > > Yesterday I tried to implement simple tool to download pages, and wanted > catch Ctrl-C (and other 'killing' messages) from haskell to handle state > saving. Without curl (when I perform some long operation) haskell throws > UserInterrupt exception immediately, but if I put long operation, which > downloads page from the WEB (from the far-far-away server :) ) than I > noticed following issues: > > > You're going to have problems any time a C library installs its own signal > handler, which I would expect libcurl to do so it can clean up after itself. > This is true even in C-to-C calling; you need a way to hook the signal > handler, which some libraries provide in their API and others you just lose. > > > Just occurred to me I should clarify: while most exception handling > mechanisms support the concept of re-throwing exceptions to outer exception > handlers, POSIX signals do not. The best you could hope for in a library > routine which handles signals itself is an API hook into the signal handler; > next best is the API returning a signal-occurred error/exception value. > > Note that I have no idea how the equivalent signaling mechanism works on > Win32. > > -- > brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com > system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu > electrical and computer engineering, carnegie mellon university KF8NH > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/2091dc5d/attachment.html From duncan.coutts at worc.ox.ac.uk Wed Sep 23 16:41:56 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 24 08:48:34 2009 Subject: [Haskell-cafe] Status of GHC as a Cross Compiler In-Reply-To: References: Message-ID: <1253738516.18961.4966.camel@localhost> On Wed, 2009-09-23 at 14:50 -0400, John Van Enk wrote: > Hi, > > This may be more appropriate for a different list, but I'm having a > hard time figuring out whether or not we're getting a cross compiler > in 6.12 or not. Can some one point me to the correct place in Traq to > find this information? We're getting slightly closer but it's not even nearly there yet. You might have read about the changes in the native code generator towards building all backends on each platform. However there are a lot of other changes needed especially in the build system to make a full cross-compiler. I know some people have worked on this for ARM but there's nothing integrated yet. Duncan From duncan.coutts at worc.ox.ac.uk Thu Sep 24 09:17:36 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 24 08:55:51 2009 Subject: [Haskell-cafe] gtk2hs and runghc In-Reply-To: References: <1C81A697-BC8B-4683-A67F-119252F4CD9A@ece.cmu.edu> <1253726969.18961.4731.camel@localhost> <1253736745.18961.4918.camel@localhost> Message-ID: <1253798256.18961.5966.camel@localhost> On Thu, 2009-09-24 at 00:10 +0200, G?nther Schmidt wrote: > Hi Duncan, > > so ... I have a green light to call gtk from within a forkIO thread for as > long as I make sure that the rts is single threaded? Yes and that works very nicely (with the cooperative scheduling trick described in the gtk2hs FAQ). > BTW: I was already strongly put off using unsafeInitGUIwForThreadedRTS but > thanks for the warning. > > Thus my back to my original question: Can I start either ghci or runghc > with a single-threaded rts so I don't have to compile the app every time I > want to check my really trick GUI code? No. The ghc binary itself (ghc, runghc, ghci) is linked using the threaded runtime system. That's a link-time choice, there's no way to turn it on/off at the command line (that might change in future with shared libs). Duncan From vanenkj at gmail.com Thu Sep 24 09:44:52 2009 From: vanenkj at gmail.com (John Van Enk) Date: Thu Sep 24 09:23:09 2009 Subject: [Haskell-cafe] Status of GHC as a Cross Compiler In-Reply-To: <1253738516.18961.4966.camel@localhost> References: <1253738516.18961.4966.camel@localhost> Message-ID: Thanks. I'd heard rumors about a year ago that 6.12 might have a cross compiler. I just wanted to check. :) On Wed, Sep 23, 2009 at 4:41 PM, Duncan Coutts wrote: > On Wed, 2009-09-23 at 14:50 -0400, John Van Enk wrote: > > Hi, > > > > This may be more appropriate for a different list, but I'm having a > > hard time figuring out whether or not we're getting a cross compiler > > in 6.12 or not. Can some one point me to the correct place in Traq to > > find this information? > > We're getting slightly closer but it's not even nearly there yet. > > You might have read about the changes in the native code generator > towards building all backends on each platform. However there are a lot > of other changes needed especially in the build system to make a full > cross-compiler. I know some people have worked on this for ARM but > there's nothing integrated yet. > > Duncan > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/bf0fc3a4/attachment.html From brad.larsen at gmail.com Thu Sep 24 12:30:24 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Sep 24 12:08:37 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> Message-ID: The modularity problem I speak of is that to add a new interpretation of the DSL, I will likely have to modify the EDSL definition to add additional constraints. Ideally, I would like to be able to define the EDSL once, in a module, and be able to write arbitrary interpretations of it in other modules, without having to go back and change the EDSL definition. Regards, Bradford Larsen On Sep 24, 2009 2:15 AM, "Luke Palmer" wrote: On Wed, Sep 23, 2009 at 10:24 PM, Brad Larsen wrote: > On Wed, Sep 23, 2009 ... >> I would like to see an example of this unmodularity, making use of the >> polymorphism, so I can ... > [...] > > A simple test case, combining boolean expressions and arithmetic expressions: > > test1 = con... Looks great! So, where is the modularity problem? Luke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/b6154a9d/attachment.html From iavor.diatchki at gmail.com Thu Sep 24 12:32:13 2009 From: iavor.diatchki at gmail.com (Iavor Diatchki) Date: Thu Sep 24 12:10:26 2009 Subject: [Haskell-cafe] Bug in writeArray? In-Reply-To: <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> References: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> <766034098.20090923193641@gmail.com> <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> Message-ID: <5ab17e790909240932u21e290eep9c771df768df51a5@mail.gmail.com> I agree with Grzegorz. Perhaps we should file a bug-report, if there isn't one already? -Iavor 2009/9/24 Grzegorz Chrupa?a : > 2009/9/23 Bulat Ziganshin : >> Hello Grzegorz, >> >> Wednesday, September 23, 2009, 7:19:59 PM, you wrote: >> >>> This seems like a bug in the implementation of writeArray: when passed >>> ? let (l,u) = ((0,10),(20,20)) >> >> writeArray computes raw index (from 0 to total number of array >> elements) and check that this index is correct. with multi-dimensional >> arrays this approach may lead to wrong results, as you mentioned. it's >> known problem that isn't fixed for a long time probably due to >> efficiency cautions. > > Hmm, I understand that efficiency is an issue, but in that case > shouldn't unsafe writing be provided by and unsafeWriteArray function, > while writeArray does proper range checking? > > Or at least this problem with writeArray should be clearly indicated > in the documentation. I for one spent several hours debugging before > finding out about this lack of proper range checks so it's not an > imaginary problem. > > -- > Grzegorz > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From haskell at gimbo.org.uk Thu Sep 24 12:49:12 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 24 12:27:40 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must be marked as source? Message-ID: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> Hi all, I've developed a bit of a taste for literate Haskell lately, being a verbose sort of guy. Unfortunately, it doesn't seem to interact with Haddock in the way I'd like/expect. I just wanted to check that my understanding of the situation is correct before I (regretfully) give up on LHS. It seems to me that Haddock only picks up annotation comments (ie those that should be included in the produced documentation) from literate Haskell source when those annotations are themselves marked up as source - it seems not to recognise them in the general text. For example, I was expecting/hoping that from the point of view of Haddock, the following literate Haskell code with an annotation-marked paragraph (starts with a vertical bar) in the non-source text. | Turn a foo into a bar. > foo :: Foo -> Bar > foo b = ... ought to be equivalent to the following "illiterate" Haskell: -- | Turn a foo into a bar. foo :: Foo -> Bar foo b = ... ie, it should produce Haddock docs where the definition of foo is annotated with that comment. Sadly, that appears not to be the case. It appears the literate version needs to look like this: > -- | Turn a foo into a bar > foo :: Foo -> Bar > foo b = ... which to my mind rather defeats the purpose of being literate. So: am I right that this is the intended/expected behaviour? If not, how does one get round it? If so, could someone perhaps comment on the prospects/complexity of implementing this - or the reasons why it is in fact a bad idea? Many thanks! -Andy From Alistair.Bayley at invesco.com Thu Sep 24 12:59:25 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Thu Sep 24 12:37:50 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must bemarked as source? In-Reply-To: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9110262AD@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andy Gimblett > > It seems to me that Haddock only picks up annotation comments (ie > those that should be included in the produced documentation) from > literate Haskell source when those annotations are themselves marked > up as source - it seems not to recognise them in the general text. > > It appears the literate > version needs to look like this: > > > -- | Turn a foo into a bar > > foo :: Foo -> Bar > > foo b = ... > > which to my mind rather defeats the purpose of being literate. > > So: am I right that this is the intended/expected behaviour? Haddock currently uses ghc's parser, and I believe the literate preprocessor discards comments. I think there is an item on the haddock wishlist to preserve the literate comments, but I'm not certain... This problem has been solved in cabal, BTW. Cabal preprocesses .lhs itself, rather than trust the compiler to do it, and it preserves the comments. If you generate you haddocks with cabal, then you should be able to use the markup the way you expected. The Takusen source files are written in this style. For example, see: http://darcs.haskell.org/takusen/Database/Enumerator.lhs Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From benja.fallenstein at gmail.com Thu Sep 24 13:07:58 2009 From: benja.fallenstein at gmail.com (Benja Fallenstein) Date: Thu Sep 24 12:46:12 2009 Subject: [Haskell-cafe] Re: [Coq-Club] An encoding of parametricity in Agda In-Reply-To: <5e0214850909230930y1a58d721u6c51935f4f9b9db0@mail.gmail.com> References: <5e0214850909230646k6768320webb9bf3c4a6ae0@mail.gmail.com> <5e0214850909230930y1a58d721u6c51935f4f9b9db0@mail.gmail.com> Message-ID: Hi Taral, Eugene, [Taral] >> Perhaps I don't understand Agda very well, but I don't see >> parametricity here. For one, there's no attempt to prove that: >> >> forall (P Q : forall a, a -> a), P = Q. [Eugene] > Under parametricity, I mean the Reynolds Abstraction Theorem, from > which free theorems follow. Would it help to say that the Abstraction Theorem states that every *definable* function is parametric, whereas Taral's formula states that *every* function of that type is parametric? (Both concepts are useful; Agda presumably has models where Taral's formula does not hold (if it's consistent, i.e. has models at all), so that formula presumably isn't provable in Agda without additional axioms.) All the best, - Benja From dave at zednenem.com Thu Sep 24 13:09:07 2009 From: dave at zednenem.com (David Menendez) Date: Thu Sep 24 12:47:20 2009 Subject: [Haskell-cafe] Bug in writeArray? In-Reply-To: <5ab17e790909240932u21e290eep9c771df768df51a5@mail.gmail.com> References: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> <766034098.20090923193641@gmail.com> <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> <5ab17e790909240932u21e290eep9c771df768df51a5@mail.gmail.com> Message-ID: <49a77b7a0909241009g740d0fa0qb94e58d695e18087@mail.gmail.com> 2009/9/24 Iavor Diatchki : > I agree with Grzegorz. ?Perhaps we should file a bug-report, if there > isn't one already? http://hackage.haskell.org/trac/ghc/ticket/2120 Apparently, it's fixed in GHC 6.12. -- Dave Menendez From duncan.coutts at worc.ox.ac.uk Thu Sep 24 12:51:52 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 24 12:58:44 2009 Subject: [Haskell-cafe] Bug in writeArray? In-Reply-To: <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> References: <73f919100909230819q173e0d0fma1dd25950915520@mail.gmail.com> <766034098.20090923193641@gmail.com> <73f919100909240453j63c63b7n2ebb6d822cd3b58@mail.gmail.com> Message-ID: <1253811112.18961.6231.camel@localhost> On Thu, 2009-09-24 at 13:53 +0200, Grzegorz Chrupa?a wrote: > 2009/9/23 Bulat Ziganshin : > > Hello Grzegorz, > > > > Wednesday, September 23, 2009, 7:19:59 PM, you wrote: > > > >> This seems like a bug in the implementation of writeArray: when passed > >> let (l,u) = ((0,10),(20,20)) > > > > writeArray computes raw index (from 0 to total number of array > > elements) and check that this index is correct. with multi-dimensional > > arrays this approach may lead to wrong results, as you mentioned. it's > > known problem that isn't fixed for a long time probably due to > > efficiency cautions. > > Hmm, I understand that efficiency is an issue, but in that case > shouldn't unsafe writing be provided by and unsafeWriteArray function, > while writeArray does proper range checking? > > Or at least this problem with writeArray should be clearly indicated > in the documentation. I for one spent several hours debugging before > finding out about this lack of proper range checks so it's not an > imaginary problem. It's now fixed: http://hackage.haskell.org/trac/ghc/ticket/2120#comment:13 Duncan From duncan.coutts at worc.ox.ac.uk Thu Sep 24 13:28:02 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 24 13:06:18 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must be marked as source? In-Reply-To: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> Message-ID: <1253813282.18961.6302.camel@localhost> On Thu, 2009-09-24 at 17:49 +0100, Andy Gimblett wrote: > So: am I right that this is the intended/expected behaviour? If not, > how does one get round it? If so, could someone perhaps comment on > the prospects/complexity of implementing this - or the reasons why it > is in fact a bad idea? As Brad says, we implemented this in Cabal by doing a non-standard "unlit" operation. So cabal haddock will "do the right thing" for your examples. Running haddock directly and letting it do the unlitting will get different results. If the consensus is that the style of unliting that Cabal is doing is generally "the right thing" then perhaps we can standardise it and have ghc/haddock do it directly. Duncan From agocorona at gmail.com Thu Sep 24 13:56:17 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Thu Sep 24 13:34:33 2009 Subject: [Haskell-cafe] ANN: Workflow-0.5.5, TCache-0.6.4 RefSerialize-0.2.4 Message-ID: Hi I'm proud to announce Workflow 0.5.5. Workflow has a monad transformer that encapsulates any monad in a state monad that bring automatic state logging and recovery. A workflow can be viewed as a thread that persist across planeed or unplanned application shutdowns. When recovering the excution is resumed at the last action that was logged. The process continues at the same state as if not interruption took place. Any feedback will be appreciated. Besides state logging and recovery, there are a number of communication primitives that are aware of persistence across reinitiations such are persistent queues, persistent timeouts, or wait for events in the STM monad. These primitives permits inter-woikflow communications and communications with external threads. I hope that this package would be useful for very long computations, either the programs that are CPU intensive and produce valuable intermediate data or programs that wait for actions from users and others processes during days or weeks. That is typical in web applications. Such programs can be defined in a single monadic procedure transparently, without regards of saving intermediate results or reinitiations at the correct point. This new version is not restricted to handle a single type. Every intermediate data must be an instance of Read and Show. For complex data types, other persistence mechanisms can be used (see documentation). The package is at: http://hackage.haskell.org/package/Workflow http://hackage.haskell.org/packages/archive/Workflow/0.5.5/Workflow-0.5.5.tar.gz The tar archive has the documentation and some examples. Among them, a simulation of workflow for the creation and approval of documents, with two levels of approval and approval timeouts, It uses most of the features of the package. NOTE: cabal install reports Tar checksum errors when installed, however, such errors do not appear by downloading the tar.gz archive and decompressing it with the unix or windows tools. I do not know why cabal install behaves as such. Here is a simple example: This is a counter that shows a sequence of numbers, one a second: *module Main where import Control.Concurrent(threadDelay) import System.IO (hFlush,stdout) count n= do putStr (show n ++ " " ) >> hFlush stdout >> threadDelay 1000000 count (n+1) main= count 0 * This is the same program, with the added feature of remembering the last count after interruption (sequence.hs): *module Main where import Control.Workflow import Control.Concurrent(threadDelay) import System.IO (hFlush,stdout) mcount n= do step $ putStr (show n ++ " " ) >> hFlush stdout >> threadDelay 1000000 mcount (n+1) main= do registerType :: IO () registerType :: IO Int let start= 0 :: Int startWF "count" start [("count", mcount)] :: IO () * This is the execution log: *Worflow-0.5.5demos>runghc sequence.hs 0 1 2 3 4 5 6 7 sequence.hs: win32ConsoleHandler sequence.hs: sequence.hs: interrupted Worflow-0.5.5demos> Worflow-0.5.5demos>runghc sequence.hs 7 8 9 10 11 .... * This package uses TCache and RefSerialize. I also uploaded new versions of these packages with extensive documentation and examplles included in the tar.gz archives ( cabal install also repor checksum errors, but are OK when downloading and installing by hand): http://hackage.haskell.org/package/TCache http://hackage.haskell.org/packages/archive/TCache/0.6.4/TCache-0.6.4.tar.gz http://hackage.haskell.org/package/RefSerialize http://hackage.haskell.org/packages/archive/RefSerialize/0.2.4/RefSerialize-0.2.4.tar.gz -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/1e513311/attachment.html From haskell at gimbo.org.uk Thu Sep 24 14:48:01 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 24 14:26:21 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must be marked as source? In-Reply-To: <1253813282.18961.6302.camel@localhost> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> <1253813282.18961.6302.camel@localhost> Message-ID: <1503C2F9-DF83-4AE9-8586-89692D231CB5@gimbo.org.uk> On 24 Sep 2009, at 18:28, Duncan Coutts wrote: > On Thu, 2009-09-24 at 17:49 +0100, Andy Gimblett wrote: > >> So: am I right that this is the intended/expected behaviour? If not, >> how does one get round it? If so, could someone perhaps comment on >> the prospects/complexity of implementing this - or the reasons why it >> is in fact a bad idea? > > As Brad says, we implemented this in Cabal by doing a non-standard > "unlit" operation. So cabal haddock will "do the right thing" for your > examples. Running haddock directly and letting it do the unlitting > will > get different results. That's great news for me, except: that's what I tried first, and I've just tried it again and it still doesn't seem to work for me. Perhaps I am doing something wrong...? Here's a toy example LHS file: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=9802 and here's the corresponding .cabal file: http://hpaste.org/fastcgi/hpaste.fcgi/view?id=9803 and here's a screenshot of the resultant HTML: http://is.gd/3DzmT (produced via "runghc Setup configure && runghc Setup haddock" ) Any idea what I'm doing wrong? One thing I did try was removing the blank line between the annotation and the code. Of course, that breaks the LHS rules, so it doesn't build. (I wondered if it was special cased for this purpose.) Thanks again, -Andy From qdunkan at gmail.com Thu Sep 24 15:10:28 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Sep 24 14:48:42 2009 Subject: [Haskell-cafe] best practices for monad transformers and exceptions? In-Reply-To: <858491B0-64EF-4326-9059-E5982CBBF3A5@gmail.com> References: <2518b95d0909232213i54722e16pb1eb2f9811647057@mail.gmail.com> <858491B0-64EF-4326-9059-E5982CBBF3A5@gmail.com> Message-ID: <2518b95d0909241210r7425bf0dw574912768e26b5cf@mail.gmail.com> On Thu, Sep 24, 2009 at 8:11 AM, pepe wrote: > Exceptions in the ErrorT monad are not compositional. > It's the first time I see the approach of stacking > several ErrorT monads. It seems slightly better than > having a 'global' exception type, although the explicit > lifting looks quite painful. > > I really don't know whether there is a way to write > catch_abort, sorry! Even if there is, I don't think you > want to use it. A much better option is to use an extensible > exception type. Yeah, I had forgotten about Tyeable implementations, which is silly since that's how the IO exceptions now work. Your extensible error framework looks pretty nice! I just made the exceptions global (i.e. put them all in the lowest level type) since I only have two at this point, but if I had more I would definitely check out Control.Monad.Exception. Ideally I would like to be able to package up a set of "services" as a transformer and plug it in compositionally without worrying about its implementation, but it seems monad transformers are only part of the way there. You can get some hiding with a newtype, and then you can get unlifted access with classes as mtl does (but then you need a bunch of instance boilerplate), but then if the one of the services the transformer needs is "early return", then you have to pull the ErrorT out and put it into the "final" monad, and handle all the exceptions in the final monad's "run". It would be nice someday to have more satisfactory way of combining effects. I dream of a way to effortlessly create encapsulated transformers that easily compose with other transformers... From duncan.coutts at worc.ox.ac.uk Thu Sep 24 15:10:44 2009 From: duncan.coutts at worc.ox.ac.uk (Duncan Coutts) Date: Thu Sep 24 14:49:33 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must be marked as source? In-Reply-To: <1503C2F9-DF83-4AE9-8586-89692D231CB5@gimbo.org.uk> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> <1253813282.18961.6302.camel@localhost> <1503C2F9-DF83-4AE9-8586-89692D231CB5@gimbo.org.uk> Message-ID: <1253819444.18961.6407.camel@localhost> On Thu, 2009-09-24 at 19:48 +0100, Andy Gimblett wrote: > That's great news for me, except: that's what I tried first, and I've > just tried it again and it still doesn't seem to work for me. Perhaps > I am doing something wrong...? You're quite right, it got broken with the move to haddock2. The code in Cabal-1.6 skips the pre-processing when using haddock2, assuming haddock will handle it. In the current Cabal development version it works properly and I get the right output for your example. Duncan From haskell at gimbo.org.uk Thu Sep 24 15:19:29 2009 From: haskell at gimbo.org.uk (Andy Gimblett) Date: Thu Sep 24 14:57:48 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must be marked as source? In-Reply-To: <1253819444.18961.6407.camel@localhost> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk> <1253813282.18961.6302.camel@localhost> <1503C2F9-DF83-4AE9-8586-89692D231CB5@gimbo.org.uk> <1253819444.18961.6407.camel@localhost> Message-ID: <1C6C538C-0DB6-4995-8F6B-C377002C1C3C@gimbo.org.uk> On 24 Sep 2009, at 20:10, Duncan Coutts wrote: > On Thu, 2009-09-24 at 19:48 +0100, Andy Gimblett wrote: > >> That's great news for me, except: that's what I tried first, and I've >> just tried it again and it still doesn't seem to work for me. >> Perhaps >> I am doing something wrong...? > > You're quite right, it got broken with the move to haddock2. The > code in > Cabal-1.6 skips the pre-processing when using haddock2, assuming > haddock > will handle it. In the current Cabal development version it works > properly and I get the right output for your example. Ah, righto. In that case, I won't shy away from LHS, and I'll be patient for the next Cabal release, or maybe even check out the development version. :-) Many thanks for your reassurance! Cheers, -Andy From byorgey at seas.upenn.edu Thu Sep 24 15:48:47 2009 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Thu Sep 24 15:27:00 2009 Subject: [Haskell-cafe] ANN: diagrams 0.2.1, and planned major improvements Message-ID: <20090924194847.GA15510@seas.upenn.edu> Hi all, I'm pleased to announce version 0.2.1 of the diagrams library, available now on Hackage [1]. This is a minor release which fixes a few bugs and adds a few new combinators, most notably a grid layout combinator contributed by Ganesh Sittampalam. For a full list of the features new to 0.2.1, see the CHANGES file [2]. The real reason for the release is to get existing new features out the door before gearing up for a planned major rewrite of the backend to use a constraint-solving layout engine. This will allow for much greater elegance and flexibility, as well as a number of features (such as arrows connecting different parts of the diagram) which would be difficult or impossible to implement in the current framework. My ultimate vision is for the diagrams library to become a viable alternative to declarative drawing systems such as MetaPost [3] and Asymptote [4], with the distinct advantages that it will be (1) *purely* declarative, and (2) an *embedded* DSL, providing the full power of Haskell and its ecosystem, as opposed to the ad-hoc specialized languages used by MetaPost and Asymptote. If this sounds exciting to you, I hope you'll join me, either by trying out diagrams for your projects and providing feedback, or by contributing some code. If you're interested in helping with the rewrite itself, let me know; I also plan to set up a core/contrib model like that of xmonad, so there should also be plenty of opportunities for contributing independent add-on modules which enhance the core functionality. -Brent [1] http://hackage.haskell.org/package/diagrams [2] http://code.haskell.org/diagrams/CHANGES [3] http://www.tug.org/metapost.html [4] http://asymptote.sourceforge.net/ From qdunkan at gmail.com Thu Sep 24 16:03:21 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Sep 24 15:41:35 2009 Subject: [Haskell-cafe] source locations (was: best practices for monad transformers and exceptions?) Message-ID: <2518b95d0909241303u31d665bbtac7b575641474ed@mail.gmail.com> I forgot to mention this, but control-monad-exception reminded me: Is there any interest in a way for ghc to report source locations? I have a preprocessor that basically works and is really useful but also awkward and not scalable. control-monad-exception has TH which is more scalable but requires manual annotation at every call site. The loch package also requires annotation at call sites. I searched on trac, but it's hard to know what to search for and I only found a feature request to make 'undefined' report line numbers. Some way to have the callee get the caller's location would be quite handy. Perhaps something like: -- | (calling_function, calling_filename, line_number) type SrcPos = Maybe (String, String, Int) {-# SRCPOS_ANNOTATE foo, foo_srcpos #-} foo :: Arg -> Result foo = foo_srcpos Nothing foo_srcpos :: SrcPos -> Arg -> Result foo_srcpos srcpos arg = do State.modify $ \st -> st { state_stack = srcpos : state_stack st } -- or whatever Then ghc will rewrite calls to 'foo' as calls to 'foo_srcpos' and add a SrcPos arg. If the extension isn't present, plain 'foo' will be called which will pass Nothing. This is basically what my preprocessor does, only it doesn't understand modules and importing, so it relies on me having a consistent import convention. I suppose the preprocessor could be extended with the ability to understand import lines... but ghc could put the annotation in .hi and wouldn't have to scan all the source files. My preprocessor wouldn't work with libraries. Getting a complete call stack would be even nicer, and I remember seeing something a while ago about how it would require keeping track of the calls separately from the real (possibly heavily inlined or tail recursive) call stack but would be technically possible especially with some more detailed source code information which I suppose may be in by now... From lemming at henning-thielemann.de Thu Sep 24 18:42:32 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu Sep 24 18:20:46 2009 Subject: [Haskell-cafe] Parallel graphics In-Reply-To: References: <4AAF7EF2.9050203@btinternet.com> <4ABAE85D.4080304@goto10.org> Message-ID: On Thu, 24 Sep 2009, Alp Mestan wrote: > This is just awesome indeed. I'm impressed, too! > You should create a haskell wiki page about that, so that "beginners" could see Haskell > can do that (TM) (yeah, some beginners doubt of it). Don't miss to add it to http://www.haskell.org/haskellwiki/Category:Graphics or so. From qdunkan at gmail.com Thu Sep 24 19:22:02 2009 From: qdunkan at gmail.com (Evan Laforge) Date: Thu Sep 24 19:00:13 2009 Subject: [Haskell-cafe] Re: source locations (was: best practices for monad transformers and exceptions?) In-Reply-To: <2518b95d0909241303u31d665bbtac7b575641474ed@mail.gmail.com> References: <2518b95d0909241303u31d665bbtac7b575641474ed@mail.gmail.com> Message-ID: <2518b95d0909241622l516809a0u33efd02de23dd93c@mail.gmail.com> Sorry! Never mind all that. I just stumbled across http://hackage.haskell.org/trac/ghc/wiki/ExplicitCallStack *sigh* From harold.stenger at gmail.com Thu Sep 24 19:24:13 2009 From: harold.stenger at gmail.com (Haroldo Stenger) Date: Thu Sep 24 19:02:25 2009 Subject: [Haskell-cafe] ANN: diagrams 0.2.1, and planned major improvements In-Reply-To: <20090924194847.GA15510@seas.upenn.edu> References: <20090924194847.GA15510@seas.upenn.edu> Message-ID: <3678e0bb0909241624lb514c75tabb40112566a86ef@mail.gmail.com> simply beautiful 2009/9/24 Brent Yorgey > Hi all, > > I'm pleased to announce version 0.2.1 of the diagrams library, > available now on Hackage [1]. This is a minor release which fixes a > few bugs and adds a few new combinators, most notably a grid layout > combinator contributed by Ganesh Sittampalam. For a full list of the > features new to 0.2.1, see the CHANGES file [2]. > > The real reason for the release is to get existing new features out > the door before gearing up for a planned major rewrite of the backend > to use a constraint-solving layout engine. This will allow for much > greater elegance and flexibility, as well as a number of features > (such as arrows connecting different parts of the diagram) which would > be difficult or impossible to implement in the current framework. > > My ultimate vision is for the diagrams library to become a viable > alternative to declarative drawing systems such as MetaPost [3] and > Asymptote [4], with the distinct advantages that it will be > > (1) *purely* declarative, and > > (2) an *embedded* DSL, providing the full power of Haskell and its > ecosystem, as opposed to the ad-hoc specialized languages used > by MetaPost and Asymptote. > > If this sounds exciting to you, I hope you'll join me, either by > trying out diagrams for your projects and providing feedback, or by > contributing some code. If you're interested in helping with the > rewrite itself, let me know; I also plan to set up a core/contrib > model like that of xmonad, so there should also be plenty of > opportunities for contributing independent add-on modules which > enhance the core functionality. > > -Brent > > [1] http://hackage.haskell.org/package/diagrams > [2] http://code.haskell.org/diagrams/CHANGES > [3] http://www.tug.org/metapost.html > [4] http://asymptote.sourceforge.net/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/bb39d562/attachment.html From wren at freegeek.org Thu Sep 24 20:36:40 2009 From: wren at freegeek.org (wren ng thornton) Date: Thu Sep 24 20:14:56 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> Message-ID: <4ABC1098.3010501@freegeek.org> Brad Larsen wrote: > The modularity problem I speak of is that to add a new interpretation of the > DSL, I will likely have to modify the EDSL definition to add additional > constraints. Ideally, I would like to be able to define the EDSL once, in a > module, and be able to write arbitrary interpretations of it in other > modules, without having to go back and change the EDSL definition. The canonical, if theoretically unsatisfying, way to do this is to lift all type variables into the class specification. Thus, instead of class Foo f where foo :: forall a. a -> f a we would instead have class Foo f a where foo :: a -> f a According to the intention of the design, variables thus lifted should remain polymorphic in instances however they can have contexts applied to them: instance (Num a) => Foo F a where foo = ... The reason this is unsatisfying is that there's no way to enforce that instances don't ground these variables, which can interfere with the validity of applying certain laws/transformations. Also, if you need to lift more than one variable in the same class then it can be tricky to do the encoding right. For instance, when converting Monad into this form (e.g. so we can define an instance for Set) it is prudent to separate it into one class for return and another for join/(>>=)/(>>). But it does solve the problem at hand. -- Live well, ~wren From tdchayes at pacbell.net Thu Sep 24 20:59:32 2009 From: tdchayes at pacbell.net (Terry Hayes) Date: Thu Sep 24 20:37:46 2009 Subject: [Haskell-cafe] Referring to Prelude.(++) Message-ID: <141034.39279.qm@web81503.mail.mud.yahoo.com> I'd like to redefine (++) so that it works on a more general class of "lists" (ListOf a). To do this, I found that I can import the Prelude hiding the definition of (++). Then I want to make [] an instance of ListOf, and have the (++) function call the built-in Prelude.(++). My problem is that I can't figure out how to call the built-in function. Just using "Prelude.(++)" doesn't seem to work in the way that "Prelude.foldl" would (for example). Any ideas? Terry -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/4e82a6dd/attachment.html From pumpkingod at gmail.com Thu Sep 24 21:02:18 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Thu Sep 24 20:40:29 2009 Subject: [Haskell-cafe] Referring to Prelude.(++) In-Reply-To: <141034.39279.qm@web81503.mail.mud.yahoo.com> References: <141034.39279.qm@web81503.mail.mud.yahoo.com> Message-ID: Did you try (Prelude.++)? I think that's the way it needs to be done. Dan On Thu, Sep 24, 2009 at 8:59 PM, Terry Hayes wrote: > I'd like to redefine (++) so that it works on a more general class of > "lists" (ListOf a).? To do this, I found that I can import the Prelude > hiding the definition of (++).? Then I want to make [] an instance of > ListOf, and have the (++) function call the built-in Prelude.(++). > > My problem is that I can't figure out how to call the built-in function. > Just using "Prelude.(++)" doesn't seem to work in the way that > "Prelude.foldl" would (for example). > > Any ideas? > > Terry > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From tdchayes at pacbell.net Thu Sep 24 21:27:39 2009 From: tdchayes at pacbell.net (Terry Hayes) Date: Thu Sep 24 21:05:52 2009 Subject: [Haskell-cafe] Referring to Prelude.(++) In-Reply-To: References: <141034.39279.qm@web81503.mail.mud.yahoo.com> Message-ID: <977260.64449.qm@web81503.mail.mud.yahoo.com> Thanks, you got me to head in the correct direction. I need to import Prelude twice, once without (++) and once qualified only for the (++) function. import Prelude hiding ( (++) ) import qualified Prelude ( (++) ) Terry ________________________________ From: Daniel Peebles To: Terry Hayes Cc: haskell-cafe@haskell.org Sent: Thursday, September 24, 2009 6:02:18 PM Subject: Re: [Haskell-cafe] Referring to Prelude.(++) Did you try (Prelude.++)? I think that's the way it needs to be done. Dan On Thu, Sep 24, 2009 at 8:59 PM, Terry Hayes wrote: > I'd like to redefine (++) so that it works on a more general class of > "lists" (ListOf a). To do this, I found that I can import the Prelude > hiding the definition of (++). Then I want to make [] an instance of > ListOf, and have the (++) function call the built-in Prelude.(++). > > My problem is that I can't figure out how to call the built-in function. > Just using "Prelude.(++)" doesn't seem to work in the way that > "Prelude.foldl" would (for example). > > Any ideas? > > Terry > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090924/8ce27f92/attachment.html From adrian.alexander.may at gmail.com Thu Sep 24 23:35:24 2009 From: adrian.alexander.may at gmail.com (AdrianMay) Date: Thu Sep 24 23:13:35 2009 Subject: [Haskell-cafe] Monad Tutorial in C++ Message-ID: <25606090.post@talk.nabble.com> Just wrote yet another of the above if anybody wants one: http://nuerd.blogspot.com/2009/09/monad-tutorial-in-c.html Adrian. -- View this message in context: http://www.nabble.com/Monad-Tutorial-in-C%2B%2B-tp25606090p25606090.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From adrian.alexander.may at gmail.com Thu Sep 24 23:48:37 2009 From: adrian.alexander.may at gmail.com (AdrianMay) Date: Thu Sep 24 23:26:49 2009 Subject: [Haskell-cafe] Monad Tutorial in C++ In-Reply-To: <25606090.post@talk.nabble.com> References: <25606090.post@talk.nabble.com> Message-ID: <25606162.post@talk.nabble.com> Sorry for the double post - the machine said it had rejected the first one. -- View this message in context: http://www.nabble.com/Monad-Tutorial-in-C%2B%2B-tp25606090p25606162.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From brad.larsen at gmail.com Fri Sep 25 00:05:41 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Sep 24 23:43:53 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <4916F7F2-2BB0-4148-8B2F-27326910A23F@ropas.snu.ac.kr> References: <4916F7F2-2BB0-4148-8B2F-27326910A23F@ropas.snu.ac.kr> Message-ID: Bruno, On Thu, Sep 24, 2009 at 1:20 AM, Bruno Oliveira wrote: > Hello Brad, > > I believe that the problem you encountered is not quite the expression > problem (which is about adding new constructors and functions modularly), > but rather about refining *existing* constructs with more specific types. > One could argue that they are related though but, for your own sake, you may > want to use a term that more directly points to the problem in question. [...] Indeed, for finding existing approaches to this problem, it is prudent to know what others refer to it as. If you squint a little, this looks like an instance of the expression problem: type classes are (families of) constructors, and instances of those type classes (i.e., interpretations) are functions on those constructors. Sincerely, Brad From brad.larsen at gmail.com Fri Sep 25 00:17:08 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Thu Sep 24 23:55:19 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <4ABC1098.3010501@freegeek.org> References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> <4ABC1098.3010501@freegeek.org> Message-ID: Wren, On Thu, Sep 24, 2009 at 8:36 PM, wren ng thornton wrote: > Brad Larsen wrote: >> >> The modularity problem I speak of is that to add a new interpretation of >> the >> DSL, I will likely have to modify the EDSL definition to add additional >> constraints. Ideally, I would like to be able to define the EDSL once, in >> a >> module, and be able to write arbitrary interpretations of it in other >> modules, without having to go back and change the EDSL definition. > > The canonical, if theoretically unsatisfying, way to do this is to lift all > type variables into the class specification. Thus, instead of > > class Foo f where > foo :: forall a. a -> f a > > we would instead have > > class Foo f a where > foo :: a -> f a > > According to the intention of the design, variables thus lifted should > remain polymorphic in instances however they can have contexts applied to > them: > > instance (Num a) => Foo F a where > foo = ... > > The reason this is unsatisfying is that there's no way to enforce that > instances don't ground these variables, which can interfere with the > validity of applying certain laws/transformations. Also, if you need to lift > more than one variable in the same class then it can be tricky to do the > encoding right. For instance, when converting Monad into this form (e.g. so > we can define an instance for Set) it is prudent to separate it into one > class for return and another for join/(>>=)/(>>). But it does solve the > problem at hand. > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I have experimented some in the past day with this canonical technique of lifting type variables into the class specification. This is somewhat successful; however, one problem is that when multiple variables are lifted into the specification, ambiguity creeps in (and over-generality?), in the absence of superclass constraints or functional dependencies. So, for example, Foo seems to work well, but Bar does not: class Foo a where ... class Bar a b where ... One can alleviate the ambiguity of Bar by splitting it into two classes, similarly to splitting up Monad: class PreBar a where ... class (PreBar a) => Bar a b where ... It's not clear to me that such a decomposition is always possible. I'll keep experimenting with modular, tagless EDSLs... Sincerely, Brad From caseyh at istar.ca Fri Sep 25 02:40:14 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Sep 25 02:18:33 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? Message-ID: How does one delare a 2D STUArray in Haskell? I see the following from a diffusion program segment: module Diffusion where import Data.Array import Data.List (sortBy) type VFieldElem = Float type VField = Array (Int,Int) VFieldElem zeros = listArray ((1,1),(imax,jmax)) (repeat 0) From Real World Haskell to declare a 1D array (I changed some of the value names) there is the following: import Data.Array.ST (STUArray) import Data.Array.Unboxed (UArray) import Data.Word (Word32) data PlayingField1D a = PF1D { pf1DState :: (a -> [Word32]) , pf1DArray :: UArray Word32 Bool } data MutPlayingField1D s a = MPF1D { mpf1DState :: (a -> [Word32]) , mutpf1DArray :: STUArray s Word32 Bool } But I cannot see how to declare a 2D array. Although, it is not "strictly" necessary, pun intended, since one can reframe the 1D array as 2D array by using row/column mapping functions. -- Regards, Casey From noteed at gmail.com Fri Sep 25 02:56:25 2009 From: noteed at gmail.com (minh thu) Date: Fri Sep 25 02:34:57 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: References: Message-ID: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> 2009/9/25 Casey Hawthorne : > How does one delare a 2D STUArray in Haskell? Hi, STUArray, like other arrays is parametrized by the type of the index, the "i" in "STUArray s i e" [1]. That "i" is should be an instance of Ix which is a class of the types that can be used as indices. If you want to use 2D indices, that's fine as pairs (of types that are themselves in Ix) are instances of Ix. In your code, (Int,Int) (2d) and Word32 (1d) are the indice types. So STUArray s (Word32,Word32) Bool would be the 2d version of an array indiced by Word32 (that is, an array indiced by pairs of Word32). Cheers, Thu [1] http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-ST.html#t%3ASTUArray From caseyh at istar.ca Fri Sep 25 03:22:25 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Sep 25 03:00:43 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> References: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> Message-ID: Well that makes sense, but for a learner, how is he/she supposed to know that 'i' could be '(i,i)' or for that matter a tuple of n of those i's? "STUArray s i e" Could you also have a tuple of states? Obviosly, 'e' could be a tuple, for instance (Int,Char) -- Regards, Casey From noteed at gmail.com Fri Sep 25 03:49:09 2009 From: noteed at gmail.com (minh thu) Date: Fri Sep 25 03:27:41 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: References: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> Message-ID: <40a414c20909250049x10635d73ka746ea1f5b4d7e4c@mail.gmail.com> 2009/9/25 Casey Hawthorne : > Well that makes sense, but for a learner, how is he/she supposed to > know that 'i' could be '(i,i)' or for that matter a tuple of n of > those i's? > > "STUArray s i e" > > Could you also have a tuple of states? > > Obviosly, 'e' could be a tuple, for instance (Int,Char) Well, 'i' is just a type variable, just like 'a' and 'b' are type variables in the function type map :: (a -> b) -> [a] -> [b] I guess you know that you can "map" a suitable function on a list of pairs, right ? Type variable mean you can use whatever type you want, including pairs, lists, or whatever. So you can have list of whaterver you want, and use whatever you want as indices in arrays.... BUT! But the whatever you want can be constrained a bit: here, the constraint is that the type of the indices must be in Ix, this is what the "Ix i =>" means. For instance, we said we can put whatever you want in a list. But ask GHCi what is the type of inc = map (+1) : Prelude> :t map (+1) map (+1) :: (Num a) => [a] -> [a] You see that you can use "inc" on list of whatever you want (the "a") *provided* the "a" is in Num, the "Num a =>" part of the type signature. Now, you have to look if the type you want to use for your indices is in Ix. Look at [1] and you see that (Ix a, Ix b) => Ix ((,) a b) is an Instance of Ix. (The right part can be read as (a,b) instead of (,) a b). So a pair is in Ix provided its elements are in Ix too. [1] http://hackage.haskell.org/packages/archive/base/4.0.0.0/doc/html/GHC-Arr.html#t%3AIx From noteed at gmail.com Fri Sep 25 03:51:08 2009 From: noteed at gmail.com (minh thu) Date: Fri Sep 25 03:29:39 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: <40a414c20909250049x10635d73ka746ea1f5b4d7e4c@mail.gmail.com> References: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> <40a414c20909250049x10635d73ka746ea1f5b4d7e4c@mail.gmail.com> Message-ID: <40a414c20909250051k207d05e6v31f7a39f3b08a5a9@mail.gmail.com> 2009/9/25 minh thu : > 2009/9/25 Casey Hawthorne : >> Well that makes sense, but for a learner, how is he/she supposed to >> know that 'i' could be '(i,i)' or for that matter a tuple of n of >> those i's? >> >> "STUArray s i e" >> >> Could you also have a tuple of states? >> >> Obviosly, 'e' could be a tuple, for instance (Int,Char) > > Well, 'i' is just a type variable, just like 'a' and 'b' are type > variables in the function type > > map :: (a -> b) -> [a] -> [b] > > I guess you know that you can "map" a suitable function on a list of > pairs, right ? > > Type variable mean you can use whatever type you want, including > pairs, lists, or whatever. > > So you can have list of whaterver you want, and use whatever you want > as indices in arrays.... BUT! > > But the whatever you want can be constrained a bit: here, the > constraint is that the type of the indices must be in Ix, this is what > the "Ix i =>" means. > > For instance, we said we can put whatever you want in a list. But ask > GHCi what is the type of > > inc = map (+1) : > > Prelude> :t map (+1) > map (+1) :: (Num a) => [a] -> [a] > > You see that you can use "inc" on list of whatever you want (the "a") > *provided* the "a" is in Num, the "Num a =>" part of the type > signature. > > Now, you have to look if the type you want to use for your indices is in Ix. > Look at [1] and you see that > > (Ix a, Ix b) => Ix ((,) a b) > > is an Instance of Ix. > > (The right part can be read as (a,b) instead of (,) a b). > > So a pair is in Ix provided its elements are in Ix too. > > [1] http://hackage.haskell.org/packages/archive/base/4.0.0.0/doc/html/GHC-Arr.html#t%3AIx > Forget to say this: You don't have a pair of indices or a pair of states: you have an index which is a pair, and you can have a state which is a pair. Cheers, Thu From Alistair.Bayley at invesco.com Fri Sep 25 04:02:07 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Fri Sep 25 03:40:19 2009 Subject: [Haskell-cafe] Haddock and literate Haskell: annotations must bemarked as source? In-Reply-To: <1C6C538C-0DB6-4995-8F6B-C377002C1C3C@gimbo.org.uk> References: <1AB7D052-41FD-4435-98D1-17F386124896@gimbo.org.uk><1253813282.18961.6302.camel@localhost><1503C2F9-DF83-4AE9-8586-89692D231CB5@gimbo.org.uk><1253819444.18961.6407.camel@localhost> <1C6C538C-0DB6-4995-8F6B-C377002C1C3C@gimbo.org.uk> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9110262AE@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Andy Gimblett > Sent: 24 September 2009 20:19 > > On 24 Sep 2009, at 20:10, Duncan Coutts wrote: > > > On Thu, 2009-09-24 at 19:48 +0100, Andy Gimblett wrote: > > > >> That's great news for me, except: that's what I tried > first, and I've > >> just tried it again and it still doesn't seem to work for me. > >> Perhaps > >> I am doing something wrong...? > > > > You're quite right, it got broken with the move to haddock2. The > > code in > > Cabal-1.6 skips the pre-processing when using haddock2, assuming > > haddock > > will handle it. In the current Cabal development version it works > > properly and I get the right output for your example. > > Ah, righto. In that case, I won't shy away from LHS, and I'll be > patient for the next Cabal release, or maybe even check out the > development version. :-) Doh. I forgot that little detail. You need cabal > 1.6.0.2, which unfortunately is the last released version. The current development one should do it (very easy to install with cabal :-). Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From daniel.is.fischer at web.de Fri Sep 25 06:07:29 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Fri Sep 25 05:46:53 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: References: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> Message-ID: <200909251207.29727.daniel.is.fischer@web.de> Am Freitag 25 September 2009 09:22:25 schrieb Casey Hawthorne: > Well that makes sense, but for a learner, how is he/she supposed to > know that 'i' could be '(i,i)' or for that matter a tuple of n of > those i's? minh thu already explained this very well. > > "STUArray s i e" > > Could you also have a tuple of states? You can't choose the state 's', the documentation says "The strict state-transformer monad. A computation of type ST s a transforms an internal state indexed by s, and returns a value of type a. The s parameter is either * an uninstantiated type variable (inside invocations of runST), or * RealWorld (inside invocations of Control.Monad.ST.stToIO). " Without evil hackery (or stToIO), you can only use ST actions/ST(U)Arrays via runST :: (forall s. ST s a) -> a or runST(U)Array :: Ix i => (forall s. ST s (ST(U)Array s i e)) -> (U)Array i e which have rank 2 types (universally qualified type as type of argument [result]), the 'forall s' within the parentheses says it has to work whatever type the rts chooses (actually none), so if you write myFancyArray :: forall s1, s2. ST (s1,s2) (STUArray (s1,s2) Int Int) you can't use it. > > Obviosly, 'e' could be a tuple, for instance (Int,Char) Not for STUArrays, but for STArrays, there's no problem. > > -- > Regards, > Casey From bulat.ziganshin at gmail.com Fri Sep 25 06:13:47 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Fri Sep 25 05:52:17 2009 Subject: [Haskell-cafe] How does one delare a 2D STUArray in Haskell? In-Reply-To: References: <40a414c20909242356q14907a52yced2ad59d5188f1a@mail.gmail.com> Message-ID: <53793697.20090925141347@gmail.com> Hello Casey, Friday, September 25, 2009, 11:22:25 AM, you wrote: > Well that makes sense, but for a learner, how is he/she supposed to > know that 'i' could be '(i,i)' or for that matter a tuple of n of > those i's? look at Ix class instances: http://www.haskell.org/ghc/docs/latest/html/libraries/base/GHC-Arr.html#v%3ArangeSize -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From Patrick.Browne at comp.dit.ie Fri Sep 25 07:14:17 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Fri Sep 25 06:53:56 2009 Subject: [Haskell-cafe] Proof in Haskell Message-ID: <4ABCA609.60706@comp.dit.ie> Hi, Below is a function that returns a mirror of a tree, originally from: http://www.nijoruj.org/~as/2009/04/20/A-little-fun.html where it was used to demonstrate the use of Haskabelle(1) which converts Haskell programs to the Isabelle theorem prover. Isabelle was used to show that the Haskell implementation of mirror is a model for the axiom: mirror (mirror x) = x My question is this: Is there any way to achieve such a proof in Haskell itself? GHC appears to reject equations such has mirror (mirror x) = x mirror (mirror(Node x y z)) = Node x y z Regards, Pat =================CODE===================== module BTree where data Tree a = Tip | Node (Tree a) a (Tree a) mirror :: Tree a -> Tree a mirror (Node x y z) = Node (mirror z) y (mirror x) mirror Tip = Tip (1)Thanks to John Ramsdell for the link to Haskabelle: http://www.cl.cam.ac.uk/research/hvg/Isabelle/haskabelle.html). From ekirpichov at gmail.com Fri Sep 25 07:19:20 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Fri Sep 25 06:57:31 2009 Subject: [Haskell-cafe] Proof in Haskell In-Reply-To: <4ABCA609.60706@comp.dit.ie> References: <4ABCA609.60706@comp.dit.ie> Message-ID: <5e0214850909250419h35c413abtd6287606bb6757b2@mail.gmail.com> It is not possible at the value level, because Haskell does not support dependent types and thus cannot express the type of the proposition "forall a . forall x:Tree a, mirror (mirror x) = x", and therefore a proof term also cannot be constructed. However, if you manage to express those trees at type level, probably with typeclasses and type families, you might have some success. 2009/9/25 pat browne : > Hi, > Below is a function that returns a mirror of a tree, originally from: > > http://www.nijoruj.org/~as/2009/04/20/A-little-fun.html > > where it was used to demonstrate the use of Haskabelle(1) which converts > Haskell programs to the Isabelle theorem prover. Isabelle was used to > show that the Haskell implementation of mirror is a model for the axiom: > > ?mirror (mirror x) = x > > My question is this: > Is there any way to achieve such a proof in Haskell itself? > GHC appears to reject equations such has > mirror (mirror x) = x > mirror (mirror(Node x y z)) = Node x y z > > > Regards, > Pat > > > =================CODE===================== > module BTree where > > data Tree a = Tip > ? ? ? ? ? ?| Node (Tree a) a (Tree a) > > mirror :: ?Tree a -> Tree a > mirror (Node x y z) = Node (mirror z) y (mirror x) > mirror Tip = Tip > > (1)Thanks to John Ramsdell for the link to Haskabelle: > http://www.cl.cam.ac.uk/research/hvg/Isabelle/haskabelle.html). > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From bugfact at gmail.com Fri Sep 25 09:54:12 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Fri Sep 25 09:32:26 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell Message-ID: Haskell's records are a bit annoying, and type-classes often group together too many methods, which means you make early decisions about future unknown requirements, and IMO you always get it wrong :-) After having read an email in the cafe about the Noop language & Self language, I realized that what I really would like to have is "strong duck typing" on records (or is it called structural subtyping? or prototype-based-objects? or something like that) For example (silly example full of inaccuracies, but you get the picture): class HasPosition a where position :: a -> Point withPosition :: Point -> a -> a class HasVelocity a where velocity :: a -> Vector withVelocity :: Vector -> a -> a which we really should write as field HasPosition :: Point field HasVelocity :: Vector And then record IsKinetic :: HasPosition HasVelocity suppose we write a function like kineticEulerStep dt k = withPosition (position k .+^ dt *^ velocity k) k kineticEulerStep will work on any type a that HasPosition and HasVelocity, and would get inferred signature kineticEulerStep :: IsKinetic a => Float -> a -> a which is identical to kineticEulerStep :: (HasPosition a, HasVelocity a) => Float -> a -> a So basically kineticEulerStep accepts anything that HasPosition and HasVelocity, whatever it is. So if it walks like a duck and ..., then it is a duck, but statically known... We could also do field HasForce :: Vector field HasMass :: Float record IsDynamic :: IsKinetic HasForce HasMass acceleration d = force d ^/ mass d withAcceleration a d = withForce (a ^* mass d) d dynamicEulerStep dt d = withVelocity (velocity d ^+^ dt *^ acceleration d) Of course you would also need type families to be really correct since Vector, Point, etc should also be parametrized. And really kineticEulerStep might also work on something that HasVelocity and HasAcceleration (since the code in dynamicEulerStep is almost the same as kineticEulerStep), so better abstraction might be needed. I'm not sure what kind of overhead a system like this would have in Haskell, since I suspect the many dictionaries are often not optimized away. I think for Haskell prime, something like this was suggested, but is was rejected? Languages like OCaml and haXe also provide a similar feature? I would like to collect ways of doing this in Haskell, without boilerplate, and preferably without runtime overhead. I remember reading OOHaskell a while time ago, and while I didn't understand a lot of it, I recall it also was doing a similar thing, but since the compiler lacks native support, the error messages you get most likely make it impossible to figure out what is going wrong. I think Grapefruit's Records, HList, Data.Accessor, etc.. might also work. Any guidelines and comments regarding "strong duck typing"/"structural subtyping" are very welcome, since the lack of this is the only reason why I would prefer a dynamic language over a static one. Thanks a lot, Peter Verswyvelen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090925/0b5a90b4/attachment.html From toralf.wittner at gmail.com Fri Sep 25 12:15:20 2009 From: toralf.wittner at gmail.com (Toralf Wittner) Date: Fri Sep 25 11:53:31 2009 Subject: [Haskell-cafe] ANN: epoll bindings 0.2 Message-ID: Hi, I am pleased to announce the release of epoll bindings 0.2 available from: http://hackage.haskell.org/package/epoll Epoll is an I/O event notification facility for Linux similar to poll but with good scaling characteristics. This release adds a buffer abstraction on top of the existing low-level bindings, so client code can write and read to buffers without having to deal directly with the underlying epoll event handling. -Toralf From paul at cogito.org.uk Fri Sep 25 12:42:53 2009 From: paul at cogito.org.uk (Paul Johnson) Date: Fri Sep 25 12:21:10 2009 Subject: [Haskell-cafe] Proof in Haskell In-Reply-To: <4ABCA609.60706@comp.dit.ie> References: <4ABCA609.60706@comp.dit.ie> Message-ID: <4ABCF30D.7030003@cogito.org.uk> One alternative approach is to use QuickCheck to test many trees and look for counter-examples. You can also use SmallCheck to do an exhaustive check up to a chosen size of tree. To do this with QuickCheck you would write a function such as prop_mirror :: Node a -> Bool prop_mirror x = (mirror (mirror x)) == x You would also need to define an instance of "Arbitrary" for Node to create random values of the Node type. Then you can call: quickCheck prop_mirror and it will call the prop_mirror function with 100 random test cases. Not the formal proof you wanted, but still very effective at finding bugs. On 25/09/09 12:14, pat browne wrote: > Hi, > Below is a function that returns a mirror of a tree, originally from: > > http://www.nijoruj.org/~as/2009/04/20/A-little-fun.html > > where it was used to demonstrate the use of Haskabelle(1) which converts > Haskell programs to the Isabelle theorem prover. Isabelle was used to > show that the Haskell implementation of mirror is a model for the axiom: > > mirror (mirror x) = x > > My question is this: > Is there any way to achieve such a proof in Haskell itself? > GHC appears to reject equations such has > mirror (mirror x) = x > mirror (mirror(Node x y z)) = Node x y z > > > Regards, > Pat > > > =================CODE===================== > module BTree where > > data Tree a = Tip > | Node (Tree a) a (Tree a) > > mirror :: Tree a -> Tree a > mirror (Node x y z) = Node (mirror z) y (mirror x) > mirror Tip = Tip > > (1)Thanks to John Ramsdell for the link to Haskabelle: > http://www.cl.cam.ac.uk/research/hvg/Isabelle/haskabelle.html). > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jvranish at gmail.com Fri Sep 25 14:14:33 2009 From: jvranish at gmail.com (Job Vranish) Date: Fri Sep 25 13:52:45 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: Message-ID: Short answer: There is no good way of doing what you want. This is actually one of my biggest annoyances with haskell (right up there with disallowing infinite types). They are many techniques that work better or worse depending on the application, but non are very satisfactory IMO. Your typeclass solution(or some variant of) is pretty much your best option. If you're careful about how you define your datatype and classes you can avoid the type families and such, but the whole point is to not have to be careful. If your types are fixed (which is usually true as long as you're not using existentials) you might be able to get away with using -XDisambiguateFieldRecords If you want anything better you're probably going to have to use some form of preprocessor (like OHaskell). Supposedly OCaml has an OO feature that does this but I haven't tried it out. I would suspect that the reason why haskell doesn't provide duck typeing on record fields is that analisys for optimizations is much more complicated (as it currently stands, records are nothing but sugar on top of algeraic datatypes). You can end up with all sorts of weird things with duck typeing on record fields, like unnamed datatypes. For example: (using class constraint style to inidicate a record field restriction for lack of a better syntax) setPosition :: (position a) =>Vector -> a -> a setPosition v x = x { position = v } translate :: (position a) =>Vector -> a -> a translate v x = x { position = v + (position x) } getPosition :: (position a) => a -> Vector getPosition x = position x result :: Vector result = getPosition $ translate someVector $ setPosition someOtherVector The type variable 'a' in these functions is never fixed to a specific type, and it actually doesn't need to be. The compiler would just have to invent a suitable one (a type with only the field 'position' of type Vector). Maybe someday haskell will finially implement good, clean, duck typeable, record functionality. I will be waiting... - Job On Fri, Sep 25, 2009 at 9:54 AM, Peter Verswyvelen wrote: > Haskell's records are a bit annoying, and type-classes often group together > too many methods, which means you make early decisions about future unknown > requirements, and IMO you always get it wrong :-) > After having read an email in the cafe about the Noop language & Self > language, I realized that what I really would like to have is "strong duck > typing" on records (or is it called structural subtyping? or > prototype-based-objects? or something like that) > For example (silly example full of inaccuracies, but you get the picture): > > class HasPosition a where > position :: a -> Point > withPosition :: Point -> a -> a > > class HasVelocity a where > velocity :: a -> Vector > withVelocity :: Vector -> a -> a > > which we really should write as > > field HasPosition :: Point > field HasVelocity :: Vector > > And then > > record IsKinetic :: HasPosition HasVelocity > > suppose we write a function like > > kineticEulerStep dt k = withPosition (position k .+^ dt *^ velocity k) k > > kineticEulerStep will work on any type a that HasPosition and HasVelocity, > and would get inferred signature > > kineticEulerStep :: IsKinetic a => Float -> a -> a > > which is identical to > > kineticEulerStep :: (HasPosition a, HasVelocity a) => Float -> a -> a > > So basically kineticEulerStep accepts anything that HasPosition and > HasVelocity, whatever it is. > > So if it walks like a duck and ..., then it is a duck, but statically > known... > > We could also do > > field HasForce :: Vector > field HasMass :: Float > > record IsDynamic :: IsKinetic HasForce HasMass > > acceleration d = force d ^/ mass d > withAcceleration a d = withForce (a ^* mass d) d > > dynamicEulerStep dt d = withVelocity (velocity d ^+^ dt *^ acceleration d) > > Of course you would also need type families to be really correct since > Vector, Point, etc should also be parametrized. > > And really kineticEulerStep might also work on something that HasVelocity > and HasAcceleration (since the code in dynamicEulerStep is almost the same > as kineticEulerStep), so better abstraction might be needed. > > I'm not sure what kind of overhead a system like this would have in > Haskell, since I suspect the many dictionaries are often not optimized away. > > I think for Haskell prime, something like this was suggested, > but is was rejected? > > Languages like OCaml and haXe also > provide a similar feature? > > I would like to collect ways of doing this in Haskell, without boilerplate, > and preferably without runtime overhead. > > I remember reading OOHaskell a while time ago, and while I didn't > understand a lot of it, I recall it also was doing a similar thing, but > since the compiler lacks native support, the error messages you get most > likely make it impossible to figure out what is going wrong. I think > Grapefruit's Records, HList, Data.Accessor, etc.. might also work. > > Any guidelines and comments regarding "strong duck typing"/"structural > subtyping" are very welcome, since the lack of this is the only reason why I > would prefer a dynamic language over a static one. > > Thanks a lot, > Peter Verswyvelen > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090925/35efa7ab/attachment.html From warrensomebody at gmail.com Fri Sep 25 15:10:37 2009 From: warrensomebody at gmail.com (Warren Harris) Date: Fri Sep 25 14:48:52 2009 Subject: [Haskell-cafe] mapping large structures into memory Message-ID: I've dabbled in haskell, but am by no means an expert. I was hoping someone here could help me settle this debate so that we can more seriously consider haskell for a next version of an application we're building.... I would like to understand better what its capabilities are for directly mapping and managing memory. For instance, I would like mmap many large files into memory and mutate their internals directly... without needing to reallocate them (or chunks of them) in the haskell heap, and without resorting to a byte-array and byte-offset representation. Furthermore, I might also like to map intrinsic haskell data structures into this mmap'd memory such that standard library functions can manipulate them (perhaps in a purely functional way, e.g. treating them as haskell arrays of smaller foreign structures). I understand that the foreign function interface has the ability to marshall/unmarshall C structs, but I'm unsure of the memory implications of using this mechanism. Our application has a very large footprint, and reallocating some or all of these mapped files is a non- starter. Thanks, Warren From dons at galois.com Fri Sep 25 15:14:06 2009 From: dons at galois.com (Don Stewart) Date: Fri Sep 25 14:54:30 2009 Subject: [Haskell-cafe] mapping large structures into memory In-Reply-To: References: Message-ID: <20090925191406.GE31221@whirlpool.galois.com> warrensomebody: > I've dabbled in haskell, but am by no means an expert. I was hoping > someone here could help me settle this debate so that we can more > seriously consider haskell for a next version of an application we're > building.... > > I would like to understand better what its capabilities are for directly > mapping and managing memory. For instance, I would like mmap many large > files into memory and mutate their internals directly... without needing > to reallocate them (or chunks of them) in the haskell heap, and without > resorting to a byte-array and byte-offset representation. Furthermore, I > might also like to map intrinsic haskell data structures into this mmap'd > memory such that standard library functions can manipulate them (perhaps > in a purely functional way, e.g. treating them as haskell arrays of > smaller foreign structures). > > I understand that the foreign function interface has the ability to > marshall/unmarshall C structs, but I'm unsure of the memory implications > of using this mechanism. Our application has a very large footprint, and > reallocating some or all of these mapped files is a non-starter. Thanks, It is entirely possible to use mmap to map structures into memory. Thanks to the foreign function interface, there are well-defined semantics for calling to and from C. The key questions would be: * what is the type and representation of the data you wish to map * what operations on them -- Don From warrensomebody at gmail.com Fri Sep 25 15:31:29 2009 From: warrensomebody at gmail.com (Warren Harris) Date: Fri Sep 25 15:09:44 2009 Subject: [Haskell-cafe] mapping large structures into memory In-Reply-To: <20090925191406.GE31221@whirlpool.galois.com> References: <20090925191406.GE31221@whirlpool.galois.com> Message-ID: <71F5FF54-F1F8-48F7-9915-4347BE7E88D5@gmail.com> On Sep 25, 2009, at 12:14 PM, Don Stewart wrote: > > It is entirely possible to use mmap to map structures into memory. > Thanks to the foreign function interface, there are well-defined > semantics for calling to and from C. > > The key questions would be: > > * what is the type and representation of the data you wish to map > * what operations on them Right... my question relates more to how well the intrinsic type system integrates with foreign/mapped structures. For instance, I wouldn't want to create my own foreign arrays, and have to replicate all sorts of library code that only works on haskell's intrinsic arrays. I'm assuming here that all this mapped data is self-contained, and doesn't point to heap-allocated structures, although that's a related question -- is it possible to inform the gc about heap pointers stored (temporarily) in these structures (and later identify them in order to swizzle them out when flushing the mapped file to disk). Warren From dons at galois.com Fri Sep 25 15:41:48 2009 From: dons at galois.com (Don Stewart) Date: Fri Sep 25 15:22:12 2009 Subject: [Haskell-cafe] mapping large structures into memory In-Reply-To: <71F5FF54-F1F8-48F7-9915-4347BE7E88D5@gmail.com> References: <20090925191406.GE31221@whirlpool.galois.com> <71F5FF54-F1F8-48F7-9915-4347BE7E88D5@gmail.com> Message-ID: <20090925194148.GI31221@whirlpool.galois.com> warrensomebody: > > On Sep 25, 2009, at 12:14 PM, Don Stewart wrote: > >> >> It is entirely possible to use mmap to map structures into memory. >> Thanks to the foreign function interface, there are well-defined >> semantics for calling to and from C. >> >> The key questions would be: >> >> * what is the type and representation of the data you wish to map >> * what operations on them > > Right... my question relates more to how well the intrinsic type system > integrates with foreign/mapped structures. For instance, I wouldn't want > to create my own foreign arrays, and have to replicate all sorts of > library code that only works on haskell's intrinsic arrays. Well, nothing is really 'intrinsic', but the fundamental distinction are unpinned GC-managed memory, and pinned memory. The 'arrays' package illustrates GC-managed memory, while Data.ByteString or the 'carray' or 'hmatrix' library illustrate pinned memory manipulatable with foreign operations. For your mmapped data, you'll need to assign (coerce) the pointers to that data to a type that describes pinned memory. > I'm assuming here that all this mapped data is self-contained, and > doesn't point to heap-allocated structures, although that's a related > question -- is it possible to inform the gc about heap pointers stored > (temporarily) in these structures (and later identify them in order to > swizzle them out when flushing the mapped file to disk). You can associated a ForeignPtr with mmapped data, and have the GC unmap the data for you once references go out of scope. Simple example: - Data.ByteString A fast Haskell type that can be allocated and manipulated by C or Haskell. -- Don From alp at mestan.fr Fri Sep 25 17:25:21 2009 From: alp at mestan.fr (Alp Mestan) Date: Fri Sep 25 17:03:32 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: Message-ID: On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish wrote: > Supposedly OCaml has an OO feature that does this but I haven't tried it > out. > Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. *# let f myobj = myobj#foo "Hi !";; val f : < foo : string -> 'a; .. > -> 'a = * IIRC, there has been work on Template Haskell for structural polymorphism. -- Alp Mestan http://blog.mestan.fr/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090925/03d18487/attachment.html From caseyh at istar.ca Fri Sep 25 17:55:23 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Sep 25 17:33:43 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: Message-ID: <4oeqb5pk39ibh6ov02ducp2cvjld2p2s2p@4ax.com> On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: >On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish wrote: > >> Supposedly OCaml has an OO feature that does this but I haven't tried it >> out. >> > >Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. > >*# let f myobj = myobj#foo "Hi !";; >val f : < foo : string -> 'a; .. > -> 'a = * > >IIRC, there has been work on Template Haskell for structural polymorphism. Structural subtyping/polymorphism: Pros: - an object can be coerced to any compatible type, the types do not have to be specified ahead of time, that is at compile time. Cons: - may be overly permissive; some coercions might not make sense semantically. I wonder how Haskell will minimize the cons, since it is strongly typed. -- Regards, Casey From brad.larsen at gmail.com Fri Sep 25 18:07:57 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Fri Sep 25 17:46:07 2009 Subject: [Haskell-cafe] Re: Beginning of a meta-Haskell [was: An issue with the ``finally tagless'' tradition] In-Reply-To: <20090924055438.C9973176DC@Adric.metnet.navy.mil> References: <20090924055438.C9973176DC@Adric.metnet.navy.mil> Message-ID: Oleg, On Thu, Sep 24, 2009 at 1:54 AM, wrote: > > The topic of an extensible, modular interpreter in the tagless final > style has come up before. A bit more than a year ago, on a flight from > Frankfurt to San Francisco I wrote two interpreters for a trivial > subset of Haskell or ML (PCF actually), just big enough for Power, > Fibonacci and other classic functions. The following code is a > fragment of meta-Haskell. It defines the object language and two > interpreters: one is the typed meta-circular interpreter, and the > other is a non-too-pretty printer. We can write the expression once: > >> power = >> ? fix $ \self -> >> ? lam $ \x -> lam $ \n -> >> ? ? if_ (n <= 0) 1 >> ? ? ? ? (x * ((self $$ x) $$ (n - 1))) > > and interpret it several times, as an integer > >> -- testpw :: Int >> testpw = (unR power) (unR 2) ((unR 7)::Int) >> -- 128 > > or as a string > >> -- testpwc :: P.String >> testpwc = showQC power > > {- > ?"(let self0 = (\\t1 -> (\\t2 -> (if (t2 <= 0) then 1 else (t1 * ((self0 ?t1) ?(t2 - 1)))))) in self0)" > -} > > The code follows. It is essentially Haskell98, with the exception of > multi-parameter type classes (but no functional dependencies, let > alone overlapping instances). > > {-# LANGUAGE NoMonomorphismRestriction, NoImplicitPrelude #-} > {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-} > > -- A trivial introduction to `meta-Haskell', just enough to give a taste > -- Please see the tests at the end of the file > > module Intro where > > import qualified Prelude as P > import Prelude (Monad(..), (.), putStrLn, IO, Integer, Int, ($), (++), > ? ? ? ? ? ? ? ?(=<<), Bool(..)) > import Control.Monad (ap) > import qualified Control.Monad.State as S > > -- Definition of our object language > -- Unlike that in the tagless final paper, the definition here is spread > -- across several type classes for modularity > > class QNum repr a where > ? ?(+) :: repr a -> repr a -> repr a > ? ?(-) :: repr a -> repr a -> repr a > ? ?(*) :: repr a -> repr a -> repr a > ? ?negate :: repr a -> repr a > ? ?fromInteger :: Integer -> repr a > infixl 6 +, - > infixl 7 * > > class QBool repr where > ? ?true, false :: repr Bool > ? ?if_ :: repr Bool -> repr w -> repr w -> repr w > > class QBool repr => QLeq repr a where > ? ?(<=) :: repr a -> repr a -> repr Bool > infix 4 <= > > -- Higher-order fragment of the language > > class QHO repr ?where > ? ?lam ?:: (repr a -> repr r) -> repr (a -> r) > ? ?($$) :: repr (a -> r) -> (repr a -> repr r) > ? ?fix ?:: (repr a -> repr a) -> repr a > infixr 0 $$ > > -- The first interpreter R -- which embeds the object language in > -- Haskell. It is a meta-circular interpreter, and so is trivial. > -- It still could be useful if we wish just to see the result > -- of our expressions, quickly > newtype R a = R{unR :: a} > > instance P.Num a => QNum R a where > ? ?R x + R y = R $ x P.+ y > ? ?R x - R y = R $ x P.- y > ? ?R x * R y = R $ x P.* y > ? ?negate ? ? ?= R . P.negate . unR > ? ?fromInteger = R . P.fromInteger > > instance QBool R where > ? ?true ?= R True > ? ?false = R False > ? ?if_ (R True) ?x y = x > ? ?if_ (R False) x y = y > > instance QLeq R Int where > ? ?R x <= R y = R $ x P.<= y > > instance QHO R where > ? ?lam f ? ? ?= R $ unR . f . R > ? ?R f $$ R x = R $ f x > ? ?fix f ? ? ?= f (fix f) > > -- The second interpreter: pretty-printer > -- Actually, it is not pretty, but sufficient > > newtype S a = S{unS :: S.State Int P.String} > > instance QNum S a where > ? ?S x + S y = S $ app_infix "+" x y > ? ?S x - S y = S $ app_infix "-" x y > ? ?S x * S y = S $ app_infix "*" x y > ? ?negate (S x) = S $ (return $ \xc -> "(negate " ++ xc ++ ")") `ap` x > ? ?fromInteger = S . return . P.show > > app_infix op x y = do > ?xc <- x > ?yc <- y > ?return $ "(" ++ xc ++ " " ++ op ++ " " ++ yc ++ ")" > > instance QBool S where > ? ?true ?= S $ return "True" > ? ?false = S $ return "False" > ? ?if_ (S b) (S x) (S y) = S $ do > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bc <- b > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?xc <- x > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?yc <- y > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?return $ "(if " ++ bc ++ " then " ++ xc ++ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? " else " ++ yc ++ ")" > instance QLeq S a where > ? ?S x <= S y = S $ app_infix "<=" x y > > newName stem = do > ?cnt <- S.get > ?S.put (P.succ cnt) > ?return $ stem ++ P.show cnt > > instance QHO S where > ?S x $$ S y = S $ app_infix "" x y > > ?lam f = S $ do > ? ? ? ? ? ? name <- newName "t" > ? ? ? ? ? ? let xc = name > ? ? ? ? ? ? bc <- unS . f . S $ return xc > ? ? ? ? ? ? return $ "(\\" ++ xc ++ " -> " ++ bc ++ ")" > > ?fix f = S $ do > ? ? ? ? ? ? self <- newName "self" > ? ? ? ? ? ? let sc = self > ? ? ? ? ? ? bc <- unS . f . S $ return sc > ? ? ? ? ? ? return $ "(let " ++ self ++ " = " ++ bc ++ " in " ++ sc ++ ")" > > showQC :: S a -> P.String > showQC (S m) = S.evalState m (unR 0) > > -- ------------------------------------------------------------------------ > -- ? Tests > > -- Perhaps the first test should be the power function... > -- The following code can be interpreted and compiled just as it is... > > power = > ?fix $ \self -> > ?lam $ \x -> lam $ \n -> > ? ?if_ (n <= 0) 1 > ? ? ? ?(x * ((self $$ x) $$ (n - 1))) > > -- The interpreted result > -- testpw :: Int > testpw = (unR power) (unR 2) ((unR 7)::Int) > -- 128 > > -- The result of compilation. > -- testpwc :: P.String > testpwc = showQC power > > {- > "(let self0 = (\\t1 -> (\\t2 -> (if (t2 <= 0) then 1 else (t1 * ((self0 ?t1) ?(t2 - 1)))))) in self0)" > -} Thank you for this example code. Using the technique you show here (and that others have mentioned in discussion in these two threads), i.e., lifting type parameters into the class head, one is able to put constraints on that type when defining instances, and hence modularly define tagless EDSLs. I have played around a bit with this technique and it seems to work well. I need to experiment more, and construct a more substantial EDSL to really evaluate this approach. Sincerely, Brad From caseyh at istar.ca Fri Sep 25 18:55:11 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Fri Sep 25 18:33:29 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: Message-ID: On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: >On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish wrote: > >> Supposedly OCaml has an OO feature that does this but I haven't tried it >> out. >> > >Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. > >*# let f myobj = myobj#foo "Hi !";; >val f : < foo : string -> 'a; .. > -> 'a = * > >IIRC, there has been work on Template Haskell for structural polymorphism. Structural subtyping/polymorphism: Pros: - an object can be coerced to any compatible type, the types do not have to be specified ahead of time, that is at compile time. Cons: - may be overly permissive; some coercions might not make sense semantically. I wonder how Haskell will minimize the cons, since it is strongly typed. I forgot to add: that even if strong typing could be measured on "sum" numerical scale, I don't know whether Haskell has a higher "measure/metric" than OCaml, in the strong typing area. -- Regards, Casey From wren at freegeek.org Fri Sep 25 23:26:43 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Sep 25 23:04:55 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: <7ca3f0160909232012h56327227g8cd7196c929d1456@mail.gmail.com> <7ca3f0160909232315p7e5b184av3cbb158af85cd6f7@mail.gmail.com> <4ABC1098.3010501@freegeek.org> Message-ID: <4ABD89F3.7050302@freegeek.org> Brad Larsen wrote: > On Thu, Sep 24, 2009 at 8:36 PM, wren ng thornton wrote: >> The reason this is unsatisfying is [...] if you need to lift >> more than one variable in the same class then it can be tricky to do the >> encoding right. For instance, when converting Monad into this form (e.g. so >> we can define an instance for Set) it is prudent to separate it into one >> class for return and another for join/(>>=)/(>>). As you say :) > I have experimented some in the past day with this canonical technique > of lifting type variables into the class specification. This is > somewhat successful; however, one problem is that when multiple > variables are lifted into the specification, ambiguity creeps in (and > over-generality?), in the absence of superclass constraints or > functional dependencies. > [...] > One can alleviate the ambiguity of Bar by splitting it into two > classes, similarly to splitting up Monad: > [...] > It's not clear to me that such a decomposition is always possible. > I'll keep experimenting with modular, tagless EDSLs... I don't know that it will always work (though Oleg could say for sure). For simple classes like Monad and similar algebraic concepts, it works quite well; but then the maths are sort of designed that way. The more you move to large families of complexly interconnected methods, the more it seems likely it'll break down or require fundeps/typefamilies to resolve ambiguity cleanly. Depending on exactly what your goal is re multiple interpretation, Ralf Hinze has some nice work on the "lifting lemma" for re-interpreting lambda-calculus syntax under different idioms: http://www.comlab.ox.ac.uk/ralf.hinze/WG2.8//26/slides/ralf.pdf -- Live well, ~wren From wren at freegeek.org Fri Sep 25 23:39:24 2009 From: wren at freegeek.org (wren ng thornton) Date: Fri Sep 25 23:17:35 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: Message-ID: <4ABD8CEC.8030403@freegeek.org> Peter Verswyvelen wrote: > After having read an email in the cafe about the Noop language & Self > language, I realized that what I really would like to have is "strong duck > typing" on records (or is it called structural subtyping? or > prototype-based-objects? or something like that) The common name for (one form of) what you're seeking is "row polymorphism": http://www.cs.cmu.edu/~neelk/rows.pdf This is implemented in OCaml but, like most OO features in functional languages, it is often ignored or forgotten about. As others've mentioned, there are some cases where row polymorphism is really nice, but it's not always semantically coherent. -- Live well, ~wren From sebastian.sylvan at gmail.com Sat Sep 26 00:30:10 2009 From: sebastian.sylvan at gmail.com (Sebastian Sylvan) Date: Sat Sep 26 00:08:20 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: <4oeqb5pk39ibh6ov02ducp2cvjld2p2s2p@4ax.com> References: <4oeqb5pk39ibh6ov02ducp2cvjld2p2s2p@4ax.com> Message-ID: <3d96ac180909252130t3f31f72fw4ef2e36b82584cd4@mail.gmail.com> On Fri, Sep 25, 2009 at 10:55 PM, Casey Hawthorne wrote: > On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: > > >On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish wrote: > > > >> Supposedly OCaml has an OO feature that does this but I haven't tried it > >> out. > >> > > > >Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. > > > >*# let f myobj = myobj#foo "Hi !";; > >val f : < foo : string -> 'a; .. > -> 'a = * > > > >IIRC, there has been work on Template Haskell for structural polymorphism. > > Structural subtyping/polymorphism: > > Pros: > - an object can be coerced to any compatible type, the types do not > have to be specified ahead of time, that is at compile time. > > Cons: > - may be overly permissive; some coercions might not make sense > semantically. > > I wonder how Haskell will minimize the cons, since it is strongly > typed. > > I kind of think there's no real problem here. If you say that you can accept any record with a given set of fields, then you have to make sure you make no other assumptions. This is, in principle, no different from passing a speed Double to a function that expects a mass Double (e.g. it may produce garbage for negative values). In both cases a function that requires extra invariants can enforce it by using a newtype that's constructed and manipulated in a way which preserves the extra semantic rules. -- Sebastian Sylvan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090926/4cdb97d0/attachment-0001.html From bugfact at gmail.com Sat Sep 26 11:40:53 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sat Sep 26 11:19:02 2009 Subject: [Haskell-cafe] Type parametrized modules (was Strong duck typing) Message-ID: Thanks a lot for the answers. Another feature I really miss is type parameterized modules. For example, suppose I have a module that defines simple geometry / linear algebra math, with types like Vector a, Matrix a, Point a, Size a, Rectangle a, etc... Usually when you import such a module, you will be picking one particular type for "a" across the whole module or even program, e.g. Double, Float, Complex Double. I see such a type more like a "module global type", so instead of writing import qualified MyGeometry (Vector, Matrix, Point, Size, Rectangle) as G type Vector = G.Vector Float type Matrix = G.Matrix Float type Point = G.Point Float etc I would like to write import (MyGeometry Float) or even module (MyGame real) import (MyGeometry real) and then I can just use Vector, Matrix, etc, without specifying the type. So it's as if (MyGeometry Float) performs a "partial type application", just like ((+) 1) does "partial value application" However, when writing import MyGeometry one would have to use the parametrized version of Vector etc again. I'm not sure if this makes any sense, or if it is even worth considering :-) On Sat, Sep 26, 2009 at 6:30 AM, Sebastian Sylvan < sebastian.sylvan@gmail.com> wrote: > > > On Fri, Sep 25, 2009 at 10:55 PM, Casey Hawthorne wrote: > >> On Fri, 25 Sep 2009 23:25:21 +0200, you wrote: >> >> >On Fri, Sep 25, 2009 at 8:14 PM, Job Vranish wrote: >> > >> >> Supposedly OCaml has an OO feature that does this but I haven't tried >> it >> >> out. >> >> >> > >> >Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. >> > >> >*# let f myobj = myobj#foo "Hi !";; >> >val f : < foo : string -> 'a; .. > -> 'a = * >> > >> >IIRC, there has been work on Template Haskell for structural >> polymorphism. >> >> Structural subtyping/polymorphism: >> >> Pros: >> - an object can be coerced to any compatible type, the types do not >> have to be specified ahead of time, that is at compile time. >> >> Cons: >> - may be overly permissive; some coercions might not make sense >> semantically. >> >> I wonder how Haskell will minimize the cons, since it is strongly >> typed. >> >> > I kind of think there's no real problem here. If you say that you can > accept any record with a given set of fields, then you have to make sure you > make no other assumptions. This is, in principle, no different from passing > a speed Double to a function that expects a mass Double (e.g. it may produce > garbage for negative values). In both cases a function that requires extra > invariants can enforce it by using a newtype that's constructed and > manipulated in a way which preserves the extra semantic rules. > > -- > Sebastian Sylvan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090926/74babbf0/attachment.html From ekmett at gmail.com Sat Sep 26 11:41:08 2009 From: ekmett at gmail.com (Edward Kmett) Date: Sat Sep 26 11:19:17 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: References: <4916F7F2-2BB0-4148-8B2F-27326910A23F@ropas.snu.ac.kr> Message-ID: <7fb8f82f0909260841q7dd8c0cbmbe1e9bad17e3cd04@mail.gmail.com> I would just like to add that Oleg and Chung-chieh made sure in their finally tagless paper to use monomorphic lifting of literals explicitly to avoid this sort of ambiguity. Using Num or another typeclass is fine as long as all you want to do is evaluate your EDSL. But what about partial evaluation? CPS transformation? Compilation? You might be able to muddle through the first two, but compilation will derail your solution. Ultimately you will not be able to work over arbitrary Num instances if you want to do more than interpret. That was the main point of the monomorphic int :: Int -> r Int, char :: Char -> r Char methods they were using. If all I know about something is that there is a valid Num instance for it I have no way to emit machine code for it. -Edward On Fri, Sep 25, 2009 at 12:05 AM, Brad Larsen wrote: > Bruno, > > On Thu, Sep 24, 2009 at 1:20 AM, Bruno Oliveira > wrote: > > Hello Brad, > > > > I believe that the problem you encountered is not quite the expression > > problem (which is about adding new constructors and functions modularly), > > but rather about refining *existing* constructs with more specific types. > > One could argue that they are related though but, for your own sake, you > may > > want to use a term that more directly points to the problem in question. > [...] > > Indeed, for finding existing approaches to this problem, it is prudent > to know what others refer to it as. If you squint a little, this > looks like an instance of the expression problem: type classes are > (families of) constructors, and instances of those type classes (i.e., > interpretations) are functions on those constructors. > > > Sincerely, > Brad > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090926/61021d72/attachment.html From jfredett at gmail.com Sat Sep 26 12:18:01 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 26 11:56:10 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - Semptember 25, 2009 Message-ID: <4abe3eb9.9453f10a.19ce.29a6@mx.google.com> This week is an experiment, I'm eliminating the mail client from the sendout, and simply using sendmail directly. If this doesn't fix the line ending problem, then I'm pretty sure it's a software issue, and not a client issue. If you notice problems, please email me at this address, put [HWN] in the subject line so my filters will catch it. Please _don't_ email me if there are no problems. Thanks, /Joe --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090926 Issue 133 - September 26, 2009 --------------------------------------------------------------------------- Welcome to issue 133 of HWN, a newsletter covering developments in the [1]Haskell community. This week, we have a few new libraries, some interesting discussion about EDSLs, a comment from Oleg, and dons extolling the virtues of SCIENCE! On the new HWN software front, I've decided to jump right into something I had planned for far further down the development chain. Specifically, rather than scraping GMane for messages, I've been working on a way to grab the messages directly from the mailing-lists. I'm not entirely sure how I'm going to create links as they are now for the messages, but one crisis at a time. Till next week, here's the Haskell Weekly News! Announcements epoll bindings 0.2. Toralf Wittner [2]announced the release of epoll bindings 0.2 available [3]here. Epoll is an I/O event notification facility for Linux similar to poll but with good scaling characteristics. This release adds a buffer abstraction on top of the existing low-level bindings, so client code can write and read to buffers without having to deal directly with the underlying epoll event handling. diagrams 0.2.1, and planned major improvements. Brent Yorgey [4]announced version 0.2.1 of the diagrams library, available now on [5]Hackage. This minor release which fixes a few bugs and adds a few new combinators, most notably a grid layout combinator contributed by Ganesh Sittampalam. Workflow-0.5.5, TCache-0.6.4 RefSerialize-0.2.4. Alberto G. Corona [6]announced Workflow 0.5.5. Workflow provides a monad transformer that encapsulates any monad in a state monad that bring automatic state logging and recovery. A workflow can be viewed as a thread that persist across planeed or unplanned application shutdowns. When recovering the execution is resumed at the last action that was logged. The process continues at the same state as if not interruption took place. graphviz-2999.5.1.1. Ivan Lazar Miljenovic [7]announced version 2999.5.1.1 of the [8]graphviz library. This is another bug-fix release, fixing the problem spotted by Kathleen Fisher where Dot keywords need to be explicitly quoted if used as labels, etc. There is no change to the API. histogram-fill, library for creating histograms. Khudyakov Alexey [9]announced [10]histogram-fill. histogram-fill provides a generic and convenient API for making histograms. Features include, multiple simultaneous histogram creation, Immutable histograms, and Serialization to and from human readable text. Darcs Hacking Sprint - 14-15 November Vienna. Eric Kow [11]announced the third Darcs Hacking Sprint. Which will take place 14-15 November, 2009 at the University of Technology, Vienna, Austria. Anybody who wants to hack on Darcs (or Camp, Focal, SO6, etc) -- Beginners especially -- are welcome! 2nd CFP: TLDI 2010. Andrew Kennedy [12]announced a second call for papers for TLDI2010, the Types in Language Design and Implementation Workshop. darcs 2.3.1: better docs, fewer bugs. Reinier Lamers [13]announced a new stable version of darcs, with bugfixes from 2.3.0, improved documentation, and removal of the old autoconf build system. TFM09: Call for Participation (FMWeek, Eindhoven, November 2009). J.N. Oliveira [14]announced a Call for Participation in TFM2009 2nd Int. FME Conference on Teaching Formal Methods Friday, November 6th 2009, co-located with FM2009 : 16th Int. Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009. Discussion Monad Tutorial in C++. Adrian May [15]wrote a tutorial about monads in some other niche language... Beginning of a meta-Haskell. Oleg -- [16]as if he needs any introduction -- commented on things far above my ability to understand. Evidently, however, it involves extensible, modular interpreters in the ``tagless final'' style. It was a reply to an earlier thread [17]here. An issue with EDSLs in the ``finally tagless'' tradition. Brad Larsen [18]talked about his run in with [19]the expression problem while experimenting with EDSLs. Blog noise [20]Haskell news from the [21]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Bryan O'Sullivan: [22]Riddle me this. * David Amos: [23]Finite geometries, part 3: Points in PG(n,Fq). David's continuing series on Finite Geometries. * Neil Brown: [24]Concurrent Pearl: The Expanding Prime Pipeline. * Mikael Vejdemo Johansson (Syzygy-): [25][MATH198] Lecture 1 now online. Mikael's first Category Theory Lecture is up online. * Brent Yorgey: [26]diagrams 0.2.1, and future plans. * Alex McLean: [27]hackpact week 4. Part of the continuing series on Alex's hackpact progress. * Manuel M T Chakravarty: [28]Heads Up: GHC devs on Macs - GHC's testsuite crashes spotlight indexer on SL. * Clint Moore: [29]8 Cores of Awesome. * Bryan O'Sullivan: [30]Video of my CUFP keynote. * Chris Smith: [31]Thoughts on Hackage and the Haskell Platform. * Manuel M T Chakravarty: [32]Haskell Bindings to C -> c2hs. * Neil Brown: [33]Functions into processes, using arrows. * Brent Yorgey: [34]Functional MetaPost. * Malcolm Wallace: [35]Haskell Symposium 2009 - videos now online. * DEFUN 2009: [36]DEFUN and CUFP 2009 registration are now open!. * Chris Smith: [37]Type Classes With An Easier Example. * Darcs: [38]darcs weekly news #41. * Greg Bacon: [39]Haskell craps. * Bryan O'Sullivan: [40]A new pseudo-random number generator for Haskell. * Thomas M. DuBuisson: [41]HacPDX is Coming. * Dan Piponi (sigfpe): [42]More Parsing With Best First Search. * Osfameron: [43]Coin Tricks. Quotes of the Week * lilac: ponders whether unsafePerformIO would be better as simonSaysPerformIO * bos: [On the type signature of hPrintf] This makes me a sad Irish panda. * ksf: (But if (on the other hand)) (I think only a number in general (whether it be five or a hundred)) (this thought is rather the representation of a method (whereby a multiplicity (for instance a thousand) may be represented (in an image in conformity with a certain concept)) than the image itself. * dons: ah, via the magic of SCIENCE * dobblego: many of my colleagues used to be [fond of ruby] as well until I was let loose on them * dons: (on whether a library is wanted) *yes* put it on Hackage! * BMeph: (about parsec) 'Cause it's light-years ahead of the competition! * switch: Comeon people! You make the news! * ray: I think programmers make the worst programmers, also the worst people, and I'm saying this having not looked at programming reddit in a while. * Orclev: ... a lot of haskell still looks greek to me, and I'm not talking about lambdas. * Jason Dusek: "Some day, we're going to need a short, catchy name for Cabal packages. Let's call them cabbages." [see http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63649]. * Reinier Lamers: If we keep up the current pace of performance hacking, darcs will be complete before you even hit the enter key in a few years * Trent Buck: [To Reiner Lamers] With the appropriate (ie unbuffered) terminal, this is already the case for interactive prompts. About the Haskell Weekly News New editions are posted to [44]the Haskell mailing list as well as to [45]the Haskell Sequence and [46]Planet Haskell. [47]RSS is also available, and headlines appear on [48]haskell.org. To help create new editions of this newsletter, please see the information on [49]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [50]http://patch-tag.com/r/HWN2/home . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63815 3. http://hackage.haskell.org/package/epoll 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63791 5. http://hackage.haskell.org/package/diagrams 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63786 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63770 8. http://hackage.haskell.org/package/graphviz-2999.5.1.1 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63640 10. http://hackage.haskell.org/package/histogram-fill 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17511 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17508 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17507 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17506 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63800 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63761 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 19. http://www.daimi.au.dk/~madst/tool/papers/expression.txt 20. http://planet.haskell.org/ 21. http://haskell.org/haskellwiki/Blog_articles 22. http://www.serpentine.com/blog/2009/09/25/riddle-me-this/ 23. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-3-points-in.html 24. http://chplib.wordpress.com/2009/09/24/the-expanding-prime-pipeline/ 25. http://blog.mikael.johanssons.org/archive/2009/09/math198-lecture-1-now-online/ 26. http://byorgey.wordpress.com/2009/09/24/diagrams-0-2-1-and-future-plans/ 27. http://yaxu.org/hackpact-week-3-2/ 28. http://justtesting.org/post/195668539 29. http://www.l2mlogistics.com/2009/09/8-cores-of-awesome.html 30. http://www.serpentine.com/blog/2009/09/23/video-of-my-cufp-keynote/ 31. http://cdsmith.wordpress.com/2009/09/23/thoughts-on-hackage-and-the-haskell-platform/ 32. http://justtesting.org/post/194790750 33. http://chplib.wordpress.com/2009/09/22/functions-into-processes-using-arrows/ 34. http://byorgey.wordpress.com/2009/09/21/functional-metapost/ 35. http://feedproxy.google.com/~r/malcolm/~3/wxsdwfUArJ8/haskell-symposium-2009-videos-now.html 36. http://www.defun2009.info/blog/2009/06/defun-2009-registration-is-now-open/ 37. http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ 38. http://blog.darcs.net/2009/09/darcs-weekly-news-41.html 39. http://feedproxy.google.com/~r/gbacon/~3/QILx5EtQN4o/haskell-craps.html 40. http://www.serpentine.com/blog/2009/09/19/a-new-pseudo-random-number-generator-for-haskell/ 41. http://tommd.wordpress.com/2009/09/19/hacpdx-is-coming/ 42. http://blog.sigfpe.com/2009/09/language-nomonomorphismrestrictiongener.html 43. http://greenokapi.net/blog/2009/09/19/coin-tricks/ 44. http://www.haskell.org/mailman/listinfo/haskell 45. http://sequence.complete.org/ 46. http://planet.haskell.org/ 47. http://sequence.complete.org/node/feed 48. http://haskell.org/ 49. http://haskell.org/haskellwiki/HWN 50. http://patch-tag.com/r/HWN2/home From brad.larsen at gmail.com Sat Sep 26 12:21:23 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Sat Sep 26 11:59:31 2009 Subject: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition In-Reply-To: <7fb8f82f0909260841q7dd8c0cbmbe1e9bad17e3cd04@mail.gmail.com> References: <4916F7F2-2BB0-4148-8B2F-27326910A23F@ropas.snu.ac.kr> <7fb8f82f0909260841q7dd8c0cbmbe1e9bad17e3cd04@mail.gmail.com> Message-ID: Edward, On Sat, Sep 26, 2009 at 11:41 AM, Edward Kmett wrote: > I would just like to add that Oleg and Chung-chieh made sure in their > finally tagless paper to use monomorphic lifting of literals explicitly to > avoid this sort of ambiguity. Using Num or another typeclass is fine as long > as all you want to do is evaluate your EDSL. But what about partial > evaluation? CPS transformation? Compilation? You might be able to muddle > through the first two, but compilation will derail your solution. Ultimately > you will not be able to work over arbitrary Num instances if you want to do > more than interpret. That was the main point of the monomorphic int :: Int > -> r Int, char :: Char -> r Char methods they were using. If all I know > about something is that there is a valid Num instance for it I have no way > to emit machine code for it. > -Edward [...] If thye type parameter is present in the class head, you can put constraints on it in your instances. E.g., class ENum repr a where constant :: a -> repr a add :: repr a -> repr a -> repr a newtype E a = E { unE :: a } instance (Num a) => ENum E a where constant = E Similarly to the ENum instance for an evaluator, E, you could define a type class for code gen: data UntypedIntermediate = ConstInt Int | ConstFloat Float | Add Intermediate Intermediate class Emittable a where emit :: a -> UntypedIntermediate instance Emittable Int where emit i = ConstInt i instance Emittable Float where emit f = ConstFloat f Then, you could do compilation, given an Emittable constraint: newtype C a = C { unC :: UntypedIntermediate } instance (Emittable a) => ENum C a where constant e = C $ emit $ unC e add e1 e2 = C $ Add (emit $ unC e1) (emit $ unC e2) I think that by using the strategy of lifting type parameters into class head, and by defining the type classes & instances you need for a certain interpretation, you can modularly define tagless EDSLs, i.e. define the language once, as a collection of typeclasses, and then be able to define arbitrary interpretations of that EDSL, in separate modules, without having to modify the EDSL type classes. (Note: I haven't tried running the above code.) Sincerely, Brad From jfredett at gmail.com Sat Sep 26 12:22:17 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 26 12:00:26 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - Semptember 25, 2009 Message-ID: <4abe3fb9.9453f10a.6e9e.708a@mx.google.com> This week is an experiment, I'm eliminating the mail client from the sendout, and simply using sendmail directly. If this doesn't fix the line ending problem, then I'm pretty sure it's a software issue, and not a client issue. If you notice problems, please email me at this address, put [HWN] in the subject line so my filters will catch it. Please _don't_ email me if there are no problems. Thanks, /Joe --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090926 Issue 133 - September 26, 2009 --------------------------------------------------------------------------- Welcome to issue 133 of HWN, a newsletter covering developments in the [1]Haskell community. This week, we have a few new libraries, some interesting discussion about EDSLs, a comment from Oleg, and dons extolling the virtues of SCIENCE! On the new HWN software front, I've decided to jump right into something I had planned for far further down the development chain. Specifically, rather than scraping GMane for messages, I've been working on a way to grab the messages directly from the mailing-lists. I'm not entirely sure how I'm going to create links as they are now for the messages, but one crisis at a time. Till next week, here's the Haskell Weekly News! Announcements epoll bindings 0.2. Toralf Wittner [2]announced the release of epoll bindings 0.2 available [3]here. Epoll is an I/O event notification facility for Linux similar to poll but with good scaling characteristics. This release adds a buffer abstraction on top of the existing low-level bindings, so client code can write and read to buffers without having to deal directly with the underlying epoll event handling. diagrams 0.2.1, and planned major improvements. Brent Yorgey [4]announced version 0.2.1 of the diagrams library, available now on [5]Hackage. This minor release which fixes a few bugs and adds a few new combinators, most notably a grid layout combinator contributed by Ganesh Sittampalam. Workflow-0.5.5, TCache-0.6.4 RefSerialize-0.2.4. Alberto G. Corona [6]announced Workflow 0.5.5. Workflow provides a monad transformer that encapsulates any monad in a state monad that bring automatic state logging and recovery. A workflow can be viewed as a thread that persist across planeed or unplanned application shutdowns. When recovering the execution is resumed at the last action that was logged. The process continues at the same state as if not interruption took place. graphviz-2999.5.1.1. Ivan Lazar Miljenovic [7]announced version 2999.5.1.1 of the [8]graphviz library. This is another bug-fix release, fixing the problem spotted by Kathleen Fisher where Dot keywords need to be explicitly quoted if used as labels, etc. There is no change to the API. histogram-fill, library for creating histograms. Khudyakov Alexey [9]announced [10]histogram-fill. histogram-fill provides a generic and convenient API for making histograms. Features include, multiple simultaneous histogram creation, Immutable histograms, and Serialization to and from human readable text. Darcs Hacking Sprint - 14-15 November Vienna. Eric Kow [11]announced the third Darcs Hacking Sprint. Which will take place 14-15 November, 2009 at the University of Technology, Vienna, Austria. Anybody who wants to hack on Darcs (or Camp, Focal, SO6, etc) -- Beginners especially -- are welcome! 2nd CFP: TLDI 2010. Andrew Kennedy [12]announced a second call for papers for TLDI2010, the Types in Language Design and Implementation Workshop. darcs 2.3.1: better docs, fewer bugs. Reinier Lamers [13]announced a new stable version of darcs, with bugfixes from 2.3.0, improved documentation, and removal of the old autoconf build system. TFM09: Call for Participation (FMWeek, Eindhoven, November 2009). J.N. Oliveira [14]announced a Call for Participation in TFM2009 2nd Int. FME Conference on Teaching Formal Methods Friday, November 6th 2009, co-located with FM2009 : 16th Int. Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009. Discussion Monad Tutorial in C++. Adrian May [15]wrote a tutorial about monads in some other niche language... Beginning of a meta-Haskell. Oleg -- [16]as if he needs any introduction -- commented on things far above my ability to understand. Evidently, however, it involves extensible, modular interpreters in the ``tagless final'' style. It was a reply to an earlier thread [17]here. An issue with EDSLs in the ``finally tagless'' tradition. Brad Larsen [18]talked about his run in with [19]the expression problem while experimenting with EDSLs. Blog noise [20]Haskell news from the [21]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Bryan O'Sullivan: [22]Riddle me this. * David Amos: [23]Finite geometries, part 3: Points in PG(n,Fq). David's continuing series on Finite Geometries. * Neil Brown: [24]Concurrent Pearl: The Expanding Prime Pipeline. * Mikael Vejdemo Johansson (Syzygy-): [25][MATH198] Lecture 1 now online. Mikael's first Category Theory Lecture is up online. * Brent Yorgey: [26]diagrams 0.2.1, and future plans. * Alex McLean: [27]hackpact week 4. Part of the continuing series on Alex's hackpact progress. * Manuel M T Chakravarty: [28]Heads Up: GHC devs on Macs - GHC's testsuite crashes spotlight indexer on SL. * Clint Moore: [29]8 Cores of Awesome. * Bryan O'Sullivan: [30]Video of my CUFP keynote. * Chris Smith: [31]Thoughts on Hackage and the Haskell Platform. * Manuel M T Chakravarty: [32]Haskell Bindings to C -> c2hs. * Neil Brown: [33]Functions into processes, using arrows. * Brent Yorgey: [34]Functional MetaPost. * Malcolm Wallace: [35]Haskell Symposium 2009 - videos now online. * DEFUN 2009: [36]DEFUN and CUFP 2009 registration are now open!. * Chris Smith: [37]Type Classes With An Easier Example. * Darcs: [38]darcs weekly news #41. * Greg Bacon: [39]Haskell craps. * Bryan O'Sullivan: [40]A new pseudo-random number generator for Haskell. * Thomas M. DuBuisson: [41]HacPDX is Coming. * Dan Piponi (sigfpe): [42]More Parsing With Best First Search. * Osfameron: [43]Coin Tricks. Quotes of the Week * lilac: ponders whether unsafePerformIO would be better as simonSaysPerformIO * bos: [On the type signature of hPrintf] This makes me a sad Irish panda. * ksf: (But if (on the other hand)) (I think only a number in general (whether it be five or a hundred)) (this thought is rather the representation of a method (whereby a multiplicity (for instance a thousand) may be represented (in an image in conformity with a certain concept)) than the image itself. * dons: ah, via the magic of SCIENCE * dobblego: many of my colleagues used to be [fond of ruby] as well until I was let loose on them * dons: (on whether a library is wanted) *yes* put it on Hackage! * BMeph: (about parsec) 'Cause it's light-years ahead of the competition! * switch: Comeon people! You make the news! * ray: I think programmers make the worst programmers, also the worst people, and I'm saying this having not looked at programming reddit in a while. * Orclev: ... a lot of haskell still looks greek to me, and I'm not talking about lambdas. * Jason Dusek: "Some day, we're going to need a short, catchy name for Cabal packages. Let's call them cabbages." [see http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63649]. * Reinier Lamers: If we keep up the current pace of performance hacking, darcs will be complete before you even hit the enter key in a few years * Trent Buck: [To Reiner Lamers] With the appropriate (ie unbuffered) terminal, this is already the case for interactive prompts. About the Haskell Weekly News New editions are posted to [44]the Haskell mailing list as well as to [45]the Haskell Sequence and [46]Planet Haskell. [47]RSS is also available, and headlines appear on [48]haskell.org. To help create new editions of this newsletter, please see the information on [49]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [50]http://patch-tag.com/r/HWN2/home . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63815 3. http://hackage.haskell.org/package/epoll 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63791 5. http://hackage.haskell.org/package/diagrams 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63786 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63770 8. http://hackage.haskell.org/package/graphviz-2999.5.1.1 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63640 10. http://hackage.haskell.org/package/histogram-fill 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17511 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17508 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17507 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17506 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63800 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63761 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 19. http://www.daimi.au.dk/~madst/tool/papers/expression.txt 20. http://planet.haskell.org/ 21. http://haskell.org/haskellwiki/Blog_articles 22. http://www.serpentine.com/blog/2009/09/25/riddle-me-this/ 23. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-3-points-in.html 24. http://chplib.wordpress.com/2009/09/24/the-expanding-prime-pipeline/ 25. http://blog.mikael.johanssons.org/archive/2009/09/math198-lecture-1-now-online/ 26. http://byorgey.wordpress.com/2009/09/24/diagrams-0-2-1-and-future-plans/ 27. http://yaxu.org/hackpact-week-3-2/ 28. http://justtesting.org/post/195668539 29. http://www.l2mlogistics.com/2009/09/8-cores-of-awesome.html 30. http://www.serpentine.com/blog/2009/09/23/video-of-my-cufp-keynote/ 31. http://cdsmith.wordpress.com/2009/09/23/thoughts-on-hackage-and-the-haskell-platform/ 32. http://justtesting.org/post/194790750 33. http://chplib.wordpress.com/2009/09/22/functions-into-processes-using-arrows/ 34. http://byorgey.wordpress.com/2009/09/21/functional-metapost/ 35. http://feedproxy.google.com/~r/malcolm/~3/wxsdwfUArJ8/haskell-symposium-2009-videos-now.html 36. http://www.defun2009.info/blog/2009/06/defun-2009-registration-is-now-open/ 37. http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ 38. http://blog.darcs.net/2009/09/darcs-weekly-news-41.html 39. http://feedproxy.google.com/~r/gbacon/~3/QILx5EtQN4o/haskell-craps.html 40. http://www.serpentine.com/blog/2009/09/19/a-new-pseudo-random-number-generator-for-haskell/ 41. http://tommd.wordpress.com/2009/09/19/hacpdx-is-coming/ 42. http://blog.sigfpe.com/2009/09/language-nomonomorphismrestrictiongener.html 43. http://greenokapi.net/blog/2009/09/19/coin-tricks/ 44. http://www.haskell.org/mailman/listinfo/haskell 45. http://sequence.complete.org/ 46. http://planet.haskell.org/ 47. http://sequence.complete.org/node/feed 48. http://haskell.org/ 49. http://haskell.org/haskellwiki/HWN 50. http://patch-tag.com/r/HWN2/home From jfredett at gmail.com Sat Sep 26 12:24:01 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 26 12:02:09 2009 Subject: [Haskell-cafe] Haskell Weekly News: Issue 131 - Semptember 25, 2009 Message-ID: <4abe4021.9553f10a.0bfb.3fbb@mx.google.com> This week is an experiment, I'm eliminating the mail client from the sendout, and simply using sendmail directly. If this doesn't fix the line ending problem, then I'm pretty sure it's a software issue, and not a client issue. If you notice problems, please email me at this address, put [HWN] in the subject line so my filters will catch it. Please _don't_ email me if there are no problems. Thanks, /Joe --------------------------------------------------------------------------- Haskell Weekly News http://sequence.complete.org/hwn/20090926 Issue 133 - September 26, 2009 --------------------------------------------------------------------------- Welcome to issue 133 of HWN, a newsletter covering developments in the [1]Haskell community. This week, we have a few new libraries, some interesting discussion about EDSLs, a comment from Oleg, and dons extolling the virtues of SCIENCE! On the new HWN software front, I've decided to jump right into something I had planned for far further down the development chain. Specifically, rather than scraping GMane for messages, I've been working on a way to grab the messages directly from the mailing-lists. I'm not entirely sure how I'm going to create links as they are now for the messages, but one crisis at a time. Till next week, here's the Haskell Weekly News! Announcements epoll bindings 0.2. Toralf Wittner [2]announced the release of epoll bindings 0.2 available [3]here. Epoll is an I/O event notification facility for Linux similar to poll but with good scaling characteristics. This release adds a buffer abstraction on top of the existing low-level bindings, so client code can write and read to buffers without having to deal directly with the underlying epoll event handling. diagrams 0.2.1, and planned major improvements. Brent Yorgey [4]announced version 0.2.1 of the diagrams library, available now on [5]Hackage. This minor release which fixes a few bugs and adds a few new combinators, most notably a grid layout combinator contributed by Ganesh Sittampalam. Workflow-0.5.5, TCache-0.6.4 RefSerialize-0.2.4. Alberto G. Corona [6]announced Workflow 0.5.5. Workflow provides a monad transformer that encapsulates any monad in a state monad that bring automatic state logging and recovery. A workflow can be viewed as a thread that persist across planeed or unplanned application shutdowns. When recovering the execution is resumed at the last action that was logged. The process continues at the same state as if not interruption took place. graphviz-2999.5.1.1. Ivan Lazar Miljenovic [7]announced version 2999.5.1.1 of the [8]graphviz library. This is another bug-fix release, fixing the problem spotted by Kathleen Fisher where Dot keywords need to be explicitly quoted if used as labels, etc. There is no change to the API. histogram-fill, library for creating histograms. Khudyakov Alexey [9]announced [10]histogram-fill. histogram-fill provides a generic and convenient API for making histograms. Features include, multiple simultaneous histogram creation, Immutable histograms, and Serialization to and from human readable text. Darcs Hacking Sprint - 14-15 November Vienna. Eric Kow [11]announced the third Darcs Hacking Sprint. Which will take place 14-15 November, 2009 at the University of Technology, Vienna, Austria. Anybody who wants to hack on Darcs (or Camp, Focal, SO6, etc) -- Beginners especially -- are welcome! 2nd CFP: TLDI 2010. Andrew Kennedy [12]announced a second call for papers for TLDI2010, the Types in Language Design and Implementation Workshop. darcs 2.3.1: better docs, fewer bugs. Reinier Lamers [13]announced a new stable version of darcs, with bugfixes from 2.3.0, improved documentation, and removal of the old autoconf build system. TFM09: Call for Participation (FMWeek, Eindhoven, November 2009). J.N. Oliveira [14]announced a Call for Participation in TFM2009 2nd Int. FME Conference on Teaching Formal Methods Friday, November 6th 2009, co-located with FM2009 : 16th Int. Symposium on Formal Methods Eindhoven, the Netherlands, November 2 - November 6, 2009. Discussion Monad Tutorial in C++. Adrian May [15]wrote a tutorial about monads in some other niche language... Beginning of a meta-Haskell. Oleg -- [16]as if he needs any introduction -- commented on things far above my ability to understand. Evidently, however, it involves extensible, modular interpreters in the ``tagless final'' style. It was a reply to an earlier thread [17]here. An issue with EDSLs in the ``finally tagless'' tradition. Brad Larsen [18]talked about his run in with [19]the expression problem while experimenting with EDSLs. Blog noise [20]Haskell news from the [21]blogosphere. Blog posts from people new to the Haskell community are marked with >>>, be sure to welcome them! * Bryan O'Sullivan: [22]Riddle me this. * David Amos: [23]Finite geometries, part 3: Points in PG(n,Fq). David's continuing series on Finite Geometries. * Neil Brown: [24]Concurrent Pearl: The Expanding Prime Pipeline. * Mikael Vejdemo Johansson (Syzygy-): [25][MATH198] Lecture 1 now online. Mikael's first Category Theory Lecture is up online. * Brent Yorgey: [26]diagrams 0.2.1, and future plans. * Alex McLean: [27]hackpact week 4. Part of the continuing series on Alex's hackpact progress. * Manuel M T Chakravarty: [28]Heads Up: GHC devs on Macs - GHC's testsuite crashes spotlight indexer on SL. * Clint Moore: [29]8 Cores of Awesome. * Bryan O'Sullivan: [30]Video of my CUFP keynote. * Chris Smith: [31]Thoughts on Hackage and the Haskell Platform. * Manuel M T Chakravarty: [32]Haskell Bindings to C -> c2hs. * Neil Brown: [33]Functions into processes, using arrows. * Brent Yorgey: [34]Functional MetaPost. * Malcolm Wallace: [35]Haskell Symposium 2009 - videos now online. * DEFUN 2009: [36]DEFUN and CUFP 2009 registration are now open!. * Chris Smith: [37]Type Classes With An Easier Example. * Darcs: [38]darcs weekly news #41. * Greg Bacon: [39]Haskell craps. * Bryan O'Sullivan: [40]A new pseudo-random number generator for Haskell. * Thomas M. DuBuisson: [41]HacPDX is Coming. * Dan Piponi (sigfpe): [42]More Parsing With Best First Search. * Osfameron: [43]Coin Tricks. Quotes of the Week * lilac: ponders whether unsafePerformIO would be better as simonSaysPerformIO * bos: [On the type signature of hPrintf] This makes me a sad Irish panda. * ksf: (But if (on the other hand)) (I think only a number in general (whether it be five or a hundred)) (this thought is rather the representation of a method (whereby a multiplicity (for instance a thousand) may be represented (in an image in conformity with a certain concept)) than the image itself. * dons: ah, via the magic of SCIENCE * dobblego: many of my colleagues used to be [fond of ruby] as well until I was let loose on them * dons: (on whether a library is wanted) *yes* put it on Hackage! * BMeph: (about parsec) 'Cause it's light-years ahead of the competition! * switch: Comeon people! You make the news! * ray: I think programmers make the worst programmers, also the worst people, and I'm saying this having not looked at programming reddit in a while. * Orclev: ... a lot of haskell still looks greek to me, and I'm not talking about lambdas. * Jason Dusek: "Some day, we're going to need a short, catchy name for Cabal packages. Let's call them cabbages." [see http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63649]. * Reinier Lamers: If we keep up the current pace of performance hacking, darcs will be complete before you even hit the enter key in a few years * Trent Buck: [To Reiner Lamers] With the appropriate (ie unbuffered) terminal, this is already the case for interactive prompts. About the Haskell Weekly News New editions are posted to [44]the Haskell mailing list as well as to [45]the Haskell Sequence and [46]Planet Haskell. [47]RSS is also available, and headlines appear on [48]haskell.org. To help create new editions of this newsletter, please see the information on [49]how to contribute. Send stories to jfredett . at . gmail . dot . com. The darcs repository is available at darcs get [50]http://patch-tag.com/r/HWN2/home . References 1. http://haskell.org/ 2. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63815 3. http://hackage.haskell.org/package/epoll 4. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63791 5. http://hackage.haskell.org/package/diagrams 6. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63786 7. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63770 8. http://hackage.haskell.org/package/graphviz-2999.5.1.1 9. http://article.gmane.org/gmane.comp.lang.haskell.cafe/63640 10. http://hackage.haskell.org/package/histogram-fill 11. http://article.gmane.org/gmane.comp.lang.haskell.general/17511 12. http://article.gmane.org/gmane.comp.lang.haskell.general/17508 13. http://article.gmane.org/gmane.comp.lang.haskell.general/17507 14. http://article.gmane.org/gmane.comp.lang.haskell.general/17506 15. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63800 16. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63761 17. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 18. http://thread.gmane.org/gmane.comp.lang.haskell.cafe/63751 19. http://www.daimi.au.dk/~madst/tool/papers/expression.txt 20. http://planet.haskell.org/ 21. http://haskell.org/haskellwiki/Blog_articles 22. http://www.serpentine.com/blog/2009/09/25/riddle-me-this/ 23. http://haskellformaths.blogspot.com/2009/09/finite-geometries-part-3-points-in.html 24. http://chplib.wordpress.com/2009/09/24/the-expanding-prime-pipeline/ 25. http://blog.mikael.johanssons.org/archive/2009/09/math198-lecture-1-now-online/ 26. http://byorgey.wordpress.com/2009/09/24/diagrams-0-2-1-and-future-plans/ 27. http://yaxu.org/hackpact-week-3-2/ 28. http://justtesting.org/post/195668539 29. http://www.l2mlogistics.com/2009/09/8-cores-of-awesome.html 30. http://www.serpentine.com/blog/2009/09/23/video-of-my-cufp-keynote/ 31. http://cdsmith.wordpress.com/2009/09/23/thoughts-on-hackage-and-the-haskell-platform/ 32. http://justtesting.org/post/194790750 33. http://chplib.wordpress.com/2009/09/22/functions-into-processes-using-arrows/ 34. http://byorgey.wordpress.com/2009/09/21/functional-metapost/ 35. http://feedproxy.google.com/~r/malcolm/~3/wxsdwfUArJ8/haskell-symposium-2009-videos-now.html 36. http://www.defun2009.info/blog/2009/06/defun-2009-registration-is-now-open/ 37. http://cdsmith.wordpress.com/2009/09/20/side-computations-via-type-classes/ 38. http://blog.darcs.net/2009/09/darcs-weekly-news-41.html 39. http://feedproxy.google.com/~r/gbacon/~3/QILx5EtQN4o/haskell-craps.html 40. http://www.serpentine.com/blog/2009/09/19/a-new-pseudo-random-number-generator-for-haskell/ 41. http://tommd.wordpress.com/2009/09/19/hacpdx-is-coming/ 42. http://blog.sigfpe.com/2009/09/language-nomonomorphismrestrictiongener.html 43. http://greenokapi.net/blog/2009/09/19/coin-tricks/ 44. http://www.haskell.org/mailman/listinfo/haskell 45. http://sequence.complete.org/ 46. http://planet.haskell.org/ 47. http://sequence.complete.org/node/feed 48. http://haskell.org/ 49. http://haskell.org/haskellwiki/HWN 50. http://patch-tag.com/r/HWN2/home From jfredett at gmail.com Sat Sep 26 12:32:07 2009 From: jfredett at gmail.com (Joe Fredette) Date: Sat Sep 26 12:10:17 2009 Subject: [Haskell-cafe] Sorry about the triple post Message-ID: Trying to work out how to make sendmail do what I want, my computer is a fickle beast. Also- it should be HWN issue 133. But I'm an idiot, and just copied the value without thinking. Someday, when I automate all the uploading/sending to the list business, this will not be an issue... :/ /Joe From mpm at alumni.caltech.edu Sat Sep 26 16:42:36 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sat Sep 26 16:20:42 2009 Subject: [Haskell-cafe] combinatorial search with running bound Message-ID: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> I have a combinatorial search problem that requires a running lower bound to be tracked in order to prune the search. I have enough Haskell experience to know how to do a combinatorial search, for example with list compresions or the list monad, but I don't know how to keep a running lower bound. The problem is: I have two groups of boxes, and need to figure out how closely the centers of the groups can be brought left-right. For example, 55 11111 55 11111 44 22 44 22 + <- how close? -> + 33333 6666 33333 6666 33333 The left group consists of boxes 1, 2, and 3, which have both a size and a position (the position is relative to the center of the group, represented with the +). The right group has boxes 4, 5, and 6. The problem is to determine how closely the groups can be brought together without any boxes intersection. The basic algorithm is to consider each pair of boxes and ask if they have any "vertical overlap"---if so, figure out how closely they can be brought together without intersecting, otherwise ignore them. Then take the maximum of those numbers. -- (Here assume lrSeparation returns minBound for boxes that don't have -- vertical intersection.) boxesSep :: [Box] -> [Box] -> Int boxesSep lefts rights = maximum [ lrSeparation l r | l <- lefts, r <- rights ] However, this algorithm can be improved by pruning. - Define the 'left extent' of a box by how far its left edge sticks out to the left of the group center. Similarly the 'right extent'. - Sort the list of left boxes in the order of decreasing right extent. Sort the list of right boxes in order of decreasing left extent. - Consider pairs of boxes as a kind of outer loop on the left boxes, and inner loop on the right boxes. - Track the current maximum required separation, which is a lower bound on the final answer. - If at any point in the inner loop, the right extent has gotten so small that there's no way you could find a new maximum, skip the rest of the inner loop (skip the remainder of the right boxes). Here's my attempt to write this using a state monad. There's probably a more idiomatic way to do it. -- This is state used in the state monad. data SearchState = SearchState { -- running maximum: ssMaximum :: Int -- remember the full list of right boxes -- so we can initiate a new outer loop , ssRights :: [Box] } boxesSep2 :: [Box] -> [Box] -> Int boxesSep2 lefts rights = let ls = sortBy ((flip compare) `on` rightExtent) lefts rs = sortBy ((flip compare) `on` leftExtent) rights in fst $ runState (boxesSep2' ls rs) (SearchState minBound rs) boxesSep2' :: [BoxBounds] -> [BoxBounds] -> State SearchState Int -- Termination of algorithm: boxesSep2' [] _ = gets ssMaximum -- Initiate a new inner loop: boxesSep2' (l:ls) [] = do rights <- gets ssRights boxesSep' ls rights -- Common case: boxesSep2' lss@(l:ls) (r:rs) = do -- In this way of writing the code, we distinguish between the -- left/right separation which is the sum of the extents, and the -- question of whether there is vertical overlap. let v = isVerticalOverlap l r sep = lrSeparation l r ss <- get let max = ssMaximum ss if sep <= max then boxesSep' ls (ssRights ss) --Here we "prune" (initiate new inner loop) else do -- Update max is needed: when v (put ss { ssMaximum = sep }) boxesSep' lss rs So if there is a better way to do this, I'm all ears. From mpm at alumni.caltech.edu Sat Sep 26 17:28:28 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Sat Sep 26 17:06:47 2009 Subject: [Haskell-cafe] combinatorial search with running bound In-Reply-To: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> References: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> Message-ID: <4ABE877C.4080104@alumni.caltech.edu> I made some mistakes in editing this code before posting it. I wrote BoxBounds in a couple places when I meant Box. Also made calls to boxesSep' when I meant boxesSep2'. Hopefully should all be obvious from context. Michael Mossey wrote: > > I have a combinatorial search problem that requires a > running lower bound to be tracked in order to prune the search. I have enough > Haskell experience to know how to do a combinatorial search, for example with > list compresions or the list monad, but I don't know how to keep a running > lower bound. From simon at joyful.com Sat Sep 26 19:44:08 2009 From: simon at joyful.com (Simon Michael) Date: Sat Sep 26 19:22:18 2009 Subject: [Haskell-cafe] ANN: rss2irc 0.4 released Message-ID: I have released rss2irc 0.4, with some improvements from the field: - fix a problem connecting with irc.quakenet.org (Radoslav Dorcik) - feed polling now recovers from transient failures - can poll a local file: uri as well as remote uris - more robust new item detection, with some alternate strategies available - --idle option, waits for channel inactivity before announcing - limit individual field sizes, preventing too many irc messages per item - misc. output improvements - logging improvements - --delay now takes minutes, not seconds See hackage for more detail. Note the new contributor! Thanks Radoslav. home: http://hackage.haskell.org/package/rss2irc darcs repo: http://joyful.com/darcsweb/darcsweb.cgi?r=rss2irc I am currently using this to run hackagebot, darcscommitbot and other announce-bots on freenode. A tip: if you experiment, avoid joining the irc server too frequently; once per minute may be ok. Feedback and patches welcome. Best, -Simon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090926/091cfae9/attachment.html From dipython at gmail.com Sun Sep 27 08:13:43 2009 From: dipython at gmail.com (Marcelo Sousa) Date: Sun Sep 27 07:51:50 2009 Subject: [Haskell-cafe] yi-editor: Duplicate instance declarations Message-ID: <4e6ade520909270513m73838dbfs2988958f3df67f27@mail.gmail.com> Hey guys, I'm trying to install yi using cabal but I got this error. Any ideas how to solve it?! I'm using ghc-6.10.1 and cabal-install version 0.6.2 using version 1.6.0.2 of the Cabal library. Thanks, Marcelo -- Code -- $ cabal install yi Resolving dependencies... Configuring yi-0.6.1... Preprocessing library yi-0.6.1... Preprocessing executables for yi-0.6.1... Building yi-0.6.1... [ 1 of 120] Compiling System.FriendlyPath ( System/FriendlyPath.hs, dist/build/System/FriendlyPath.o ) [ 2 of 120] Compiling Shim.ProjectContent ( Shim/ProjectContent.hs, dist/build/Shim/ProjectContent.o ) [ 3 of 120] Compiling Parser.Incremental ( Parser/Incremental.hs, dist/build/Parser/Incremental.o ) [ 4 of 120] Compiling Data.Trie ( Data/Trie.hs, dist/build/Data/Trie.o ) [ 5 of 120] Compiling Data.DelayList ( Data/DelayList.hs, dist/build/Data/DelayList.o ) [ 6 of 120] Compiling Data.Rope ( Data/Rope.hs, dist/build/Data/Rope.o ) [ 7 of 120] Compiling Data.Prototype ( Data/Prototype.hs, dist/build/Data/Prototype.o ) [ 8 of 120] Compiling HConf.Utils ( HConf/Utils.hs, dist/build/HConf/Utils.o ) [ 9 of 120] Compiling HConf.Paths ( HConf/Paths.hs, dist/build/HConf/Paths.o ) [ 10 of 120] Compiling Paths_yi ( dist/build/autogen/Paths_yi.hs, dist/build/Paths_yi.o ) [ 11 of 120] Compiling HConf ( HConf.hs, dist/build/HConf.o ) [ 12 of 120] Compiling Yi.Char.Unicode ( Yi/Char/Unicode.hs, dist/build/Yi/Char/Unicode.o ) [ 13 of 120] Compiling Yi.UI.Common[boot] ( Yi/UI/Common.hs-boot, dist/build/Yi/UI/Common.o-boot ) [ 14 of 120] Compiling Yi.String ( Yi/String.hs, dist/build/Yi/String.o ) [ 15 of 120] Compiling Yi.Monad ( Yi/Monad.hs, dist/build/Yi/Monad.o ) [ 16 of 120] Compiling Yi.Keymap.Completion ( Yi/Keymap/Completion.hs, dist/build/Yi/Keymap/Completion.o ) [ 17 of 120] Compiling Yi.Editor[boot] ( Yi/Editor.hs-boot, dist/build/Yi/Editor.o-boot ) [ 18 of 120] Compiling Yi.Debug ( Yi/Debug.hs, dist/build/Yi/Debug.o ) [ 19 of 120] Compiling Yi.Prelude ( Yi/Prelude.hs, dist/build/Yi/Prelude.o ) Yi/Prelude.hs:182:9: Duplicate instance declarations: instance Category Accessor.T -- Defined at Yi/Prelude.hs:182:9-38 instance Category Accessor.T -- Defined in data-accessor-0.2.1:Data.Accessor.Private cabal: Error: some packages failed to install: yi-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 From nicolas.pouillard at gmail.com Sun Sep 27 10:27:58 2009 From: nicolas.pouillard at gmail.com (Nicolas Pouillard) Date: Sun Sep 27 10:05:27 2009 Subject: [Haskell-cafe] yi-editor: Duplicate instance declarations In-Reply-To: <4e6ade520909270513m73838dbfs2988958f3df67f27@mail.gmail.com> References: <4e6ade520909270513m73838dbfs2988958f3df67f27@mail.gmail.com> Message-ID: <1254061587-sup-2258@peray> Excerpts from Marcelo Sousa's message of Sun Sep 27 14:13:43 +0200 2009: > Hey guys, > > I'm trying to install yi using cabal but I got this error. Any ideas > how to solve it?! > I'm using ghc-6.10.1 and cabal-install version 0.6.2 using version > 1.6.0.2 of the Cabal library. This means that you either have to downgrade data-accessor, or trash out the Category instance in Yi/Prelude.hs line 182. > $ cabal install yi > Resolving dependencies... > Configuring yi-0.6.1... > Preprocessing library yi-0.6.1... > Preprocessing executables for yi-0.6.1... > Building yi-0.6.1... > [ 1 of 120] Compiling System.FriendlyPath ( System/FriendlyPath.hs, > dist/build/System/FriendlyPath.o ) > [ 2 of 120] Compiling Shim.ProjectContent ( Shim/ProjectContent.hs, > dist/build/Shim/ProjectContent.o ) > [ 3 of 120] Compiling Parser.Incremental ( Parser/Incremental.hs, > dist/build/Parser/Incremental.o ) > [ 4 of 120] Compiling Data.Trie ( Data/Trie.hs, dist/build/Data/Trie.o ) > [ 5 of 120] Compiling Data.DelayList ( Data/DelayList.hs, > dist/build/Data/DelayList.o ) > [ 6 of 120] Compiling Data.Rope ( Data/Rope.hs, dist/build/Data/Rope.o ) > [ 7 of 120] Compiling Data.Prototype ( Data/Prototype.hs, > dist/build/Data/Prototype.o ) > [ 8 of 120] Compiling HConf.Utils ( HConf/Utils.hs, > dist/build/HConf/Utils.o ) > [ 9 of 120] Compiling HConf.Paths ( HConf/Paths.hs, > dist/build/HConf/Paths.o ) > [ 10 of 120] Compiling Paths_yi ( > dist/build/autogen/Paths_yi.hs, dist/build/Paths_yi.o ) > [ 11 of 120] Compiling HConf ( HConf.hs, dist/build/HConf.o ) > [ 12 of 120] Compiling Yi.Char.Unicode ( Yi/Char/Unicode.hs, > dist/build/Yi/Char/Unicode.o ) > [ 13 of 120] Compiling Yi.UI.Common[boot] ( Yi/UI/Common.hs-boot, > dist/build/Yi/UI/Common.o-boot ) > [ 14 of 120] Compiling Yi.String ( Yi/String.hs, dist/build/Yi/String.o ) > [ 15 of 120] Compiling Yi.Monad ( Yi/Monad.hs, dist/build/Yi/Monad.o ) > [ 16 of 120] Compiling Yi.Keymap.Completion ( Yi/Keymap/Completion.hs, > dist/build/Yi/Keymap/Completion.o ) > [ 17 of 120] Compiling Yi.Editor[boot] ( Yi/Editor.hs-boot, > dist/build/Yi/Editor.o-boot ) > [ 18 of 120] Compiling Yi.Debug ( Yi/Debug.hs, dist/build/Yi/Debug.o ) > [ 19 of 120] Compiling Yi.Prelude ( Yi/Prelude.hs, > dist/build/Yi/Prelude.o ) > > Yi/Prelude.hs:182:9: > Duplicate instance declarations: > instance Category Accessor.T -- Defined at Yi/Prelude.hs:182:9-38 > instance Category Accessor.T > -- Defined in data-accessor-0.2.1:Data.Accessor.Private > cabal: Error: some packages failed to install: > yi-0.6.1 failed during the building phase. The exception was: > exit: ExitFailure 1 -- Nicolas Pouillard http://nicolaspouillard.fr From gue.schmidt at web.de Sun Sep 27 10:59:57 2009 From: gue.schmidt at web.de (=?iso-8859-15?Q?G=FCnther_Schmidt?=) Date: Sun Sep 27 10:43:01 2009 Subject: [Haskell-cafe] Hurray! I hit my 1st true lazy IO problem Message-ID: and now I'll really have to figure out Iteratee / Enumerator to solve it. Can I call myself a Haskeller now? G?nther. PS: The problem domain is crawling over a website. From colin at colina.demon.co.uk Sun Sep 27 11:15:49 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Sep 27 10:53:54 2009 Subject: [Haskell-cafe] Processing EXIF data with Haskell Message-ID: I'm writing web software for a photograph gallery. I want to be able to display selective fields from the EXIF data. I thought I would be able to use the GD and exif libraries from Hackage to do this. However: Calling Graphics.GD.loadJpegByteString followed by Graphics.GD.saveJpegFile does not preserve the EXIF fields of the uploaded file, but instead writes some new ones (many fewer fields than the original, and nothing of interest). Graphics.Exif.allTags shows an interesting subset of the original EXIF data, but nothing from the version saved by GD. Can anyone shed any light on any of this? -- Colin Adams Preston Lancashire From greg at gregorycollins.net Sun Sep 27 11:16:57 2009 From: greg at gregorycollins.net (Gregory Collins) Date: Sun Sep 27 10:55:00 2009 Subject: [Haskell-cafe] Re: Snow Leopard Breaks GHC In-Reply-To: (Tom Tobin's message of "Tue, 1 Sep 2009 22:12:33 -0500") References: <3e1162e60908281615u3b2840beh32b89dac378e9808@mail.gmail.com> <74C174C8-F693-4775-8C5C-25D2EE12AB3C@gmail.com> <3e1162e60908290910k344c4926p3a4bf1b2f27e1cd7@mail.gmail.com> <3e1162e60908300706k7997c21flc385e5ed6aa34317@mail.gmail.com> <4A9BADE3.8020201@dfki.de> <5C4479A6-F74F-4CEF-B492-A3DBBBA701B2@gmail.com> <4A9CD7F3.9010703@dfki.de> Message-ID: <877hvka046.fsf@gregorycollins.net> Tom Tobin writes: > On Tue, Sep 1, 2009 at 3:14 AM, Christian > Maeder wrote: >> >> It seems, bootstrapping cabal went wrong. Does >> http://hackage.haskell.org/platform/2009.2.0.2/haskell-platform-2009.2.0.2-i386.dmg >> work? > > Installing the Haskell Platform package, combined with adding the > previously mentioned options to /usr/bin/ghc (-optc-m32 -opta-m32 > -optl-m32), seems to have done the trick. Thank you! N.B. everybody, you also need to patch /usr/bin/hsc2hs to read: exec /Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/hsc2hs \ $tflag $HSC2HS_EXTRA --cflag="-m32" --lflag="-m32" ${1+"$@"} "$Iflag" if you want FFI to work. See details on http://hackage.haskell.org/trac/ghc/ticket/3400#comment:9. G. -- Gregory Collins From alexey.skladnoy at gmail.com Sun Sep 27 11:26:09 2009 From: alexey.skladnoy at gmail.com (Khudyakov Alexey) Date: Sun Sep 27 10:57:51 2009 Subject: [Haskell-cafe] Hurray! I hit my 1st true lazy IO problem In-Reply-To: References: Message-ID: <200909271926.09311.alexey.skladnoy@gmail.com> ? ????????? ?? 27 ???????? 2009 18:59:57 G?nther Schmidt ???????: > and now I'll really have to figure out Iteratee / Enumerator to solve it. > > Can I call myself a Haskeller now? > If you wish so. But in fact you only need to overcome laziness. Not the first time in the life I suppose. From daniel.is.fischer at web.de Sun Sep 27 11:23:06 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Sep 27 11:02:26 2009 Subject: [Haskell-cafe] Hurray! I hit my 1st true lazy IO problem In-Reply-To: References: Message-ID: <200909271723.06459.daniel.is.fischer@web.de> Am Sonntag 27 September 2009 16:59:57 schrieb G?nther Schmidt: > PS: The problem domain is crawling over a website. Ewwww. Quick, swat it! From dons at galois.com Sun Sep 27 12:03:05 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 27 11:43:25 2009 Subject: [Haskell-cafe] Hurray! I hit my 1st true lazy IO problem In-Reply-To: References: Message-ID: <20090927160305.GA8092@whirlpool.galois.com> gue.schmidt: > and now I'll really have to figure out Iteratee / Enumerator to solve it. > > Can I call myself a Haskeller now? > > G?nther. > > > PS: The problem domain is crawling over a website. > Can you just use strict IO? -- Don From dons at galois.com Sun Sep 27 12:09:39 2009 From: dons at galois.com (Don Stewart) Date: Sun Sep 27 11:50:18 2009 Subject: [Haskell-cafe] Processing EXIF data with Haskell In-Reply-To: References: Message-ID: <20090927160939.GB8092@whirlpool.galois.com> colin: > I'm writing web software for a photograph gallery. I want to be able > to display selective fields from the EXIF data. I thought I would be > able to use the GD and exif libraries from Hackage to do > this. However: > > Calling Graphics.GD.loadJpegByteString followed by > Graphics.GD.saveJpegFile does not preserve the EXIF fields of the > uploaded file, but instead writes some new ones (many fewer fields > than the original, and nothing of interest). > > Graphics.Exif.allTags shows an interesting subset of the original EXIF > data, but nothing from the version saved by GD. > > Can anyone shed any light on any of this? Contact the author, patch the library? -- Don From bertram.felgenhauer at googlemail.com Sun Sep 27 12:14:23 2009 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Sun Sep 27 11:52:33 2009 Subject: [Haskell-cafe] Quadratic complexity though use of STArrays In-Reply-To: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> References: <3defcb4e0909221231n6bd66c64y8085d84f428b88c3@mail.gmail.com> Message-ID: <20090927161423.GA9013@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Dan Ros?n wrote: > What complexity does these functions have? > > I argue that the shuffleArr function should be O(n), since it only contains > one loop of n, where each loop does actions that are O(1): generating a random > number and swapping two elements in an array. > > However, they both have the same runnig time (roughly), and through looking > at the plot it _very_ much looks quadratic. Right. In the case of shuffleArr, it's the garbage collection time that explodes. I think that the reason is that the garbage collector has to scan the whole array (which lives in the old generation) on each garbage collection, while the young generation is kept very small, making GCs very frequent. Indeed the program behaves much better with just one GC generation: > ./a.out +RTS -G1 (1000000, 1988698, 1760732, 1.98870,1.76073) (1500000, 2991546, 2683592, 1.99436,1.78906) (2000000, 4018388, 3611451, 2.00919,1.80573) Output format: (n, time for your original shuffleArray (t1), time for Daniel's stricter version (t2), t1/n, t2/n) While with the default settings, it looks much worse: > ./a.out (1000000, 7575850, 7958790, 7.57585, 7.95879) (1500000,17119397,19449044,11.41293,12.96602) (2000000,30687335,35125661,15.34367,17.56283) You can also increase the initial heap size, > ./a.out +RTS -H250M (1000000, 1131828, 901863, 1.13183, 0.90186) (1500000, 1726737, 1427783, 1.15116, 0.95186) (2000000, 2324647, 1935705, 1.16232, 0.96785) Bertram From cjs at starling-software.com Sun Sep 27 12:16:53 2009 From: cjs at starling-software.com (Curt Sampson) Date: Sun Sep 27 11:54:59 2009 Subject: [Haskell-cafe] Comments requested: succ Java Message-ID: <20090927161653.GG1381@poetic.cynic.net> No, it's not quite what it sounds like. :-) Stuart Halloway recently posted a series of blog entries entitled "Java.next"[1], discussing the benefits of four other languages that compile to JVM bytecode and interoperate with Java: Clojure, Groovy, JRuby, and Scala. I thought I'd put my oar in and write a parallel series comparing Haskell to these. I've finished a draft of the first posting, started on the third, and made a couple of notes on the second and fourth, and I thought I'd post the drafts[2] and solicit comments here. If you have time to read and comment, I'd greatly appreciate the help; feel free either to e-mail me privately or post here. Also feel free to forward this to anybody else you feel might be interested in commenting. I'll probably be posting these about one per week, starting some time next week. [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview [2]: http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From jochem at functor.nl Sun Sep 27 12:31:12 2009 From: jochem at functor.nl (Jochem Berndsen) Date: Sun Sep 27 12:09:18 2009 Subject: [Haskell-cafe] yi-editor: Duplicate instance declarations In-Reply-To: <1254061587-sup-2258@peray> References: <4e6ade520909270513m73838dbfs2988958f3df67f27@mail.gmail.com> <1254061587-sup-2258@peray> Message-ID: <4ABF9350.5040303@functor.nl> Nicolas Pouillard wrote: > Excerpts from Marcelo Sousa's message of Sun Sep 27 14:13:43 +0200 2009: >> Hey guys, >> >> I'm trying to install yi using cabal but I got this error. Any ideas >> how to solve it?! >> I'm using ghc-6.10.1 and cabal-install version 0.6.2 using version >> 1.6.0.2 of the Cabal library. > > This means that you either have to downgrade data-accessor, or trash out the > Category instance in Yi/Prelude.hs line 182. > FYI: I had the same problem this morning. Using data-accessor 0.2.0.2 worked. Regards, Jochem -- Jochem Berndsen | jochem@functor.nl | jochem@????.com From john at n-brain.net Sun Sep 27 12:36:31 2009 From: john at n-brain.net (John A. De Goes) Date: Sun Sep 27 12:14:41 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090927161653.GG1381@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: I'm not sure what the point of your series is. No one who is using Java now commercially can move to Haskell because Haskell doesn't run on the JVM. It makes sense to discuss Clojure, Groovy, JRuby, Scala, Fan, etc., as "next Java's", because they all run on the JVM and have seamless interop with Java. Haskell is not in this category. It's stuck in a different world, wholly inaccessible to the masses. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 27, 2009, at 10:16 AM, Curt Sampson wrote: > No, it's not quite what it sounds like. :-) > > Stuart Halloway recently posted a series of blog entries entitled > "Java.next"[1], discussing the benefits of four other languages that > compile to JVM bytecode and interoperate with Java: Clojure, Groovy, > JRuby, and Scala. I thought I'd put my oar in and write a parallel > series comparing Haskell to these. I've finished a draft of the first > posting, started on the third, and made a couple of notes on the > second > and fourth, and I thought I'd post the drafts[2] and solicit comments > here. If you have time to read and comment, I'd greatly appreciate the > help; feel free either to e-mail me privately or post here. Also feel > free to forward this to anybody else you feel might be interested in > commenting. > > I'll probably be posting these about one per week, starting some time > next week. > > [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview > [2]: http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From colin at colina.demon.co.uk Sun Sep 27 12:37:29 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Sun Sep 27 12:15:34 2009 Subject: [Haskell-cafe] Processing EXIF data with Haskell In-Reply-To: <20090927160939.GB8092@whirlpool.galois.com> (Don Stewart's message of "Sun\, 27 Sep 2009 09\:09\:39 -0700") References: <20090927160939.GB8092@whirlpool.galois.com> Message-ID: >>>>> "Don" == Don Stewart writes: Don> colin: >> I'm writing web software for a photograph gallery. I want to be >> able to display selective fields from the EXIF data. I thought >> I would be able to use the GD and exif libraries from Hackage >> to do this. However: >> >> Calling Graphics.GD.loadJpegByteString followed by >> Graphics.GD.saveJpegFile does not preserve the EXIF fields of >> the uploaded file, but instead writes some new ones (many fewer >> fields than the original, and nothing of interest). >> >> Graphics.Exif.allTags shows an interesting subset of the >> original EXIF data, but nothing from the version saved by GD. >> >> Can anyone shed any light on any of this? Don> Contact the author, patch the library? I tried the former - no answer yet. Maybe just waiting a little will help. As for the latter, it's just a binding to a C library. -- Colin Adams Preston Lancashire From yairchu at gmail.com Sun Sep 27 14:12:42 2009 From: yairchu at gmail.com (yairchu@gmail.com) Date: Sun Sep 27 13:50:46 2009 Subject: [Haskell-cafe] ANN: ListTree 0.1 Message-ID: <88b0f98e-a113-4153-85a1-df56d7deb031@z28g2000vbl.googlegroups.com> Hi, I am pleased to announce the release of ListTree. ListTree is a package for combinatorial search and pruning of trees, and should be useful for problems such as those in Google Code Jam (where I, and possibly others* could make use of it), but possibly could even be useful for real applications! It offers BFS, DFS, Best-First-Search, Branch-And-Bound pruning, and more. The trees it works on are not those from Data.Tree, but rather monadic lists of a list monad (ListT []), which is an alternative that has the advantages of working with standard MonadPlus or List operations like takeWhile etc, and where consumption is a monadic action, which allows keeping state required for branch-and-bound (the bound) etc. This would be best explained with an example. Google Code Jam 2009 Round 2 Problem C: Given the prices at 25 time points for 16 stocks (in the small input), split the stocks into several groups, where in each group, the line- plots of its stocks' prices do not intersect or touch. Your mission is to find the minimum number of groups necessary. I will present an inefficient (best one I could come up with during the compo) solution that can solve their small input (it cannot solve the large input of a 100 stocks): * Search the space of all possible splits into groups of the stocks * Prune this search by cutting branches where the plots of two stocks in the same group intersect * Use "Branch and Bound". For each node, calculate a lower and upper bound. Lower bound is number of groups so far, and large bound is number of groups plus number of remaining items to place in group (each one may require a new group). Keep the lowest upper bound encountered, and prune all subtrees with a lower bound larger or equal to it. Code for this solution below. Using ListTree, the code is as modular as the algorithm description above, and there's a function to perform branch-and-bound. One problem with my package (which I'll attempt fixing), however, is speed. I haven't used it during the competition, and the quick and dirty, less modular code, that I coded in the competition, which performs exactly the same algorithm, runs a 100 times faster! Both are fast enough, but this is still troubling. I guess I should look into "Stream Fusion" to try and make my package faster. And the example's code below: import Control.Monad.Identity import Control.Monad.ListT -- from "List", not mtl import Control.Monad.State import Control.Monad.Trans import Data.Array import Data.List.Class (cons, execute) import Data.List.Tree import Data.Maybe -- search tree for all possible splits to separate groups -- each node has the same groups of its parent with a new element added to a group -- or as the sole element of a new group -- the new element is the first element of the first group searchTree :: [a] -> [[a]] -> ListT [] [[a]] searchTree [] groups = return groups searchTree (x : xs) groups = do i <- lift [0 .. length groups] let (pre, group : post) = splitAt i ([] : groups) cur = (x : group) : dropWhile null (pre ++ post) cons groups $ searchTree xs cur getWords :: Read a => IO [a] getWords = fmap (map read . words) getLine main :: IO () main = do numCases <- readLn :: IO Int forM_ [1..numCases] $ \i -> do [n, _] <- getWords stocks <- replicateM n getWords :: IO [[Int]] let friends = listArray rng . map isFriends . range $ rng rng = ((0, 0), (n-1, n-1)) isFriends (a, b) = f (>) a b || f (<) a b f op a b = and $ zipWith op (stocks !! a) (stocks !! b) res = fromJust . snd . runIdentity . (`runStateT` Nothing) . execute . execute . branchAndBound bnds . prune p $ searchTree [0 .. n-1] [] p ((x : xs) : _) = all ((friends !) . ((,) x)) xs p _ = True bnds [] = (Just 0, Just n) bnds groups = ( Just (length groups) , Just (length groups + n - 1 - head (head groups)) ) putStrLn $ "Case #" ++ show i ++ ": " ++ show res * possibly others - currently only 2 out of the 500 "surviving" contestants of codejam use Haskell (http://www.go-hero.net/jam/09/lang/ Haskell). so by others I mean Reid from the US. Good luck Reid! From hoknamahn at gmail.com Sun Sep 27 14:42:25 2009 From: hoknamahn at gmail.com (Olex P) Date: Sun Sep 27 14:20:29 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? Message-ID: Hi guys, Do we have anything like half precision floats in Haskell? Maybe in some non standard libraries? Or I have to use FFI + OpenEXR library to achieve this? Cheers, Oleksandr. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/92a6661f/attachment.html From nonowarn at gmail.com Sun Sep 27 15:19:24 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Sep 27 14:57:29 2009 Subject: [Haskell-cafe] QuickCheck Questions Message-ID: Hello, I recently worked with QuickCheck for a while, But I still can't handle it well, And a few questions come to my mind. 1. How to find properties In QuickCheck examples on the codes or the papers, they find good properties easily. How did they find these properties? What property can make us believed its implementation is collect? 2. Property driven developments But finally, I could find some patterns of the properties. For example, occasionally, their shape is like unF . f == id or unF . f == Just I thought it could be applied to writing parser, and lead me to "Property Driven Developments." I tried writing S-expression parser in this way. First, I defined my property as parseSexpr . prettySexpr == Just where parseSexpr :: String -> Maybe Sexpr, prettySexpr :: Sexpr -> String. As you see, I should write printer before parser. Fortunately writing such printer for S-expr is easy, but I don't know if what I did is right. Do you think I wasted times? Have you ever tried PDD? And has it worked? If you have experience with TDD, how do you think about PDD? If you have any answers in any questions above, please tell me them. Thanks in advance. Cheers -nwn From wren at freegeek.org Sun Sep 27 15:35:34 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Sep 27 15:13:40 2009 Subject: [Haskell-cafe] ANN: ListTree 0.1 In-Reply-To: <88b0f98e-a113-4153-85a1-df56d7deb031@z28g2000vbl.googlegroups.com> References: <88b0f98e-a113-4153-85a1-df56d7deb031@z28g2000vbl.googlegroups.com> Message-ID: <4ABFBE86.4000007@freegeek.org> yairchu@gmail.com wrote: > Hi, > I am pleased to announce the release of ListTree. > ListTree is a package for combinatorial search and pruning of trees, > and should be useful for problems such as those in Google Code Jam > (where I, and possibly others* could make use of it), but possibly > could even be useful for real applications! > [...] > One problem with my package (which I'll attempt fixing), however, is > speed. I haven't used it during the competition, and the quick and > dirty, less modular code, that I coded in the competition, which > performs exactly the same algorithm, runs a 100 times faster! Both are > fast enough, but this is still troubling. > I guess I should look into "Stream Fusion" to try and make my package > faster. Have you seen Andrew Tolmach & Thomas Nordin's "Modular Lazy Search for Constraint Satisfaction Problems"? They describe a very similar project which incorporates many of the common optimizations in the field (backjumping, backmarking, forward-checking, fail-first,...) and provide their code as well. paper: http://web.cecs.pdx.edu/~apt/jfp01.ps code: http://web.cecs.pdx.edu/~apt/CSP_jfp.hs -- Live well, ~wren From gwern0 at gmail.com Sun Sep 27 15:42:03 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Sun Sep 27 15:20:10 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: Message-ID: On Sun, Sep 27, 2009 at 3:19 PM, Yusaku Hashimoto wrote: ... > Do you think I wasted times? Have you ever tried PDD? And has it > worked? If you have experience with TDD, how do you think about PDD? > > If you have any answers in any questions above, please tell me them. > Thanks in advance. > > Cheers > -nwn Here are some links from my Wikipedia article on QC which tout it: - http://haskell.org/haskellwiki/QuickCheck_as_a_test_set_generator - http://blog.moertel.com/articles/2006/10/31/introductory-haskell-solving-the-sorting-it-out-kata - http://blog.moertel.com/pages/seven-lessons-from-the-icfp-programming-contest - http://neilmitchell.blogspot.com/2006/11/systemfilepath-automated-testing.html - http://book.realworldhaskell.org/read/testing-and-quality-assurance.html -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/29b32e00/signature.bin From rmm-haskell at z.odi.ac Sun Sep 27 15:47:35 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Sep 27 15:25:43 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: Message-ID: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> What about the built-in Float type? Prelude Foreign.Storable> sizeOf (undefined :: Float) 4 Prelude Foreign.Storable> sizeOf (undefined :: Double) 8 Or maybe you mean something that can be used with FFI calls to C, in which case Foreign.C.Types (CFloat). Both instance the Floating, RealFloat, RealFrac, etc, classes so should operate largely the same as (modulo precision) a Double. -Ross On Sep 27, 2009, at 2:42 PM, Olex P wrote: > Hi guys, > > Do we have anything like half precision floats in Haskell? Maybe in > some non standard libraries? Or I have to use FFI + OpenEXR library > to achieve this? > > Cheers, > Oleksandr. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From p.f.moore at gmail.com Sun Sep 27 15:50:25 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Sun Sep 27 15:28:29 2009 Subject: [Haskell-cafe] Debugging Haskell code Message-ID: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> I'm still playing round with my random dieroll generation program. In doing so, I just hit a segmentation fault (I didn't think Haskell could *cause* a segfault!) I'm sure it's my code - I got this to compile by fiddling with types until the errors (which I didn't understand) went away. Certainly not the right way to code, I know, but never mind. The problem is that I have *no idea* how to begin debugging this. In C, Python, or any other imperative language, I'd put traces in, etc. But in Haskell, I don't even know where to start. I attach the code below. While help in the form of pointers to what I did wrong would of course be appreciated, what I'm really looking for is a pointer on how I'd find out for myself. (Hey! I just read the bit in the ghc manual which says if I am not using foreign or unsafe functions, a crash is a compiler bug. Did I find a compiler bug?) My code is below. All I did is ghc --make hist_3d6.hs, then run hist_3d6.exe. This is ghc 6.10.4 on Windows Vista Home 32-bit. Thanks for any help, Paul. import System.Random.Mersenne import qualified Data.Map as Map import Data.Map (Map) import Data.List takes :: Int -> [a] -> [[a]] takes n [] = [] takes n xs = take n xs : takes n (drop n xs) sums :: Num a => Int -> [a] -> [a] sums n xs = map sum (takes n xs) simulate :: Int -> IO [Double] simulate count = do gen <- newMTGen Nothing dice <- (randoms gen :: IO [Double]) return (take count dice) histogram :: Ord a => [a] -> [(a,Int)] histogram = Map.assocs . foldl' f Map.empty where f m k = Map.insertWith' (+) k 1 m simulation = do lst <- simulate 100000 return lst --return (histogram lst) main = do s <- simulation putStrLn (show s) From andy at adradh.org.uk Sun Sep 27 16:02:45 2009 From: andy at adradh.org.uk (andy morris) Date: Sun Sep 27 15:41:08 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> Message-ID: 2009/9/27 Paul Moore : > I'm still playing round with my random dieroll generation program. In > doing so, I just hit a segmentation fault (I didn't think Haskell > could *cause* a segfault!) I'm sure it's my code - I got this to > compile by fiddling with types until the errors (which I didn't > understand) went away. Certainly not the right way to code, I know, > but never mind. > > The problem is that I have *no idea* how to begin debugging this. In > C, Python, or any other imperative language, I'd put traces in, etc. > But in Haskell, I don't even know where to start. > > I attach the code below. While help in the form of pointers to what I > did wrong would of course be appreciated, what I'm really looking for > is a pointer on how I'd find out for myself. (Hey! I just read the bit > in the ghc manual which says if I am not using foreign or unsafe > functions, a crash is a compiler bug. Did I find a compiler bug?) > > My code is below. All I did is ghc --make hist_3d6.hs, then run > hist_3d6.exe. This is ghc 6.10.4 on Windows Vista Home 32-bit. > > Thanks for any help, > Paul. > > import System.Random.Mersenne > import qualified Data.Map as Map > import Data.Map (Map) > import Data.List > > takes :: Int -> [a] -> [[a]] > takes n [] = [] > takes n xs = take n xs : takes n (drop n xs) > > sums :: Num a => Int -> [a] -> [a] > sums n xs = map sum (takes n xs) > > simulate :: Int -> IO [Double] > simulate count = do > ?gen <- newMTGen Nothing > ?dice <- (randoms gen :: IO [Double]) > ?return (take count dice) > > histogram :: Ord a => [a] -> [(a,Int)] > histogram = Map.assocs . foldl' f Map.empty > ?where > ? f m k = Map.insertWith' (+) k 1 m > > simulation = do > ?lst <- simulate 100000 > ?return lst > ?--return (histogram lst) > > main = do > ?s <- simulation > ?putStrLn (show s) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > mersenne-random uses the FFI, so it's probably that. I just ran your code with mersenne-random-1.0 and didn't get a segfault. What version are you using? From jmillikin at gmail.com Sun Sep 27 16:06:20 2009 From: jmillikin at gmail.com (John Millikin) Date: Sun Sep 27 15:44:33 2009 Subject: [Haskell-cafe] Hackage bug? Autobuild failure on literate source with ignored code blocks. Message-ID: <1254081980.5924.37.camel@desktop> According to , the following should compile properly because the second block of code will be ignored by GHC: \begin{code} main = putStrLn "Hello world!" \end{code} \begin{code}% main = -- TODO \end{code}% However, Hackage's automatic build system seems to pre-process the literate source in such a way that the ignored block is included in the .hs source, resulting in a compilation error: http://hackage.haskell.org/packages/archive/dbus-core/0.2/logs/failure/ghc-6.10 dist/build/tmp23596/DBus/Bus/Connection.hs:119:12: Empty 'do' construct The block in question is a TODO feature that should be included in documents generated from the LaTeX source, but does not build and shouldn't be parsed as Haskell: \begin{code}% -- TODO tcp :: A.Address -> Transport tcp a@(A.Address _ params) = handleTransport a connect' where connect' = do -- check host -- check port -- check family -- return handle \end{code}% Although Hackage fails to build the package, it works fine on my local system when I run "cabal configure && cabal build && cabal haddock". Is this a bug in the Hackage auto-build mechanism, or have I done something wrong when uploading the package? -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/8c6687d1/attachment.bin From p.f.moore at gmail.com Sun Sep 27 16:17:48 2009 From: p.f.moore at gmail.com (Paul Moore) Date: Sun Sep 27 15:55:52 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> Message-ID: <79990c6b0909271317q4fcbe311g8b788c9c9ac2c456@mail.gmail.com> 2009/9/27 andy morris : > mersenne-random uses the FFI, so it's probably that. I just ran your > code with mersenne-random-1.0 and didn't get a segfault. What version > are you using? Not entirely sure, I just did a cabal install a short while back. >cabal list mersenne Warning: The package list for 'hackage.haskell.org' is 19 days old. Run 'cabal update' to get the latest list of available packages. * mersenne-random Synopsis: Generate high quality pseudorandom numbers using a SIMD Fast Mersenne Twister Latest version available: 1.0 Latest version installed: [ Not installed ] Homepage: http://code.haskell.org/~dons/code/mersenne-random License: BSD3 * mersenne-random-pure64 Synopsis: Generate high quality pseudorandom numbers purely using a Mersenne Twister Latest version available: 0.2.0.2 Latest version installed: [ Not installed ] Homepage: http://code.haskell.org/~dons/code/mersenne-random-pure64/ License: BSD3 That's odd, it seems to be saying it's not installed at all! Hmm, no - I did a cabal install --user (because Vista doesn't let me do site-wide installs), looks like cabal list doesn't pick up user installs. Hmm, cabal install mersenne-random --user didn't do anything, but cabal install mersenne-random --user --reinstall did reinstall it, and now it seems to work. Odd. Thanks for the help - presumably the lesson for me is that a crash implies that unless I am using FFI or unsafe functions, I should look to any libraries I use. It begs the question of how I'd prove that was the problem if there hadn't been an updated version of the library - I guess I'd use the standard random module & see if that worked. Paul. From bugfact at gmail.com Sun Sep 27 16:19:08 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Sep 27 15:57:14 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: He meant 16-bit floats, which have sizeOf 2 On GPUs this is common and implemented in hardware (at least on the old GPUs). On DPSs you commonly had 24-bit floats too. But these days I guess 32-bit is the minimum one would want to use? Most of the time I just use double anyway :) On Sun, Sep 27, 2009 at 9:47 PM, Ross Mellgren wrote: > What about the built-in Float type? > > Prelude Foreign.Storable> sizeOf (undefined :: Float) > 4 > Prelude Foreign.Storable> sizeOf (undefined :: Double) > 8 > > Or maybe you mean something that can be used with FFI calls to C, in which > case Foreign.C.Types (CFloat). > > Both instance the Floating, RealFloat, RealFrac, etc, classes so should > operate largely the same as (modulo precision) a Double. > > -Ross > > > On Sep 27, 2009, at 2:42 PM, Olex P wrote: > > Hi guys, >> >> Do we have anything like half precision floats in Haskell? Maybe in some >> non standard libraries? Or I have to use FFI + OpenEXR library to achieve >> this? >> >> Cheers, >> Oleksandr. >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/6f557eb2/attachment.html From daniel.is.fischer at web.de Sun Sep 27 16:22:47 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Sun Sep 27 16:02:04 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> Message-ID: <200909272222.47893.daniel.is.fischer@web.de> Am Sonntag 27 September 2009 22:02:45 schrieb andy morris: > mersenne-random uses the FFI, so it's probably that. I just ran your > code with mersenne-random-1.0 and didn't get a segfault. Yup, works here, too. And everything but mersenne-random should be fool-proof. > What version are you using? From rmm-haskell at z.odi.ac Sun Sep 27 16:38:33 2009 From: rmm-haskell at z.odi.ac (Ross Mellgren) Date: Sun Sep 27 16:16:40 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: <54ECC9B6-DE40-4A1E-AB53-5FBB39378A79@z.odi.ac> Oh sorry, I misread the original question. I take it all back! -Ross On Sep 27, 2009, at 4:19 PM, Peter Verswyvelen wrote: > He meant 16-bit floats, which have sizeOf 2 > > On GPUs this is common and implemented in hardware (at least on the > old GPUs). > > On DPSs you commonly had 24-bit floats too. > > But these days I guess 32-bit is the minimum one would want to use? > Most of the time I just use double anyway :) > > On Sun, Sep 27, 2009 at 9:47 PM, Ross Mellgren haskell@z.odi.ac> wrote: > What about the built-in Float type? > > Prelude Foreign.Storable> sizeOf (undefined :: Float) > 4 > Prelude Foreign.Storable> sizeOf (undefined :: Double) > 8 > > Or maybe you mean something that can be used with FFI calls to C, in > which case Foreign.C.Types (CFloat). > > Both instance the Floating, RealFloat, RealFrac, etc, classes so > should operate largely the same as (modulo precision) a Double. > > -Ross > > > On Sep 27, 2009, at 2:42 PM, Olex P wrote: > > Hi guys, > > Do we have anything like half precision floats in Haskell? Maybe in > some non standard libraries? Or I have to use FFI + OpenEXR library > to achieve this? > > Cheers, > Oleksandr. > _______________________________________________ > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/b386a83b/attachment.html From hoknamahn at gmail.com Sun Sep 27 16:39:49 2009 From: hoknamahn at gmail.com (Olex P) Date: Sun Sep 27 16:17:52 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: Hi, Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" software. Think of huge data sets in computer graphics (particle clouds, volumetric data, images etc.) Some data (normals, density, temperature and so on) can be easily represented as float 16 making files 200 GB instead of 300 GB. Good benefits. Cheers, Oleksandr. On Sun, Sep 27, 2009 at 9:19 PM, Peter Verswyvelen wrote: > He meant 16-bit floats, which have sizeOf 2 > On GPUs this is common and implemented in hardware (at least on the old > GPUs). > > On DPSs you commonly had 24-bit floats too. > > But these days I guess 32-bit is the minimum one would want to use? Most of > the time I just use double anyway :) > > On Sun, Sep 27, 2009 at 9:47 PM, Ross Mellgren wrote: > >> What about the built-in Float type? >> >> Prelude Foreign.Storable> sizeOf (undefined :: Float) >> 4 >> Prelude Foreign.Storable> sizeOf (undefined :: Double) >> 8 >> >> Or maybe you mean something that can be used with FFI calls to C, in which >> case Foreign.C.Types (CFloat). >> >> Both instance the Floating, RealFloat, RealFrac, etc, classes so should >> operate largely the same as (modulo precision) a Double. >> >> -Ross >> >> >> On Sep 27, 2009, at 2:42 PM, Olex P wrote: >> >> Hi guys, >>> >>> Do we have anything like half precision floats in Haskell? Maybe in some >>> non standard libraries? Or I have to use FFI + OpenEXR library to achieve >>> this? >>> >>> Cheers, >>> Oleksandr. >>> _______________________________________________ >>> 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/7b75fc05/attachment.html From hoknamahn at gmail.com Sun Sep 27 16:40:46 2009 From: hoknamahn at gmail.com (Olex P) Date: Sun Sep 27 16:18:49 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: Hi, Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" software. Think of huge data sets in computer graphics (particle clouds, volumetric data, images etc.) Some data (normals, density, temperature and so on) can be easily represented as float 16 making files 200 GB instead of 300 GB. Good benefits. Cheers, Oleksandr. On Sun, Sep 27, 2009 at 9:19 PM, Peter Verswyvelen wrote: > He meant 16-bit floats, which have sizeOf 2 > On GPUs this is common and implemented in hardware (at least on the old > GPUs). > > On DPSs you commonly had 24-bit floats too. > > But these days I guess 32-bit is the minimum one would want to use? Most of > the time I just use double anyway :) > > On Sun, Sep 27, 2009 at 9:47 PM, Ross Mellgren wrote: > >> What about the built-in Float type? >> >> Prelude Foreign.Storable> sizeOf (undefined :: Float) >> 4 >> Prelude Foreign.Storable> sizeOf (undefined :: Double) >> 8 >> >> Or maybe you mean something that can be used with FFI calls to C, in which >> case Foreign.C.Types (CFloat). >> >> Both instance the Floating, RealFloat, RealFrac, etc, classes so should >> operate largely the same as (modulo precision) a Double. >> >> -Ross >> >> >> On Sep 27, 2009, at 2:42 PM, Olex P wrote: >> >> Hi guys, >>> >>> Do we have anything like half precision floats in Haskell? Maybe in some >>> non standard libraries? Or I have to use FFI + OpenEXR library to achieve >>> this? >>> >>> Cheers, >>> Oleksandr. >>> _______________________________________________ >>> 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 >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/8108a421/attachment.html From caseyh at istar.ca Sun Sep 27 16:49:38 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Sep 27 16:27:45 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: <1pjvb5hrojusmt79j6huhfv0r1k0fif863@4ax.com> I think a 16-bit float type would require compiler revisions as opposed to doing something within the present type classes. This is similar to how Java would benefit from an unsigned byte primitive type for processing images, etc., whereas Haskell already has Word8. -- Regards, Casey From wren at freegeek.org Sun Sep 27 16:50:40 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Sep 27 16:28:47 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: <4ABFD020.10009@freegeek.org> Olex P wrote: > Hi, > > Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" > software. Think of huge data sets in computer graphics (particle clouds, > volumetric data, images etc.) Some data (normals, density, temperature and > so on) can be easily represented as float 16 making files 200 GB instead of > 300 GB. Good benefits. I think, if you're going to want any kind of performance and portability, then you'll have to use the FFI to wrap some C code that performs the primops. From there you can define the instances for Floating, RealFloat, etc. to use them like normal types in Haskell. There are a number of embedded systems that still use 24-bit floating registers, so it'd be nice to provide both Float16 and Float24. But since these aren't natively supported in C, it's not clear how best to write the primops so they're portable across GPUs and embedded systems. -- Live well, ~wren From nonowarn at gmail.com Sun Sep 27 16:50:58 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Sun Sep 27 16:29:02 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: References: Message-ID: On Mon, Sep 28, 2009 at 4:42 AM, Gwern Branwen wrote: > On Sun, Sep 27, 2009 at 3:19 PM, Yusaku Hashimoto > wrote: > ... >> >> Do you think I wasted times? Have you ever tried PDD? And has it >> worked? If you have experience with TDD, how do you think about PDD? >> >> If you have any answers in any questions above, please tell me them. >> Thanks in advance. >> >> Cheers >> -nwn > > Here are some links from my Wikipedia article on QC which tout it: Thanks for pointers. But I feel curious about in many QC examples (especially RWH's in your pointers), if property is falsifiable, they changes definition of the property, not implementation. And it annoys me because it seemed to almost duplicate its implementation. Am I misunderstanding? Cheers -nwn From hoknamahn at gmail.com Sun Sep 27 16:52:51 2009 From: hoknamahn at gmail.com (Olex P) Date: Sun Sep 27 16:30:56 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: <4ABFD020.10009@freegeek.org> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> <4ABFD020.10009@freegeek.org> Message-ID: Okay looks like FFI is the only way to go, Thanks. Cheers, Oleksandr. On Sun, Sep 27, 2009 at 9:50 PM, wren ng thornton wrote: > Olex P wrote: > >> Hi, >> >> Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in "normal" >> software. Think of huge data sets in computer graphics (particle clouds, >> volumetric data, images etc.) Some data (normals, density, temperature and >> so on) can be easily represented as float 16 making files 200 GB instead >> of >> 300 GB. Good benefits. >> > > I think, if you're going to want any kind of performance and portability, > then you'll have to use the FFI to wrap some C code that performs the > primops. From there you can define the instances for Floating, RealFloat, > etc. to use them like normal types in Haskell. > > There are a number of embedded systems that still use 24-bit floating > registers, so it'd be nice to provide both Float16 and Float24. But since > these aren't natively supported in C, it's not clear how best to write the > primops so they're portable across GPUs and embedded systems. > > -- > Live well, > ~wren > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/398868bf/attachment-0001.html From ben.franksen at online.de Sun Sep 27 17:22:50 2009 From: ben.franksen at online.de (Ben Franksen) Date: Sun Sep 27 17:01:22 2009 Subject: [Haskell-cafe] Re: ANN: CmdArgs - easy command line argument processing References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> Message-ID: Neil Mitchell wrote: > I am pleased to announce CmdArgs v0.1. CmdArgs is a library for easy > command line argument processing - taking the arguments passed into > your program from getArgs and converting them into a structured value > for use in your program. Compared to the System.Console.GetOpts > library there are two key advantages: > > 1) The command line argument processors are shorter - in a typical > case they are about 1/3 the size, 90 lines with getopts vs 30 simpler > lines with CmdArgs (for HLint). > > 2) CmdArgs can support multiple mode command lines, such as those > found in hpc, darcs and cabal. > > The guiding principle of CmdArgs is to try and write each piece of > information only once, which makes the command line processing > shorter, and eliminates many of the accidental copy-and-paste style > bugs that are easy with getopts. CmdArgs requires GHC, but other than > this restriction, I do not foresee any reason for anyone to use > getopts over CmdArgs. I very much like the general idea of this thing, but have a question regarding the interface. This is from the docs: (&=) :: a -> Attrib -> a Add attributes to a value. Always returns the first argument, but has a non-pure effect on the environment. Take care when performing program transformations. value &= attrib1 & attrib2 To expose an impure function (!) in an API, I don't know... I mean, couldn't one just wrap the value like this data Attributed a -- opaque (&=) :: a -> Attrib -> Attributed a mode :: Data a => Attributed a -> Mode a and thus retain a purely functional interface? Cheers Ben From wasserman.louis at gmail.com Sun Sep 27 17:29:01 2009 From: wasserman.louis at gmail.com (Louis Wasserman) Date: Sun Sep 27 17:07:24 2009 Subject: [Haskell-cafe] A proposals Message-ID: I'd like to see something resembling as-patterns in type signatures. Specifically, there are cases where I'm inclined to use (m ~ pat) in a type context when m isn't otherwise constrained, just so I can use m as an abbreviation for pat. To reduce these cases, I'd like to see the syntax m@pat allowed for use in type signatures, with m becoming simply an alias for pat. Thoughts? I've added a ticket here . Louis Wasserman wasserman.louis@gmail.com http://profiles.google.com/wasserman.louis -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/b6fe3e58/attachment.html From brad.larsen at gmail.com Sun Sep 27 17:33:01 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Sun Sep 27 17:11:04 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: References: Message-ID: On Sun, Sep 27, 2009 at 5:29 PM, Louis Wasserman wrote: > I'd like to see something resembling as-patterns in type signatures. > Specifically, there are cases where I'm inclined to use > (m ~ pat) in a type context when m isn't otherwise constrained, just so I > can use m as an abbreviation for pat.? To reduce these cases, I'd like to > see the syntax m@pat allowed for use in type signatures, with m becoming > simply an alias for pat.? Thoughts? > > I've added a ticket here. > > Louis Wasserman > wasserman.louis@gmail.com > http://profiles.google.com/wasserman.louis > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe I was looking for a feature like this just the other day, for more succinctly defining a type class that made use of several associated type synonyms. Sincerely, Bradford Larsen From bugfact at gmail.com Sun Sep 27 17:38:51 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Sun Sep 27 17:16:55 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: That's not really true. Just use CAL from the Open Quark framework... It's almost Haskell 98, with some extras, and compiles to fast JVM code. http://openquark.org/Open_Quark/Welcome.html They even seem to do all kinds of advanced optimizations - like converting tail calls to loops - to get good Java performance. And they have a better record system, a graphical environment to learn it, etc. So I think CAL should be in the list, and since it's basically Haskell... On Sun, Sep 27, 2009 at 6:36 PM, John A. De Goes wrote: > > I'm not sure what the point of your series is. No one who is using Java now > commercially can move to Haskell because Haskell doesn't run on the JVM. > > It makes sense to discuss Clojure, Groovy, JRuby, Scala, Fan, etc., as > "next Java's", because they all run on the JVM and have seamless interop > with Java. Haskell is not in this category. It's stuck in a different world, > wholly inaccessible to the masses. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > > On Sep 27, 2009, at 10:16 AM, Curt Sampson wrote: > > No, it's not quite what it sounds like. :-) >> >> Stuart Halloway recently posted a series of blog entries entitled >> "Java.next"[1], discussing the benefits of four other languages that >> compile to JVM bytecode and interoperate with Java: Clojure, Groovy, >> JRuby, and Scala. I thought I'd put my oar in and write a parallel >> series comparing Haskell to these. I've finished a draft of the first >> posting, started on the third, and made a couple of notes on the second >> and fourth, and I thought I'd post the drafts[2] and solicit comments >> here. If you have time to read and comment, I'd greatly appreciate the >> help; feel free either to e-mail me privately or post here. Also feel >> free to forward this to anybody else you feel might be interested in >> commenting. >> >> I'll probably be posting these about one per week, starting some time >> next week. >> >> [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview >> [2]: >> http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html >> >> cjs >> -- >> Curt Sampson +81 90 7737 2974 >> Functional programming in all senses of the word: >> http://www.starling-software.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/21470c37/attachment.html From simon at joyful.com Sun Sep 27 17:52:32 2009 From: simon at joyful.com (Simon Michael) Date: Sun Sep 27 17:30:38 2009 Subject: [Haskell-cafe] Re: ANN: rss2irc 0.4 released In-Reply-To: References: Message-ID: <273501BB-A5E9-4CCA-B8D0-13E737ECCC04@joyful.com> Whoops, bugfixes: Release notes for 0.4.2, 2009-09-27: - fix a bug where every --max-items-th announcement was skipped Release notes for 0.4.1, 2009-09-26: - fix release notes From kili at outback.escape.de Sun Sep 27 18:18:58 2009 From: kili at outback.escape.de (Matthias Kilian) Date: Sun Sep 27 17:57:11 2009 Subject: [Haskell-cafe] (mostly OT) Strange patterns of commas Message-ID: <20090927221858.GA1283@nutty.outback.escape.de> Fibonacci numbers are always surprising. Try this on a terminal that's 159 characters wide (using a properly sized xterm(1) may be a good idea): let f = 1 : 1 : zipWith (+) f (tail f) in take 780 f Ciao, Kili -- There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult. -- C.A.R. Hoare From matthew at brecknell.net Sun Sep 27 18:56:29 2009 From: matthew at brecknell.net (Matthew Brecknell) Date: Sun Sep 27 18:34:38 2009 Subject: [Haskell-cafe] (mostly OT) Strange patterns of commas In-Reply-To: <20090927221858.GA1283@nutty.outback.escape.de> References: <20090927221858.GA1283@nutty.outback.escape.de> Message-ID: <1254092189.8513.8.camel@localhost> Now see if you can tell us why this pattern is similar: [ replicate n '-' | n <- [140..171] ] Hint: Look at the closed form as n gets big: http://en.wikipedia.org/wiki/Fibonacci_number#Closed_form_expression After that, you can tell us why it's a parabola. Matthias Kilian wrote: > Fibonacci numbers are always surprising. > > Try this on a terminal that's 159 characters wide (using a properly > sized xterm(1) may be a good idea): > > let f = 1 : 1 : zipWith (+) f (tail f) in take 780 f > > Ciao, > Kili > From ok at cs.otago.ac.nz Sun Sep 27 19:06:47 2009 From: ok at cs.otago.ac.nz (Richard O'Keefe) Date: Sun Sep 27 18:44:55 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: On Sep 28, 2009, at 9:40 AM, Olex P wrote: > Hi, > > Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in > "normal" software. Think of huge data sets in computer graphics > (particle clouds, volumetric data, images etc.) Some data (normals, > density, temperature and so on) can be easily represented as float > 16 making files 200 GB instead of 300 GB. Good benefits. From the OpenEXR technical introduction: half numbers have 1 sign bit, 5 exponent bits, and 10 mantissa bits. The interpretation of the sign, exponent and mantissa is analogous to IEEE-754 floating-point numbers. half supports normalized and denormalized numbers, infinities and NANs (Not A Number). The range of representable numbers is roughly 6.0E-8 to 6.5E4; numbers smaller than 6.1E-5 are denormalized. Single-precision floats are already dangerously short for many computations. (Oh the dear old B6700 with 39 bits of precision in single-precision floats...) Half-precision floats actually have less than half the precision of singles (11 bits instead of 23). It's probably best to think of binary 16 as a form of compression for Float, and to write stuff that will read half-precision from a binary stream as single-precision, and conversely stuff that will accept single-precision values and write them to a binary stream in half-precision form. From dougal at dougalstanton.net Sun Sep 27 19:09:15 2009 From: dougal at dougalstanton.net (Dougal Stanton) Date: Sun Sep 27 18:47:22 2009 Subject: [Haskell-cafe] Edinburgh Hackathon (Hac7) summary Message-ID: <2d3641330909271609m7d897c4eted7ea760ee11ec72@mail.gmail.com> It's been nearly a month now since the Edinburgh Hackathon (29 & 30 August), organised to coincide with the convergence of Haskellers arriving for the ICFP. My apologies for this very late summary! Eric Kow was the driving force behind this Hackathon, though I agreed to help out locally because I live in Edinburgh. We had trouble organising a good venue through a combination of university holidays and Edinburgh International Festival. We spent the first day camping out in a cafe. On the second day Graeme Hutton arranged for us to use an empty room in the bowels of the ICFP venue. If I remember well the first day was heavily Darcs-oriented, and there were interesting conversations on version control representation, conflicts, and the future of Darcs over breakfast. The staff at Henderson's Restaurant didn't seem to mind our impromptu geeky enclave, and we kept buying coffee to pay for our wifi usage. I'll let the other Haskellers explain in their own words what they were up to for the rest of the time. Maybe some of them have updates on where these projects have gone since then? "At the hackathon I started working on a small extension to the GHCi debugger. The goal of the extension is to allow the debugger to show the term representation of thunks where possible. Presently, to find out the value of a thunk in the debugger you must force its evaluation. However, this is not always desirable, especially if the thunk contains breakpoints, or if it diverges. In some cases it ought to be possible to extract source code information from a thunk and show that to the user. I didn't get very far in the implementation because I spent most of the time re-learning how the term printer in the debugger works (and chatting to other people)." -- Bernie Pope "I was continuing to work on my camp correctness proofs. In particular, investigating how best to handle symmetric lemmas, and refactoring the existing definitions and proofs." -- Ian Lynagh "I worked on fixing Solaris/SPARC port of GHC. It turned out to be a tedious header file related issue, not very interesting." -- Ben Lippmeier "I worked on the formlets (again), I released a version that doesn't add any functionality, it only solves a bug." -- Chris Eidhof "I worked on a feature to let darcs users more conveniently upgrade to the hashed repository format. I also had lots of interesting discussions with darcs users and hackers :-)" -- Eric Kow "I worked on analysing some darcs performance problems, fixing a couple of GHC bugs, and some discussion about packages." -- Simon Marlow "I (along with Benedikt Huber) worked on adding a 'cabal init' command which automates much of the work of cabalising a project (creating a .cabal file, a Setup.hs file, a LICENSE file, etc). It's not quite done yet but should be finding its way into the cabal-install HEAD soon! -- Brent Yorgey "I worked on the new hackage-server a bit. darcs get http://code.haskell.org/hackage-server/ live instance at http://sparky.haskell.org:8080/" -- Duncan Coutts Thanks everyone who took part and who supplied an elegant summary of their work that weekend. I hope you all had a good time! Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net From caseyh at istar.ca Sun Sep 27 19:23:39 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Sun Sep 27 19:01:45 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: On Mon, 28 Sep 2009 12:06:47 +1300, you wrote: > >On Sep 28, 2009, at 9:40 AM, Olex P wrote: > >> Hi, >> >> Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in >> "normal" software. Think of huge data sets in computer graphics >> (particle clouds, volumetric data, images etc.) Some data (normals, >> density, temperature and so on) can be easily represented as float >> 16 making files 200 GB instead of 300 GB. Good benefits. > > From the OpenEXR technical introduction: > > half numbers have 1 sign bit, 5 exponent bits, > and 10 mantissa bits. The interpretation of > the sign, exponent and mantissa is analogous > to IEEE-754 floating-point numbers. half > supports normalized and denormalized numbers, > infinities and NANs (Not A Number). The range > of representable numbers is roughly 6.0E-8 to 6.5E4; > numbers smaller than 6.1E-5 are denormalized. > >Single-precision floats are already dangerously short for >many computations. (Oh the dear old B6700 with 39 bits of >precision in single-precision floats...) Half-precision >floats actually have less than half the precision of singles >(11 bits instead of 23). It's probably best to think of >binary 16 as a form of compression for Float, and to write >stuff that will read half-precision from a binary stream as >single-precision, and conversely stuff that will accept >single-precision values and write them to a binary stream in >half-precision form. > I agree with the above. I hadn't realized how dangerously short for many computations single-precision is. So, as he says, for computing, you do want to convert half-precision to single-precision, if not double-precision. If you want to save storage space, then some sort of compression scheme might be better on secondary storage. As for the video card, some sort of fast decompression scheme would be necessary for the half-precision numbers coming in. You are probably in the realm of DSP. -- Regards, Casey From selahattin.gerdan at gmail.com Sun Sep 27 20:00:40 2009 From: selahattin.gerdan at gmail.com (selahaddin gerdan) Date: Sun Sep 27 19:38:46 2009 Subject: [Haskell-cafe] frag game-compiling error Message-ID: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> Hi there, when I try to install frag,I get this error: .cabal/bin/cabal install frag Resolving dependencies... Downloading frag-1.1.2... Configuring frag-1.1.2... Preprocessing executables for frag-1.1.2... Building frag-1.1.2... [ 1 of 39] Compiling IdentityList ( src/IdentityList.hs, dist/build/frag/frag-tmp/IdentityList.o ) [ 2 of 39] Compiling Quaternion ( src/Quaternion.hs, dist/build/frag/frag-tmp/Quaternion.o ) src/Quaternion.hs:22:27: Couldn't match expected type `GLfloat' against inferred type `Float' In the expression: (r00 :: GLfloat) In the second argument of `newMatrix', namely `[(r00 :: GLfloat), r01, r02, r03, ....]' In the expression: newMatrix ColumnMajor [(r00 :: GLfloat), r01, r02, r03, ....] cabal: Error: some packages failed to install: frag-1.1.2 failed during the building phase. The exception was: exit: ExitFailure 1 Why? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090927/f21e417a/attachment.html From jon at ffconsultancy.com Sun Sep 27 21:02:58 2009 From: jon at ffconsultancy.com (Jon Harrop) Date: Sun Sep 27 20:40:35 2009 Subject: [Haskell-cafe] F# mailing list? In-Reply-To: References: Message-ID: <200909280202.58578.jon@ffconsultancy.com> On Saturday 27 June 2009 18:31:25 G??nther Schmidt wrote: > Hi guys, > > is there a mailing list for haskellers that defected to F#? Here's the F# mailing list on Google Groups: http://groups.google.com/group/fsharp?hl=en -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e From maydwell at gmail.com Sun Sep 27 21:38:45 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Sun Sep 27 21:16:50 2009 Subject: [Haskell-cafe] frag game-compiling error In-Reply-To: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> References: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> Message-ID: I think this is an opengl version problem. I came across this error in vacuum-opengl after I had upgraded my opengl. I patched it up using a "from" call. On Mon, Sep 28, 2009 at 8:00 AM, selahaddin gerdan wrote: > Hi there, > when I try to install frag,I get this error: > > .cabal/bin/cabal install frag > Resolving dependencies... > Downloading frag-1.1.2... > Configuring frag-1.1.2... > Preprocessing executables for frag-1.1.2... > Building frag-1.1.2... > [ 1 of 39] Compiling IdentityList???? ( src/IdentityList.hs, > dist/build/frag/frag-tmp/ > IdentityList.o ) > [ 2 of 39] Compiling Quaternion?????? ( src/Quaternion.hs, > dist/build/frag/frag-tmp/Quaternion.o ) > > src/Quaternion.hs:22:27: > ??? Couldn't match expected type `GLfloat' > ?????????? against inferred type `Float' > ??? In the expression: (r00 :: GLfloat) > ??? In the second argument of `newMatrix', namely > ??????? `[(r00 :: GLfloat), r01, r02, r03, ....]' > ??? In the expression: > ??????? newMatrix ColumnMajor [(r00 :: GLfloat), r01, r02, r03, ....] > cabal: Error: some packages failed to install: > frag-1.1.2 failed during the building phase. The exception was: > exit: ExitFailure 1 > > Why? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From wren at freegeek.org Sun Sep 27 22:02:37 2009 From: wren at freegeek.org (wren ng thornton) Date: Sun Sep 27 21:40:43 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: References: Message-ID: <4AC0193D.8020101@freegeek.org> Louis Wasserman wrote: > I'd like to see something resembling as-patterns in type signatures. > Specifically, there are cases where I'm inclined to use > (m ~ pat) in a type context when m isn't otherwise constrained, just so I > can use m as an abbreviation for pat. To reduce these cases, I'd like to > see the syntax m@pat allowed for use in type signatures, with m becoming > simply an alias for pat. Thoughts? > > I've added a ticket here . +1. I've often wanted this when doing type-level programming. Another nice thing this suggests is the ability to use underscore as a pattern for when you know the compiler will infer the type but it's too complex to want to write out (e.g. while experimenting). With x@_ you could even share the complex type in multiple places, since x will be bound to some actual type rather than being universally quantified. (Of course, ISTR someone's suggested the underscores in the past and had it rejected. Alas.) -- Live well, ~wren From cjs at starling-software.com Sun Sep 27 22:10:06 2009 From: cjs at starling-software.com (Curt Sampson) Date: Sun Sep 27 21:48:10 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: <20090928021004.GN1381@poetic.cynic.net> On 2009-09-27 10:36 -0600 (Sun), John A. De Goes wrote: > I'm not sure what the point of your series is. No one who is using Java > now commercially can move to Haskell because Haskell doesn't run on the > JVM. That's a rather strong statement, and I don't accept it. I can not only think of many possible circumstances where it would be possible for a Java-using shop to write a piece of software that doesn't run on the JVM, but I have sween many of these. There are lots of shops out there using, e.g., C++ code as well as Java code, who are already obviously able to use non-JVM languages. Given that, one point would be to show that there are more benefits to be gained by switching from Java to Haskell than there are from switching from Java to one of the other languages mentioned. This may be enough to tip some shops into Haskell. Second, it might inspire people to have a look at bringing a more Haskell-like language to the JVM, or add more Haskell-like features to existing JVM languages. Third, even if a shop is not going to switch, having people understand what's out there, and where many of these ideas come from, is a good thing, I feel. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From shulman at ugcs.caltech.edu Sun Sep 27 23:36:11 2009 From: shulman at ugcs.caltech.edu (Michael Shulman) Date: Sun Sep 27 23:14:16 2009 Subject: [Haskell-cafe] Re: [Hs-Generics] how to automatically create and install documentations of a package? In-Reply-To: <8955AB5E-C667-4115-BA3C-5BBCF83B31C3@gimbo.org.uk> References: <3c6288ab0909190859g4deb6212w405b502960c76fb@mail.gmail.com> <4AB5BEAD.90001@ugcs.caltech.edu> <4AB735EE.1050103@van.steenbergen.nl> <8955AB5E-C667-4115-BA3C-5BBCF83B31C3@gimbo.org.uk> Message-ID: <4AC02F2B.1000304@ugcs.caltech.edu> Andy Gimblett wrote: >>> Is there a way to make it automatically update a single contents page >>> with links to the documentation of all installed packages? >> >> See: >> http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/focus=53560 >> http://thread.gmane.org/gmane.comp.lang.haskell.cafe/53531/focus=53572 > > Seeing this today (I'm catching up on haskell-cafe!) made me want this > too, so I rolled my own. Thanks! Actually, this looks like maybe what I really wanted: http://hackage.haskell.org/trac/hackage/ticket/516 I'll probably keep using my script for now, though, until a new version of cabal is released with doc-index-file. I've copied my little script below in case anyone else wants a lightweight solution. Mike #!/bin/bash # This script, when run in a directory containing subdirectories of # the form pkg-1.1.1/html with haddock documentation, builds a master # table of contents for all this documentation, including all the # system-installed libraries from SYSDOCPATH. SYSDOCPATH=/usr/share/doc/ghc6-doc/libraries args="" # Skip the 'ghc' package, which has a lot of packages we don't care about for dir in $(find $SYSDOCPATH -type d -path '*libraries/*' -and -not -name 'ghc'); do pushd $dir >/dev/null for thing in $(find . -name '*.haddock'); do args="$args -i $dir,$dir/$thing" done popd >/dev/null done for dir in $(find . -type d -name 'html'); do pushd $dir >/dev/null for thing in $(find . -name '*.haddock'); do args="$args -i $dir,$dir/$thing" done popd >/dev/null done haddock --gen-contents $args From tgdavies at gmail.com Mon Sep 28 02:14:38 2009 From: tgdavies at gmail.com (Tom Davies) Date: Mon Sep 28 01:52:50 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: On 28/09/2009, at 7:38 AM, Peter Verswyvelen wrote: > That's not really true. Just use CAL from the Open Quark > framework... It's almost Haskell 98, with some extras, and compiles > to fast JVM code. > > http://openquark.org/Open_Quark/Welcome.html > > They even seem to do all kinds of advanced optimizations - like > converting tail calls to loops - to get good Java performance. > > And they have a better record system, a graphical environment to > learn it, etc. > > So I think CAL should be in the list, and since it's basically > Haskell... Liking CAL, I suggested it be included in a comment when the original post was made, but I never made the time to write up a matching set of examples myself. Curt, your first blog post is almost compatible with CAL -- you don't need to use a record type to get named accessors, CAL doesn't support list comprehension syntax, and the isBlank implementation would be different. Obviously the Java interop capabilities of CAL are very different to Haskell (and a bit verbose, though quite extensive). Dispatch comes out more-or-less the same -- although CAL doesn't do equational style function defs or comprehensive pattern matching like Haskell. In CAL I'd write letter_grade something like (untested): letter_grade :: Num a => a -> Maybe Char; letter_grade val = find (\pair -> fst pair $ val) [(> 90, 'A'), ... )] `bind` (\p -> return $ snd p); where bind is >>= Tom From noteed at gmail.com Mon Sep 28 03:04:24 2009 From: noteed at gmail.com (minh thu) Date: Mon Sep 28 02:42:47 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: <40a414c20909280004s10b045b8r1d5a4949633d2221@mail.gmail.com> 2009/9/28 Casey Hawthorne : > On Mon, 28 Sep 2009 12:06:47 +1300, you wrote: > >> >>On Sep 28, 2009, at 9:40 AM, Olex P wrote: >> >>> Hi, >>> >>> Yes, I mean "sizeOf 2". It's useful not only on GPUs but also in >>> "normal" software. Think of huge data sets in computer graphics >>> (particle clouds, volumetric data, images etc.) Some data (normals, >>> density, temperature and so on) can be easily represented as float >>> 16 making files 200 GB instead of 300 GB. Good benefits. >> >> From the OpenEXR technical introduction: >> >> half numbers have 1 sign bit, 5 exponent bits, >> and 10 mantissa bits. The interpretation of >> the sign, exponent and mantissa is analogous >> to IEEE-754 floating-point numbers. half >> supports normalized and denormalized numbers, >> infinities and NANs (Not A Number). The range >> of representable numbers is roughly 6.0E-8 to 6.5E4; >> numbers smaller than 6.1E-5 are denormalized. >> >>Single-precision floats are already dangerously short for >>many computations. (Oh the dear old B6700 with 39 bits of >>precision in single-precision floats...) Half-precision >>floats actually have less than half the precision of singles >>(11 bits instead of 23). It's probably best to think of >>binary 16 as a form of compression for Float, and to write >>stuff that will read half-precision from a binary stream as >>single-precision, and conversely stuff that will accept >>single-precision values and write them to a binary stream in >>half-precision form. >> > > I agree with the above. > > I hadn't realized how dangerously short for many computations > single-precision is. > > So, as he says, for computing, you do want to convert half-precision > to single-precision, if not double-precision. > > If you want to save storage space, then some sort of compression > scheme might be better on secondary storage. > > As for the video card, some sort of fast decompression scheme would be > necessary for the half-precision numbers coming in. 'Half', as they are called, are supported in GPU. The half-precision floating point is a core feature in OpenGL 3.0. As said above, they are merely a data storage format, which should be translated to floats or doubles before any computation. Cheers, Thu From bulat.ziganshin at gmail.com Mon Sep 28 03:13:52 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Sep 28 02:56:09 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090927161653.GG1381@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: <404367540.20090928111352@gmail.com> Hello Curt, Sunday, September 27, 2009, 8:16:53 PM, you wrote: > http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html what are the types of balance and interest in balance * interest expression? ;) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From cjs at starling-software.com Mon Sep 28 03:32:37 2009 From: cjs at starling-software.com (Curt Sampson) Date: Mon Sep 28 03:10:40 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <404367540.20090928111352@gmail.com> References: <20090927161653.GG1381@poetic.cynic.net> <404367540.20090928111352@gmail.com> Message-ID: <20090928073237.GJ9366@analytic.cynic.net> On 2009-09-28 11:13 +0400 (Mon), Bulat Ziganshin wrote: > > http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html > > what are the types of balance and interest in balance * interest > expression? ;) I dunno, but I think it's not really relevant to the point of the example from the original article.... cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From andrewcoppin at btinternet.com Mon Sep 28 03:55:09 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 28 03:33:07 2009 Subject: [Haskell-cafe] 80 bit floating point data in Haskell? In-Reply-To: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> Message-ID: <4AC06BDD.4070903@btinternet.com> Ross Mellgren wrote: > What about the built-in Float type? > > Prelude Foreign.Storable> sizeOf (undefined :: Float) > 4 > Prelude Foreign.Storable> sizeOf (undefined :: Double) > 8 While we're on the subject... I understand that certain FPUs support 80-bit precision. Is there any way to get at that? Or is this going to require FFI too? From martijn at van.steenbergen.nl Mon Sep 28 05:42:10 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Sep 28 05:20:17 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: <4AC0193D.8020101@freegeek.org> References: <4AC0193D.8020101@freegeek.org> Message-ID: <4AC084F2.1060700@van.steenbergen.nl> wren ng thornton wrote: > Another nice > thing this suggests is the ability to use underscore as a pattern for > when you know the compiler will infer the type but it's too complex to > want to write out (e.g. while experimenting). I'd love this! M. From ganesh.sittampalam at credit-suisse.com Mon Sep 28 05:46:04 2009 From: ganesh.sittampalam at credit-suisse.com (Sittampalam, Ganesh) Date: Mon Sep 28 05:24:44 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: <4AC084F2.1060700@van.steenbergen.nl> References: <4AC0193D.8020101@freegeek.org> <4AC084F2.1060700@van.steenbergen.nl> Message-ID: <16442B752A06A74AB4D9F9A5FF076E4B03B9FAD9@ELON17P32001A.csfb.cs-group.com> Martijn van Steenbergen wrote: > wren ng thornton wrote: >> Another nice >> thing this suggests is the ability to use underscore as a pattern for >> when you know the compiler will infer the type but it's too complex >> to want to write out (e.g. while experimenting). > > I'd love this! F# has this and I find it very useful. Ganesh =============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html =============================================================================== From bulat.ziganshin at gmail.com Mon Sep 28 06:02:29 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Sep 28 05:41:20 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: <4AC084F2.1060700@van.steenbergen.nl> References: <4AC0193D.8020101@freegeek.org> <4AC084F2.1060700@van.steenbergen.nl> Message-ID: <117396102.20090928140229@gmail.com> Hello Martijn, Monday, September 28, 2009, 1:42:10 PM, you wrote: >> Another nice >> thing this suggests is the ability to use underscore as a pattern for >> when you know the compiler will infer the type but it's too complex to >> want to write out (e.g. while experimenting). in case you not seen this and may be interested: http://okmij.org/ftp/Haskell/types.html#partial-sigs -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From jason.dusek at gmail.com Mon Sep 28 06:11:58 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Sep 28 05:50:00 2009 Subject: [Haskell-cafe] ANN: JSONb-0.0.2 Message-ID: <42784f260909280311w353c208cxbfb342c769ed8b8b@mail.gmail.com> JSONb is a ByteString parser for JSON, yielding a simple JSON type composed of Rationals, ByteString tries and strict ByteStrings. http://hackage.haskell.org/package/json-b-0.0.2 An example application program, `json-schema`, is provided. It derives schema for JSON input. When first looking at a web API, for example, you can feed it a few thousand lines of input and see what you got. A sample schema, derived from a stream of the Twitter API, is here: http://wiki.github.com/jsnx/JSONb/schema-example It's worth noting that the schema has a lone object at the bottom that has exactly the format of the "user" property of the schema ahead of it -- why is that? Well, `json-schema` uses a fault tolerant parsing approach; the very last Tweet was cut off and the "user" property's value was among the things that could be salvaged. -- Jason Dusek From martijn at van.steenbergen.nl Mon Sep 28 06:12:24 2009 From: martijn at van.steenbergen.nl (Martijn van Steenbergen) Date: Mon Sep 28 05:50:26 2009 Subject: [Haskell-cafe] A proposals In-Reply-To: <117396102.20090928140229@gmail.com> References: <4AC0193D.8020101@freegeek.org> <4AC084F2.1060700@van.steenbergen.nl> <117396102.20090928140229@gmail.com> Message-ID: <4AC08C08.5060903@van.steenbergen.nl> Bulat Ziganshin wrote: > in case you not seen this and may be interested: > http://okmij.org/ftp/Haskell/types.html#partial-sigs Yes, I know there are workarounds (and I use them sometimes). It'd be nice if there was direct support for them. :-) Thanks, Martijn. From andrewcoppin at btinternet.com Mon Sep 28 06:52:00 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 28 06:29:58 2009 Subject: [Haskell-cafe] 80 bit floating point data in Haskell? In-Reply-To: <4AC082ED.7030404@freegeek.org> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> <4AC06BDD.4070903@btinternet.com> <4AC082ED.7030404@freegeek.org> Message-ID: <4AC09550.5070106@btinternet.com> wren ng thornton wrote: > Andrew Coppin wrote: >> While we're on the subject... I understand that certain FPUs support >> 80-bit precision. Is there any way to get at that? Or is this going >> to require FFI too? > > Perhaps you want Foreign.C.Types.CLDouble ? > > http://hackage.haskell.org/packages/archive/base/latest/doc/html/Foreign-C-Types.html#t%3ACLDouble > > http://en.wikipedia.org/wiki/Long_double > > (Or do you really want to ensure that it's 80-bits regardless of > platform and the whims of the C compiler?) > Yep, that'll do. :-) From selahattin.gerdan at gmail.com Mon Sep 28 06:57:03 2009 From: selahattin.gerdan at gmail.com (selahaddin gerdan) Date: Mon Sep 28 06:35:09 2009 Subject: Fwd: [Haskell-cafe] frag game-compiling error In-Reply-To: <65ac1a170909280346o21c0b41anfe915c068736ba28@mail.gmail.com> References: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> <65ac1a170909280346o21c0b41anfe915c068736ba28@mail.gmail.com> Message-ID: <65ac1a170909280357r6c0564e5y5e7c127e39345329@mail.gmail.com> ---------- Forwarded message ---------- From: selahaddin gerdan Date: 2009/9/28 Subject: Re: [Haskell-cafe] frag game-compiling error To: Lyndon Maydwell Sorry I'm just learning haskell, so I don't get your suggestion. Could you explain to me what exactly I have to do? According to thispage GLfloat is just a type synonym for type Float. How come the error message differentiates between them? 2009/9/28 Lyndon Maydwell I think this is an opengl version problem. I came across this error in > vacuum-opengl after I had upgraded my opengl. I patched it up using a > "from" call. > > On Mon, Sep 28, 2009 at 8:00 AM, selahaddin gerdan > wrote: > > Hi there, > > when I try to install frag,I get this error: > > > > .cabal/bin/cabal install frag > > Resolving dependencies... > > Downloading frag-1.1.2... > > Configuring frag-1.1.2... > > Preprocessing executables for frag-1.1.2... > > Building frag-1.1.2... > > [ 1 of 39] Compiling IdentityList ( src/IdentityList.hs, > > dist/build/frag/frag-tmp/ > > IdentityList.o ) > > [ 2 of 39] Compiling Quaternion ( src/Quaternion.hs, > > dist/build/frag/frag-tmp/Quaternion.o ) > > > > src/Quaternion.hs:22:27: > > Couldn't match expected type `GLfloat' > > against inferred type `Float' > > In the expression: (r00 :: GLfloat) > > In the second argument of `newMatrix', namely > > `[(r00 :: GLfloat), r01, r02, r03, ....]' > > In the expression: > > newMatrix ColumnMajor [(r00 :: GLfloat), r01, r02, r03, ....] > > cabal: Error: some packages failed to install: > > frag-1.1.2 failed during the building phase. The exception was: > > exit: ExitFailure 1 > > > > Why? > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/67e77533/attachment-0001.html From felipe.lessa at gmail.com Mon Sep 28 07:28:06 2009 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon Sep 28 07:06:12 2009 Subject: Fwd: [Haskell-cafe] frag game-compiling error In-Reply-To: <65ac1a170909280357r6c0564e5y5e7c127e39345329@mail.gmail.com> References: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> <65ac1a170909280346o21c0b41anfe915c068736ba28@mail.gmail.com> <65ac1a170909280357r6c0564e5y5e7c127e39345329@mail.gmail.com> Message-ID: <20090928112806.GA7161@kira.casa> On Mon, Sep 28, 2009 at 01:57:03PM +0300, selahaddin gerdan wrote: > Sorry I'm just learning haskell, so I don't get your suggestion. Could you > explain to me what exactly I have to do? > > According to thispage > GLfloat is just a type synonym for type Float. > How come the error message differentiates between them? That's not the latest documentation, you should go to [1] if you want it. Nowadays GLfloat isn't a type synonym anymore[2]. HTH, [1] http://hackage.haskell.org/package/OpenGL [2] http://hackage.haskell.org/packages/archive/OpenGLRaw/1.1.0.0/doc/html/Graphics-Rendering-OpenGL-Raw-Core31.html#t%3AGLfloat -- Felipe. From aslatter at gmail.com Mon Sep 28 08:04:34 2009 From: aslatter at gmail.com (Antoine Latter) Date: Mon Sep 28 07:42:36 2009 Subject: [Haskell-cafe] 80 bit floating point data in Haskell? In-Reply-To: <4AC09550.5070106@btinternet.com> References: <4B1FDFA7-C2B5-41D1-BE99-8B34EFEA320B@z.odi.ac> <4AC06BDD.4070903@btinternet.com> <4AC082ED.7030404@freegeek.org> <4AC09550.5070106@btinternet.com> Message-ID: <694519c50909280504o24473e04u61e02f76edf582f6@mail.gmail.com> On Mon, Sep 28, 2009 at 5:52 AM, Andrew Coppin wrote: > wren ng thornton wrote: >> >> Andrew Coppin wrote: >>> >>> While we're on the subject... I understand that certain FPUs support >>> 80-bit precision. Is there any way to get at that? Or is this going to >>> require FFI too? >> >> Perhaps you want Foreign.C.Types.CLDouble ? >> >> >> http://hackage.haskell.org/packages/archive/base/latest/doc/html/Foreign-C-Types.html#t%3ACLDouble >> http://en.wikipedia.org/wiki/Long_double >> >> (Or do you really want to ensure that it's 80-bits regardless of platform >> and the whims of the C compiler?) >> > > Yep, that'll do. :-) > >From the source: -- HACK: Currently no long double in the FFI, so we simply re-use double -- | Haskell type representing the C @long double@ type. FLOATING_TYPE(CLDouble,tyConCLDouble,"CLDouble",HTYPE_DOUBLE) I also believe that CLDouble is gone in GHC 6.12.1, since it isn't really there. Antoine From batterseapower at hotmail.com Mon Sep 28 08:20:25 2009 From: batterseapower at hotmail.com (Max Bolingbroke) Date: Mon Sep 28 07:58:27 2009 Subject: [Haskell-cafe] Re: ANN: CmdArgs - easy command line argument processing In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> Message-ID: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> 2009/9/28 Ben Franksen : > To expose an impure function (!) in an API, I don't know... I mean, couldn't > one just wrap the value like this > > ?data Attributed a -- opaque > > ?(&=) :: a -> Attrib -> Attributed a > > ?mode :: Data a => Attributed a -> Mode a > > and thus retain a purely functional interface? Hi Ben, I don't think this would work because you need to be able to put the Attributed things in the fields of your command options data type. If they are wrapped in an "Attributed" then this may not be possible. In particular the sample won't compile in your proposal: data Sample = Sample {hello :: String} deriving (Show, Data, Typeable) sample = mode $ Sample{hello = def &= text "World argument" & empty "world"} Because the &= would return an Attributed String whereas you are actually after a String. Essential the problem is that attributes are attached to *fields*, but mode consumes a *record*. The best way to do this typefully is to paramaterise the options data type with a functor: data Sample f = Sample {hello :: f String} deriving (Show, Data, Typeable) Now you can do what you want, where mode :: Data a => a Attribute -> Mode (a Id). In fact, you could even do away with Data and substitute some sort of Foldable/Traversable as long as you were happy with the library not being able to fill in a default argument name from the record field name. The current interface is the best tradeoff given what Neil is trying to do IMHO - though the side effects make me shudder too! Cheers, Max From maydwell at gmail.com Mon Sep 28 08:42:25 2009 From: maydwell at gmail.com (Lyndon Maydwell) Date: Mon Sep 28 08:20:26 2009 Subject: Fwd: [Haskell-cafe] frag game-compiling error In-Reply-To: <20090928112806.GA7161@kira.casa> References: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> <65ac1a170909280346o21c0b41anfe915c068736ba28@mail.gmail.com> <65ac1a170909280357r6c0564e5y5e7c127e39345329@mail.gmail.com> <20090928112806.GA7161@kira.casa> Message-ID: > src/Quaternion.hs:22:27 This would probably be the place to start. On Mon, Sep 28, 2009 at 7:28 PM, Felipe Lessa wrote: > On Mon, Sep 28, 2009 at 01:57:03PM +0300, selahaddin gerdan wrote: >> Sorry I'm just learning haskell, so I don't get your suggestion. Could you >> explain to me what exactly I have to do? >> >> According to thispage >> GLfloat is just a type synonym for type Float. >> How come the error message differentiates between them? > > That's not the latest documentation, you should go to [1] if you > want it. ?Nowadays GLfloat isn't a type synonym anymore[2]. > > HTH, > > [1] http://hackage.haskell.org/package/OpenGL > [2] http://hackage.haskell.org/packages/archive/OpenGLRaw/1.1.0.0/doc/html/Graphics-Rendering-OpenGL-Raw-Core31.html#t%3AGLfloat > > -- > Felipe. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From joerg.rudnick at t-online.de Mon Sep 28 09:01:13 2009 From: joerg.rudnick at t-online.de (=?ISO-8859-1?Q?J=F6rg_Roman_Rudnick?=) Date: Mon Sep 28 08:39:27 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> Message-ID: <4AC0B399.8080105@t-online.de> In the last months, I made the experience it seems difficult to find commercial Haskell developer teams to take responsibility for projects in the range of $ 10.000 - 100.000. The Industrial Haskell Group does not seem to be the appropriate place for this, while harvesting Haskell team at general market places appears to be tedious. I would be very interested in others' experiences, and inhowfar my opinion is shared that there should be a demand for such a market place, for developer teams as well as those sympathizing with introducing Haskell somewhere. Nick From john at n-brain.net Mon Sep 28 09:01:50 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Sep 28 08:39:57 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090928021004.GN1381@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> Message-ID: Interop between Haskell and Java is too difficult to be practical. And I stand by my statement that no Java shop is going to switch over to Haskell, precisely because they cannot afford to abandon either their existing investment, or the _billions of dollars_ worth of commercial- friendly open source libraries available for the Java platform. But I do agree on this: the JVM does indeed need a Haskell-like language. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 27, 2009, at 8:10 PM, Curt Sampson wrote: > On 2009-09-27 10:36 -0600 (Sun), John A. De Goes wrote: > >> I'm not sure what the point of your series is. No one who is using >> Java >> now commercially can move to Haskell because Haskell doesn't run on >> the >> JVM. > > That's a rather strong statement, and I don't accept it. I can not > only > think of many possible circumstances where it would be possible for a > Java-using shop to write a piece of software that doesn't run on the > JVM, but I have sween many of these. There are lots of shops out there > using, e.g., C++ code as well as Java code, who are already obviously > able to use non-JVM languages. > > Given that, one point would be to show that there are more benefits > to be gained by switching from Java to Haskell than there are from > switching from Java to one of the other languages mentioned. This > may be > enough to tip some shops into Haskell. > > Second, it might inspire people to have a look at bringing a more > Haskell-like language to the JVM, or add more Haskell-like features to > existing JVM languages. > > Third, even if a shop is not going to switch, having people understand > what's out there, and where many of these ideas come from, is a good > thing, I feel. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com From john at n-brain.net Mon Sep 28 09:02:56 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Sep 28 08:41:02 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> Message-ID: <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> CAL is interesting, but unfortunately dead, and has no community. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 27, 2009, at 3:38 PM, Peter Verswyvelen wrote: > That's not really true. Just use CAL from the Open Quark > framework... It's almost Haskell 98, with some extras, and compiles > to fast JVM code. > > http://openquark.org/Open_Quark/Welcome.html > > They even seem to do all kinds of advanced optimizations - like > converting tail calls to loops - to get good Java performance. > > And they have a better record system, a graphical environment to > learn it, etc. > > So I think CAL should be in the list, and since it's basically > Haskell... > > On Sun, Sep 27, 2009 at 6:36 PM, John A. De Goes > wrote: > > I'm not sure what the point of your series is. No one who is using > Java now commercially can move to Haskell because Haskell doesn't > run on the JVM. > > It makes sense to discuss Clojure, Groovy, JRuby, Scala, Fan, etc., > as "next Java's", because they all run on the JVM and have seamless > interop with Java. Haskell is not in this category. It's stuck in a > different world, wholly inaccessible to the masses. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > > On Sep 27, 2009, at 10:16 AM, Curt Sampson wrote: > > No, it's not quite what it sounds like. :-) > > Stuart Halloway recently posted a series of blog entries entitled > "Java.next"[1], discussing the benefits of four other languages that > compile to JVM bytecode and interoperate with Java: Clojure, Groovy, > JRuby, and Scala. I thought I'd put my oar in and write a parallel > series comparing Haskell to these. I've finished a draft of the first > posting, started on the third, and made a couple of notes on the > second > and fourth, and I thought I'd post the drafts[2] and solicit comments > here. If you have time to read and comment, I'd greatly appreciate the > help; feel free either to e-mail me privately or post here. Also feel > free to forward this to anybody else you feel might be interested in > commenting. > > I'll probably be posting these about one per week, starting some time > next week. > > [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview > [2]: http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/86213876/attachment.html From titto at quicquid.org Mon Sep 28 09:16:49 2009 From: titto at quicquid.org (Titto Assini) Date: Mon Sep 28 08:54:53 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> Message-ID: <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> Hi, I am looking for an unicode strings library, I found on hackage: http://hackage.haskell.org/package/compact-string http://hackage.haskell.org/package/text They both look solid and functionally complete so ... I don't know which one to use :-) As I am sure I am not the first one facing this choice, may I ask which one you preferred and why? Thanks titto -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ From john at n-brain.net Mon Sep 28 09:33:36 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Sep 28 09:11:42 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <4AC0B399.8080105@t-online.de> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> Message-ID: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> It's very difficult to find information on: 1. How many Haskell developers are out there; 2. What a typical salary is for a Haskell developer; 3. Whether or not the skills of a typical Haskell developer scale to large applications (most Haskell developers are "hobby" Haskellers and have only written tiny to small Haskell apps); 4. How many shops are capable of handling Haskell development & maintenance. These are the kinds of information one needs to make an informed decision about whether to introduce Haskell into the workplace. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 28, 2009, at 7:01 AM, J?rg Roman Rudnick wrote: > In the last months, I made the experience it seems difficult to find > commercial Haskell developer teams to take responsibility for > projects in the range of $ 10.000 - 100.000. The Industrial Haskell > Group does not seem to be the appropriate place for this, while > harvesting Haskell team at general market places appears to be > tedious. > > I would be very interested in others' experiences, and inhowfar my > opinion is shared that there should be a demand for such a market > place, for developer teams as well as those sympathizing with > introducing Haskell somewhere. > > Nick > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/4ca8517a/attachment.html From cjs at starling-software.com Mon Sep 28 09:49:44 2009 From: cjs at starling-software.com (Curt Sampson) Date: Mon Sep 28 09:27:47 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> Message-ID: <20090928134941.GD17527@poetic.cynic.net> On 2009-09-28 07:01 -0600 (Mon), John A. De Goes wrote: > And I stand by my statement that no Java shop is going to switch over > to Haskell.... I have counterexamples. So "pfffft!" > ...or the _billions of dollars_ worth of commercial- > friendly open source libraries available for the Java platform. Right; the library myth. I rank this one up there with, "Haskell can never be an effective programming language, because it doesn't have objects." I've been hearing that having lots of libraries is an insurmountable advantage, and you're doomed if you give them up, since long before I took up Haskell. It's mostly myth promulgated by people driven by fear. I'm sure it's the case in some shops that they have lots of people who can glue libraries together but can't program, and they somehow manage to produce applications this way, but even that I suspect is not so frequent a situation as you'd think. Nonetheless, since all of this is rather missing the point of my articles, anyway, I think I'll leave that as my last word on the topic. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From john at n-brain.net Mon Sep 28 10:13:53 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Sep 28 09:51:58 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090928134941.GD17527@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> Message-ID: <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> If you have counterexamples, then perhaps you can name them. I'm looking for Java shops with 5+ developers and code bases of > 100k converting over to Haskell. I don't know _any such shop_ that has switched to Haskell, and I doubt any exist, but I'd be delighted to learn I'm wrong. Let me ask you this question: how long would it take you to get an HTML/CSS, W3 compliant browser in Haskell? Or how about a peer-to-peer networking system with seamless scaling and automatic failover? How about a scalable BigTable implementation? In Java, the answer to these questions -- and just about any others you can think of -- is "a few minutes", because the code has already been written. Libraries are _everything_. In many cases, they can increase your effective budget by 10x or even 100x. That means instead of having $100k for a project, you suddenly have $1 - 10 million worth of resources at your disposal. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 28, 2009, at 7:49 AM, Curt Sampson wrote: > On 2009-09-28 07:01 -0600 (Mon), John A. De Goes wrote: > >> And I stand by my statement that no Java shop is going to switch over >> to Haskell.... > > I have counterexamples. So "pfffft!" > >> ...or the _billions of dollars_ worth of commercial- >> friendly open source libraries available for the Java platform. > > Right; the library myth. I rank this one up there with, "Haskell can > never be an effective programming language, because it doesn't have > objects." > > I've been hearing that having lots of libraries is an insurmountable > advantage, and you're doomed if you give them up, since long before I > took up Haskell. It's mostly myth promulgated by people driven by > fear. > I'm sure it's the case in some shops that they have lots of people who > can glue libraries together but can't program, and they somehow manage > to produce applications this way, but even that I suspect is not so > frequent a situation as you'd think. > > Nonetheless, since all of this is rather missing the point of my > articles, anyway, I think I'll leave that as my last word on the > topic. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com From yairchu at gmail.com Mon Sep 28 10:16:52 2009 From: yairchu at gmail.com (yairchu@gmail.com) Date: Mon Sep 28 09:54:55 2009 Subject: [Haskell-cafe] Re: ANN: ListTree 0.1 In-Reply-To: <4ABFBE86.4000007@freegeek.org> References: <88b0f98e-a113-4153-85a1-df56d7deb031@z28g2000vbl.googlegroups.com> <4ABFBE86.4000007@freegeek.org> Message-ID: Hi, I haven't seen that paper. I certainly agree with their point that Haskell easily allows to separate the code of the search and pruning algorithms from the code of the search-space etc. It seems that my package and their paper focus on different algorithms. They mostly focus on pruning methods, and it seems that the order they search in is always depth-first, although sometimes with reordering of nodes' children. They also use a different structure for the search trees. Theirs is like Data.Tree's. My package uses monadic trees (like "ListT []") and so allows the iteration of the tree to be monadic, allowing to add stateful pruning to the mix (by adding a StateT to the tree's underlying monad). In their paper they also describe stateful pruning methods, but if I understand correctly, the consumption of the trees has to be made by their backtracking functions which are aware of their pruning methods. cheers, Yair On Sep 27, 9:35?pm, wren ng thornton wrote: > yair...@gmail.com wrote: > > Hi, > > I am pleased to announce the release of ListTree. > > ListTree is a package for combinatorial search and pruning of trees, > > and should be useful for problems such as those in Google Code Jam > > (where I, and possibly others* could make use of it), but possibly > > could even be useful for real applications! > > [...] > > One problem with my package (which I'll attempt fixing), however, is > > speed. I haven't used it during the competition, and the quick and > > dirty, less modular code, that I coded in the competition, which > > performs exactly the same algorithm, runs a 100 times faster! Both are > > fast enough, but this is still troubling. > > I guess I should look into "Stream Fusion" to try and make my package > > faster. > > Have you seen Andrew Tolmach & Thomas Nordin's "Modular Lazy Search for > Constraint Satisfaction Problems"? They describe a very similar project > which incorporates many of the common optimizations in the field > (backjumping, backmarking, forward-checking, fail-first,...) and provide > their code as well. > > ? ? ?paper:http://web.cecs.pdx.edu/~apt/jfp01.ps > ? ? ?code: ?http://web.cecs.pdx.edu/~apt/CSP_jfp.hs > > -- > Live well, > ~wren > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From emiddleton at bebear.net Mon Sep 28 10:26:12 2009 From: emiddleton at bebear.net (Edward Middleton) Date: Mon Sep 28 10:04:16 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> Message-ID: <4AC0C784.8020809@bebear.net> John A. De Goes wrote: > > If you have counterexamples, then perhaps you can name them. I'm looking > for Java shops with 5+ developers and code bases of > 100k converting > over to Haskell. I don't know _any such shop_ that has switched to > Haskell, and I doubt any exist, but I'd be delighted to learn I'm wrong. http://portal.acm.org/citation.cfm?doid=1596550.1596578 Edward From Alistair.Bayley at invesco.com Mon Sep 28 10:31:36 2009 From: Alistair.Bayley at invesco.com (Bayley, Alistair) Date: Mon Sep 28 10:09:39 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <4AC0C784.8020809@bebear.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net><21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <4AC0C784.8020809@bebear.net> Message-ID: <125EACD0CAE4D24ABDB4D148C4593DA9110262C3@GBLONXMB02.corp.amvescap.net> > From: haskell-cafe-bounces@haskell.org > [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Edward > Middleton > > > > If you have counterexamples, then perhaps you can name > them. I'm looking > > for Java shops with 5+ developers and code bases of > 100k > converting > > over to Haskell. I don't know _any such shop_ that has switched to > > Haskell, and I doubt any exist, but I'd be delighted to > learn I'm wrong. > > http://portal.acm.org/citation.cfm?doid=1596550.1596578 If you lack an ACM subscription, then this is likely the same document: http://www.starling-software.com/misc/icfp-2009-cjs.pdf Alistair ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. ***************************************************************** From nonowarn at gmail.com Mon Sep 28 10:59:07 2009 From: nonowarn at gmail.com (Yusaku Hashimoto) Date: Mon Sep 28 10:37:08 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: References: Message-ID: After a few more investigations, I can say QuickCheck does: - make easy to finding couter-cases and refactoring codes - make easy to test some functions if they have good mathematical properties - generate random test cases But QuickCheck does *not*: - help us to find good properties So what I want to know is "how to find good properties." Please let me know how do you find QuickCheck properties. There are so many tutorials or papers for using QuickCheck, but when I try to apply them to my programming, I often miss properties in my codes. Cheers -nwn From bulat.ziganshin at gmail.com Mon Sep 28 11:09:39 2009 From: bulat.ziganshin at gmail.com (Bulat Ziganshin) Date: Mon Sep 28 10:48:31 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <4AC0C784.8020809@bebear.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <4AC0C784.8020809@bebear.net> Message-ID: <1283312306.20090928190939@gmail.com> Hello Edward, Monday, September 28, 2009, 6:26:12 PM, you wrote: >> If you have counterexamples, then perhaps you can name them. I'm looking >> for Java shops with 5+ developers and code bases of > 100k converting >> over to Haskell. I don't know _any such shop_ that has switched to >> Haskell, and I doubt any exist, but I'd be delighted to learn I'm wrong. > http://portal.acm.org/citation.cfm?doid=1596550.1596578 citation: "we thought we might have to interface with Java libraries. This turned out not to be the case" -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com From gwern0 at gmail.com Mon Sep 28 11:14:36 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Mon Sep 28 10:52:39 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: Message-ID: On Mon, Sep 28, 2009 at 10:59 AM, Yusaku Hashimoto wrote: > After a few more investigations, I can say > > QuickCheck does: > - make easy to finding couter-cases and refactoring codes > - make easy to test some functions if they have good mathematical properties > - generate random test cases > > But QuickCheck does *not*: > - help us to find good properties > > So what I want to know is "how to find good properties." Please let me > know how do you find QuickCheck properties. There are so many > tutorials or papers for using QuickCheck, but when I try to apply them > to my programming, I often miss properties in my codes. > > Cheers > -nwn I don't think there's any automated way to come up with good properties given a function; that seems tantamount to solving AI. One thing I've meant to do is look at checkers: http://hackage.haskell.org/package/checkers - which I understand includes a collection of lots of properties for various datatypes and classes. Presumably you could look through it for ideas ('ooh, I forgot that my results should monotonically increase!') or pick the module closest to what you're testing and steal as many of its properties as you can. -- gwern -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 197 bytes Desc: OpenPGP digital signature Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/233d6a9a/signature.bin From emax at chalmers.se Mon Sep 28 11:16:38 2009 From: emax at chalmers.se (Emil Axelsson) Date: Mon Sep 28 10:54:40 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: References: Message-ID: <4AC0D356.9070303@chalmers.se> Not sure this is what you want, but I thought I'd mention "Formal Specifications for Free": http://www.erlang.org/euc/08/1005Hughes2.pdf (I wasn't able to find a better link. That talk is for Erlang, but people are working on this for Haskell QuickCheck.) / Emil Yusaku Hashimoto skrev: > After a few more investigations, I can say > > QuickCheck does: > - make easy to finding couter-cases and refactoring codes > - make easy to test some functions if they have good mathematical properties > - generate random test cases > > But QuickCheck does *not*: > - help us to find good properties > > So what I want to know is "how to find good properties." Please let me > know how do you find QuickCheck properties. There are so many > tutorials or papers for using QuickCheck, but when I try to apply them > to my programming, I often miss properties in my codes. > > Cheers > -nwn > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From selahattin.gerdan at gmail.com Mon Sep 28 11:36:57 2009 From: selahattin.gerdan at gmail.com (selahaddin) Date: Mon Sep 28 11:14:58 2009 Subject: [Haskell-cafe] Fwd: frag game-compiling error In-Reply-To: References: <65ac1a170909271700v7200fc0bt4fb2ae069ef1c4e3@mail.gmail.com> <65ac1a170909280357r6c0564e5y5e7c127e39345329@mail.gmail.com> <20090928112806.GA7161@kira.casa> Message-ID: <25645411.post@talk.nabble.com> Lyndon Maydwell wrote: > >> src/Quaternion.hs:22:27 > > This would probably be the place to start. > Ok,I managed to get past the error like this: newMatrix ColumnMajor [realToFrac r00,realToFrac r01,realToFrac r02,realToFrac r03, realToFrac r10,realToFrac r11,realToFrac r12,realToFrac r13, realToFrac r20,realToFrac r21,realToFrac r22,realToFrac r23, realToFrac r30,realToFrac r31,realToFrac r32,realToFrac r33] So Quaternion.hs compiled fine,but now it gives error messages in another file. As far as I understand, this games code is incompatible with the new version of haskell opengl libraries. Am I right? -- View this message in context: http://www.nabble.com/frag-game-compiling-error-tp25638949p25645411.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From dons at galois.com Mon Sep 28 11:49:11 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 28 11:29:26 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> Message-ID: <20090928154911.GA12575@whirlpool.galois.com> titto: > Hi, > > I am looking for an unicode strings library, I found on hackage: > > http://hackage.haskell.org/package/compact-string > > http://hackage.haskell.org/package/text > > They both look solid and functionally complete so ... I don't know which > one to use :-) > > As I am sure I am not the first one facing this choice, may I ask > which one you preferred and why? Data.Text From bugfact at gmail.com Mon Sep 28 11:59:28 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Mon Sep 28 11:37:32 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> Message-ID: That's a really shame. Any idea why? On Mon, Sep 28, 2009 at 3:02 PM, John A. De Goes wrote: > > CAL is interesting, but unfortunately dead, and has no community. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Sep 27, 2009, at 3:38 PM, Peter Verswyvelen wrote: > > That's not really true. Just use CAL from the Open Quark framework... It's > almost Haskell 98, with some extras, and compiles to fast JVM code. > http://openquark.org/Open_Quark/Welcome.html > > They even seem to do all > kinds of advanced optimizations - like converting tail calls to loops - to > get good Java performance. > > And they have a better record system, a graphical environment to learn it, > etc. > > So I think CAL should be in the list, and since it's basically Haskell... > > On Sun, Sep 27, 2009 at 6:36 PM, John A. De Goes wrote: > >> >> I'm not sure what the point of your series is. No one who is using Java >> now commercially can move to Haskell because Haskell doesn't run on the JVM. >> >> It makes sense to discuss Clojure, Groovy, JRuby, Scala, Fan, etc., as >> "next Java's", because they all run on the JVM and have seamless interop >> with Java. Haskell is not in this category. It's stuck in a different world, >> wholly inaccessible to the masses. >> >> Regards, >> >> John A. De Goes >> N-Brain, Inc. >> The Evolution of Collaboration >> >> http://www.n-brain.net | 877-376-2724 x 101 >> >> >> On Sep 27, 2009, at 10:16 AM, Curt Sampson wrote: >> >> No, it's not quite what it sounds like. :-) >>> >>> Stuart Halloway recently posted a series of blog entries entitled >>> "Java.next"[1], discussing the benefits of four other languages that >>> compile to JVM bytecode and interoperate with Java: Clojure, Groovy, >>> JRuby, and Scala. I thought I'd put my oar in and write a parallel >>> series comparing Haskell to these. I've finished a draft of the first >>> posting, started on the third, and made a couple of notes on the second >>> and fourth, and I thought I'd post the drafts[2] and solicit comments >>> here. If you have time to read and comment, I'd greatly appreciate the >>> help; feel free either to e-mail me privately or post here. Also feel >>> free to forward this to anybody else you feel might be interested in >>> commenting. >>> >>> I'll probably be posting these about one per week, starting some time >>> next week. >>> >>> [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview >>> [2]: >>> http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html >>> >>> cjs >>> -- >>> Curt Sampson +81 90 7737 2974 >>> Functional programming in all senses of the word: >>> http://www.starling-software.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 >> > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/5dd6afea/attachment.html From dons at galois.com Mon Sep 28 12:15:17 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 28 11:55:33 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> Message-ID: <20090928161517.GA12679@whirlpool.galois.com> tittoassini: > 2009/9/28 Don Stewart : > > titto: > >> Hi, > >> > >> I am looking for an unicode strings ?library, I found on hackage: > >> > >> http://hackage.haskell.org/package/compact-string > >> > >> http://hackage.haskell.org/package/text > >> > >> They both look solid and functionally complete so ... I don't know which > >> one to use :-) > >> > >> As I am sure I am not the first one facing this choice, may I ask > >> which one you preferred and why? > > > Data.Text > > Thanks , but .. why? Sorry, was on the way out the door. Data.Text has growing use, is well designed, and builds on the pedigree of bytestring and the vector* series of fusion libraries. I trust that code. -- Don From johan.tibell at gmail.com Mon Sep 28 12:32:07 2009 From: johan.tibell at gmail.com (Johan Tibell) Date: Mon Sep 28 12:10:29 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <20090928161517.GA12679@whirlpool.galois.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> Message-ID: <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> On Mon, Sep 28, 2009 at 6:15 PM, Don Stewart wrote: > tittoassini: >> 2009/9/28 Don Stewart : >> > titto: >> >> Hi, >> >> >> >> I am looking for an unicode strings ?library, I found on hackage: >> >> >> >> http://hackage.haskell.org/package/compact-string >> >> >> >> http://hackage.haskell.org/package/text >> >> >> >> They both look solid and functionally complete so ... I don't know which >> >> one to use :-) >> >> >> >> As I am sure I am not the first one facing this choice, may I ask >> >> which one you preferred and why? >> >> > Data.Text >> >> Thanks , but .. why? > > Sorry, was on the way out the door. Data.Text has growing use, is well > designed, and builds on the pedigree of bytestring and the vector* > series of fusion libraries. I trust that code. I agree with Don. Also, I don't think that a Unicode type should mention what encoding it uses as it's an implementation detail. -- Johan From duncan.coutts at googlemail.com Mon Sep 28 12:21:55 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Sep 28 12:30:30 2009 Subject: [Haskell-cafe] Hackage bug? Autobuild failure on literate source with ignored code blocks. In-Reply-To: <1254081980.5924.37.camel@desktop> References: <1254081980.5924.37.camel@desktop> Message-ID: <1254154915.4588.699.camel@localhost> On Sun, 2009-09-27 at 21:06 +0100, John Millikin wrote: > According to , > the following should compile properly because the second block of code > will be ignored by GHC: > > \begin{code} > main = putStrLn "Hello world!" > \end{code} > > \begin{code}% > main = -- TODO > \end{code}% It looks to me like the advice on that wiki page is incorrect. The Haskell98 report states: An alternative style of literate programming is particularly suitable for use with the LaTeX text processing system. In this convention, only those parts of the literate program that are entirely enclosed between \begin{code}...\end{code} delimiters are treated as program text; all other lines are comment. More precisely: * Program code begins on the first line following a line that begins \begin{code}. * Program code ends just before a subsequent line that begins \end{code} (ignoring string literals, of course). The key phrases is "a line that begins \begin{code}". In other words, a line "\begin{code}%" does indeed begin a code block. > However, Hackage's automatic build system seems to pre-process the > literate source in such a way that the ignored block is included in > the .hs source, resulting in a compilation error: Right. Having checked the H98 report I think this is the correct behaviour. > Although Hackage fails to build the package, it works fine on my local > system when I run "cabal configure && cabal build && cabal haddock". Is > this a bug in the Hackage auto-build mechanism, or have I done something > wrong when uploading the package? It looks like ghc gets this wrong and ignores "\begin{code}%". I have filed this as http://hackage.haskell.org/trac/ghc/ticket/3549 Your local Cabal version is older than the one Hackage is using and that older version lets haddock (ie ghc) do the pre-processing where as in the current version Cabal does the unlitting before running haddock. That explains the difference you observe. The solution is not to use "\begin{code}%" and assume it will not be recognised as the start of a code block. Duncan From duncan.coutts at googlemail.com Mon Sep 28 12:29:50 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Sep 28 12:30:35 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: References: Message-ID: <1254155390.4588.713.camel@localhost> On Mon, 2009-09-28 at 23:59 +0900, Yusaku Hashimoto wrote: > After a few more investigations, I can say > > QuickCheck does: > - make easy to finding couter-cases and refactoring codes > - make easy to test some functions if they have good mathematical properties > - generate random test cases > > But QuickCheck does *not*: > - help us to find good properties > > So what I want to know is "how to find good properties." Please let me > know how do you find QuickCheck properties. This requires thought and practise. The properties are a partial formal description of what your program does. You have to decide what your program is supposed to do. There is no magic here. Sometimes you find that you adjust your properties to fit the program and sometimes adjust the program to fit the properties. To gain experience in thinking about properties of programs you probably want to look at books and articles and try examples. This is the kind of thing they teach in CS degrees. It is a matter of training yourself. Duncan From duncan.coutts at googlemail.com Mon Sep 28 11:48:59 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Sep 28 12:30:47 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> Message-ID: <1254152939.4588.643.camel@localhost> On Mon, 2009-09-28 at 14:16 +0100, Titto Assini wrote: > Hi, > > I am looking for an unicode strings library, I found on hackage: > > http://hackage.haskell.org/package/compact-string > > http://hackage.haskell.org/package/text > > They both look solid and functionally complete so ... I don't know which > one to use :-) > > As I am sure I am not the first one facing this choice, may I ask > which one you preferred and why? I would use the text package because in my opinion it has a better API. It is the hope of several of us that the text package will become the standard Unicode counterpart to ByteString and be included in the platform. Duncan From tittoassini at gmail.com Mon Sep 28 12:56:31 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Mon Sep 28 12:34:32 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: <4AC0D356.9070303@chalmers.se> References: <4AC0D356.9070303@chalmers.se> Message-ID: <2d34474e0909280956q7bc3e9bdoa38f936f38dd4be3@mail.gmail.com> Fantastic. If I understand correctly it inductively derives equations that hold for a set of examples. I am looking forward to see it in Haskell, who is working on the port? titto 2009/9/28 Emil Axelsson : > Not sure this is what you want, but I thought I'd mention "Formal > Specifications for Free": > > ?http://www.erlang.org/euc/08/1005Hughes2.pdf > > (I wasn't able to find a better link. That talk is for Erlang, but people > are working on this for Haskell QuickCheck.) > > / Emil > > > > Yusaku Hashimoto skrev: >> >> After a few more investigations, I can say >> >> QuickCheck does: >> - make easy to finding couter-cases and refactoring codes >> - make easy to test some functions if they have good mathematical >> properties >> - generate random test cases >> >> But QuickCheck does *not*: >> - help us to find good properties >> >> So what I want to know is "how to find good properties." Please let me >> know how do you find QuickCheck properties. There are so many >> tutorials or papers for using QuickCheck, but when I try to apply them >> to my programming, I often miss properties in my codes. >> >> Cheers >> -nwn >> _______________________________________________ >> 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 > -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ From cjs at starling-software.com Mon Sep 28 12:56:42 2009 From: cjs at starling-software.com (Curt Sampson) Date: Mon Sep 28 12:34:45 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> Message-ID: <20090928165642.GF17527@poetic.cynic.net> Ok, my last post on this for real this time. On 2009-09-28 08:13 -0600 (Mon), John A. De Goes wrote: > Let me ask you this question: how long would it take you to get an > HTML/CSS, W3 compliant browser in Haskell? A long time. On the other hand, by grabbing a copy of Mozilla, I'll have one far faster than you'll have yours in Java, mine will work a lot better, run more quickly, and work better with most sites. While I advocate using Haskell, I don't advocate being silly. (Incidently, I have direct experience with an almost exactly parallel situation. I replaced a system that was thousands of lines of difficult-to-maintain Java code with a few hundred lines of Haskell that feed Microsoft Excel. The user is very pleased that he can now can do far more extensive tweaking of the UI himself, including major features he never had at all before, such as real-time graphing of the data.) > Or how about a peer-to-peer networking system with seamless scaling > and automatic failover? Can you give me an example of a real-life system using this you've set up in "a few minutes"? My experience building systems with similar things (the very mature and proven MogileFS suite of tools) has been that the libraries were nice, but did not solve the majority, or even a large minority, of the problem. > Libraries are _everything_. In many cases, they can increase your > effective budget by 10x or even 100x. Or the other way around, as I've seen by ripping out thousands of lines of Hibernate code, and all of the work done to adapt a system to that model, and replace it with a few hundred lines of SQL and JDBC calls. That library has probably wasted more man-years than anything else I've seen in the Java world. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From jason.dusek at gmail.com Mon Sep 28 13:01:04 2009 From: jason.dusek at gmail.com (Jason Dusek) Date: Mon Sep 28 12:39:05 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> Message-ID: <42784f260909281001q42df0115w41fdfaf7a1a014ec@mail.gmail.com> 2009/09/28 John A. De Goes : > Libraries are _everything_... Not exactly. Python would never have gotten a foothold over Perl, nor Java over C, if cleaner language semantics weren't enough for some shops or certain applications. -- Jason Dusek From john at n-brain.net Mon Sep 28 13:14:49 2009 From: john at n-brain.net (John A. De Goes) Date: Mon Sep 28 12:52:55 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> Message-ID: I think they made a mistake choosing a syntax so close to Haskell: 1. It's close enough to Haskell to attract Haskellers; 2. It's far enough away from Haskell to push Haskellers away; 3. It's not the language one would design if one were prioritizing easy interop with Java in a modern lazy, functional language. If CAL were 100% Haskell 98 + extensions, it would be a success (Haskell + all Java libraries, trivial cross-platform library development, Haskell on Android & AppEngine, etc.). If it were nothing like Haskell, but had the features of Haskell plus strong, seamless, and easy Java interop, then it would be a success. Having neither, I'm not surprised it has no community and development has ceased. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 28, 2009, at 9:59 AM, Peter Verswyvelen wrote: > That's a really shame. Any idea why? > > On Mon, Sep 28, 2009 at 3:02 PM, John A. De Goes > wrote: > > CAL is interesting, but unfortunately dead, and has no community. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Sep 27, 2009, at 3:38 PM, Peter Verswyvelen wrote: > >> That's not really true. Just use CAL from the Open Quark >> framework... It's almost Haskell 98, with some extras, and compiles >> to fast JVM code. >> >> http://openquark.org/Open_Quark/Welcome.html >> >> They even seem to do all kinds of advanced optimizations - like >> converting tail calls to loops - to get good Java performance. >> >> And they have a better record system, a graphical environment to >> learn it, etc. >> >> So I think CAL should be in the list, and since it's basically >> Haskell... >> >> On Sun, Sep 27, 2009 at 6:36 PM, John A. De Goes >> wrote: >> >> I'm not sure what the point of your series is. No one who is using >> Java now commercially can move to Haskell because Haskell doesn't >> run on the JVM. >> >> It makes sense to discuss Clojure, Groovy, JRuby, Scala, Fan, etc., >> as "next Java's", because they all run on the JVM and have seamless >> interop with Java. Haskell is not in this category. It's stuck in a >> different world, wholly inaccessible to the masses. >> >> Regards, >> >> John A. De Goes >> N-Brain, Inc. >> The Evolution of Collaboration >> >> http://www.n-brain.net | 877-376-2724 x 101 >> >> >> On Sep 27, 2009, at 10:16 AM, Curt Sampson wrote: >> >> No, it's not quite what it sounds like. :-) >> >> Stuart Halloway recently posted a series of blog entries entitled >> "Java.next"[1], discussing the benefits of four other languages that >> compile to JVM bytecode and interoperate with Java: Clojure, Groovy, >> JRuby, and Scala. I thought I'd put my oar in and write a parallel >> series comparing Haskell to these. I've finished a draft of the first >> posting, started on the third, and made a couple of notes on the >> second >> and fourth, and I thought I'd post the drafts[2] and solicit comments >> here. If you have time to read and comment, I'd greatly appreciate >> the >> help; feel free either to e-mail me privately or post here. Also feel >> free to forward this to anybody else you feel might be interested in >> commenting. >> >> I'll probably be posting these about one per week, starting some time >> next week. >> >> [1]: http://blog.thinkrelevance.com/2008/9/24/java-next-overview >> [2]: http://www.starling-software.com/en/blog/drafts/2009/09/27.succ-java-summary.html >> >> cjs >> -- >> Curt Sampson +81 90 7737 >> 2974 >> Functional programming in all senses of the word: >> http://www.starling-software.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 >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/38ddb681/attachment.html From duncan.coutts at googlemail.com Mon Sep 28 13:01:37 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Mon Sep 28 12:59:02 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> Message-ID: <1254157297.4588.752.camel@localhost> On Mon, 2009-09-28 at 18:32 +0200, Johan Tibell wrote: > On Mon, Sep 28, 2009 at 6:15 PM, Don Stewart wrote: > > tittoassini: > >> 2009/9/28 Don Stewart : > >> > titto: > >> >> Hi, > >> >> > >> >> I am looking for an unicode strings library, I found on hackage: > >> >> > >> >> http://hackage.haskell.org/package/compact-string > >> >> > >> >> http://hackage.haskell.org/package/text > >> >> > >> >> They both look solid and functionally complete so ... I don't know which > >> >> one to use :-) > >> >> > >> >> As I am sure I am not the first one facing this choice, may I ask > >> >> which one you preferred and why? > Also, I don't think that a Unicode type should mention what encoding > it uses as it's an implementation detail. I would put it more strongly. The encoding should not be in the API because it makes it harder to compose functionality. While there may be some circumstances where for performance reasons you may want precise control over the internal encoding, that is not appropriate to use in component interfaces. I know we've made this worse recently, but a proliferation of different string types makes it harder to reuse code. An exposed encoding parameter makes that even worse. Duncan From allbery at ece.cmu.edu Mon Sep 28 14:08:08 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Sep 28 13:46:14 2009 Subject: [Haskell-cafe] Hackage bug? Autobuild failure on literate source with ignored code blocks. In-Reply-To: <1254154915.4588.699.camel@localhost> References: <1254081980.5924.37.camel@desktop> <1254154915.4588.699.camel@localhost> Message-ID: <8B8FEDC2-8C4A-40CC-B601-E0701ECCCEF2@ece.cmu.edu> On Sep 28, 2009, at 12:21 , Duncan Coutts wrote: > On Sun, 2009-09-27 at 21:06 +0100, John Millikin wrote: >> According to > Literate_programming>, >> the following should compile properly because the second block of >> code >> will be ignored by GHC: >> >> \begin{code} >> main = putStrLn "Hello world!" >> \end{code} >> >> \begin{code}% >> main = -- TODO >> \end{code}% > > It looks to me like the advice on that wiki page is incorrect. > > The Haskell98 report states: > > An alternative style of literate programming is particularly > suitable for use with the LaTeX text processing system. In this > convention, only those parts of the literate program that are > entirely enclosed between \begin{code}...\end{code} delimiters > are treated as program text; all other lines are comment. More > precisely: > > * Program code begins on the first line following a line > that begins \begin{code}. > * Program code ends just before a subsequent line that > begins \end{code} (ignoring string literals, of > course). > > The key phrases is "a line that begins \begin{code}". In other > words, a > line "\begin{code}%" does indeed begin a code block. Isn't the better solution to this something like \let\uncode\code \let\enduncode\endcode then use \begin{uncode} .. \end{uncode} ? (depends on how the code environment is defined) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/da6c8fa8/PGP.bin From Patrick.Browne at comp.dit.ie Mon Sep 28 15:23:38 2009 From: Patrick.Browne at comp.dit.ie (pat browne) Date: Mon Sep 28 15:03:02 2009 Subject: [Haskell-cafe] river crossing puzzle Message-ID: <4AC10D3A.6060703@comp.dit.ie> Hi, Does anyone know where there are any Haskell implementations of the the River Crossing puzzle (AKA Farmer/Fox/Goose/Grain). There are several variations but the general ideas are explained at: http://en.wikipedia.org/wiki/River_crossing_puzzle http://en.wikipedia.org/wiki/Fox,_goose_and_bag_of_beans_puzzle I have found one at: http://www.shido.info/hs/haskell9.html Thanks, Pat From emax at chalmers.se Mon Sep 28 15:26:20 2009 From: emax at chalmers.se (Emil Axelsson) Date: Mon Sep 28 15:05:06 2009 Subject: [Haskell-cafe] QuickCheck Questions In-Reply-To: <2d34474e0909280956q7bc3e9bdoa38f936f38dd4be3@mail.gmail.com> References: <4AC0D356.9070303@chalmers.se> <2d34474e0909280956q7bc3e9bdoa38f936f38dd4be3@mail.gmail.com> Message-ID: <4AC10DDC.5070008@chalmers.se> Pasqualino "Titto" Assini skrev: > Fantastic. > > If I understand correctly it inductively derives equations that hold > for a set of examples. AFAIU, it enumerates a set of terms and uses random testing to approximate an equivalence relation for these. The real trick, apparently, is in filtering out the interesting equations. > I am looking forward to see it in Haskell, who is working on the port? John Hughes, Koen Claessen and Nick Smallbone. (At least.) / Emil From jmillikin at gmail.com Mon Sep 28 15:53:48 2009 From: jmillikin at gmail.com (John Millikin) Date: Mon Sep 28 15:31:50 2009 Subject: [Haskell-cafe] Hackage bug? Autobuild failure on literate source with ignored code blocks. In-Reply-To: <1254154915.4588.699.camel@localhost> References: <1254081980.5924.37.camel@desktop> <1254154915.4588.699.camel@localhost> Message-ID: <3283f7fe0909281253o78ea779dv31576ef0c5a131b@mail.gmail.com> In that case, I'll update my code and the wiki to use an alternative code style. On Mon, Sep 28, 2009 at 09:21, Duncan Coutts wrote: > Your local Cabal version is older than the one Hackage is using and that > older version lets haddock (ie ghc) do the pre-processing where as in > the current version Cabal does the unlitting before running haddock. > That explains the difference you observe. Since Hackage is using an unstable development build of Cabal, I'd like to force it to use a released version to prevent such an issue from occurring again. I've added the following line to my .cabal file: cabal-version: >= 1.6 && < 1.7 However, when testing with Cabal 1.7.3 (which is the version used by Hackage), I am warned that: ------------- Warning: dbus-core.cabal: This package requires Cabal version: >=1.6 && <1.7 Distribution quality errors: This package requires Cabal version: >=1.6 && <1.7 Note: the public hackage server would reject this package. ------------- Does this mean that it's impossible to require an earlier version of Cabal in Hackage-published packages? If so, the use of a development version of Cabal in the auto-build system seems unwise. From ben.franksen at online.de Mon Sep 28 16:00:42 2009 From: ben.franksen at online.de (Ben Franksen) Date: Mon Sep 28 15:39:06 2009 Subject: [Haskell-cafe] Re: QuickCheck Questions References: Message-ID: Yusaku Hashimoto wrote: > So what I want to know is "how to find good properties." Please let me > know how do you find QuickCheck properties. There are so many > tutorials or papers for using QuickCheck, but when I try to apply them > to my programming, I often miss properties in my codes. Dijkstra would have said a good program (or program fragment, such as a library or even a single function) should /start out/ with properties, ideally a set of properties which completely specifies the program's output/behaviour. The implementation should then be structured in a way that makes it possible to prove (with reasonable effort) that the properties hold (and runnign QC on these properties then merely tests whether your proof was erroneous). Thus your problem is solved by construction. However, in practice we most often start out with only a vague idea of what our program should do. After hacking away for a time, however, we usually arrive at a level of granularity (individual small functions) where we have a more or less precise idea what we want it to achieve. It is then a matter of making this specification as precise as possible. If it turns out that a precise spec is unwieldy (too complex) then this is a hint that maybe it is not a good abstraction. Try to generalize or otherwise simplify the spec (refactoring the program) until you arrive at something manageable. It should then be possible to formalize this specification and convert it into a QC property. I think that this process is not something that can be automated (in general). Cheers Ben From lemming at henning-thielemann.de Mon Sep 28 17:24:39 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Sep 28 17:02:42 2009 Subject: [Haskell-cafe] combinatorial search with running bound In-Reply-To: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> References: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> Message-ID: On Sat, 26 Sep 2009, Michael Mossey wrote: > I have a combinatorial search problem that requires a > running lower bound to be tracked in order to prune the search. I have enough > Haskell experience to know how to do a combinatorial search, for example with > list compresions or the list monad, but I don't know how to keep a running > lower bound. Sometimes the omega monad can help by searching the space in a diagonal manner: http://hackage.haskell.org/package/control-monad-omega From andrewcoppin at btinternet.com Mon Sep 28 17:28:41 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Mon Sep 28 17:06:37 2009 Subject: [Haskell-cafe] Re: QuickCheck Questions In-Reply-To: References: Message-ID: <4AC12A89.8030801@btinternet.com> Ben Franksen wrote: > If it turns out that a > precise spec is unwieldy (too complex) then this is a hint that maybe it is > not a good abstraction. Or your specification language is insufficient to describe it... (I don't know about anybody else, but I find that when I use QC, about 75% of the bugs reported are bugs in the spec, and only 25% are bugs in the thing I'm actually trying to test...) From saul.malesac at gmail.com Mon Sep 28 17:30:08 2009 From: saul.malesac at gmail.com (Saul Malesac) Date: Mon Sep 28 17:08:08 2009 Subject: [Haskell-cafe] Writing tool question (may be out of scope here) Message-ID: <59940e500909281430o54ffe2f7v4b8dbc6c644dccaf@mail.gmail.com> Hi, Excuse me if that is out of subject here, but does anyone know which tool/writing framework was used to write the "Real world Haskell" book ? I'm wondering, in particular, about the capability to write/edit/publish it online while allowing people to leave comments, then have a paperback/PDF version. Thanks in advance, -- Saul From lemming at henning-thielemann.de Mon Sep 28 17:40:59 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon Sep 28 17:19:00 2009 Subject: [Haskell-cafe] 16 bit floating point data in Haskell? In-Reply-To: References: Message-ID: On Sun, 27 Sep 2009, Olex P wrote: > Hi guys, > > Do we have anything like half precision floats in Haskell? Maybe in some non standard > libraries? Or I have to use FFI + OpenEXR library to achieve this? If you only want to save storage, you may define newtype Float16 = Float16 Int16 and write Num, Fractional and Floating instances that convert operands to Float, perform operations on Float and put the results back to Int16. By some fusion you may save conversions, but you would also get different results due to higher precision. From jpaulo at di.uminho.pt Mon Sep 28 17:56:58 2009 From: jpaulo at di.uminho.pt (=?ISO-8859-1?Q?Jo=E3o_Paulo?=) Date: Mon Sep 28 17:35:01 2009 Subject: [Haskell-cafe] GADT pattern match in non-rigid context Message-ID: Dear all, The following is a (I'm afraid too large!) fragment of a program implementing a GADT-based generic zipper: ********************************************** data Zipper path where Zipper :: hole -> Context (Up (left, hole, right) up) -> Zipper (Up (left, hole, right) up) data Context path where ContTop :: Context (Up (Top, a, Top) Top) Cont :: Left l (h -> r) -> Right r h_parent -> Context (Up (l_parent, h_parent, r_parent) path) -> Context (Up (l, h, r) (Up (l_parent, h_parent, r_parent) path)) data Up a b data Top data Left contains expects where LeftUnit :: a -> Left Top a LeftCons :: Left c (b -> a) -> b -> Left (c -> b) a data Right provides final where RightNull :: Right final final RightCons :: b -> Right a final -> Right (b -> a) final data Erase c a = forall b. (Typeable b) => Erase (c b a) ff :: (Typeable l, Data h, Typeable r, Typeable up) => Zipper (Up (l, h, r) up) -> Erase Left h ff (Zipper h c) = (gfoldl erased_left_cons erased_left_unit h) gg :: (Typeable l_down, Typeable h_down, Data h) => Erase Left h -> Maybe (Left (l_down -> h_down) h) gg (Erase l) = cast l move_down :: (Typeable l_down, Typeable h_down, Typeable l, Data h, Typeable r, Typeable up) => Zipper (Up (l, h, r) up) -> Maybe (Zipper (Up (l_down, h_down, h) (Up (l, h, r) up))) move_down z@(Zipper h c) = case gg (ff z) of # Just (LeftCons l' h_down) -> Just (Zipper h_down (Cont l' RightNull c)) Nothing -> Nothing instance Typeable Top where typeOf _ = mkTyConApp (mkTyCon "Top") [] instance Typeable2 Left where typeOf2 _ = mkTyConApp (mkTyCon "Left") [] instance Typeable2 Up where typeOf2 _ = mkTyConApp (mkTyCon "Up") [] erased_left_cons :: (Typeable b) => Erase Left (b -> a) -> b -> Erase Left a erased_left_cons (Erase c) b = Erase (LeftCons c b) erased_left_unit :: a -> Erase Left a erased_left_unit a = Erase (LeftUnit a) ********************************************** Compiling it with GHC 6.10.4 yelds the error: *** GADT pattern match in non-rigid context for `LeftCons' Solution: add a type signature In the pattern: LeftCons l' h_down [marked with # in the code] *** The suggestion is quite clear :D (in fact, I think this compiler suggestion is the result of previous interactions in this mailing list) The thing is that, in order to add a type signature to the suggested pattern, I believe I have to use the type variables in the signature of function 'move_down' (which I don't think is possible); Can anyone help me with this? I believe this code has compiled before, on previous GHC versions... Thank you very much, Jo?o -- Jo?o Paulo Fernandes Universidade do Minho www.di.uminho.pt/~jpaulo From allbery at ece.cmu.edu Mon Sep 28 17:59:34 2009 From: allbery at ece.cmu.edu (Brandon S. Allbery KF8NH) Date: Mon Sep 28 17:38:00 2009 Subject: [Haskell-cafe] GADT pattern match in non-rigid context In-Reply-To: References: Message-ID: <8A5B9F0C-EBBE-4E85-8F63-5C3227E354F0@ece.cmu.edu> On Sep 28, 2009, at 17:56 , Jo?o Paulo wrote: > GADT pattern match in non-rigid context for `LeftCons' > Solution: add a type signature > In the pattern: LeftCons l' h_down [marked with # > in the code] > > The suggestion is quite clear :D (in fact, I think this compiler > suggestion is the result of previous interactions in this mailing > list) > > The thing is that, in order to add a type signature to the suggested > pattern, I believe I have to use the type variables in the signature > of function 'move_down' (which I don't think is possible); You want the ScopedTypeVariables extension. Read the documentation before using; you need to explicitly forall the type variables you want to use later. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 195 bytes Desc: This is a digitally signed message part Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/f79083e3/PGP.bin From alexander.dunlap at gmail.com Mon Sep 28 18:00:39 2009 From: alexander.dunlap at gmail.com (Alexander Dunlap) Date: Mon Sep 28 17:38:59 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <20090928161517.GA12679@whirlpool.galois.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> Message-ID: <57526e770909281500j3d06c63cpa986acb67f7a2b31@mail.gmail.com> On Mon, Sep 28, 2009 at 9:15 AM, Don Stewart wrote: > tittoassini: >> 2009/9/28 Don Stewart : >> > titto: >> >> Hi, >> >> >> >> I am looking for an unicode strings ?library, I found on hackage: >> >> >> >> http://hackage.haskell.org/package/compact-string >> >> >> >> http://hackage.haskell.org/package/text >> >> >> >> They both look solid and functionally complete so ... I don't know which >> >> one to use :-) >> >> >> >> As I am sure I am not the first one facing this choice, may I ask >> >> which one you preferred and why? >> >> > Data.Text >> >> Thanks , but .. why? > > Sorry, was on the way out the door. Data.Text has growing use, is well > designed, and builds on the pedigree of bytestring and the vector* > series of fusion libraries. I trust that code. > > -- Don > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I just have a question out of curiosity - why was the decision made to have Data.Text, uvector, and ByteString all separate data structures, rather than defining the string types in terms of uvector? Alex From bos at serpentine.com Mon Sep 28 18:29:05 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Mon Sep 28 18:07:06 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <57526e770909281500j3d06c63cpa986acb67f7a2b31@mail.gmail.com> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> <57526e770909281500j3d06c63cpa986acb67f7a2b31@mail.gmail.com> Message-ID: On Mon, Sep 28, 2009 at 3:00 PM, Alexander Dunlap < alexander.dunlap@gmail.com> wrote: > I just have a question out of curiosity - why was the decision made to > have Data.Text, uvector, and ByteString all separate data structures, > rather than defining the string types in terms of uvector? > bytestring predates the other two libraries by several years. The underlying stream type for uvector and text are almost the same, so they could in principle be merged. There's a fair amount of duplication there, but uvector is in some ways more complicated and in others much less thorough than text. Merging them would be a lot of work! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/49b7916c/attachment.html From lrpalmer at gmail.com Mon Sep 28 18:51:28 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Mon Sep 28 18:29:30 2009 Subject: [Haskell-cafe] Re: QuickCheck Questions In-Reply-To: <4AC12A89.8030801@btinternet.com> References: <4AC12A89.8030801@btinternet.com> Message-ID: <7ca3f0160909281551m59273043x2f6c3912e1748578@mail.gmail.com> On Mon, Sep 28, 2009 at 3:28 PM, Andrew Coppin wrote: > Ben Franksen wrote: >> >> If it turns out that a >> precise spec is unwieldy (too complex) then this is a hint that maybe it >> is >> not a good abstraction. > > Or your specification language is insufficient to describe it... > > (I don't know about anybody else, but I find that when I use QC, about 75% > of the bugs reported are bugs in the spec, and only 25% are bugs in the > thing I'm actually trying to test...) Maybe that means that you don't apply the same level of care to testing as you do to coding your main program. Or perhaps that is the quality of many bugs: the code does exactly what I intended, but what I intended was wrong. Luke From tanimoto at arizona.edu Mon Sep 28 19:19:50 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Mon Sep 28 18:58:10 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> <57526e770909281500j3d06c63cpa986acb67f7a2b31@mail.gmail.com> Message-ID: Hi Bryan and others, On Mon, Sep 28, 2009 at 5:29 PM, Bryan O'Sullivan wrote: > bytestring predates the other two libraries by several years. The underlying > stream type for uvector and text are almost the same, so they could in > principle be merged. There's a fair amount of duplication there, but uvector > is in some ways more complicated and in others much less thorough than text. > Merging them would be a lot of work! > If I may free-ride on this thread: how should one go about deriving a Data.Binary instance for text? It looks like doing it efficiently would require using some parts of the internal module that are not exposed, am I correct? I've been using "encodeUtf8", but that doesn't feel right. I don't know what to do, hopefully I'm missing something simple. I agree with Duncan, the text API is beautifully designed. Thanks! Paulo From claudiusmaximus at goto10.org Mon Sep 28 19:26:21 2009 From: claudiusmaximus at goto10.org (Claude Heiland-Allen) Date: Mon Sep 28 19:04:27 2009 Subject: [Haskell-cafe] river crossing puzzle In-Reply-To: <4AC10D3A.6060703@comp.dit.ie> References: <4AC10D3A.6060703@comp.dit.ie> Message-ID: <4AC1461D.2090204@goto10.org> pat browne wrote: > Hi, > Does anyone know where there are any Haskell implementations of the the > River Crossing puzzle (AKA Farmer/Fox/Goose/Grain). I wrote some code to generate a map of some version of the game: https://code.goto10.org/svn/maximus/2009/boatman/BoatMan.hs ghc -O2 --make BoatMan.hs && ./BoatMan | neato -Tpng | display Claude -- http://claudiusmaximus.goto10.org From mpm at alumni.caltech.edu Mon Sep 28 19:40:02 2009 From: mpm at alumni.caltech.edu (Michael P Mossey) Date: Mon Sep 28 19:18:06 2009 Subject: [Haskell-cafe] Doing people's homework? Message-ID: <4AC14952.1080606@alumni.caltech.edu> I'm not really hip to the culture here so this is just an observation, but some of the recent questions posted to this list (and beginners@haskell.org) look a lot like someone's homework. Is anyone here concerned about avoiding giving the full answer, or maybe it's really none of our business (we aren't responsible for anyone's learning process)? From tgdavies at gmail.com Mon Sep 28 19:41:21 2009 From: tgdavies at gmail.com (Tom Davies) Date: Mon Sep 28 19:19:29 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> Message-ID: On 29/09/2009, at 1:59 AM, Peter Verswyvelen wrote: > That's a really shame. Any idea why? > > On Mon, Sep 28, 2009 at 3:02 PM, John A. De Goes > wrote: > > CAL is interesting, but unfortunately dead, and has no community. I think Haskell users would miss too many of the post 98 extensions -- overlapping instances, multi parameter type classes and many other things. I've had a lot of enjoyment using CAL for hobby projects and learning about fp, while still being able leverage the Java ecosystem I am so familiar with (I'm in the 'libraries matter' camp, although I agree with Curt on the uncertain benefits of Hibernate). I believe that it's high enough quality to use in production as part of a Java based product, but, so far, I just don't have enough free time to do anything substantial. I hope one day to use CAL to teach myself a bit more about types without getting lost in the (assumed) complexity of GHC. For instance I'd like to replace the CAL type system with HMF. Note that while it is 'dead', it isn't broken or bit-rotted -- everything still works, including the Eclipse plugin. Tom From jfredett at gmail.com Mon Sep 28 19:49:32 2009 From: jfredett at gmail.com (Joe Fredette) Date: Mon Sep 28 19:27:34 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <4AC14952.1080606@alumni.caltech.edu> References: <4AC14952.1080606@alumni.caltech.edu> Message-ID: <035958CE-7545-4FEE-A233-AF5E3C25E9DE@gmail.com> I think the consensus is "Help, not do" when it comes to homework (esp. on -beginners). At least, thats what I try to do. I've always got the sense that that is what the community expects. On Sep 28, 2009, at 7:40 PM, Michael P Mossey wrote: > I'm not really hip to the culture here so this is just an > observation, but some of the recent questions posted to this list > (and beginners@haskell.org) look a lot like someone's homework. Is > anyone here concerned about avoiding giving the full answer, or > maybe it's really none of our business (we aren't responsible for > anyone's learning process)? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From thomas.dubuisson at gmail.com Mon Sep 28 19:51:50 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Mon Sep 28 19:29:51 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <035958CE-7545-4FEE-A233-AF5E3C25E9DE@gmail.com> References: <4AC14952.1080606@alumni.caltech.edu> <035958CE-7545-4FEE-A233-AF5E3C25E9DE@gmail.com> Message-ID: <4c44d90b0909281651r45c0ecbsfcea1e5e19486f9@mail.gmail.com> > I think the consensus is "Help, not do" when it comes to homework (esp. on > -beginners). At least, thats what I try to do. I've always got the sense > that that is what the community expects. Yep, there's a whole policy on this. http://www.haskell.org/haskellwiki/Homework_help TomMD From daniel.is.fischer at web.de Mon Sep 28 20:01:22 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Mon Sep 28 19:40:35 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <4AC14952.1080606@alumni.caltech.edu> References: <4AC14952.1080606@alumni.caltech.edu> Message-ID: <200909290201.22738.daniel.is.fischer@web.de> Am Dienstag 29 September 2009 01:40:02 schrieb Michael P Mossey: > I'm not really hip to the culture here so this is just an observation, but > some of the recent questions posted to this list (and > beginners@haskell.org) look a lot like someone's homework. Is anyone here > concerned about avoiding giving the full answer, or maybe it's really none > of our business (we aren't responsible for anyone's learning process)? The (unofficial and not enforceable) policy is here: http://www.haskell.org/haskellwiki/Homework_help If you notice somebody wants you to do their homework, you don't. If the proper questions are asked, you help (guide into the right direction). If you don't realize soon enough that somebody wanted their homework done and you've given a complete answer, hopefully their instructors read the lists, too. From mauricio.antunes at gmail.com Mon Sep 28 21:09:24 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Mon Sep 28 20:47:47 2009 Subject: [Haskell-cafe] Re: Doing people's homework? In-Reply-To: <4AC14952.1080606@alumni.caltech.edu> References: <4AC14952.1080606@alumni.caltech.edu> Message-ID: > I'm not really hip to the culture here so this is just an > observation, but some of the recent questions posted to this > list (and beginners@haskell.org) look a lot like someone's > homework. Well, if homework "looks like" homework, the teacher is guilty of cheating. Best, Maur?cio From caseyh at istar.ca Mon Sep 28 22:19:50 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 28 21:57:56 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <4AC14952.1080606@alumni.caltech.edu> References: <4AC14952.1080606@alumni.caltech.edu> Message-ID: <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> If you do a student's homework, you are cheating that student out of an education. He/She may realize that toooo late in the future. -- Regards, Casey From caseyh at istar.ca Mon Sep 28 22:22:11 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 28 22:00:17 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> Message-ID: I think a language needs the following to exist: - a community - good library - a package manager Thoughts? -- Regards, Casey From tonymorris at gmail.com Mon Sep 28 22:25:30 2009 From: tonymorris at gmail.com (Tony Morris) Date: Mon Sep 28 22:03:23 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> Message-ID: <4AC1701A.9060103@gmail.com> I think one must distinguish what it means for a language to "exist" and "be practical." Counter-example: Java fails catastrophically at all three and it most certainly exists; boy do I know it. Casey Hawthorne wrote: > I think a language needs the following to exist: > > - a community > > - good library > > - a package manager > > Thoughts? > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Tony Morris http://tmorris.net/ From caseyh at istar.ca Mon Sep 28 22:29:53 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 28 22:07:58 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <4AC1701A.9060103@gmail.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: On Tue, 29 Sep 2009 12:25:30 +1000, you wrote: >I think one must distinguish what it means for a language to "exist" and >"be practical." Counter-example: Java fails catastrophically at all >three and it most certainly exists; boy do I know it. QOTM! > >Casey Hawthorne wrote: >> I think a language needs the following to exist: >> >> - a community >> >> - good library >> >> - a package manager >> >> Thoughts? >> -- -- Regards, Casey From hyangfji at gmail.com Mon Sep 28 22:50:14 2009 From: hyangfji at gmail.com (Hong Yang) Date: Mon Sep 28 22:28:13 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <4AC1701A.9060103@gmail.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: Good libraries are not enough for a language to go beyond mere existence. There must exist good documents, i.e., good tutorials, good books, and good explanations and examples in the libraries, etc, that are easy for people to learn and use. In my humble opinion, Haskell has a lot of libraries, but most of them offer few examples of how to use the modules. In this regards, Perl is much much better. On Mon, Sep 28, 2009 at 9:25 PM, Tony Morris wrote: > I think one must distinguish what it means for a language to "exist" and > "be practical." Counter-example: Java fails catastrophically at all > three and it most certainly exists; boy do I know it. > > Casey Hawthorne wrote: > > I think a language needs the following to exist: > > > > - a community > > > > - good library > > > > - a package manager > > > > Thoughts? > > -- > > Regards, > > Casey > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Tony Morris > http://tmorris.net/ > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/d8fc03af/attachment.html From caseyh at istar.ca Mon Sep 28 22:52:24 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 28 22:30:30 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: >Good libraries are not enough for a language to go beyond mere existence. >There must exist good documents, i.e., good tutorials, good books, and good >explanations and examples in the libraries, etc, that are easy for people to >learn and use. In my humble opinion, Haskell has a lot of libraries, but >most of them offer few examples of how to use the modules. In this regards, >Perl is much much better. Good thought! Is there a good way to add Haskell examples to the libraries? -- Regards, Casey From ramsdell0 at gmail.com Mon Sep 28 22:53:08 2009 From: ramsdell0 at gmail.com (John D. Ramsdell) Date: Mon Sep 28 22:31:53 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> Message-ID: <7687290b0909281953x3fe4824dg2837c892b59d815c@mail.gmail.com> On Sun, Sep 27, 2009 at 3:50 PM, Paul Moore wrote: > The problem is that I have *no idea* how to begin debugging this. I've had great success debugging a large program by loading the Main module into ghci after setting GHC extensions, changing the search path, and setting break on errors. If you then place calls to the error function at the right location, and trace the execution, you'll be able to get a stack trace of the context in which the error function was called. John From caseyh at istar.ca Mon Sep 28 22:55:44 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Mon Sep 28 22:33:50 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: >Good libraries are not enough for a language to go beyond mere existence. >There must exist good documents, i.e., good tutorials, good books, and good >explanations and examples in the libraries, etc, that are easy for people to >learn and use. In my humble opinion, Haskell has a lot of libraries, but >most of them offer few examples of how to use the modules. In this regards, >Perl is much much better. Good thought! Is there a good way to add Haskell examples to the libraries? A Haskell CookBook might be just the ticket, also. -- Regards, Casey From hyangfji at gmail.com Mon Sep 28 23:11:15 2009 From: hyangfji at gmail.com (Hong Yang) Date: Mon Sep 28 22:54:48 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: A Cook Book is good but relies on people specifically working on it. I think most of the package authors submit their packages because they themselves need the modules in his real world. I think package authors adding examples in the Descriptions section is a good start when they submit their packages. You do want to facilitate people understanding and using your modules, right? Maybe later on we can add an Example section to Description, Synopsis, and Documentation sections produced by Haddock. Also, having a section for comments is helpful. This is the case especially when there are several similar packages coexisting, comments can help people choose which one to use. Thanks, Hong On Mon, Sep 28, 2009 at 9:55 PM, Casey Hawthorne wrote: > On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: > > >Good libraries are not enough for a language to go beyond mere existence. > >There must exist good documents, i.e., good tutorials, good books, and > good > >explanations and examples in the libraries, etc, that are easy for people > to > >learn and use. In my humble opinion, Haskell has a lot of libraries, but > >most of them offer few examples of how to use the modules. In this > regards, > >Perl is much much better. > > Good thought! > > Is there a good way to add Haskell examples to the libraries? > > > A Haskell CookBook might be just the ticket, also. > > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090928/84df74f2/attachment.html From brad.larsen at gmail.com Mon Sep 28 23:24:42 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Mon Sep 28 23:02:41 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: On Mon, Sep 28, 2009 at 11:11 PM, Hong Yang wrote: [...] > Maybe later on we can add an Example section to Description, Synopsis, and > Documentation sections produced by Haddock. > > Also, having a section for comments is helpful. This is the case especially > when there are several similar packages coexisting, comments can help people > choose which one to use. > > Thanks, > > Hong [...] +1 I'd love to see more examples in the Haddock documentation for packages. From dons at galois.com Mon Sep 28 23:52:52 2009 From: dons at galois.com (Don Stewart) Date: Mon Sep 28 23:33:08 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: <20090929035252.GA15160@whirlpool.galois.com> brad.larsen: > On Mon, Sep 28, 2009 at 11:11 PM, Hong Yang wrote: > [...] > > Maybe later on we can add an Example section to Description, Synopsis, and > > Documentation sections produced by Haddock. > > > > Also, having a section for comments is helpful. This is the case especially > > when there are several similar packages coexisting, comments can help people > > choose which one to use. > > > > Thanks, > > > > Hong > [...] > > +1 I'd like to see people writing comparative reviews of libraries in each category, and publishing those reviews online. -- Don From ccshan at post.harvard.edu Mon Sep 28 23:32:15 2009 From: ccshan at post.harvard.edu (Chung-chieh Shan) Date: Mon Sep 28 23:38:37 2009 Subject: [Haskell-cafe] Re: combinatorial search with running bound References: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> Message-ID: Michael Mossey wrote in article <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> in gmane.comp.lang.haskell.cafe: > The problem is to determine how closely the groups can be brought together > without any boxes intersection. > > The basic algorithm is to consider each pair of boxes and ask if they > have any "vertical overlap"---if so, figure out how closely they can be > brought together without intersecting, otherwise ignore them. Then take > the maximum of those numbers. Wouldn't you mean minimum instead of maximum then? I suspect that your code would be clearer without using a state monad. -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig Computer Science is no more about computers than astronomy is about telescopes. -Edsger Dijkstra From cjs at starling-software.com Tue Sep 29 00:01:47 2009 From: cjs at starling-software.com (Curt Sampson) Date: Mon Sep 28 23:39:47 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: <7687290b0909281953x3fe4824dg2837c892b59d815c@mail.gmail.com> References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> <7687290b0909281953x3fe4824dg2837c892b59d815c@mail.gmail.com> Message-ID: <20090929040146.GB14581@analytic.cynic.net> On 2009-09-28 22:53 -0400 (Mon), John D. Ramsdell wrote: > I've had great success debugging a large program by loading the Main > module into ghci after setting GHC extensions, changing the search > path, and setting break on errors. If you then place calls to the > error function at the right location, and trace the execution, you'll > be able to get a stack trace of the context in which the error > function was called. Yes, I often use the interpreter to poke at and play with my code. Note that by using the -odir and so forth options, you can mix interpreted and compiled code, so that you need interpret only the particular modules you're trying to debug, and all the rest the application can run at full, compiled speed. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From mpm at alumni.caltech.edu Tue Sep 29 00:09:32 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Mon Sep 28 23:47:37 2009 Subject: [Haskell-cafe] Re: combinatorial search with running bound In-Reply-To: References: <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> Message-ID: <4AC1887C.2000005@alumni.caltech.edu> Hi Chung-chieh, When you ask for a pair of boxes, "How closely can they be brought together without intersection?" that provides a lower bound on the question "How closely can the groups be brought together?" (I.e. for that pair of boxes, bring them any closer and they intersect, so it is a lower bound.) The maximum of all these lower bounds in the minimum needed separation. -Mike Chung-chieh Shan wrote: > Michael Mossey wrote in article <3942.75.50.175.130.1253997756.squirrel@mail.alumni.caltech.edu> in gmane.comp.lang.haskell.cafe: >> The problem is to determine how closely the groups can be brought together >> without any boxes intersection. >> >> The basic algorithm is to consider each pair of boxes and ask if they >> have any "vertical overlap"---if so, figure out how closely they can be >> brought together without intersecting, otherwise ignore them. Then take >> the maximum of those numbers. > > Wouldn't you mean minimum instead of maximum then? > > I suspect that your code would be clearer without using a state monad. > From wren at freegeek.org Tue Sep 29 00:19:30 2009 From: wren at freegeek.org (wren ng thornton) Date: Mon Sep 28 23:57:32 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090928134941.GD17527@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> Message-ID: <4AC18AD2.1000509@freegeek.org> Curt Sampson wrote: > I've been hearing that having lots of libraries is an insurmountable > advantage, and you're doomed if you give them up, since long before I > took up Haskell. It's mostly myth promulgated by people driven by fear. > I'm sure it's the case in some shops that they have lots of people who > can glue libraries together but can't program, and they somehow manage > to produce applications this way, but even that I suspect is not so > frequent a situation as you'd think. The real insurmountable advantage is not in the quantity (nor quality) of the libraries, it is in the *particular* libraries. Shops which are only using libraries for basic data structures and for glue work are able (and not infrequently willing) to switch to another language provided it has a library ecosphere ---which Haskell with Cabal/Hackage most certainly does. The glue workers are not the ones most unwilling to switch. The real demographic that's unwilling to switch are those who are using a particular high-performance library. The reason they won't switch has nothing to do with the language, and everything to do with the countless man-years invested in that specific library. To pick some examples familiar to me: the Joshua SMT toolkit[0], the MALT parser[1], NLTK[2], GMTK[3], etc. Not all of these are Java, some are Python, some are Perl, and some are C++; but bridgework is annoying and most people stick to the original language. These libraries keep client developers near because they are not replaceable. Data structures, network stacks, XML parsing,... everyone has these. But the high-performance state-of-the-art libraries tend to be written once and tweaked ever after. The conversion of the Moses translator (Python) into the original version of the Joshua translator (Java) was a non-trivial undertaking and it earned a few publications along the way ---just for converting it to a different yet similar language! And, of course, a number of man-years and publications have been invested in it since then. [0] http://joshua.sourceforge.net/ [1] http://maltparser.org/ [2] http://www.nltk.org/ [3] http://ssli.ee.washington.edu/~bilmes/gmtk/ -- Live well, ~wren From mwotton at gmail.com Tue Sep 29 00:53:52 2009 From: mwotton at gmail.com (Mark Wotton) Date: Tue Sep 29 00:31:59 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: If there's an Example section, it might actually be a good idea to include it on the package's hackage page, too. From a usability point of view, CPAN is much more helpful than the relatively spartan hackage description - if you're looking for a particular set of functionality, being able to filter out misses quickly is really nice. mark On 29/09/2009, at 1:11 PM, Hong Yang wrote: > A Cook Book is good but relies on people specifically working on it. > I think most of the package authors submit their packages because > they themselves need the modules in his real world. > > I think package authors adding examples in the Descriptions section > is a good start when they submit their packages. You do want to > facilitate people understanding and using your modules, right? > > Maybe later on we can add an Example section to Description, > Synopsis, and Documentation sections produced by Haddock. > > Also, having a section for comments is helpful. This is the case > especially when there are several similar packages coexisting, > comments can help people choose which one to use. > > Thanks, > > Hong > > > On Mon, Sep 28, 2009 at 9:55 PM, Casey Hawthorne > wrote: > On Mon, 28 Sep 2009 21:50:14 -0500, you wrote: > > >Good libraries are not enough for a language to go beyond mere > existence. > >There must exist good documents, i.e., good tutorials, good books, > and good > >explanations and examples in the libraries, etc, that are easy for > people to > >learn and use. In my humble opinion, Haskell has a lot of > libraries, but > >most of them offer few examples of how to use the modules. In this > regards, > >Perl is much much better. > > Good thought! > > Is there a good way to add Haskell examples to the libraries? > > > A Haskell CookBook might be just the ticket, also. > > -- > Regards, > Casey > _______________________________________________ > 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/df8db34c/attachment.html From magicloud.magiclouds at gmail.com Tue Sep 29 01:58:55 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 01:36:54 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? Message-ID: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> Hi, In other weak-type language, `round i == i` would work. But in haskell, what should I do? Thanks. -- ??????? ??????? From magicloud.magiclouds at gmail.com Tue Sep 29 02:11:07 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 01:49:07 2009 Subject: [Haskell-cafe] Re: How to decide if a number is an integer? In-Reply-To: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> Message-ID: <3bd412d40909282311y2dd80e95g6765d9bd413aa44c@mail.gmail.com> Hi, Here is an example: let l = fun num in if isIntegral l then l else 0 How to do the isIntegral thing? On Tue, Sep 29, 2009 at 1:58 PM, Magicloud Magiclouds wrote: > Hi, > ?In other weak-type language, `round i == i` would work. But in > haskell, what should I do? Thanks. > -- > ??????? > ??????? > -- ??????? ??????? From thomas.dubuisson at gmail.com Tue Sep 29 02:16:54 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Sep 29 01:54:55 2009 Subject: [Haskell-cafe] Re: How to decide if a number is an integer? In-Reply-To: <3bd412d40909282311y2dd80e95g6765d9bd413aa44c@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <3bd412d40909282311y2dd80e95g6765d9bd413aa44c@mail.gmail.com> Message-ID: <4c44d90b0909282316s6e659d61kd06aa531f6808089@mail.gmail.com> Magicloud, There are numerous ways to construct such a function. Hoogling "(Fractional a, Integral b) => a -> b" brings up a host of functions that would be of use here in combination with fromIntegral. Thomas On Mon, Sep 28, 2009 at 11:11 PM, Magicloud Magiclouds wrote: > Hi, > Here is an example: > let l = fun num in > if isIntegral l > then l > else 0 > How to do the isIntegral thing? > > On Tue, Sep 29, 2009 at 1:58 PM, Magicloud Magiclouds > wrote: >> Hi, >> In other weak-type language, `round i == i` would work. But in >> haskell, what should I do? Thanks. >> -- >> ??????? >> ??????? >> > > > > -- > ??????? > ??????? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > From jim at shareyourgifts.net Tue Sep 29 02:18:09 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 29 01:56:09 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> Message-ID: <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> Use properFraction: http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction > Hi, > In other weak-type language, `round i == i` would work. But in > haskell, what should I do? Thanks. > -- > ????????????????????? > ????????????????????? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From magicloud.magiclouds at gmail.com Tue Sep 29 02:35:08 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 02:13:07 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> Message-ID: <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> It never matches to (_, 0.0).... I mean case properFraction l of (_, 0) -> l _ -> 0 -- always goes here. On Tue, Sep 29, 2009 at 2:18 PM, Jimmy Hartzell wrote: > Use properFraction: > http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction > >> Hi, >> ? In other weak-type language, `round i == i` would work. But in >> haskell, what should I do? Thanks. >> -- >> ??????? >> ??????? >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > -- ??????? ??????? From michael at snoyman.com Tue Sep 29 02:42:59 2009 From: michael at snoyman.com (Michael Snoyman) Date: Tue Sep 29 02:20:59 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> Message-ID: <29bf512f0909282342w7c61c2f6qfbec2d345a80e53a@mail.gmail.com> On Mon, Sep 28, 2009 at 4:13 PM, John A. De Goes wrote: > > If you have counterexamples, then perhaps you can name them. I'm looking > for Java shops with 5+ developers and code bases of > 100k converting over > to Haskell. I don't know _any such shop_ that has switched to Haskell, and I > doubt any exist, but I'd be delighted to learn I'm wrong. > > Let me ask you this question: how long would it take you to get an > HTML/CSS, W3 compliant browser in Haskell? Or how about a peer-to-peer > networking system with seamless scaling and automatic failover? How about a > scalable BigTable implementation? In Java, the answer to these questions -- > and just about any others you can think of -- is "a few minutes", because > the code has already been written. > > Well, as far as browser goes, this is a start: http://github.com/snoyberg/hack-handler-webkit. It may not be written in pure Haskell, but then again I'm not sure if there are any fully W3 compliant browsers *not* written in C++. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/0e1d16e5/attachment.html From thomas.dubuisson at gmail.com Tue Sep 29 02:45:59 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Sep 29 02:23:58 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> Message-ID: <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds wrote: > It never matches to (_, 0.0).... > I mean > case properFraction l of > (_, 0) -> l > _ -> 0 -- always goes here. Odd, it works fine for me. f x = case properFraction x of (_,0) -> True _ -> False *Main> f 5 True *Main> f 5.5 False *Main> f 4.0 True *Main> f 4.00000001 False Thomas From jim at shareyourgifts.net Tue Sep 29 02:51:10 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 29 02:29:08 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> Message-ID: <660c026b851ed5049fd84ec62c9dc0bf.squirrel@mail.shareyourgifts.net> $ ghci Prelude> let isInteger' l = case properFraction l of { (_,0) -> 1; _ -> 0 } Prelude> isInteger' 2.0 1 Prelude> isInteger' 1.9 0 Do you really get 1? For what input types/values? Although I would write: isInteger = (== 0) . snd . properFraction > It never matches to (_, 0.0).... > I mean > case properFraction l of > (_, 0) -> l > _ -> 0 -- always goes here. > > On Tue, Sep 29, 2009 at 2:18 PM, Jimmy Hartzell > wrote: >> Use properFraction: >> http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v%3AproperFraction >> >>> Hi, >>> ?? In other weak-type language, `round i == i` would work. But in >>> haskell, what should I do? Thanks. >>> -- >>> ????????????????????? >>> ????????????????????? >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe@haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> > > > > -- > ????????????????????? > ????????????????????? > From magicloud.magiclouds at gmail.com Tue Sep 29 02:54:52 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 02:32:52 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> Message-ID: <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> The original code is givenSum num = map (\a -> let l = (sqrt $ fromIntegral (a * a + 2 + 2 * num)) - (fromIntegral a) in case properFraction l of (_, 0) -> True _ -> False ) $ take num [1..] :t l is (Floating a) => a Well, in ghci *Main> givenSum 10 [False,False,False,False,False,False,False,False,False,False] On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson wrote: > On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds > wrote: >> It never matches to (_, 0.0).... >> I mean >> case properFraction l of >> ?(_, 0) -> l >> ?_ -> 0 -- always goes here. > > Odd, it works fine for me. > > f x = > ? ? ? ?case properFraction x of > ? ? ? ? ? ? ? ?(_,0) -> True > ? ? ? ? ? ? ? ?_ ? ? -> False > > > *Main> f 5 > True > *Main> f 5.5 > False > *Main> f 4.0 > True > *Main> f 4.00000001 > False > > > Thomas > -- ??????? ??????? From colin at colina.demon.co.uk Tue Sep 29 02:55:03 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Sep 29 02:33:05 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <29bf512f0909282342w7c61c2f6qfbec2d345a80e53a@mail.gmail.com> (Michael Snoyman's message of "Tue\, 29 Sep 2009 08\:42\:59 +0200") References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <29bf512f0909282342w7c61c2f6qfbec2d345a80e53a@mail.gmail.com> Message-ID: >>>>> "Michael" == Michael Snoyman writes: Michael> not be written in pure Haskell, but then again I'm not Michael> sure if there are any fully W3 compliant browsers *not* Michael> written in C++. I'm not sure if there are any fully W3 compliant browsers. How could there be? It would mean consistent W3C recommendations. -- Colin Adams Preston Lancashire From thomas.dubuisson at gmail.com Tue Sep 29 03:02:19 2009 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Tue Sep 29 02:40:19 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> Message-ID: <4c44d90b0909290002q42b94567hfc488f725488d390@mail.gmail.com> Unless I missed something, the function in question is: sqrt (a * a + 2 + 2 * num) - fromIntegral a where num = 10 1 -> sqrt (1 * 1 + 2 + 2 * 10) - 1 -> sqrt (1 + 2 + 20) - 1 -> sqrt (23) - 1 -> 3.79xxxxx the fractional will only ever come from the sqrt function. Do any of the following actually look like square values to you? 26 31 38 47 58 71 86 103 122 IMO, the code works and your expectations are a bit off. Thomas On Mon, Sep 28, 2009 at 11:54 PM, Magicloud Magiclouds wrote: > The original code is > givenSum num = map (\a -> > let l = (sqrt $ fromIntegral (a * a + 2 + 2 * > num)) - (fromIntegral a) in > case properFraction l of > (_, 0) -> > True > _ -> > False > ) $ take num [1..] > :t l is (Floating a) => a > Well, in ghci > *Main> givenSum 10 > [False,False,False,False,False,False,False,False,False,False] > > On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson > wrote: >> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >> wrote: >>> It never matches to (_, 0.0).... >>> I mean >>> case properFraction l of >>> (_, 0) -> l >>> _ -> 0 -- always goes here. >> >> Odd, it works fine for me. >> >> f x = >> case properFraction x of >> (_,0) -> True >> _ -> False >> >> >> *Main> f 5 >> True >> *Main> f 5.5 >> False >> *Main> f 4.0 >> True >> *Main> f 4.00000001 >> False >> >> >> Thomas >> > > > > -- > ??????? > ??????? > From jim at shareyourgifts.net Tue Sep 29 03:07:05 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 29 02:45:05 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> Message-ID: <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> Did you test the properFraction-based code in isolation? If code is broken, it's important to figure out which part of it is broken. Also, this function is not divided into constituent parts, but is a long unruly mess. Dividing it into parts would make it much much more readable, and you would then be able to test the parts individually. Jimmy > The original code is > givenSum num = map (\a -> > let l = (sqrt $ fromIntegral (a * a + 2 + 2 * > num)) - (fromIntegral a) in > case properFraction l of > (_, 0) -> > True > _ -> > False > ) $ take num [1..] > :t l is (Floating a) => a > Well, in ghci > *Main> givenSum 10 > [False,False,False,False,False,False,False,False,False,False] > > On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson > wrote: >> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >> wrote: >>> It never matches to (_, 0.0).... >>> I mean >>> case properFraction l of >>> ??(_, 0) -> l >>> ??_ -> 0 -- always goes here. >> >> Odd, it works fine for me. >> >> f x = >> ?? ?? ?? ??case properFraction x of >> ?? ?? ?? ?? ?? ?? ?? ??(_,0) -> True >> ?? ?? ?? ?? ?? ?? ?? ??_ ?? ?? -> False >> >> >> *Main> f 5 >> True >> *Main> f 5.5 >> False >> *Main> f 4.0 >> True >> *Main> f 4.00000001 >> False >> >> >> Thomas >> > > > > -- > ????????????????????? > ????????????????????? > From magicloud.magiclouds at gmail.com Tue Sep 29 03:07:14 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 02:45:18 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <4c44d90b0909290002q42b94567hfc488f725488d390@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <4c44d90b0909290002q42b94567hfc488f725488d390@mail.gmail.com> Message-ID: <3bd412d40909290007k583dcce4t63f9f50177eb1649@mail.gmail.com> Of course them are not. But that is why I need the detector.... 2009/9/29 Thomas DuBuisson : > Unless I missed something, the function in question is: > > sqrt (a * a + 2 + 2 * num) - fromIntegral a > where num = 10 > > 1 -> sqrt (1 * 1 + 2 + 2 * 10) - 1 -> sqrt (1 + 2 + 20) - 1 -> sqrt > (23) - 1 -> 3.79xxxxx > > the fractional will only ever come from the sqrt function. ?Do any of > the following actually look like square values to you? > > 26 > 31 > 38 > 47 > 58 > 71 > 86 > 103 > 122 > > IMO, the code works and your expectations are a bit off. > > Thomas > > On Mon, Sep 28, 2009 at 11:54 PM, Magicloud Magiclouds > wrote: >> The original code is >> givenSum num = map (\a -> >> ? ? ? ? ? ? ? ? ? ? ?let l = (sqrt $ fromIntegral (a * a + 2 + 2 * >> num)) - (fromIntegral a) in >> ? ? ? ? ? ? ? ? ? ? ?case properFraction l of >> ? ? ? ? ? ? ? ? ? ? ? ?(_, 0) -> >> ? ? ? ? ? ? ? ? ? ? ? ? ?True >> ? ? ? ? ? ? ? ? ? ? ? ?_ -> >> ? ? ? ? ? ? ? ? ? ? ? ? ?False >> ? ? ? ? ? ? ? ? ? ) $ take num [1..] >> :t l is (Floating a) => a >> Well, in ghci >> *Main> givenSum 10 >> [False,False,False,False,False,False,False,False,False,False] >> >> On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson >> wrote: >>> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >>> wrote: >>>> It never matches to (_, 0.0).... >>>> I mean >>>> case properFraction l of >>>> ?(_, 0) -> l >>>> ?_ -> 0 -- always goes here. >>> >>> Odd, it works fine for me. >>> >>> f x = >>> ? ? ? ?case properFraction x of >>> ? ? ? ? ? ? ? ?(_,0) -> True >>> ? ? ? ? ? ? ? ?_ ? ? -> False >>> >>> >>> *Main> f 5 >>> True >>> *Main> f 5.5 >>> False >>> *Main> f 4.0 >>> True >>> *Main> f 4.00000001 >>> False >>> >>> >>> Thomas >>> >> >> >> >> -- >> ??????? >> ??????? >> > -- ??????? ??????? From magicloud.magiclouds at gmail.com Tue Sep 29 03:13:19 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 02:51:18 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> Message-ID: <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> The properFaction part is correct. So I posted the whole code, since "isInteger" should accept any reasonable incoming types. Well, in this one situation, it does not. And I cannot figure out why.... On Tue, Sep 29, 2009 at 3:07 PM, Jimmy Hartzell wrote: > Did you test the properFraction-based code in isolation? If code is > broken, it's important to figure out which part of it is broken. Also, > this function is not divided into constituent parts, but is a long unruly > mess. Dividing it into parts would make it much much more readable, and > you would then be able to test the parts individually. > > Jimmy > >> The original code is >> givenSum num = map (\a -> >> ? ? ? ? ? ? ? ? ? ? ? let l = (sqrt $ fromIntegral (a * a + 2 + 2 * >> num)) - (fromIntegral a) in >> ? ? ? ? ? ? ? ? ? ? ? case properFraction l of >> ? ? ? ? ? ? ? ? ? ? ? ? (_, 0) -> >> ? ? ? ? ? ? ? ? ? ? ? ? ? True >> ? ? ? ? ? ? ? ? ? ? ? ? _ -> >> ? ? ? ? ? ? ? ? ? ? ? ? ? False >> ? ? ? ? ? ? ? ? ? ?) $ take num [1..] >> :t l is (Floating a) => a >> Well, in ghci >> *Main> givenSum 10 >> [False,False,False,False,False,False,False,False,False,False] >> >> On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson >> wrote: >>> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >>> wrote: >>>> It never matches to (_, 0.0).... >>>> I mean >>>> case properFraction l of >>>> ?(_, 0) -> l >>>> ?_ -> 0 -- always goes here. >>> >>> Odd, it works fine for me. >>> >>> f x = >>> ? ? ? ?case properFraction x of >>> ? ? ? ? ? ? ? ?(_,0) -> True >>> ? ? ? ? ? ? ? ?_ ? ? -> False >>> >>> >>> *Main> f 5 >>> True >>> *Main> f 5.5 >>> False >>> *Main> f 4.0 >>> True >>> *Main> f 4.00000001 >>> False >>> >>> >>> Thomas >>> >> >> >> >> -- >> ??????? >> ??????? >> > > > -- ??????? ??????? From dav.vire+haskell at gmail.com Tue Sep 29 03:23:58 2009 From: dav.vire+haskell at gmail.com (david48) Date: Tue Sep 29 03:01:57 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> Message-ID: <4c88418c0909290023p699176f1r40a33c0fe2ca01d7@mail.gmail.com> On Tue, Sep 29, 2009 at 9:13 AM, Magicloud Magiclouds wrote: > The properFaction part is correct. So I posted the whole code, since > "isInteger" should accept any reasonable incoming types. Well, in this > one situation, it does not. And I cannot figure out why.... Floating point gives a lot of small errors, so maybe you shouldn't test your fractional part to be = 0, but you should test it to be close enough. From bos at serpentine.com Tue Sep 29 03:26:57 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Sep 29 03:04:57 2009 Subject: [Haskell-cafe] So I wrote this performance measurement library thingy Message-ID: Which I will not blather on too long about here, but point you at a blog posting instead: http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/63af2532/attachment.html From jim at shareyourgifts.net Tue Sep 29 03:32:54 2009 From: jim at shareyourgifts.net (Jimmy Hartzell) Date: Tue Sep 29 03:10:53 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> Message-ID: <81980d76fcbf944da943a2f2b8cdd985.squirrel@mail.shareyourgifts.net> *Should* isInteger be returning True for any numbers generated by this code? If so, can you simplify this test down to that example, so that it's obvious what the test should do, and that it's not doing it (if it in fact is not doing as it should)? In any case, it would help to divide this block of code into more manageable pieces. isInteger should have the type Fractional a => a -> Boolean. > The properFaction part is correct. So I posted the whole code, since > "isInteger" should accept any reasonable incoming types. Well, in this > one situation, it does not. And I cannot figure out why.... > > On Tue, Sep 29, 2009 at 3:07 PM, Jimmy Hartzell > wrote: >> Did you test the properFraction-based code in isolation? If code is >> broken, it's important to figure out which part of it is broken. Also, >> this function is not divided into constituent parts, but is a long >> unruly >> mess. Dividing it into parts would make it much much more readable, and >> you would then be able to test the parts individually. >> >> Jimmy >> >>> The original code is >>> givenSum num = map (\a -> >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? let l = (sqrt $ fromIntegral (a * a + >>> 2 + 2 * >>> num)) - (fromIntegral a) in >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? case properFraction l of >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? (_, 0) -> >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? True >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? _ -> >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? False >>> ?? ?? ?? ?? ?? ?? ?? ?? ?? ??) $ take num [1..] >>> :t l is (Floating a) => a >>> Well, in ghci >>> *Main> givenSum 10 >>> [False,False,False,False,False,False,False,False,False,False] >>> >>> On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson >>> wrote: >>>> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >>>> wrote: >>>>> It never matches to (_, 0.0).... >>>>> I mean >>>>> case properFraction l of >>>>> ??(_, 0) -> l >>>>> ??_ -> 0 -- always goes here. >>>> >>>> Odd, it works fine for me. >>>> >>>> f x = >>>> ?? ?? ?? ??case properFraction x of >>>> ?? ?? ?? ?? ?? ?? ?? ??(_,0) -> True >>>> ?? ?? ?? ?? ?? ?? ?? ??_ ?? ?? -> False >>>> >>>> >>>> *Main> f 5 >>>> True >>>> *Main> f 5.5 >>>> False >>>> *Main> f 4.0 >>>> True >>>> *Main> f 4.00000001 >>>> False >>>> >>>> >>>> Thomas >>>> >>> >>> >>> >>> -- >>> ????????????????????? >>> ????????????????????? >>> >> >> >> > > > > -- > ????????????????????? > ????????????????????? > From ivan.miljenovic at gmail.com Tue Sep 29 03:36:37 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Sep 29 03:14:44 2009 Subject: [Haskell-cafe] ANNOUNCE: graphviz-2999.6.0.0 Message-ID: <87my4ew6be.fsf@gmail.com> I'm pleased to announce version 2999.6.0.0 [1] of the graphviz library, which provides bindings to the GraphViz [2] suite of tools for drawing graphs. [1] http://hackage.haskell.org/package/graphviz-2999.6.0.0 [2] http://www.graphviz.org/ Changes since the previous version are: * Remove some Shape aliases and change capitalisation of others. * Properly parse and print IDs of clusters. * Allow NodeCluster values have node types different from the LNode they come from. Since the node type is only used for passing to the function to create the appropriate Attributes for that node, this can mean avoiding having to apply a transformation function before getting the attributes if you have a composite type for node value/cluster. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From oleg at okmij.org Tue Sep 29 03:37:09 2009 From: oleg at okmij.org (oleg@okmij.org) Date: Tue Sep 29 03:18:41 2009 Subject: [Haskell-cafe] Strong duck typing / structural subtyping / type class aliases / ??? in Haskell Message-ID: <20090929073709.EBC7D1753C@Adric.metnet.navy.mil> Alp Mestan wrote: > Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. > > *# let f myobj = myobj#foo "Hi !";; > val f : < foo : string -> 'a; .. > -> 'a = * And Haskell has that too: > -- This is how we define labels. > data Field1 deriving Typeable; field1 = proxy::Proxy Field1 > > -- This is how record selection looks like. > foo f = f # field1 The inferred type of foo is *OCamlTutorial> :t foo foo :: (HasField (Proxy Field1) r v) => r -> v It doesn't seem too different from the OCaml's type; the type variable r acts as a row type. The quoted example is the first from many others described in http://darcs.haskell.org/OOHaskell/OCamlTutorial.hs The file quotes at length OCaml's Object tutorial and then demonstrates how the OCaml code can be written in Haskell. When it comes to objects, structural subtyping, width and depth subtyping, etc., Haskell does not seem to miss match compared to OCaml. In contrast, Haskell has a few advantages when it comes to coercions (one does not have to specify the type to coerce to, as Haskell can figure that out). The other files in that directory give many more example of encoding C++, Eiffel, OCaml patterns. From ivan.miljenovic at gmail.com Tue Sep 29 03:46:09 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Sep 29 03:24:13 2009 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.7.0.0 Message-ID: <87iqf2w5vi.fsf@gmail.com> Graphalyze [1] is a library for using graph-theoretic techniques to analyse the relationships inherent within discrete data. It was originally written for my Honours thesis [2] last year, and I have now started updating it. [1] http://hackage.haskell.org/package/Graphalyze [2] http://ivanmiljenovic.wordpress.com/2008/11/03/graph-theoretic-analysis-of-relationships-within-discrete-data/ Graphalyze provides helper functions to import discrete data, analyse it using various algorithms (a dodgy term, I know, but I couldn't think of a better one) and then create a report with the results. The main changes since the previous version are: * The ability to have graphs with edge labels. * More of a focus on applying changes to the overall information state of the data rather than just extracting the graph and applying a function to it. * Usage of the updated features in the graphviz library (http://hackage.haskell.org/package/graphviz) to visualise graphs. Changes to come: * Re-do the reporting framework to use more of a pretty-printing approach and make it more customisable. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From aeyakovenko at gmail.com Tue Sep 29 03:54:21 2009 From: aeyakovenko at gmail.com (Anatoly Yakovenko) Date: Tue Sep 29 03:32:20 2009 Subject: [Haskell-cafe] i am missing something really trivial with parsec Message-ID: number = do { num <- natural ; return $ num } main = do txt <- hGetContents stdin print $ parse number "stdin" txt why doesn't that work? From ekirpichov at gmail.com Tue Sep 29 03:56:58 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Sep 29 03:34:58 2009 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.7.0.0 In-Reply-To: <87iqf2w5vi.fsf@gmail.com> References: <87iqf2w5vi.fsf@gmail.com> Message-ID: <5e0214850909290056t20d97012m24869d6a0f32126f@mail.gmail.com> Ivan, could you please mention some examples of things you can do with the library here in the mailing list? I am intrigued by the idea. 2009/9/29 Ivan Lazar Miljenovic : > Graphalyze [1] is a library for using graph-theoretic techniques to > analyse the relationships inherent within discrete data. ?It was > originally written for my Honours thesis [2] last year, and I have now > started updating it. > > [1] http://hackage.haskell.org/package/Graphalyze > [2] http://ivanmiljenovic.wordpress.com/2008/11/03/graph-theoretic-analysis-of-relationships-within-discrete-data/ > > Graphalyze provides helper functions to import discrete data, analyse it > using various algorithms (a dodgy term, I know, but I couldn't think of > a better one) and then create a report with the results. > > The main changes since the previous version are: > > * The ability to have graphs with edge labels. > > * More of a focus on applying changes to the overall information state > ?of the data rather than just extracting the graph and applying a > ?function to it. > > * Usage of the updated features in the graphviz library > ?(http://hackage.haskell.org/package/graphviz) to visualise graphs. > > Changes to come: > > * Re-do the reporting framework to use more of a pretty-printing > ?approach and make it more customisable. > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic@gmail.com > IvanMiljenovic.wordpress.com > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Eugene Kirpichov Web IR developer, market.yandex.ru From tittoassini at gmail.com Tue Sep 29 04:00:30 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Sep 29 03:38:30 2009 Subject: [Haskell-cafe] So I wrote this performance measurement library thingy In-Reply-To: References: Message-ID: <2d34474e0909290100h34900250h134d81c32c57920d@mail.gmail.com> Hi Bryan looks great. The examples directory mentioned in the README, however, does not seem to be included in the package updated to hackage (though is available in darcs). This might be a bit confusing for new users. Regards, titto 2009/9/29 Bryan O'Sullivan : > Which I will not blather on too long about here, but point you at a blog > posting instead: > http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Pasqualino "Titto" Assini, Ph.D. http://quicquid.org/ From ivan.miljenovic at gmail.com Tue Sep 29 04:00:57 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Sep 29 03:39:03 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.5.0.0 Message-ID: <87eipqw56u.fsf@gmail.com> SourceGraph [1] is a tool to statically analyse your Haskell code by applying graph-theoretic techniques on the call graph. It utilised the Graphalyze [2] library to do so, both of which were originally written as part of my Honours thesis last year [3]. [1] http://hackage.haskell.org/package/SourceGraph [2] http://hackage.haskell.org/package/Graphalyze [3] http://ivanmiljenovic.wordpress.com/2008/11/03/graph-theoretic-analysis-of-relationships-within-discrete-data/ I have been meaning to update SourceGraph since last year, but was waiting for improvements to the graphviz [4] library first. Now that these are done and I have fewer excuses, I've started to improve upon it. [4] http://hackage.haskell.org/package/graphviz When I first released SourceGraph last year, several people (e.g. Gwern) wanted support for CPP and command-line options. Unfortunately, I haven't yet gotten around to that; what I have done is added support for type classes and data structures, something I originally said I wasn't going to do. This support isn't perfect, especially when dealing with type classes from outside the scope of the code base, but in most cases works (except that the virtual instance functions don't always get positioned in the correct spots for some reason). The produced graphs are now also much prettier, with various colours and shapes being used. The useful features that SourceGraph offers include: * Visualisation of each module, the relations between modules and the entire code base. * Finds functions that are exported from a module that isn't in exposed in the .cabal file. * Alternate module splits. Please note that SourceGraph is _not_ a refactoring tool: it is designed to give you the programmer more information about what is in your code. I'd appreciate it if people could give SourceGraph a whirl and at least check how well the conversion from Haskell code to the graph is, as I'm not that sure how well I've converted haskel-src-ext's [5] internal state to SourceGraph's state. Please note that there are already various aspects that I know don't work properly; these can be found in the ParsingProblems.txt file (KnownProblems.txt contains other non-parsing problems that I'm aware of). In particular, TH, etc. aren't supported. [5] http://hackage.haskell.org/package/haskell-src-exts-1.1.4 To use SourceGraph after it's been installed, at a prompt do the following: > SourceGraph path/to/project.cabal The resulting report will then be found in a directory called "SourceGraph" in the same directory as the cabal file. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From alp at mestan.fr Tue Sep 29 04:03:23 2009 From: alp at mestan.fr (Alp Mestan) Date: Tue Sep 29 03:41:22 2009 Subject: [Haskell-cafe] Re: Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: <20090929073709.EBC7D1753C@Adric.metnet.navy.mil> References: <20090929073709.EBC7D1753C@Adric.metnet.navy.mil> Message-ID: I had never seen this work, it's just awesome ! And it only needs few Haskell extensions. Is this work deeply documented somewhere except in research papers ? If not, it could be worth doing, IMO. On Tue, Sep 29, 2009 at 9:37 AM, wrote: > > Alp Mestan wrote: > > Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. > > > > *# let f myobj = myobj#foo "Hi !";; > > val f : < foo : string -> 'a; .. > -> 'a = * > > And Haskell has that too: > > > -- This is how we define labels. > > data Field1 deriving Typeable; field1 = proxy::Proxy Field1 > > > > -- This is how record selection looks like. > > foo f = f # field1 > > The inferred type of foo is > > *OCamlTutorial> :t foo > foo :: (HasField (Proxy Field1) r v) => r -> v > > It doesn't seem too different from the OCaml's type; the type variable > r acts as a row type. > > The quoted example is the first from many others described in > http://darcs.haskell.org/OOHaskell/OCamlTutorial.hs > > The file quotes at length OCaml's Object tutorial and then > demonstrates how the OCaml code can be written in Haskell. When it > comes to objects, structural subtyping, width and depth subtyping, > etc., Haskell does not seem to miss match compared to OCaml. In > contrast, Haskell has a few advantages when it comes to coercions > (one does not have to specify the type to coerce to, as Haskell can > figure that out). The other files in that directory give many more > example of encoding C++, Eiffel, OCaml patterns. > > -- Alp Mestan http://blog.mestan.fr/ http://alp.developpez.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/f7652ff9/attachment.html From ivan.miljenovic at gmail.com Tue Sep 29 04:03:23 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Sep 29 03:41:35 2009 Subject: [Haskell-cafe] ANNOUNCE: Graphalyze-0.7.0.0 In-Reply-To: <5e0214850909290056t20d97012m24869d6a0f32126f@mail.gmail.com> (Eugene Kirpichov's message of "Tue, 29 Sep 2009 11:56:58 +0400") References: <87iqf2w5vi.fsf@gmail.com> <5e0214850909290056t20d97012m24869d6a0f32126f@mail.gmail.com> Message-ID: <87ab0ew52s.fsf@gmail.com> Eugene Kirpichov writes: > Ivan, could you please mention some examples of things you can do with > the library here in the mailing list? I am intrigued by the idea. Couldn't you wait until you read my announcement email for SourceGraph? :p Other ideas I had for this kind of analysis: * Examine the internal structure of a company/department/etc. in terms of the employee hierarchy. * Who-knows-who: analyse address books (whether it's traditional, email, Facebook, etc.); this is related to the six-degree problem. > > 2009/9/29 Ivan Lazar Miljenovic : >> Graphalyze [1] is a library for using graph-theoretic techniques to >> analyse the relationships inherent within discrete data. ?It was >> originally written for my Honours thesis [2] last year, and I have now >> started updating it. >> >> [1] http://hackage.haskell.org/package/Graphalyze >> [2] http://ivanmiljenovic.wordpress.com/2008/11/03/graph-theoretic-analysis-of-relationships-within-discrete-data/ >> >> Graphalyze provides helper functions to import discrete data, analyse it >> using various algorithms (a dodgy term, I know, but I couldn't think of >> a better one) and then create a report with the results. >> >> The main changes since the previous version are: >> >> * The ability to have graphs with edge labels. >> >> * More of a focus on applying changes to the overall information state >> ?of the data rather than just extracting the graph and applying a >> ?function to it. >> >> * Usage of the updated features in the graphviz library >> ?(http://hackage.haskell.org/package/graphviz) to visualise graphs. >> >> Changes to come: >> >> * Re-do the reporting framework to use more of a pretty-printing >> ?approach and make it more customisable. >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic@gmail.com >> IvanMiljenovic.wordpress.com >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From tittoassini at gmail.com Tue Sep 29 04:05:08 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Sep 29 03:43:07 2009 Subject: [Haskell-cafe] unicode text libraries, and the winner is ... Message-ID: <2d34474e0909290105n32ec81a5vbb25c76e55f3d2f1@mail.gmail.com> By unanimous opinion the "text" library is the man. Thanks to all who answered. titto From tittoassini at gmail.com Tue Sep 29 04:15:09 2009 From: tittoassini at gmail.com (Pasqualino "Titto" Assini) Date: Tue Sep 29 03:53:10 2009 Subject: [Haskell-cafe] Instances for Data.Text Message-ID: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> 2009/9/29 Paulo Tanimoto : > Hi Bryan and others, > > On Mon, Sep 28, 2009 at 5:29 PM, Bryan O'Sullivan wrote: >> bytestring predates the other two libraries by several years. The underlying >> stream type for uvector and text are almost the same, so they could in >> principle be merged. There's a fair amount of duplication there, but uvector >> is in some ways more complicated and in others much less thorough than text. >> Merging them would be a lot of work! >> > > If I may free-ride on this thread: how should one go about deriving a > Data.Binary instance for text? ?It looks like doing it efficiently > would require using some parts of the internal module that are not > exposed, am I correct? ?I've been using "encodeUtf8", but that doesn't > feel right. ?I don't know what to do, hopefully I'm missing something > simple. This is a good point, I also need to make Data.Text an instance of a few basic classes and I am not sure that I did it correctly. So far I have: import Data.Text instance Binary Text where put = put . encodeUtf8 get = liftM decodeUtf8 get -- DOUBT: Is this correct also for Data.Text.Lazy ? instance NFData Text instance Serial Text where -- DOUBT: is this efficient? series d = [T.pack (series d :: String)] -- DOUBT: how to define this coseries rs = error "coseries" More in general: what is the right policy for instances definition? Should the library author provide them, at least for the most common and appropriate classes (at the cost of adding some additional dependencies) ? Should they go in a separate package? Should the Haskell Platform team provide some guidance on this point to library authors? titto From ryani.spam at gmail.com Tue Sep 29 04:29:49 2009 From: ryani.spam at gmail.com (Ryan Ingram) Date: Tue Sep 29 04:07:53 2009 Subject: [Haskell-cafe] i am missing something really trivial with parsec In-Reply-To: References: Message-ID: <2f9b2d30909290129r167fb52fy39f8afe3c854bbf0@mail.gmail.com> I don't know, but: number -- definition = do { num <- natural ; return $ num } -- desugar = natural >>= \num -> return $ num -- apply ($) = natural >>= \num -> return num -- eta elimination (f == \x -> f x) = natural >>= return -- monad law = natural (modulo monomorphism restriction, since number doesn't take any arguments and doesn't have a type signature) -- ryan On Tue, Sep 29, 2009 at 12:54 AM, Anatoly Yakovenko wrote: > number = do { num <- natural > ; return $ num > } > main = do > txt <- hGetContents stdin > print $ parse number "stdin" txt > > > why doesn't that work? > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/e10c1471/attachment.html From magicloud.magiclouds at gmail.com Tue Sep 29 04:30:50 2009 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue Sep 29 04:08:51 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <81980d76fcbf944da943a2f2b8cdd985.squirrel@mail.shareyourgifts.net> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> <81980d76fcbf944da943a2f2b8cdd985.squirrel@mail.shareyourgifts.net> Message-ID: <3bd412d40909290130j2e6e844ew747b024ae894170@mail.gmail.com> Resolved. As Thomas said, mixing up sure is a bad thing. But then I have to name so many meanless (at least I think) computing process.... On Tue, Sep 29, 2009 at 3:32 PM, Jimmy Hartzell wrote: > *Should* isInteger be returning True for any numbers generated by this > code? ?If so, can you simplify this test down to that example, so that > it's obvious what the test should do, and that it's not doing it (if it in > fact is not doing as it should)? In any case, it would help to divide this > block of code into more manageable pieces. > > isInteger should have the type Fractional a => a -> Boolean. > >> The properFaction part is correct. So I posted the whole code, since >> "isInteger" should accept any reasonable incoming types. Well, in this >> one situation, it does not. And I cannot figure out why.... >> >> On Tue, Sep 29, 2009 at 3:07 PM, Jimmy Hartzell >> wrote: >>> Did you test the properFraction-based code in isolation? If code is >>> broken, it's important to figure out which part of it is broken. Also, >>> this function is not divided into constituent parts, but is a long >>> unruly >>> mess. Dividing it into parts would make it much much more readable, and >>> you would then be able to test the parts individually. >>> >>> Jimmy >>> >>>> The original code is >>>> givenSum num = map (\a -> >>>> ? ? ? ? ? ? ? ? ? ? ? let l = (sqrt $ fromIntegral (a * a + >>>> 2 + 2 * >>>> num)) - (fromIntegral a) in >>>> ? ? ? ? ? ? ? ? ? ? ? case properFraction l of >>>> ? ? ? ? ? ? ? ? ? ? ? ? (_, 0) -> >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? True >>>> ? ? ? ? ? ? ? ? ? ? ? ? _ -> >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? False >>>> ? ? ? ? ? ? ? ? ? ?) $ take num [1..] >>>> :t l is (Floating a) => a >>>> Well, in ghci >>>> *Main> givenSum 10 >>>> [False,False,False,False,False,False,False,False,False,False] >>>> >>>> On Tue, Sep 29, 2009 at 2:45 PM, Thomas DuBuisson >>>> wrote: >>>>> On Mon, Sep 28, 2009 at 11:35 PM, Magicloud Magiclouds >>>>> wrote: >>>>>> It never matches to (_, 0.0).... >>>>>> I mean >>>>>> case properFraction l of >>>>>> ?(_, 0) -> l >>>>>> ?_ -> 0 -- always goes here. >>>>> >>>>> Odd, it works fine for me. >>>>> >>>>> f x = >>>>> ? ? ? ?case properFraction x of >>>>> ? ? ? ? ? ? ? ?(_,0) -> True >>>>> ? ? ? ? ? ? ? ?_ ? ? -> False >>>>> >>>>> >>>>> *Main> f 5 >>>>> True >>>>> *Main> f 5.5 >>>>> False >>>>> *Main> f 4.0 >>>>> True >>>>> *Main> f 4.00000001 >>>>> False >>>>> >>>>> >>>>> Thomas >>>>> >>>> >>>> >>>> >>>> -- >>>> ??????? >>>> ??????? >>>> >>> >>> >>> >> >> >> >> -- >> ??????? >> ??????? >> > > > -- ??????? ??????? From ketil at malde.org Tue Sep 29 04:48:53 2009 From: ketil at malde.org (Ketil Malde) Date: Tue Sep 29 04:26:53 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> (Johan Tibell's message of "Mon, 28 Sep 2009 18:32:07 +0200") References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> Message-ID: <877hvi3zm2.fsf@malde.org> Johan Tibell writes: > I agree with Don. Also, I don't think that a Unicode type should > mention what encoding it uses as it's an implementation detail. Right. I see from the documentation that it uses Word16s (and presumably the utf-16 encoding). Out of curiosity, why was this particular encoding chosen, as opposed to utf-8 or utf-32/ucs-4? Any benchmarks or other information? -k -- If I haven't seen further, it is by standing in the footprints of giants From colin at colina.demon.co.uk Tue Sep 29 05:32:09 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Sep 29 05:10:10 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.5.0.0 In-Reply-To: <87eipqw56u.fsf@gmail.com> (Ivan Lazar Miljenovic's message of "Tue\, 29 Sep 2009 18\:00\:57 +1000") References: <87eipqw56u.fsf@gmail.com> Message-ID: >>>>> "Ivan" == Ivan Lazar Miljenovic writes: Ivan> I'd appreciate it if people could give SourceGraph a whirl Fails to install (Linux x86_64): Data/Graph/Analysis/Utils.hs:207:43: Ambiguous occurrence `dotizeGraph' It could refer to either `Data.Graph.Analysis.Utils.dotizeGraph', defined at Data/Graph/Analysis/Utils.hs:199:0 or `Data.GraphViz.dotizeGraph', imported from Data.GraphViz at Data/Graph/Analysis/Utils.hs:81:0-19 Data/Graph/Analysis/Utils.hs:220:18: Not in scope: data constructor `PointList' cabal: Error: some packages failed to install: Graphalyze-0.5 failed during the building phase. The exception was: exit: ExitFailure 1 SourceGraph-0.3 depends on Graphalyze-0.5 which failed to install. -- Colin Adams Preston Lancashire From DekuDekuplex at Yahoo.com Tue Sep 29 05:33:25 2009 From: DekuDekuplex at Yahoo.com (Benjamin L.Russell) Date: Tue Sep 29 05:11:46 2009 Subject: [Haskell-cafe] Re: Haskell Weekly News: Issue 131 - Semptember 25, 2009 References: <4abe3eb9.9453f10a.19ce.29a6@mx.google.com> Message-ID: <3ik3c5lc0cqqbffgc5vfqqvgf73hts695f@4ax.com> On Sat, 26 Sep 2009 09:18:01 -0700 (PDT), Joe Fredette wrote: > * ksf: (But if (on the other hand)) (I think only a number in general > (whether it be five or a hundred)) (this thought is rather the > representation of a method (whereby a multiplicity (for instance a > thousand) may be represented (in an image in conformity with a > certain concept)) than the image itself. * dekudekuplex: (Unfortunately (unless intentional)) the preceding (by ksf (in the "Quotes of the Week" section)) quote had mismatched (one too many opening) parentheses (although it was still funny (even though it could have been edited (to make the parentheses match (even though that is not an important issue)))). -- Benjamin L. Russell -- 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^ From joerg.rudnick at t-online.de Tue Sep 29 05:48:52 2009 From: joerg.rudnick at t-online.de (=?UTF-8?B?SsO2cmcgUm9tYW4gUnVkbmljaw==?=) Date: Tue Sep 29 05:27:15 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> Message-ID: <4AC1D804.7060608@t-online.de> These problems are critical -- but not hopeless, I think: (1) A simple technical matter, any average Haskell programmer (including myself...) can build a platform, e.g. in Happstack or the like, to clear this up (given you want to do this in Haskell ;-). (4) This is a special one, which I have pondered on some time ago. The customers' main concern seems to be "will this company still support me in n years??" o if the project is interesting enough, I see hope there might be some academic unit willing to partake in this, as I have heard enough complaint of not having enough examples to demonstrate business relevance to students. Normally, the customer should have no problem in believing an academic unit and its interests to last some time. o I would propose to pick up the insourcing concept -- as, what I can confirm by my own teaching experiences, it sometimes is easier to introduce Haskell to beginners (once the do have sufficient OS experience) then to people who already are adherents of some other language. Ok, we might need some more introductory literature etc. (3) Yes, there seem to be lots of people organized at a smaller level than what I described -- groups of one or very few members, working on a limited time range. Yesterday, I would have written there should be remarkable interest in greater projects, but, due to the poor resonance to my mail, I feel wary to do so now. (3)&(2) Such a reserved reaction might indicate many Haskellers are not motivated by the money but by the fame, and -- as the lively succJava thread shows -- what could be greater fame (besides the evaluation of 42) than stealing the Java etc. community just another attractive project? ;-)) Do I go wrong in saying there's a good deal of competitive spirit in the Haskell community interesting in taking claims away of other programming cultures which have grown saturated over the years? And, isn't the this *Haskeller bonus* indicating that doing the step to larger project should not be as hard as for others? A remaining issue might be a need for some facility to find cooperations and realize synergies -- see (1). Enough blah-blah. I got one email response (not posted to here) of a highly qualified Haskeller whom I could name two projects which might have interested him in his proximity, 80 miles and 75 miles away (and I do not have so many...). My learning is that a communication platform in this concern might be interesting to at least some of us. There are larger projects possible -- if we pick them up. All the best, Nick John A. De Goes wrote: > > It's very difficult to find information on: > > 1. How many Haskell developers are out there; > 2. What a typical salary is for a Haskell developer; > 3. Whether or not the skills of a typical Haskell developer scale > to large applications (most Haskell developers are "hobby" > Haskellers and have only written tiny to small Haskell apps); > 4. How many shops are capable of handling Haskell development & > maintenance. > > > These are the kinds of information one needs to make an informed > decision about whether to introduce Haskell into the workplace. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Sep 28, 2009, at 7:01 AM, J?rg Roman Rudnick wrote: > >> In the last months, I made the experience it seems difficult to find >> commercial Haskell developer teams to take responsibility for >> projects in the range of $ 10.000 - 100.000. The Industrial Haskell >> Group does not seem to be the appropriate place for this, while >> harvesting Haskell team at general market places appears to be tedious. >> >> I would be very interested in others' experiences, and inhowfar my >> opinion is shared that there should be a demand for such a market >> place, for developer teams as well as those sympathizing with >> introducing Haskell somewhere. >> >> Nick >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/62682ece/attachment-0001.html From lrpalmer at gmail.com Tue Sep 29 06:06:12 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Sep 29 05:44:11 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909290130j2e6e844ew747b024ae894170@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <2cf2b209c602053253fb49895b96776b.squirrel@mail.shareyourgifts.net> <3bd412d40909282335q3d302c68r91a7fd263498ab80@mail.gmail.com> <4c44d90b0909282345i41e31aabw868a23e1f8f8f7f@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <8d5d40084a3633edd1f522aab7c15459.squirrel@mail.shareyourgifts.net> <3bd412d40909290013j668d143al408461c7d5400f2c@mail.gmail.com> <81980d76fcbf944da943a2f2b8cdd985.squirrel@mail.shareyourgifts.net> <3bd412d40909290130j2e6e844ew747b024ae894170@mail.gmail.com> Message-ID: <7ca3f0160909290306w19017249t4305f367be0b3800@mail.gmail.com> On Tue, Sep 29, 2009 at 2:30 AM, Magicloud Magiclouds wrote: > Resolved. As Thomas said, mixing up sure is a bad thing. But then I > have to name so many meanless (at least I think) computing process.... That is the primary challenge of writing readable code: identifying the meaningful parts. You can separate out a function into its parts in many, many ways, but only a few of them will have parts that are comprehensible in isolation. Your original question asked "how to decide if a number is an integer". Surely you would have loved it if isInteger were a library function. It has a nice, simple meaning, that is completely independent of what the surrounding code is doing. It is pretty easy to name. These things often line up. They indicate that the function is most easily understood outside of its context, as an atomic building block. It is an ideal candidate for a small function. An example of a bad constituent function from your example would be this one: huh a = fromIntegral (a * a + 2 + 2 * a) What does it mean, why are you doing it? It would be absurd to ask for this as a library function in any library. Who knows what it could possibly be named, except something inane like doArithmetic. This function is most easily understood in its context; the function that is trying to find integral values of this expression. Spending a lot of time and thought about how to break up your functions in the most understandable way will make you a better engineer. In fact, it's a quality I find missing in many professional programmers... unfortunately. Luke From ivan.miljenovic at gmail.com Tue Sep 29 06:18:48 2009 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Tue Sep 29 05:56:51 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.5.0.0 In-Reply-To: (Colin Paul Adams's message of "Tue, 29 Sep 2009 10:32:09 +0100") References: <87eipqw56u.fsf@gmail.com> Message-ID: <87ljjyuk8n.fsf@gmail.com> Colin Paul Adams writes: Compare the version in the subject to the version you're trying to install... >>>>>> "Ivan" == Ivan Lazar Miljenovic writes: > > Ivan> I'd appreciate it if people could give SourceGraph a whirl > > Fails to install (Linux x86_64): > > Data/Graph/Analysis/Utils.hs:207:43: > Ambiguous occurrence `dotizeGraph' > It could refer to either `Data.Graph.Analysis.Utils.dotizeGraph', defined at Data/Graph/Analysis/Utils.hs:199:0 > or `Data.GraphViz.dotizeGraph', imported from Data.GraphViz at Data/Graph/Analysis/Utils.hs:81:0-19 > > Data/Graph/Analysis/Utils.hs:220:18: > Not in scope: data constructor `PointList' > cabal: Error: some packages failed to install: > Graphalyze-0.5 failed during the building phase. The exception was: > exit: ExitFailure 1 > SourceGraph-0.3 depends on Graphalyze-0.5 which failed to install. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com From duncan.coutts at googlemail.com Tue Sep 29 06:23:02 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Tue Sep 29 06:16:47 2009 Subject: [Haskell-cafe] unicode text libraries In-Reply-To: <877hvi3zm2.fsf@malde.org> References: <2d34474e0909280613q50f142f4i14fbc30658ab7817@mail.gmail.com> <2d34474e0909280616p31e14e02r38f2e669dc9092@mail.gmail.com> <20090928154911.GA12575@whirlpool.galois.com> <2d34474e0909280908k79c563l5be3a1c5b851aed6@mail.gmail.com> <20090928161517.GA12679@whirlpool.galois.com> <90889fe70909280932p794a4180jeb7f7981f7579b2@mail.gmail.com> <877hvi3zm2.fsf@malde.org> Message-ID: <1254219782.4588.978.camel@localhost> On Tue, 2009-09-29 at 10:48 +0200, Ketil Malde wrote: > Johan Tibell writes: > > > I agree with Don. Also, I don't think that a Unicode type should > > mention what encoding it uses as it's an implementation detail. > > Right. I see from the documentation that it uses Word16s (and presumably > the utf-16 encoding). Out of curiosity, why was this particular > encoding chosen, as opposed to utf-8 or utf-32/ucs-4? Any benchmarks or > other information? Yes, the choice was based on benchmarks. All three (UTF-8,16,32) were implemented and benchmarked. You can read about the details in Tom Harper's MSc thesis. Duncan From colin at colina.demon.co.uk Tue Sep 29 06:45:48 2009 From: colin at colina.demon.co.uk (Colin Paul Adams) Date: Tue Sep 29 06:23:52 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.5.0.0 In-Reply-To: <87ljjyuk8n.fsf@gmail.com> (Ivan Lazar Miljenovic's message of "Tue\, 29 Sep 2009 20\:18\:48 +1000") References: <87eipqw56u.fsf@gmail.com> <87ljjyuk8n.fsf@gmail.com> Message-ID: >>>>> "Ivan" == Ivan Lazar Miljenovic writes: Ivan> Colin Paul Adams writes: Compare Ivan> the version in the subject to the version you're trying to Ivan> install... You are right. i forgot to do a cabal update first. -- Colin Adams Preston Lancashire From iainspeed at gmail.com Tue Sep 29 07:04:38 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Tue Sep 29 06:43:14 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> Message-ID: <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> On 29 Sep 2009, at 03:19, Casey Hawthorne wrote: > If you do a student's homework, you are cheating that student out of > an education. > > He/She may realize that toooo late in the future. > -- > Regards, > Casey I'm not sure I agree with that. If they're old enough to be doing Haskell homework then they're old enough to make their own decisions and take the consequences of that. As they might say in Calvinist Scotland, "Let the child play with the knife, they'll soon learn" :) Personally, I tend to find "exercises" without access to the answers a poor way to learn. You'll learn more from a well crafted example than you ever will by struggling at something yourself. Regards Iain From agocorona at gmail.com Tue Sep 29 07:18:28 2009 From: agocorona at gmail.com (Alberto G. Corona ) Date: Tue Sep 29 06:56:28 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <4AC1D804.7060608@t-online.de> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> Message-ID: Some thoughs: Most successful languages spread because they are part of a platform which solves an IT problem. C was part of Unix, both brougth CPU independence when this was necessary. Java is part of the Java platform, that brougth OS independence and interoperability at the right time. .Download-execution on the client was also a reason for the initial success of Java in the Internet era. Javascript is part of the web browser. The .NET languages are part of NET. Rubi and Pyton came with libraries targeted to Rapid development of Internet applications. What is the vehicle that haskell can use to enter the mainstream?. I think that the mere interest of the ideas in the language is not enough. Many people will play with Haskell in the spare time, and many of them will be permitted to develop some non critical applications at work. But that is all. Java was not designed for the Internet but it was re-targeted to it because some needed features where already implemented in Java. Maybe something like that will happen to Haskell. I think that all the current niches are filled, but new niches are coming. specially with higher level programming that is made on top of current sorware software infrastructure such are BPM, workflows, more flexible scientific applicatins, creation of models in business intelligence, as part of ERPs,.Data mining too. And higuer levels of netwrok communications( for example, Google Wave robots) etc. About the last point, sometimes a basically identical infrastructure is re-engineered to a higher level, and a new language takes over. For example, the architecture of many Internet applications in the 80s was client-server based, where C, C++ was the king. This was substituted by the web architecture with Java because Java was involved in the gradual change by filling the holes of the new architecture. It could be that in a few years, instead of Web sites people could develop interoperable gadgets for aggregators such are netvibes or IGoogle or, even more radical, robots and gadgets in google Wave. Anyway, for sure, people will think and develop at a higher level. Financial applications are an example of higher level programming where tasks usually performed by humans are now automatized and there is no or few traditions about that. The need to think at a higher level without being worried by side effects and other details are specially needed in such kind of areas. That's where haskell could have its own niche. Regards 2009/9/29 J?rg Roman Rudnick > These problems are critical -- but not hopeless, I think: > > (1) A simple technical matter, any average Haskell programmer (including > myself...) can build a platform, e.g. in Happstack or the like, to clear > this up (given you want to do this in Haskell ;-). > > (4) This is a special one, which I have pondered on some time ago. The > customers' main concern seems to be "will this company still support me in n > years??" > o if the project is interesting enough, I see hope there might be some > academic unit willing to partake in this, as I have heard enough complaint > of not having enough examples to demonstrate business relevance to students. > Normally, the customer should have no problem in believing an academic unit > and its interests to last some time. > o I would propose to pick up the insourcing concept -- as, what I can > confirm by my own teaching experiences, it sometimes is easier to introduce > Haskell to beginners (once the do have sufficient OS experience) then to > people who already are adherents of some other language. Ok, we might need > some more introductory literature etc. > > (3) Yes, there seem to be lots of people organized at a smaller level than > what I described -- groups of one or very few members, working on a limited > time range. > > Yesterday, I would have written there should be remarkable interest in > greater projects, but, due to the poor resonance to my mail, I feel wary to > do so now. > > (3)&(2) Such a reserved reaction might indicate many Haskellers are not > motivated by the money but by the fame, and -- as the lively succJava thread > shows -- what could be greater fame (besides the evaluation of 42) than > stealing the Java etc. community just another attractive project? ;-)) > > Do I go wrong in saying there's a good deal of competitive spirit in the > Haskell community interesting in taking claims away of other programming > cultures which have grown saturated over the years? And, isn't the this > *Haskeller bonus* indicating that doing the step to larger project should > not be as hard as for others? > > A remaining issue might be a need for some facility to find cooperations > and realize synergies -- see (1). > > Enough blah-blah. I got one email response (not posted to here) of a highly > qualified Haskeller whom I could name two projects which might have > interested him in his proximity, 80 miles and 75 miles away (and I do not > have so many...). My learning is that a communication platform in this > concern might be interesting to at least some of us. There are larger > projects possible -- if we pick them up. > > > All the best, > > Nick > > > > John A. De Goes wrote: > > > It's very difficult to find information on: > > 1. How many Haskell developers are out there; > 2. What a typical salary is for a Haskell developer; > 3. Whether or not the skills of a typical Haskell developer scale to large > applications (most Haskell developers are "hobby" Haskellers and have only > written tiny to small Haskell apps); > 4. How many shops are capable of handling Haskell development & > maintenance. > > > These are the kinds of information one needs to make an informed decision > about whether to introduce Haskell into the workplace. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Sep 28, 2009, at 7:01 AM, J?rg Roman Rudnick wrote: > > In the last months, I made the experience it seems difficult to find > commercial Haskell developer teams to take responsibility for projects in > the range of $ 10.000 - 100.000. The Industrial Haskell Group does not seem > to be the appropriate place for this, while harvesting Haskell team at > general market places appears to be tedious. > > I would be very interested in others' experiences, and inhowfar my opinion > is shared that there should be a demand for such a market place, for > developer teams as well as those sympathizing with introducing Haskell > somewhere. > > Nick > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ------------------------------ > > _______________________________________________ > Haskell-Cafe mailing listHaskell-Cafe@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/9a6ea237/attachment.html From daniel.is.fischer at web.de Tue Sep 29 07:32:53 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 29 07:12:08 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <4c44d90b0909290002q42b94567hfc488f725488d390@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> <3bd412d40909282354w3f88cc32ge87f8815647eeb9b@mail.gmail.com> <4c44d90b0909290002q42b94567hfc488f725488d390@mail.gmail.com> Message-ID: <200909291332.53895.daniel.is.fischer@web.de> Am Dienstag 29 September 2009 09:02:19 schrieb Thomas DuBuisson: > Unless I missed something, the function in question is: > > sqrt (a * a + 2 + 2 * num) - fromIntegral a > where num = 10 > > 1 -> sqrt (1 * 1 + 2 + 2 * 10) - 1 -> sqrt (1 + 2 + 20) - 1 -> sqrt > (23) - 1 -> 3.79xxxxx > > the fractional will only ever come from the sqrt function. Do any of > the following actually look like square values to you? > > 26 > 31 > 38 > 47 > 58 > 71 > 86 > 103 > 122 > > IMO, the code works and your expectations are a bit off. Quite. *MMlouds> givenSum 11 [True,False,False,False,True,False,False,False,False,False,False] The code tests whether a*a+2*(num+1) is a square, equivalently, whether there's a b such that 2*(num+1) == b^2 - a^2 Now, the difference of two squares is either odd or a multiple of 4. 2*(num+1) is never odd, so it must be a multiple of 4, i.e. num must be odd for any number of the form a^2 + 2*(num+1) to be a square. isIntegral x = snd (properFraction x) == 0 works for rational x and for small enough doubles/floats, but beware: *MMlouds> [n | n <- [1 .. 100], not $ isIntegral (sqrt $ 4^n+222)] [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29] > > Thomas > > On Mon, Sep 28, 2009 at 11:54 PM, Magicloud Magiclouds > > wrote: > > *Main> givenSum 10 > > [False,False,False,False,False,False,False,False,False,False] From simonpj at microsoft.com Tue Sep 29 07:35:22 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Sep 29 07:13:23 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C3641DD744CA@EA-EXMSG-C334.europe.corp.microsoft.com> Type splices are implemented in the upcoming GHC 6.10. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of George Pollard | Sent: 16 September 2009 13:45 | To: Haskell Caf? | Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax | | Also (sorry for the triple-post!) I noticed that in the TH | documentation, it says: | | Type splices are not implemented, and neither are pattern splices | | This means, while we could write a preprocessor that would give us, e.g.: | | x :: Set Int | x = {1,2,3,4} | | We cannot splice in the right places to allow: | | x :: {Int} | x = {1,2,3,4} | | isSetEmpty :: {a} ? Bool | isSetEmpty {} = True | isSetEmpty _ = False | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe From daniel.is.fischer at web.de Tue Sep 29 07:48:29 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 29 07:27:43 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> Message-ID: <200909291348.29665.daniel.is.fischer@web.de> Am Dienstag 29 September 2009 13:04:38 schrieb Iain Barnett: > Personally, I tend to find "exercises" without access to the answers ? > a poor way to learn. You'll learn more from a well crafted example ? > than you ever will by struggling at something yourself. I sort of disagree. You'll learn more if you can read a well crafted example *after* you've struggled to get something good on your own. If you start inspecting an example before you've spent considerable effort understanding the matter on your own, you're likely to miss some important things. From martin.hofmann at uni-bamberg.de Tue Sep 29 07:56:32 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Tue Sep 29 07:34:21 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors Message-ID: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> Hi, The API of Language.Haskell.Interpreter says, that 'runInterpreter' runInterpreter :: (MonadCatchIO m, Functor m) => InterpreterT m a -> m (Either InterpreterError a) returns 'Left' in case of errors and 'GhcExceptions from the underlying GHC API are caught and rethrown as this'. What kind of errors do a generate here, why are they not caught by runInterpreter and how can I catch them? I assumed to get a 'Left InterpreterError' from the first and an error in MonadCatchIO in the second. > :m +Language.Haskell.Interpreter > let estr1 = "let lst [a] = a; lst _ = error \"foo\" in lst []" > let estr1 = "let lst [a] = a; in lst []" > runInterpreter (setImportsQ [("Prelude", Nothing)] >> eval estr1 ) Right "*** Exception: foo > runInterpreter ( eval estr2) Right "*** Exception: :1:101-111: Non-exhaustive patterns in function lst Thanks a lot From iainspeed at gmail.com Tue Sep 29 08:47:27 2009 From: iainspeed at gmail.com (Iain Barnett) Date: Tue Sep 29 08:26:03 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: <200909291348.29665.daniel.is.fischer@web.de> References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> <200909291348.29665.daniel.is.fischer@web.de> Message-ID: On 29 Sep 2009, at 12:48, Daniel Fischer wrote: > Am Dienstag 29 September 2009 13:04:38 schrieb Iain Barnett: >> Personally, I tend to find "exercises" without access to the answers >> a poor way to learn. You'll learn more from a well crafted example >> than you ever will by struggling at something yourself. > > I sort of disagree. You'll learn more if you can read a well > crafted example *after* > you've struggled to get something good on your own. > If you start inspecting an example before you've spent considerable > effort understanding > the matter on your own, you're likely to miss some important things. > So, if I was trying to come up with a solution to a problem that possibly has multiple solutions, like building an engine for a car, I would do better if I hadn't seen a (well crafted) working engine by someone else than if I had? If effort is there, then give me the example any time, because insight will be quicker. If you're going to be lazy then it doesn't matter either way. Regards, Iain From RafaelGCPP.Linux at gmail.com Tue Sep 29 08:59:01 2009 From: RafaelGCPP.Linux at gmail.com (Rafael Gustavo da Cunha Pereira Pinto) Date: Tue Sep 29 08:36:59 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <638ABD0A29C8884A91BC5FB5C349B1C3641DD744CA@EA-EXMSG-C334.europe.corp.microsoft.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C3641DD744CA@EA-EXMSG-C334.europe.corp.microsoft.com> Message-ID: <351ff25e0909290559s3555eba6g90a8932c54ec89f8@mail.gmail.com> Hmm... Simon, was it a typo? Is it 6.10.x or 6.12? Regards, Rafael 2009/9/29 Simon Peyton-Jones > Type splices are implemented in the upcoming GHC 6.10. > > Simon > > | -----Original Message----- > | From: haskell-cafe-bounces@haskell.org [mailto: > haskell-cafe-bounces@haskell.org] On > | Behalf Of George Pollard > | Sent: 16 September 2009 13:45 > | To: Haskell Caf? > | Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax > | > | Also (sorry for the triple-post!) I noticed that in the TH > | documentation, it says: > | > | Type splices are not implemented, and neither are pattern splices > | > | This means, while we could write a preprocessor that would give us, e.g.: > | > | x :: Set Int > | x = {1,2,3,4} > | > | We cannot splice in the right places to allow: > | > | x :: {Int} > | x = {1,2,3,4} > | > | isSetEmpty :: {a} ? Bool > | isSetEmpty {} = True > | isSetEmpty _ = False > | _______________________________________________ > | 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 > > -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/ebf7674a/attachment.html From simonpj at microsoft.com Tue Sep 29 09:06:00 2009 From: simonpj at microsoft.com (Simon Peyton-Jones) Date: Tue Sep 29 08:44:00 2009 Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax In-Reply-To: <351ff25e0909290559s3555eba6g90a8932c54ec89f8@mail.gmail.com> References: <6d942a4a0909152259w2a429cc2m705759256f24ba19@mail.gmail.com> <6d942a4a0909160536i4dd576ebrb1114fbea1200a9@mail.gmail.com> <6d942a4a0909160537i2a7957f6kc174dbc5e864fc68@mail.gmail.com> <6d942a4a0909160544h13d2e318l2d52b522cb8a55eb@mail.gmail.com> <638ABD0A29C8884A91BC5FB5C349B1C3641DD744CA@EA-EXMSG-C334.europe.corp.microsoft.com> <351ff25e0909290559s3555eba6g90a8932c54ec89f8@mail.gmail.com> Message-ID: <638ABD0A29C8884A91BC5FB5C349B1C3641DD74508@EA-EXMSG-C334.europe.corp.microsoft.com> sorry ? 6.12 From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Rafael Gustavo da Cunha Pereira Pinto Sent: 29 September 2009 13:59 To: Simon Peyton-Jones Cc: Haskell Caf? Subject: Re: [Haskell-cafe] Re: A thought about liberating Haskell's syntax Hmm... Simon, was it a typo? Is it 6.10.x or 6.12? Regards, Rafael 2009/9/29 Simon Peyton-Jones > Type splices are implemented in the upcoming GHC 6.10. Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On | Behalf Of George Pollard | Sent: 16 September 2009 13:45 | To: Haskell Caf? | Subject: [Haskell-cafe] Re: A thought about liberating Haskell's syntax | | Also (sorry for the triple-post!) I noticed that in the TH | documentation, it says: | | Type splices are not implemented, and neither are pattern splices | | This means, while we could write a preprocessor that would give us, e.g.: | | x :: Set Int | x = {1,2,3,4} | | We cannot splice in the right places to allow: | | x :: {Int} | x = {1,2,3,4} | | isSetEmpty :: {a} ? Bool | isSetEmpty {} = True | isSetEmpty _ = False | _______________________________________________ | 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 -- Rafael Gustavo da Cunha Pereira Pinto -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/7fa72bbd/attachment.html From mauricio.antunes at gmail.com Tue Sep 29 09:34:58 2009 From: mauricio.antunes at gmail.com (=?ISO-8859-1?Q?Maur=ED=ADcio_CA?=) Date: Tue Sep 29 09:13:22 2009 Subject: [Haskell-cafe] Re: Doing people's homework? In-Reply-To: <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> Message-ID: >> If you do a student's homework, you are cheating that student out of >> an education. > Personally, I tend to find "exercises" without access to the answers a > poor way to learn. You'll learn more from a well crafted example than > you ever will by struggling at something yourself. In these lines, the homework policy could be extended to contain great solutions to all typical homework tasks. Teachers could build on that by instructing students to study and use such solutions to solve other tasks. Bonus could be given to students who could find even better solutions than those in the page, maybe with exponencial prizes like Knuth's checks :) Best, Maur?cio From john at n-brain.net Tue Sep 29 09:51:38 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Sep 29 09:29:44 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <20090928165642.GF17527@poetic.cynic.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <20090928165642.GF17527@poetic.cynic.net> Message-ID: <09183FC1-1879-4E5F-A1D0-03AEE59F2323@n-brain.net> You misunderstood my point. The browser, BigTable clone, and peer-to- peer networking libraries are starting points for applications -- ones that I've actually needed at various points in my career. You can grab them and start developing with them in a few minutes. If you want these components (or 100 others) in Haskell, you're going to have to write them yourself (at a cost of several to dozens of man years), or at least write sucky imperative wrappers around existing C libraries, compile those libraries, develop a cross-platform build process, be prepared to fix bugs in multiple languages, etc. Hackage is great, except when it's not, which is most of the time. No one's bit off the really big projects. In fact, they get voted down on the Reddit Haskell proposals, because somehow really practical software like an AMQP client isn't "cool" enough. Haskell's great for small applications that don't need specialized libraries (and apparently, for small segments of the financial industry). For other applications, it usually cannot compete economically with other, vastly technically inferior languages like Java. Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 28, 2009, at 10:56 AM, Curt Sampson wrote: > Ok, my last post on this for real this time. > > On 2009-09-28 08:13 -0600 (Mon), John A. De Goes wrote: > >> Let me ask you this question: how long would it take you to get an >> HTML/CSS, W3 compliant browser in Haskell? > > A long time. On the other hand, by grabbing a copy of Mozilla, I'll > have > one far faster than you'll have yours in Java, mine will work a lot > better, run more quickly, and work better with most sites. > > While I advocate using Haskell, I don't advocate being silly. > > (Incidently, I have direct experience with an almost exactly parallel > situation. I replaced a system that was thousands of lines of > difficult-to-maintain Java code with a few hundred lines of Haskell > that > feed Microsoft Excel. The user is very pleased that he can now can do > far more extensive tweaking of the UI himself, including major > features > he never had at all before, such as real-time graphing of the data.) > >> Or how about a peer-to-peer networking system with seamless scaling >> and automatic failover? > > Can you give me an example of a real-life system using this you've set > up in "a few minutes"? My experience building systems with similar > things (the very mature and proven MogileFS suite of tools) has been > that the libraries were nice, but did not solve the majority, or > even a > large minority, of the problem. > >> Libraries are _everything_. In many cases, they can increase your >> effective budget by 10x or even 100x. > > Or the other way around, as I've seen by ripping out thousands of > lines > of Hibernate code, and all of the work done to adapt a system to that > model, and replace it with a few hundred lines of SQL and JDBC calls. > That library has probably wasted more man-years than anything else > I've > seen in the Java world. > > cjs > -- > Curt Sampson +81 90 7737 2974 > Functional programming in all senses of the word: > http://www.starling-software.com From tonymorris at gmail.com Tue Sep 29 09:57:19 2009 From: tonymorris at gmail.com (Tony Morris) Date: Tue Sep 29 09:35:05 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <09183FC1-1879-4E5F-A1D0-03AEE59F2323@n-brain.net> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <20090928165642.GF17527@poetic.cynic.net> <09183FC1-1879-4E5F-A1D0-03AEE59F2323@n-brain.net> Message-ID: <4AC2123F.5030907@gmail.com> John A. De Goes wrote: > write them yourself (at a cost of several to dozens of man years), Is that right? -- Tony Morris http://tmorris.net/ From john at n-brain.net Tue Sep 29 09:58:01 2009 From: john at n-brain.net (John A. De Goes) Date: Tue Sep 29 09:36:08 2009 Subject: [Haskell-cafe] Comments requested: succ Java In-Reply-To: <42784f260909281001q42df0115w41fdfaf7a1a014ec@mail.gmail.com> References: <20090927161653.GG1381@poetic.cynic.net> <20090928021004.GN1381@poetic.cynic.net> <20090928134941.GD17527@poetic.cynic.net> <21BB7575-DE91-41B3-B85B-24F86C526D2C@n-brain.net> <42784f260909281001q42df0115w41fdfaf7a1a014ec@mail.gmail.com> Message-ID: <18FD6462-5FB2-49DE-A024-B22A793871D2@n-brain.net> It's the early adopters who develop the first libraries that pull in ever wider audiences. Yes, the early adopters are drawn by the syntax of the language, but commercial adoption doesn't come until it's economically competitive to do so. And that doesn't happen until the library market is booming and/or they can seamlessly reuse existing assets (that's what the JVM languages discovered: if you allow people to use what they already have, in a seamless fashion, incrementally building new stuff using the new language, then you can dramatically shorten the time between early adoption and mass adoption). Regards, John A. De Goes N-Brain, Inc. The Evolution of Collaboration http://www.n-brain.net | 877-376-2724 x 101 On Sep 28, 2009, at 11:01 AM, Jason Dusek wrote: > 2009/09/28 John A. De Goes : >> Libraries are _everything_... > > Not exactly. Python would never have gotten a foothold over > Perl, nor Java over C, if cleaner language semantics weren't > enough for some shops or certain applications. > > -- > Jason Dusek From jvranish at gmail.com Tue Sep 29 10:03:18 2009 From: jvranish at gmail.com (Job Vranish) Date: Tue Sep 29 09:41:19 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <4AC1D804.7060608@t-online.de> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> Message-ID: If there is demand for shops to work on smaller jobs in haskell then I think a having a more specific marketplace/communication platform for haskell work would be very helpful. If there is a perceived demand, supply will soon follow. - Job On Tue, Sep 29, 2009 at 5:48 AM, J?rg Roman Rudnick < joerg.rudnick@t-online.de> wrote: > These problems are critical -- but not hopeless, I think: > > (1) A simple technical matter, any average Haskell programmer (including > myself...) can build a platform, e.g. in Happstack or the like, to clear > this up (given you want to do this in Haskell ;-). > > (4) This is a special one, which I have pondered on some time ago. The > customers' main concern seems to be "will this company still support me in n > years??" > o if the project is interesting enough, I see hope there might be some > academic unit willing to partake in this, as I have heard enough complaint > of not having enough examples to demonstrate business relevance to students. > Normally, the customer should have no problem in believing an academic unit > and its interests to last some time. > o I would propose to pick up the insourcing concept -- as, what I can > confirm by my own teaching experiences, it sometimes is easier to introduce > Haskell to beginners (once the do have sufficient OS experience) then to > people who already are adherents of some other language. Ok, we might need > some more introductory literature etc. > > (3) Yes, there seem to be lots of people organized at a smaller level than > what I described -- groups of one or very few members, working on a limited > time range. > > Yesterday, I would have written there should be remarkable interest in > greater projects, but, due to the poor resonance to my mail, I feel wary to > do so now. > > (3)&(2) Such a reserved reaction might indicate many Haskellers are not > motivated by the money but by the fame, and -- as the lively succJava thread > shows -- what could be greater fame (besides the evaluation of 42) than > stealing the Java etc. community just another attractive project? ;-)) > > Do I go wrong in saying there's a good deal of competitive spirit in the > Haskell community interesting in taking claims away of other programming > cultures which have grown saturated over the years? And, isn't the this > *Haskeller bonus* indicating that doing the step to larger project should > not be as hard as for others? > > A remaining issue might be a need for some facility to find cooperations > and realize synergies -- see (1). > > Enough blah-blah. I got one email response (not posted to here) of a highly > qualified Haskeller whom I could name two projects which might have > interested him in his proximity, 80 miles and 75 miles away (and I do not > have so many...). My learning is that a communication platform in this > concern might be interesting to at least some of us. There are larger > projects possible -- if we pick them up. > > > All the best, > > Nick > > > > John A. De Goes wrote: > > > It's very difficult to find information on: > > 1. How many Haskell developers are out there; > 2. What a typical salary is for a Haskell developer; > 3. Whether or not the skills of a typical Haskell developer scale to large > applications (most Haskell developers are "hobby" Haskellers and have only > written tiny to small Haskell apps); > 4. How many shops are capable of handling Haskell development & > maintenance. > > > These are the kinds of information one needs to make an informed decision > about whether to introduce Haskell into the workplace. > > Regards, > > John A. De Goes > N-Brain, Inc. > The Evolution of Collaboration > > http://www.n-brain.net | 877-376-2724 x 101 > > On Sep 28, 2009, at 7:01 AM, J?rg Roman Rudnick wrote: > > In the last months, I made the experience it seems difficult to find > commercial Haskell developer teams to take responsibility for projects in > the range of $ 10.000 - 100.000. The Industrial Haskell Group does not seem > to be the appropriate place for this, while harvesting Haskell team at > general market places appears to be tedious. > > I would be very interested in others' experiences, and inhowfar my opinion > is shared that there should be a demand for such a market place, for > developer teams as well as those sympathizing with introducing Haskell > somewhere. > > Nick > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ------------------------------ > > _______________________________________________ > Haskell-Cafe mailing listHaskell-Cafe@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/04179701/attachment-0001.html From dgorin at dc.uba.ar Tue Sep 29 10:16:50 2009 From: dgorin at dc.uba.ar (=?ISO-8859-1?Q?Daniel_Gor=EDn?=) Date: Tue Sep 29 09:54:57 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> References: <1254225392.6118.80.camel@ios.cogsys.wiai.uni-bamberg.de> Message-ID: <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc.uba.ar> On Sep 29, 2009, at 8:56 AM, Martin Hofmann wrote: > Hi, > > The API of Language.Haskell.Interpreter says, that 'runInterpreter' > > runInterpreter :: (MonadCatchIO m, Functor m) => > InterpreterT m a -> > m (Either InterpreterError a) > > returns 'Left' in case of errors and 'GhcExceptions from the > underlying > GHC API are caught and rethrown as this'. > > > What kind of errors do a generate here, why are they not caught by > runInterpreter and how can I catch them? I assumed to get a 'Left > InterpreterError' from the first and an error in MonadCatchIO in the > second. > >> :m +Language.Haskell.Interpreter >> let estr1 = "let lst [a] = a; lst _ = error \"foo\" in lst []" >> let estr1 = "let lst [a] = a; in lst []" >> runInterpreter (setImportsQ [("Prelude", Nothing)] >> eval estr1 ) > Right "*** Exception: foo >> runInterpreter ( eval estr2) > Right "*** Exception: :1:101-111: Non-exhaustive > patterns in function lst > > > Thanks a lot > InterpreterErrors are those that prevent your to-be-interpreted code from "compiling/typechecking". In this case, estr1 is interpreted just fine; but the interpreted value is an exception. So I think Ritght... is ok. You ought to be able to add a Control.Monad.CatchIO.catch clause to your interpreter to catch this kind of errors, if you want. I just tried it and failed, though, so this is probably a bug. I'll try to track it down in more detail. Thanks for the report! Daniel From apfelmus at quantentunnel.de Tue Sep 29 10:20:44 2009 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Tue Sep 29 10:00:35 2009 Subject: [Haskell-cafe] Re: Writing tool question (may be out of scope here) In-Reply-To: <59940e500909281430o54ffe2f7v4b8dbc6c644dccaf@mail.gmail.com> References: <59940e500909281430o54ffe2f7v4b8dbc6c644dccaf@mail.gmail.com> Message-ID: Saul Malesac wrote: > Excuse me if that is out of subject here, but does anyone know which > tool/writing framework was used to write the "Real world Haskell" book > ? > I'm wondering, in particular, about the capability to > write/edit/publish it online while allowing people to leave comments, > then have a paperback/PDF version. This might be what you're looking for: http://www.realworldhaskell.org/blog/2008/02/10/about-our-comment-system/ A pity the web interface wasn't written in Haskell. ;) Regards, apfelmus -- http://apfelmus.nfshost.com From vandijk.roel at gmail.com Tue Sep 29 10:26:02 2009 From: vandijk.roel at gmail.com (Roel van Dijk) Date: Tue Sep 29 10:04:02 2009 Subject: [Haskell-cafe] ANNOUNCE: SourceGraph-0.5.0.0 In-Reply-To: References: <87eipqw56u.fsf@gmail.com> <87ljjyuk8n.fsf@gmail.com> Message-ID: Looks very nice! One thing I noticed are a bunch of escaped newlines somehow ending up in the report: Class: Num\nData: Bit, Class: Num They appear each time a class is displayed. From paolo.losi at gmail.com Tue Sep 29 10:36:57 2009 From: paolo.losi at gmail.com (Paolo Losi) Date: Tue Sep 29 10:14:56 2009 Subject: [Haskell-cafe] Ghci dynamic linking (Was: C++ libraries and GHCI) Message-ID: <2af4014d0909290736l110908f4vaf058c6efdfd0f86@mail.gmail.com> Hi all, I would really appreciate if anyone could give a look to the following problem. Thanks in advance!!! Paolo ---------- Forwarded message ---------- From: Paolo Losi Date: Mon, Sep 14, 2009 at 10:33 AM Subject: C++ libraries and GHCI To: glasgow-haskell-users@haskell.org Hi all, I'm working on a tentative implementation of haskell binding to libsvm [1]: http://hackage.haskell.org/package/HSvm The package includes libsvm C++ sources. While it works perfectly with ghc --make (try to install the package and compile http://bitbucket.org/pao/hsvm/raw/6cf7ca91f1e5/test/test.hs), it fails with ghci: (hsvm)(env)paolo@moltrasio:~/trash$ ghci test.hs GHCi, version 6.10.4: http://www.haskell.org/ghc/ ?:? for help Loading package ghc-prim ... linking ... done. Loading package integer ... linking ... done. Loading package base ... linking ... done. Ok, modules loaded: Main. Prelude Main> main Loading package syb ... linking ... done. Loading package array-0.2.0.0 ... linking ... done. Loading package containers-0.2.0.1 ... linking ... done. Loading package HSvm-0.1.0.2.89 ... linking ... : /home/paolo/trash/hsvm/lib/HSvm-0.1.0.2.89/ghc-6.10.4/HSHSvm-0.1.0.2.89.o: unknown symbol `_ZTV6Kernel' ghc: unable to load package `HSvm-0.1.0.2.89' Please note that the symbol is available in libHSHSvm-0.1.0.2.89.a $ nm HSHSvm-0.1.0.2.89.o |grep _ZTV6Kernel 00000000 V _ZTV6Kernel $ nm libHSHSvm-0.1.0.2.89.a |grep _ZTV6Kernel 00000000 V _ZTV6Kernel Can anyone give a look to the problem? Thanks Paolo [1] http://www.csie.ntu.edu.tw/~cjlin/libsvm/ -- Paolo Losi e-mail: paolo@enuan.com mob: +39 348 7705261 ENUAN Srl Via XX Settembre, 12 - 29100 Piacenza From saul.malesac at gmail.com Tue Sep 29 10:41:29 2009 From: saul.malesac at gmail.com (Saul Malesac) Date: Tue Sep 29 10:19:29 2009 Subject: [Haskell-cafe] Re: Writing tool question (may be out of scope here) In-Reply-To: References: <59940e500909281430o54ffe2f7v4b8dbc6c644dccaf@mail.gmail.com> Message-ID: <59940e500909290741j775bccacn76777a7d36fbc26e@mail.gmail.com> Perfect ! I've missed this. Thank you very much. 2009/9/29 Heinrich Apfelmus : > Saul Malesac wrote: >> Excuse me if that is out of subject here, but does anyone know which >> tool/writing framework was used to write the "Real world Haskell" book >> ? >> I'm wondering, in particular, about the capability to >> write/edit/publish it online while allowing people to leave comments, >> then have a paperback/PDF version. > > This might be what you're looking for: > > http://www.realworldhaskell.org/blog/2008/02/10/about-our-comment-system/ > > A pity the web interface wasn't written in Haskell. ;) > > > Regards, > apfelmus > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Saul From brad.larsen at gmail.com Tue Sep 29 10:57:05 2009 From: brad.larsen at gmail.com (Brad Larsen) Date: Tue Sep 29 10:35:04 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <20090929035252.GA15160@whirlpool.galois.com> References: <4AC1701A.9060103@gmail.com> <20090929035252.GA15160@whirlpool.galois.com> Message-ID: Don, On Mon, Sep 28, 2009 at 11:52 PM, Don Stewart wrote: > brad.larsen: >> On Mon, Sep 28, 2009 at 11:11 PM, Hong Yang wrote: >> [...] >> > Maybe later on we can add an Example section to Description, Synopsis, and >> > Documentation sections produced by Haddock. >> > >> > Also, having a section for comments is helpful. This is the case especially >> > when there are several similar packages coexisting, comments can help people >> > choose which one to use. >> > >> > Thanks, >> > >> > Hong >> [...] >> >> +1 > > I'd like to see people writing comparative reviews of libraries in each > category, and publishing those reviews online. > > -- Don If there were a comments section for the packages on Hackage, it would lower the barrier to entry for writing such comparisons. :-) It takes a good chunk of time to write up a detailed, informative blog post, with performance measurements, etc. for competing packages. Many people do not have the time to do an in-depth review of a package; I am grateful when people do take the time to such reviews. If there were a comments or review section on Hackage (a la CPAN), I imagine that more people would provide feedback. Another issue with the published package comparisons is an indexing problem. At present, the only way for potential users of a package to find reviews is through actively searching for them via Google or asking other Haskellers. With a comments area for a package, one could link to an off-site, in-depth review. Sincerely, Brad From tanimoto at arizona.edu Tue Sep 29 11:07:23 2009 From: tanimoto at arizona.edu (Paulo Tanimoto) Date: Tue Sep 29 10:45:41 2009 Subject: [Haskell-cafe] Instances for Data.Text In-Reply-To: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> References: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> Message-ID: Hi Titto, On Tue, Sep 29, 2009 at 3:15 AM, Pasqualino "Titto" Assini wrote: > > More in general: what is the right policy for instances definition? > > Should the library author provide them, at least for the most common > and appropriate classes (at the cost of adding some additional > dependencies) ? > > Should they go in a separate package? > > Should the Haskell Platform team provide some guidance on this point > to library authors? > > ? ? ?titto > Thanks for changing the subject, I forgot to do that. I have a similar derivation for a Data.Binary instance, but after looking at Text.Internal, I got the impression that it wasn't as efficient as it could be. But yes, in general this boils down to your questions. I do remember someone asking a similar question perhaps a year or so ago. Now that we have Haskell Platform, does that change anything? In particular, I believe Data.Binary is proposed for inclusion in the platform. Regards, Paulo From cjs at starling-software.com Tue Sep 29 11:35:51 2009 From: cjs at starling-software.com (Curt Sampson) Date: Tue Sep 29 11:13:50 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> Message-ID: <20090929153550.GG24761@analytic.cynic.net> On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona wrote: > Java is part of the Java platform, that brought OS independence and > interoperability at the right time. .Download-execution on the client > was also a reason for the initial success of Java in the Internet era. I was a die-hard Java hacker from 1999 until some undetermined time in the early-to-mid-2000s. (I abandoned it more or less completely sometime around late 2005, if I recall correctly.) This may be somewhat anecdotal evidence, but I disagree with both of your statements here. I've rarely known anybody to use Java cross-platform in a non-trival way, barring a few major GUI-centric projects such as Eclipse. (I've far more cross-platform use of Haskell than Java myself.) And I know of nobody who did anything serious with download-execution of Java. As an example, Amazon and Google are two fairly large companies that use Java extensively in their operations, and neither of them make any significant use of the cross-platform or download-execution abilities of it. They'd do just as well with a language that had a single compiler producing only Unix binaries. > Rubi and Python came with libraries targeted to Rapid development of > Internet applications. No, neither originally "came" with that. Python has never been a big language for web applications (though it's had a few outstanding successes). It has been the source of some very good ideas in the web application framework area (Django introduced some great ideas that were, at best, exceedingly rare when it came out), but those haven't really caught on. (RoR is still missing a lot of wonderful stuff from Django. Heck, even my sad Ruby web framework QWeb has more in certain respects.) Ruby on Rails arrived more than a decade after Ruby was developed, and while it's increased the popularity of the language, that's little to do with Ruby itself. RoR was well described by someone as "the bastard spawn of a PHP programmer and a Web designer." I posit that "it's slightly better than PHP, yet still very accessible to PHP programmers" is the main reason for its popularity. > What is the vehicle that haskell can use to enter the mainstream?. That may be the wrong question. "Avoid success at all costs" still rings true to me. A year or so ago I seemed like one of the few on the haskell-libraries list voting in favour of fixing API problems in libraries, rather than etching in stone those problems in the name of backwards compatibility so that we could "become more popular." Do you really want, in 2020, to look back at the 2010 revision of the Haskell standard and think, "we entrenched things that for a decade everybody agreed was dumb"? I can tell you, even when you're a Java enthusiast, there's nothing more depressing than looking at java.util.Date and thinking, "That should have been immutable, but it's going to be mutable for the rest of eternity. We will never fix that." But let's try this again: > What is the vehicle that haskell can use to enter the mainstream?. Become more stupid. Is that a better answer? I'm not just a geek; I do marketing too (this is what happens when you start your own company), and if you asked me, using the utmost of my technical knowledge and marketing skills, to make Haskell popular, this is what I'd recommend. (I suppose it's a sign of my professionalism that to do this would nearly break my heart, but if you wanted me to tell you the best way to do this, and I couldn't tell you to get lost, that's what I'd say.) > Many people will play with Haskell in the spare time, and many of them > will be permitted to develop some non critical applications at work. > But that is all. Hm. So I suppose that this options trading system I'm working on, which is the sole way our business makes money and is entirely written in Haskell, doesn't actually exist. > I think that all the current niches are filled, but new niches are coming. Haskell already has a good niche. In fact, a brilliant one. We have a whole bunch of academics doing truly wonderful stuff (imagine the world without monads!--thank you Philip Wadler (and Eugenio Moggi)) that the rest of us (relatively) dumb idiots can use to make our lives better. We've got several very good implementations of the language, one of which is a truly shit-hot compiler[1]. And we can use that to do commercial applications quite comfortably[2]. My personal opinion is, yes, let's let Haskell stick to the niche where it's great, but it changes so fast that it's scary to everybody else. To echo Paul Graham, I'm extremely happy to see my competition use Java. [1] Like that's so important. Ruby's standard implementation to this day is an interpreter that implements all the popular extensions and has a reasonably decent FFI. In Haskell-land, we call that "Hugs." It's only because we have GHC as well that we can look down on Hugs; in the Ruby (and Python, and PHP) worlds, they're saying that interpreters are just fine for all sorts of "enterprise applications." [2] (Warning: self-promotion): http://www.starling-software.com/misc/icfp-2009-cjs.pdf > Financial applications are an example of higher level programming > where tasks usually performed by humans are now automatized and there > is no or few traditions about that. The need to think at a higher > level without being worried by side effects and other details are > specially needed in such kind of areas. That's where haskell could > have its own niche. Actually, I think that Haskell has a niche there not because of that sort of thing, but merely because it's better than Java at doing what Java does well, but scary enough that only small groups of brave people who are comfortable with risk would ever attempt to use it. The financial sector happens to have a lot more of those than many others. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From cjs at starling-software.com Tue Sep 29 11:41:10 2009 From: cjs at starling-software.com (Curt Sampson) Date: Tue Sep 29 11:19:09 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> <200909291348.29665.daniel.is.fischer@web.de> Message-ID: <20090929154110.GI24761@analytic.cynic.net> On 2009-09-29 13:47 +0100 (Tue), Iain Barnett wrote: > So, if I was trying to come up with a solution to a problem that > possibly has multiple solutions, like building an engine for a car, I > would do better if I hadn't seen a (well crafted) working engine by > someone else than if I had? Yes, because the work you'd done thinking about it would give you a better understanding of the problem, even if the answer you'd come up with was completely wrong. That said, learning from the good example afterwards is without question extremely valuable. > If effort is there, then give me the example any time, because insight > will be quicker. Actually, I find that for many problems there is no quick insight. The true understanding of the problem comes with struggling with it, rather than mastering it. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com From mpm at alumni.caltech.edu Tue Sep 29 12:09:06 2009 From: mpm at alumni.caltech.edu (Michael Mossey) Date: Tue Sep 29 11:47:20 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: References: <4AC14952.1080606@alumni.caltech.edu> <3kr2c5patc2t0jh6st46ddjbnk8l5s92s6@4ax.com> <86F2CAC4-F732-42F0-B45B-C9528F73B080@gmail.com> <200909291348.29665.daniel.is.fischer@web.de> Message-ID: <4AC23122.4000808@alumni.caltech.edu> Iain Barnett wrote: > > So, if I was trying to come up with a solution to a problem that > possibly has multiple solutions, like building an engine for a car, I > would do better if I hadn't seen a (well crafted) working engine by > someone else than if I had? > > If effort is there, then give me the example any time, because insight > will be quicker. If you're going to be lazy then it doesn't matter > either way. This could be a question of learning styles. You wrote "If the effort is there..." so I assume that means you have a way of putting effort into understanding an engine design, even if you have never seen an engine design before. Furthermore you have some way of digesting and transforming that knowledge so you can make new designs rather than be a slave to imitation. I definitely cannot do this very well. I learn much faster by struggling with a problem so I learn where the "problem" is---what is the key thing I'm trying to do, and why do my efforts seem to fall short? Why do I feel confused? And THEN looking at the answer to get that "aha!" moment. This is especially nice in learning Haskell because solutions tend to be elegant and contain deep insights. Isn't there some saying like: "See and remember for a day. Do and remember for a lifetime." In struggling to answer, a student is not simpling "doing" the problem, but is actually "doing" part of the thinking that led to the creation of Haskell. They are retracing problems and alternative solutions that are in some way related to the history of computer science. Mike From daniel.is.fischer at web.de Tue Sep 29 12:14:43 2009 From: daniel.is.fischer at web.de (Daniel Fischer) Date: Tue Sep 29 11:53:58 2009 Subject: [Haskell-cafe] Doing people's homework? In-Reply-To: References: <4AC14952.1080606@alumni.caltech.edu> <200909291348.29665.daniel.is.fischer@web.de> Message-ID: <200909291814.43382.daniel.is.fischer@web.de> Am Dienstag 29 September 2009 14:47:27 schrieb Iain Barnett: > On 29 Sep 2009, at 12:48, Daniel Fischer wrote: > > Am Dienstag 29 September 2009 13:04:38 schrieb Iain Barnett: > >> Personally, I tend to find "exercises" without access to the answers > >> a poor way to learn. You'll learn more from a well crafted example > >> than you ever will by struggling at something yourself. > > > > I sort of disagree. You'll learn more if you can read a well > > crafted example *after* > > you've struggled to get something good on your own. > > If you start inspecting an example before you've spent considerable > > effort understanding > > the matter on your own, you're likely to miss some important things. > > So, if I was trying to come up with a solution to a problem that > possibly has multiple solutions, like building an engine for a car, I > would do better if I hadn't seen a (well crafted) working engine by > someone else than if I had? I thought we were talking about homework for a school/university course. I tacitly assumed that the principles and some examples would have previously been given in the lectures. Then you're given the homework exercise to build upon those to solve a bigger task. > > If effort is there, then give me the example any time, because > insight will be quicker. But it will be deeper if you explored the matter first without your vision constrained by the example. > If you're going to be lazy then it doesn't matter either way. True. > > > Regards, > Iain From bos at serpentine.com Tue Sep 29 12:24:49 2009 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue Sep 29 12:02:54 2009 Subject: [Haskell-cafe] Instances for Data.Text In-Reply-To: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> References: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> Message-ID: On Tue, Sep 29, 2009 at 1:15 AM, Pasqualino "Titto" Assini < tittoassini@gmail.com> wrote: > > This is a good point, I also need to make Data.Text an instance of a > few basic classes and I am not sure that I did it correctly. > > So far I have: > > import Data.Text > > instance Binary Text where > put = put . encodeUtf8 > get = liftM decodeUtf8 get > Well, independent of the implementation (yours seems fine, by the way), we can't have Platform packages depend on non-Platform packages. The text library isn't in a position to make it ready for inclusion there yet, but it's getting close, and it might even get there before binary. So it's no problem to write an NFData instance, but a Binary instance would be an issue. -- DOUBT: Is this correct also for Data.Text.Lazy ? > instance NFData Text > > instance Serial Text where > -- DOUBT: is this efficient? > series d = [T.pack (series d :: String)] > -- DOUBT: how to define this > coseries rs = error "coseries" > What's Serial? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/199cd22e/attachment.html From lemming at henning-thielemann.de Tue Sep 29 12:35:09 2009 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue Sep 29 12:13:27 2009 Subject: [Haskell-cafe] How to decide if a number is an integer? In-Reply-To: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> References: <3bd412d40909282258x32b4f955n6efa4192632634b1@mail.gmail.com> Message-ID: On Tue, 29 Sep 2009, Magicloud Magiclouds wrote: > Hi, > In other weak-type language, `round i == i` would work. But in > haskell, what should I do? Thanks. Am I right, that you want to check whether a number is a square number? http://www.haskell.org/haskellwiki/Generic_number_type#isSquare From tomahawkins at gmail.com Tue Sep 29 12:58:31 2009 From: tomahawkins at gmail.com (Tom Hawkins) Date: Tue Sep 29 12:36:30 2009 Subject: [Haskell-cafe] ANN: atom-0.1.1 Message-ID: <594c1e830909290958w381e2671nd12998c1f04ca44@mail.gmail.com> Atom is a Haskell DSL for designing hard real-time embedded applications. At Eaton, we use it for automotive control systems. An Atom description is composed of a set of guarded atomic actions that operate on a global program state. Atom makes it easy to manage program concurrency without the need for mutex locking and run-time task scheduling. As such, Atom can eliminate the need and overhead of an RTOS, which traditionally serves these functions. This release includes several improvements to C code generation, including a simplified rule scheduler that consumes less memory and execution time. It also ships with a new unit testing framework that allows the use of assertions and functional coverage points to assist with program verification. http://hackage.haskell.org/package/atom From malcolm.wallace at cs.york.ac.uk Tue Sep 29 12:59:29 2009 From: malcolm.wallace at cs.york.ac.uk (Malcolm Wallace) Date: Tue Sep 29 12:37:33 2009 Subject: [Haskell-cafe] Instances for Data.Text In-Reply-To: References: <2d34474e0909290115s5509a271mf262d1213cfe0771@mail.gmail.com> Message-ID: > instance Serial Text where > -- DOUBT: is this efficient? > series d = [T.pack (series d :: String)] > -- DOUBT: how to define this > coseries rs = error "coseries" > > What's Serial? The class used in SmallCheck, similar to the Arbitrary class used by QuickCheck. Regards, Malcolm From hoknamahn at gmail.com Tue Sep 29 13:40:29 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 29 13:18:27 2009 Subject: [Haskell-cafe] Type synonyms vs standard types Message-ID: Hi everyone, Dumb question about declaring a function and type synonyms. There are to different declarations of the same function: attrNames :: String -> AttrDict -> [String] attrNames :: AttrClass -> AttrDict -> AttrNames First gives you the idea about exact types it expects (except AttrDict for which user has to take a look into the docs or sources) while the second one gives you the idea about meaning of parameters. Both reasons make sense. The question is when which one should be used? I'm using type synonyms everywhere and possibly without too much reasons... Maybe I should stop doing it? :) Cheers, Oleksandr. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/2c0616fd/attachment.html From gabor at karamaan.com Tue Sep 29 13:51:29 2009 From: gabor at karamaan.com (siki) Date: Tue Sep 29 13:29:27 2009 Subject: [Haskell-cafe] Exciting job opportunity Message-ID: <25667801.post@talk.nabble.com> Principal investment firm based in Manhattan is looking for an outstanding software developer to maintain and develop proprietary accounting and portfolio management systems. Job duties will include coding projects as well as management of outsourced system maintenance. Candidates should have at least a bachelor?s degree in computer science from a top university and impeccable coding style. The majority of the programming is done in JAVA at present, so candidates must have extensive experience with JAVA and related technologies but we are always experimenting with the most exciting technologies (e.g. Haskell) and you will be given freedom in choosing suitable programming languages and technologies. Experience working with SQL is a must and familiarity with functional programming is a plus. We are looking for a candidate who shows strong analytical, organizational, and communication skills. Attention to detail is essential. We are a growth oriented firm that values people who take a craftsman?s pride in their work. Candidates must have a desire to constantly improve one's knowledge of programming and the financial markets. A true love of building quality software and a team spirit is strongly recommended. Background in accounting is not necessary but is definitely a plus. This is a high-impact, high-visibility job opportunity where successful candidates will be entrusted with a lot of responsibility for products that have a direct effect on the P&L of the firm and influences our workflow. Please send your CV and cover letter to recruitment@karamaan.com, thank you. -- View this message in context: http://www.nabble.com/Exciting-job-opportunity-tp25667801p25667801.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From douyaxu at gmail.com Tue Sep 29 14:15:48 2009 From: douyaxu at gmail.com (xu zhang) Date: Tue Sep 29 13:53:47 2009 Subject: [Haskell-cafe] double colon equal Message-ID: Hi, is there anyone can tell me what does the ::= mean?And what does the code below mean? expr ::= expr addop term | term Thank you in advance! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/089f536e/attachment.html From ekirpichov at gmail.com Tue Sep 29 14:19:07 2009 From: ekirpichov at gmail.com (Eugene Kirpichov) Date: Tue Sep 29 13:57:10 2009 Subject: [Haskell-cafe] double colon equal In-Reply-To: References: Message-ID: <5e0214850909291119o7288f9f9h6adf4dacffda2d50@mail.gmail.com> google://BNF 2009/9/29 xu zhang : > Hi, is there anyone can tell me what does the ::= mean? > And what does the code below mean? > > expr ::= expr addop term?| term > > Thank you in advance! > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Eugene Kirpichov Web IR developer, market.yandex.ru From seanmcl at gmail.com Tue Sep 29 14:31:40 2009 From: seanmcl at gmail.com (Sean McLaughlin) Date: Tue Sep 29 14:09:37 2009 Subject: [Haskell-cafe] suggestion for hslogger Message-ID: <6579f8680909291131v9481310l41dc63d8938309f5@mail.gmail.com> Hello, I have a program that does a lot of unicode manipulation. I'd like to use hslogger to log various operations. However, since hslogger uses System.IO.putX, the unicode comes out mangled. I hacked the source to use System.IO.UTF8 instead, but it would be nice if that was an option so I don't have to rehack the code whenever there is a new release. Thanks! Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/abd38e60/attachment.html From michael at snoyman.com Tue Sep 29 14:36:13 2009 From: michael at snoyman.com (Michael Snoyman) Date: Tue Sep 29 14:14:11 2009 Subject: [Haskell-cafe] Type synonyms vs standard types In-Reply-To: References: Message-ID: <29bf512f0909291136g5db212fpbfc5edaa0ad43cf1@mail.gmail.com> On Tue, Sep 29, 2009 at 7:40 PM, Olex P wrote: > Hi everyone, > > Dumb question about declaring a function and type synonyms. > There are to different declarations of the same function: > > attrNames :: String -> AttrDict -> [String] > > attrNames :: AttrClass -> AttrDict -> AttrNames > > First gives you the idea about exact types it expects (except AttrDict for > which user has to take a look into the docs or sources) while the second one > gives you the idea about meaning of parameters. > Both reasons make sense. The question is when which one should be used? I'm > using type synonyms everywhere and possibly without too much reasons... > Maybe I should stop doing it? :) > > I like type synonyms. You can always look up what the type synonym boils down to, while the reverse cannot be done. Of course, some Haddock markup can also solve the problem. Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/0335ca46/attachment.html From hectorg87 at gmail.com Tue Sep 29 14:50:46 2009 From: hectorg87 at gmail.com (Hector Guilarte) Date: Tue Sep 29 14:29:04 2009 Subject: [Haskell-cafe] double colon equal In-Reply-To: References: Message-ID: <1136604440-1254250262-cardhu_decombobulator_blackberry.rim.net-970113245-@bda078.bisx.prod.on.blackberry> That expression below Is a part of a Grammar in BNF. It means that an expression is form by an expression, an add operation and a Term or simply just a Term... -----Original Message----- From: xu zhang Date: Tue, 29 Sep 2009 14:15:48 To: Subject: [Haskell-cafe] double colon equal _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From korpios at korpios.com Tue Sep 29 15:13:49 2009 From: korpios at korpios.com (Tom Tobin) Date: Tue Sep 29 14:51:48 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: On Mon, Sep 28, 2009 at 9:50 PM, Hong Yang wrote: > Good libraries are not enough for a language to go beyond mere existence. > There must exist good documents, i.e., good tutorials, good books, and good > explanations and examples in the libraries, etc, that are easy for people to > learn and use. In my humble opinion, Haskell has a lot of libraries, but > most of them offer few examples of how to use the modules. In this regards, > Perl is much much better. This. As an experienced Pythonista but a beginning Haskeller, there is *no way* I would have been able to wrap my head around the basics of Haskell without the tutorage of Learn You A Haskell, Real World Haskell, and various smaller tutorials scattered around the Haskell wiki ??but I still find the array of libraries confusing (just what comes with GHC ??I'm not even talking about Hackage here), since the documentation seems to be quite terse compared to Python's docs. I'm getting better at reading the code directly, but I'm often at a loss for what a particular library is good for in the first place. The library documentation seems to assume a mathematical or (advanced) computer science background, and has no problem sending a reader off to see a journal paper for details ? not exactly friendly to those who are trying their hardest to unlearn their imperative ways as it is. ;-) From andrewcoppin at btinternet.com Tue Sep 29 15:36:24 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Sep 29 15:14:23 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: <4AC261B8.4020902@btinternet.com> Tom Tobin wrote: > This. As an experienced Pythonista but a beginning Haskeller, there > is *no way* I would have been able to wrap my head around the basics > of Haskell without the tutorage of Learn You A Haskell, Real World > Haskell, and various smaller tutorials scattered around the Haskell > wiki ? but I still find the array of libraries confusing (just what > comes with GHC ? I'm not even talking about Hackage here), since the > documentation seems to be quite terse compared to Python's docs. I'm > getting better at reading the code directly, but I'm often at a loss > for what a particular library is good for in the first place. The > library documentation seems to assume a mathematical or (advanced) > computer science background, and has no problem sending a reader off > to see a journal paper for details ? not exactly friendly to those who > are trying their hardest to unlearn their imperative ways as it is. > ;- While some of the stuff that comes with GHC is quite well documented, others are highly under-documented. (As an exercise, go count how many module descriptions say "inspired by the paper by XXX at this URL"...) Admittedly, the System.IO module probably isn't the place to explain what a monad is and write a full tutorial on using them. However, look at (say) Control.Concurrent.STM.TVar. In my copy (GHC 6.10.3) it lacks even type signatures, let alone actual descriptions. Similarly, Parsec has some lovely external documentation (unfortunately as a single giant HTML page), but the Haddock stuff is bare. Now, the operative question (and I'm sure we've debated this one before) is: how do we fix all this? From andrewcoppin at btinternet.com Tue Sep 29 15:41:42 2009 From: andrewcoppin at btinternet.com (Andrew Coppin) Date: Tue Sep 29 15:20:06 2009 Subject: [Haskell-cafe] Library docs glitch In-Reply-To: <4AC261B8.4020902@btinternet.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <4AC261B8.4020902@btinternet.com> Message-ID: <4AC262F6.8000800@btinternet.com> Andrew Coppin wrote: > While some of the stuff that comes with GHC is quite well documented, > others are highly under-documented. (As an exercise, go count how many > module descriptions say "inspired by the paper by XXX at this URL"...) Somewhat related: If I click on Control.Monad.Error, I get... an error. File not found, to be exact. It seems that the Haddock page is expecting this module to be in doc/libraries/ghc-mtl, when it is in fact in doc/libraries/mtl. I don't know if this glitch is Windows-specific, but everything in the ghc-mtl package appears to be broken. (So... most of Control.Monad then.) I have GHC 6.10.3; is this already a known problem? Or is my installation broken somehow? From jgbailey at gmail.com Tue Sep 29 15:50:08 2009 From: jgbailey at gmail.com (Justin Bailey) Date: Tue Sep 29 15:28:25 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> Message-ID: On Sun, Sep 27, 2009 at 12:50 PM, Paul Moore wrote: > The problem is that I have *no idea* how to begin debugging this. In > C, Python, or any other imperative language, I'd put traces in, etc. > But in Haskell, I don't even know where to start. > One of the standard modules is Debug.Trace module, which does allow you to print information to the console. It just may come in an odd order and of course, it can change your program if you force evaluation. Under the covers it is really "unsafePerformIO $ putStrLn msg", i.e., it just prints to the console. I've found that forcing a flush on the output stream can be useful too, so I've defined my own trace before too. There is also the GHC debugger, which is best described in the user manual - read the section there to learn more. If you hadn't already received help on the list, either of these could be used to narrow down where the crash is occurring. Justin From gwern0 at gmail.com Tue Sep 29 16:00:52 2009 From: gwern0 at gmail.com (Gwern Branwen) Date: Tue Sep 29 15:38:52 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <4AC261B8.4020902@btinternet.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <4AC261B8.4020902@btinternet.com> Message-ID: On Tue, Sep 29, 2009 at 3:36 PM, Andrew Coppin wrote: > Tom Tobin wrote: >> >> This. ?As an experienced Pythonista but a beginning Haskeller, there >> is *no way* I would have been able to wrap my head around the basics >> of Haskell without the tutorage of Learn You A Haskell, Real World >> Haskell, and various smaller tutorials scattered around the Haskell >> wiki ? but I still find the array of libraries confusing (just what >> comes with GHC ? I'm not even talking about Hackage here), since the >> documentation seems to be quite terse compared to Python's docs. ?I'm >> getting better at reading the code directly, but I'm often at a loss >> for what a particular library is good for in the first place. ?The >> library documentation seems to assume a mathematical or (advanced) >> computer science background, and has no problem sending a reader off >> to see a journal paper for details ? not exactly friendly to those who >> are trying their hardest to unlearn their imperative ways as it is. >> ;- > > While some of the stuff that comes with GHC is quite well documented, others > are highly under-documented. (As an exercise, go count how many module > descriptions say "inspired by the paper by XXX at this URL"...) > > Admittedly, the System.IO module probably isn't the place to explain what a > monad is and write a full tutorial on using them. However, look at (say) > Control.Concurrent.STM.TVar. In my copy (GHC 6.10.3) it lacks even type > signatures, let alone actual descriptions. Similarly, Parsec has some lovely > external documentation (unfortunately as a single giant HTML page), but the > Haddock stuff is bare. > > Now, the operative question (and I'm sure we've debated this one before) is: > how do we fix all this? As a Wikipedian, my knee-jerk answer is: lower entrance costs! Specifically, in the past I've tried to think of uses for Gitit beyond just the normal wiki stuff. One thing I came up with: - run a Gitit wiki on top of a copy of the base libraries' repos. The actual Haskell files will be displayed as highlighted articles; eg. here's a .lisp file displayed nicely: http://gitit.net/sudoku.lisp People will be able to log in and edit the docs as they please. Every week or so, the edits could be batched up by some sort of hook and emailed to the libraries@haskell.org ML; good edits get applied to the master repo, bad edits get ignored. Another hook periodically deletes patches that don't make it to the master repo. Thanks to the darcs backend and per-article editing, we can have the 'wiki' repo (with all the Front Pages and .conf files one wants for a nice wiki) follow the 'master' repo without running into conflicts. This is nice enough an idea, but we can go further. Even better would be haddocks rebuilt on every edit, so users can edit and see the results immediately*. (You can sort of approximate this locally by working on files in an editor, keeping a cabal-install looping, and refreshing in your browser.) I can't guarantee that this would get people to contribute tips, work-arounds, and examples to the docs, but it seems much more likely to encourage contributions than our current quite arcane system of hidden repos and obscure darcs sends to even more obscure mailing lists. (Wait, you want me to implement this idea instead of just throwing out suggestions? Maybe next week...) * It's not clear to me how to make the built haddocks immediately accessible to an editor of the .hs page. After all, half the point of using Gitit is that it can work with the original repo almost as-is. I have a crazy idea that the Haddock .html can be built and then moved to Talk:sudoku.lisp, but I've no idea whether this would work. I'm not sure Talk: pages of non-article files are even possible. -- gwern From lrpalmer at gmail.com Tue Sep 29 15:58:37 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Sep 29 15:42:57 2009 Subject: [Haskell-cafe] Type synonyms vs standard types In-Reply-To: References: Message-ID: <7ca3f0160909291258h1579adeak9939694734d19328@mail.gmail.com> On Tue, Sep 29, 2009 at 11:40 AM, Olex P wrote: > Hi everyone, > > Dumb question about declaring a function and type synonyms. > There are to different declarations of the same function: > > attrNames :: String -> AttrDict -> [String] > > attrNames :: AttrClass -> AttrDict -> AttrNames > > First gives you the idea about exact types it expects (except AttrDict for > which user has to take a look into the docs or sources) while the second one > gives you the idea about meaning of parameters. > Both reasons make sense. The question is when which one should be used? I'm > using type synonyms everywhere and possibly without too much reasons... > Maybe I should stop doing it? :) I get the impression that it is still largely a matter of style, and the community hasn't reached a consensus. Personally, I don't usually use type synonyms for this purpose. The function name and type are usually enough. Eg in attrNames above it should be clear what's going on: you are taking one AttrDict and one String, so the String is probably a key into the dictionary. The return is a list of Strings, and your function is called "attrNames", so it's probably a list of attr names. In the cases when it is not as obvious, I usually increase the level of abstraction (typechecked documentation) instead of introducing synonyms (un-typechecked documentation). Take for example the function which checks whether a point is inside a bounding box: insideBoundingBox :: Point -> Point -> Point -> Bool I could use synonyms to rename those arguments: insideBoundingBox :: LowerLeftPoint -> UpperRightPoint -> Point -> Bool But I would prefer to introduce a new abstraction: data BoundingBox = BoundingBox { lowerLeft :: Point, upperRight :: Point } insideBoundingBox :: BoundingBox -> Point -> Bool And now the roles of the arguments are clear again. Luke From jvranish at gmail.com Tue Sep 29 16:12:48 2009 From: jvranish at gmail.com (Job Vranish) Date: Tue Sep 29 15:50:46 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <4AC261B8.4020902@btinternet.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <4AC261B8.4020902@btinternet.com> Message-ID: Andrew Coppin wrote: > how do we fix all this? > I think the key here is to reduce the cost of contribution to a minimum. Make it as easy as possible to contribute an example, or to fill in some missing documentation (and to find it later). Cabal and hackage have made it very easy to contribute and fetch packages and I think this is the primary reason why there are so many hackage packages. We need to make it even easier to contribute documentation. I think having some haddock/wiki system that allowed user contributions which could be displayed alongside the official package dos and an easy way for package maintainers to incorporate the user supplied documentation into the official package documentation would be very helpful. To sum up: 1. Make it stupidly easy to contribute documentation, notes, comments, examples 2. Make sure all of this good stuff can be easily accessed in one place. - Job On Tue, Sep 29, 2009 at 3:36 PM, Andrew Coppin wrote: > Tom Tobin wrote: > >> This. As an experienced Pythonista but a beginning Haskeller, there >> is *no way* I would have been able to wrap my head around the basics >> of Haskell without the tutorage of Learn You A Haskell, Real World >> Haskell, and various smaller tutorials scattered around the Haskell >> wiki ? but I still find the array of libraries confusing (just what >> comes with GHC ? I'm not even talking about Hackage here), since the >> documentation seems to be quite terse compared to Python's docs. I'm >> getting better at reading the code directly, but I'm often at a loss >> for what a particular library is good for in the first place. The >> library documentation seems to assume a mathematical or (advanced) >> computer science background, and has no problem sending a reader off >> to see a journal paper for details ? not exactly friendly to those who >> are trying their hardest to unlearn their imperative ways as it is. >> ;- >> > > While some of the stuff that comes with GHC is quite well documented, > others are highly under-documented. (As an exercise, go count how many > module descriptions say "inspired by the paper by XXX at this URL"...) > > Admittedly, the System.IO module probably isn't the place to explain what a > monad is and write a full tutorial on using them. However, look at (say) > Control.Concurrent.STM.TVar. In my copy (GHC 6.10.3) it lacks even type > signatures, let alone actual descriptions. Similarly, Parsec has some lovely > external documentation (unfortunately as a single giant HTML page), but the > Haddock stuff is bare. > > Now, the operative question (and I'm sure we've debated this one before) > is: how do we fix all this? > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/582f2f53/attachment.html From dons at galois.com Tue Sep 29 16:16:54 2009 From: dons at galois.com (Don Stewart) Date: Tue Sep 29 15:57:05 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> Message-ID: <20090929201654.GS17961@whirlpool.galois.com> korpios: > On Mon, Sep 28, 2009 at 9:50 PM, Hong Yang wrote: > > Good libraries are not enough for a language to go beyond mere existence. > > There must exist good documents, i.e., good tutorials, good books, and good > > explanations and examples in the libraries, etc, that are easy for people to > > learn and use. In my humble opinion, Haskell has a lot of libraries, but > > most of them offer few examples of how to use the modules. In this regards, > > Perl is much much better. > > This. As an experienced Pythonista but a beginning Haskeller, there > is *no way* I would have been able to wrap my head around the basics > of Haskell without the tutorage of Learn You A Haskell, Real World > Haskell, and various smaller tutorials scattered around the Haskell > wiki ??but I still find the array of libraries confusing (just what > comes with GHC ??I'm not even talking about Hackage here), since the What comes with GHC is the Haskell Platform these days. Actually, the other way around. GHC comes with the Haskell Platform. http://haskell.org/platform/ The contents of which are specified here: http://haskell.org/platform/contents.html -- Don From hoknamahn at gmail.com Tue Sep 29 16:21:02 2009 From: hoknamahn at gmail.com (Olex P) Date: Tue Sep 29 15:59:00 2009 Subject: [Haskell-cafe] Type synonyms vs standard types In-Reply-To: <7ca3f0160909291258h1579adeak9939694734d19328@mail.gmail.com> References: <7ca3f0160909291258h1579adeak9939694734d19328@mail.gmail.com> Message-ID: This idea with new level of abstraction is good but in some cases it can make things overcomplicated / less efficient. Does that mean "leave simple built-in types as is"? But probably that's all is the matter of habit and style. Thanks guys On Tue, Sep 29, 2009 at 8:58 PM, Luke Palmer wrote: > On Tue, Sep 29, 2009 at 11:40 AM, Olex P wrote: > > Hi everyone, > > > > Dumb question about declaring a function and type synonyms. > > There are to different declarations of the same function: > > > > attrNames :: String -> AttrDict -> [String] > > > > attrNames :: AttrClass -> AttrDict -> AttrNames > > > > First gives you the idea about exact types it expects (except AttrDict > for > > which user has to take a look into the docs or sources) while the second > one > > gives you the idea about meaning of parameters. > > Both reasons make sense. The question is when which one should be used? > I'm > > using type synonyms everywhere and possibly without too much reasons... > > Maybe I should stop doing it? :) > > I get the impression that it is still largely a matter of style, and > the community hasn't reached a consensus. > > Personally, I don't usually use type synonyms for this purpose. The > function name and type are usually enough. Eg in attrNames above it > should be clear what's going on: you are taking one AttrDict and one > String, so the String is probably a key into the dictionary. The > return is a list of Strings, and your function is called "attrNames", > so it's probably a list of attr names. > > In the cases when it is not as obvious, I usually increase the level > of abstraction (typechecked documentation) instead of introducing > synonyms (un-typechecked documentation). Take for example the > function which checks whether a point is inside a bounding box: > > insideBoundingBox :: Point -> Point -> Point -> Bool > > I could use synonyms to rename those arguments: > > insideBoundingBox :: LowerLeftPoint -> UpperRightPoint -> Point -> Bool > > But I would prefer to introduce a new abstraction: > > data BoundingBox = BoundingBox { lowerLeft :: Point, upperRight :: Point } > insideBoundingBox :: BoundingBox -> Point -> Bool > > And now the roles of the arguments are clear again. > > Luke > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/b6d8bd1f/attachment.html From korpios at korpios.com Tue Sep 29 16:26:12 2009 From: korpios at korpios.com (Tom Tobin) Date: Tue Sep 29 16:04:10 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: <20090929201654.GS17961@whirlpool.galois.com> References: <20090927161653.GG1381@poetic.cynic.net> <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <20090929201654.GS17961@whirlpool.galois.com> Message-ID: On Tue, Sep 29, 2009 at 3:16 PM, Don Stewart wrote: > korpios: >> wiki ??but I still find the array of libraries confusing (just what >> comes with GHC ??I'm not even talking about Hackage here), since the > > What comes with GHC is the Haskell Platform these days. > Actually, the other way around. GHC comes with the Haskell Platform. > > ? ?http://haskell.org/platform/ > > The contents of which are specified here: > > ? ?http://haskell.org/platform/contents.html I'm talking about poking around here randomly: http://www.haskell.org/ghc/docs/latest/html/libraries/index.html ... and trying to figure out what a given library does ? not for the sake of selecting it among other options (the Platform idea), but just as part of getting a grip on Haskell's "standard library", as it were. Put another way, I'm doing the opposite of the Platform ??instead of saying "I have requirement X, what library would be the best match?", I'm asking "Hmm, hello library Y, what could I use you for?" From dons at galois.com Tue Sep 29 16:28:53 2009 From: dons at galois.com (Don Stewart) Date: Tue Sep 29 16:09:04 2009 Subject: [Haskell-cafe] Cal, Clojure, Groovy, Haskell, OCaml, etc. In-Reply-To: References: <6787C3FD-1D0E-49C5-A49C-1EE493E072E4@n-brain.net> <4AC1701A.9060103@gmail.com> <20090929201654.GS17961@whirlpool.galois.com> Message-ID: <20090929202853.GV17961@whirlpool.galois.com> korpios: > On Tue, Sep 29, 2009 at 3:16 PM, Don Stewart wrote: > > korpios: > >> wiki ??but I still find the array of libraries confusing (just what > >> comes with GHC ??I'm not even talking about Hackage here), since the > > > > What comes with GHC is the Haskell Platform these days. > > Actually, the other way around. GHC comes with the Haskell Platform. > > > > ? ?http://haskell.org/platform/ > > > > The contents of which are specified here: > > > > ? ?http://haskell.org/platform/contents.html > > I'm talking about poking around here randomly: > > http://www.haskell.org/ghc/docs/latest/html/libraries/index.html > > ... and trying to figure out what a given library does ? not for the > sake of selecting it among other options (the Platform idea), but just > as part of getting a grip on Haskell's "standard library", as it were. > Put another way, I'm doing the opposite of the Platform ??instead of > saying "I have requirement X, what library would be the best match?", > I'm asking "Hmm, hello library Y, what could I use you for?" Oh, indeed. Starting with the aggregated package index is a difficult direction. You might instead want to look up those core packages on Hackage, and read their overview separately: [base] http://hackage.haskell.org/package/base [array] http://hackage.haskell.org/package/array [bytestring] http://hackage.haskell.org/package/bytestring [Cabal] http://hackage.haskell.org/package/Cabal [containers] http://hackage.haskell.org/package/containers [directory] http://hackage.haskell.org/package/directory [editline] http://hackage.haskell.org/package/editline [filepath] http://hackage.haskell.org/package/filepath [haskell98] http://hackage.haskell.org/package/haskell98 [hpc] http://hackage.haskell.org/package/hpc [old-locale] http://hackage.haskell.org/package/old-locale [old-time] http://hackage.haskell.org/package/old-time [packedstring] http://hackage.haskell.org/package/packedstring [pretty] http://hackage.haskell.org/package/pretty [process] http://hackage.haskell.org/package/process [random] http://hackage.haskell.org/package/random [syb] http://hackage.haskell.org/package/syb [template-haskell] http://hackage.haskell.org/package/template-haskel [unix] http://hackage.haskell.org/package/unix [win32] http://hackage.haskell.org/package/Win32 [cgi] http://hackage.haskell.org/package/cgi [fgl] http://hackage.haskell.org/package/fgl [parsec] http://hackage.haskell.org/package/parsec [GLUT] http://hackage.haskell.org/package/GLUT [haskell-src] http://hackage.haskell.org/package/haskell-src [html] http://hackage.haskell.org/package/html [HUnit] http://hackage.haskell.org/package/HUnit [mtl] http://hackage.haskell.org/package/mtl [network] http://hackage.haskell.org/package/network [OpenGL] http://hackage.haskell.org/package/OpenGL [parallel] http://hackage.haskell.org/package/parallel [QuickCheck] http://hackage.haskell.org/package/QuickCheck [regex-base] http://hackage.haskell.org/package/regex-base [regex-compat] http://hackage.haskell.org/package/regex-compat [regex-posix] http://hackage.haskell.org/package/regex-posix [stm] http://hackage.haskell.org/package/stm [time] http://hackage.haskell.org/package/time [xhtml] http://hackage.haskell.org/package/xhtml [zlib] http://hackage.haskell.org/package/zlib [HTTP] http://hackage.haskell.org/package/HTTP I'd welcome input on how to best present all this -- the Haskell Platform gives us a chance to package up the docs in a better format for consumption. From duncan.coutts at googlemail.com Tue Sep 29 15:57:21 2009 From: duncan.coutts at googlemail.com (Duncan Coutts) Date: Tue Sep 29 16:14:41 2009 Subject: [Haskell-cafe] Hackage bug? Autobuild failure on literate source with ignored code blocks. In-Reply-To: <3283f7fe0909281253o78ea779dv31576ef0c5a131b@mail.gmail.com> References: <1254081980.5924.37.camel@desktop> <1254154915.4588.699.camel@localhost> <3283f7fe0909281253o78ea779dv31576ef0c5a131b@mail.gmail.com> Message-ID: <1254254241.4588.1197.camel@localhost> On Mon, 2009-09-28 at 12:53 -0700, John Millikin wrote: > In that case, I'll update my code and the wiki to use an alternative code style. Ok. > On Mon, Sep 28, 2009 at 09:21, Duncan Coutts > wrote: > > Your local Cabal version is older than the one Hackage is using and that > > older version lets haddock (ie ghc) do the pre-processing where as in > > the current version Cabal does the unlitting before running haddock. > > That explains the difference you observe. > > Since Hackage is using an unstable development build of Cabal, I'd > like to force it to use a released version to prevent such an issue > from occurring again. I've added the following line to my .cabal file: > > cabal-version: >= 1.6 && < 1.7 > > However, when testing with Cabal 1.7.3 (which is the version used by > Hackage), I am warned that: > > ------------- > Warning: dbus-core.cabal: This package requires Cabal version: >=1.6 && <1.7 > Distribution quality errors: > This package requires Cabal version: >=1.6 && <1.7 > Note: the public hackage server would reject this package. > ------------- > > Does this mean that it's impossible to require an earlier version of > Cabal in Hackage-published packages? If so, the use of a development > version of Cabal in the auto-build system seems unwise. There's two separate issues. One is whether the package is readable by the later Cabal versions and the other is if it can be built. The hackage server itself must be able to handle the .cabal file. If that .cabal file declares that it cannot be used with a later Cabal version then we cannot do that, and we cannot accept that package on hackage. We need to be able to use later versions of Cabal on hackage than are in general use so that we can add new QA checks etc. The auto-builder is a separate matter. It's widely acknowledged that using a single builder is not a good idea. The new server will allow there to be many build clients and they can run a variety of versions of Cabal. What we really want is to version the package spec separately from the default build system. Upper bounds on the package spec make no sense where as upper bounds on the build system version make some sense sometimes. Duncan From lrpalmer at gmail.com Tue Sep 29 16:48:58 2009 From: lrpalmer at gmail.com (Luke Palmer) Date: Tue Sep 29 16:26:56 2009 Subject: [Haskell-cafe] Type synonyms vs standard types In-Reply-To: References: <7ca3f0160909291258h1579adeak9939694734d19328@mail.gmail.com> Message-ID: <7ca3f0160909291348w2d42fb12kb65feb13eca8c70d@mail.gmail.com> On Tue, Sep 29, 2009 at 2:21 PM, Olex P wrote: > This idea with new level of abstraction is good but in some cases it can > make things overcomplicated / less efficient. Does that mean "leave simple > built-in types as is"? > But probably that's all is the matter of habit and style. Well as far as efficiency, these are typically micro-considerations -- you're talking in terms of cycles. Cross those bridges when you come to them. As with overcomplication, the story is the same as with all abstraction: it's a fine balance between how much work they are to declare, their cognitive benefit, and how many times they are used. Haskell has wonderfully lightweight declarations, so that trade-off favors the new abstraction much more quickly than in other languages. Luke From bugfact at gmail.com Tue Sep 29 16:58:31 2009 From: bugfact at gmail.com (Peter Verswyvelen) Date: Tue Sep 29 16:36:30 2009 Subject: [Haskell-cafe] Re: Strong duck typing / structural subtyping / type class aliases / ??? in Haskell In-Reply-To: References: <20090929073709.EBC7D1753C@Adric.metnet.navy.mil> Message-ID: Yes, the OOHaskell paper blew my mind too, but I still only understood half of it when reading it for the second time (especially the mfix thing was scary :-) Not giving up though ;-) But I wander if the error messages you would get from GHC make it easy to see what is going wrong. It would be great if a library author could somehow customize error reporting too, although I have no idea if that is possible. On Tue, Sep 29, 2009 at 10:03 AM, Alp Mestan wrote: > I had never seen this work, it's just awesome ! > And it only needs few Haskell extensions. > > Is this work deeply documented somewhere except in research papers ? If > not, it could be worth doing, IMO. > > > On Tue, Sep 29, 2009 at 9:37 AM, wrote: > >> >> Alp Mestan wrote: >> > Indeed, OCaml has stuctural polymorphism, it's a wonderful feature. >> > >> > *# let f myobj = myobj#foo "Hi !";; >> > val f : < foo : string -> 'a; .. > -> 'a = * >> >> And Haskell has that too: >> >> > -- This is how we define labels. >> > data Field1 deriving Typeable; field1 = proxy::Proxy Field1 >> > >> > -- This is how record selection looks like. >> > foo f = f # field1 >> >> The inferred type of foo is >> >> *OCamlTutorial> :t foo >> foo :: (HasField (Proxy Field1) r v) => r -> v >> >> It doesn't seem too different from the OCaml's type; the type variable >> r acts as a row type. >> >> The quoted example is the first from many others described in >> http://darcs.haskell.org/OOHaskell/OCamlTutorial.hs >> >> The file quotes at length OCaml's Object tutorial and then >> demonstrates how the OCaml code can be written in Haskell. When it >> comes to objects, structural subtyping, width and depth subtyping, >> etc., Haskell does not seem to miss match compared to OCaml. In >> contrast, Haskell has a few advantages when it comes to coercions >> (one does not have to specify the type to coerce to, as Haskell can >> figure that out). The other files in that directory give many more >> example of encoding C++, Eiffel, OCaml patterns. >> >> > > > -- > Alp Mestan > http://blog.mestan.fr/ > http://alp.developpez.com/ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/7ac4bf0c/attachment.html From aslatter at gmail.com Tue Sep 29 17:51:05 2009 From: aslatter at gmail.com (Antoine Latter) Date: Tue Sep 29 17:29:04 2009 Subject: Fwd: [Haskell-cafe] suggestion for hslogger In-Reply-To: <6579f8680909291131v9481310l41dc63d8938309f5@mail.gmail.com> References: <6579f8680909291131v9481310l41dc63d8938309f5@mail.gmail.com> Message-ID: <694519c50909291451s1d9d9535uc2a663c195b6bfb@mail.gmail.com> Forwarding on to the maintainer, in case he's not on the list. ---------- Forwarded message ---------- From: Sean McLaughlin Date: Tue, Sep 29, 2009 at 1:31 PM Subject: [Haskell-cafe] suggestion for hslogger To: haskell-cafe@haskell.org Hello, ??I have a program that does a lot of unicode manipulation. ?I'd like to use hslogger to log various operations. However, since hslogger uses System.IO.putX, the unicode comes out mangled. ?I hacked the source to use System.IO.UTF8 instead, but it would be nice if that was an option so I don't have to rehack the code whenever there is a new release. Thanks! Sean _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From midfield at gmail.com Tue Sep 29 17:56:14 2009 From: midfield at gmail.com (Ben) Date: Tue Sep 29 17:34:15 2009 Subject: [Haskell-cafe] type class question In-Reply-To: <9157df230909180738m38797aacta2bc94b3631f3be4@mail.gmail.com> References: <9157df230909180738m38797aacta2bc94b3631f3be4@mail.gmail.com> Message-ID: <9157df230909291456u6f9d76ceu753d6f6a6ba0b292@mail.gmail.com> dear haskellers -- i'm trying this question again, in haskell-cafe. i got some responses in haskell-beginners but am looking for more guidance. also, i understand this functionality is encapsulated in the Workflow module in hackage, but i'd like to understand this myself. this email is an (il)literate haskell file. suppose i have class of computations a -> State s b. ?for concreteness, let's say i'm writing a library of on-line statistical summary functions, like > {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances #-} > > module Foo where > > import Control.Monad > import Control.Monad.State > import Control.Monad.State.Class > > data RunningAverageState = S Double Int > > runningAverage :: Double -> State RunningAverageState Double > runningAverage v = do > ? ? ? ? ? ? ? ? ? ?S sum count <- get > ? ? ? ? ? ? ? ? ? ?let nsum = sum + v > ? ? ? ? ? ? ? ? ? ? ? ?ncount = count + 1 > ? ? ? ? ? ? ? ? ? ?put $ S nsum ncount > ? ? ? ? ? ? ? ? ? ?return $ nsum / (fromIntegral ncount) > > test = take 10 $ evalState (mapM runningAverage [1..]) $ S 0 0 test -> [1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5] here "on-line" means that we may be taking data from an intermittant external source, e.g. a data generator IO [Double], say, and want to be able to feed the summarizer datum one-by-one, and produce intermediate summaries. ?also we may want to be able to serialize our computation state (with Data.Binary, say) so that we can resume data collection and summarization later. naturally i want to create some common higher order operations on these primitives, like applying them to a stream of data, or combining them in some way. ?it seems that one would want some kind of type class to define a common interface to them. > class (MonadState s m) => Summarizer s m | m -> s where > ? ? initialState :: s > ? ? runOne :: Double -> m Double > where initialize puts some intial state into the system, and runOne collects and summarizes the next piece of data. ?an instance for runningAverage would look like > instance Summarizer RunningAverageState (State RunningAverageState) where > ? ?initialState = S 0 0 > ? ?runOne = runningAverage but how would i use this, e.g. > --summarizeMany vs = last $ evalState (mapM runOne vs) initialState is not possible as it has an ambiguous type. 1) what am i doing wrong? ?what are the right type class and instance declarations? 2) is there a better way of expressing this kind of "on-line" calculation, perhaps in pure (non-monadic) functions? i tried mapAccumL, but was looking for something a little cleaner. best, ben From ithika at gmail.com Tue Sep 29 18:05:29 2009 From: ithika at gmail.com (Dougal Stanton) Date: Tue Sep 29 17:43:26 2009 Subject: [Haskell-cafe] Debugging Haskell code In-Reply-To: <79990c6b0909271317q4fcbe311g8b788c9c9ac2c456@mail.gmail.com> References: <79990c6b0909271250w2ba52520i6c135ce01774a0e9@mail.gmail.com> <79990c6b0909271317q4fcbe311g8b788c9c9ac2c456@mail.gmail.com> Message-ID: <2d3641330909291505i9d3414h2221bbf36b6e1a22@mail.gmail.com> On Sun, Sep 27, 2009 at 9:17 PM, Paul Moore wrote: > > That's odd, it seems to be saying it's not installed at all! Hmm, no - > I did a cabal install --user (because Vista doesn't let me do > site-wide installs), looks like cabal list doesn't pick up user > installs. > > Hmm, cabal install mersenne-random --user didn't do anything, but > cabal install mersenne-random --user --reinstall did reinstall it, and > now it seems to work. To find out what GHC picks up automatically: $ ghc-pkg list /home/dougal/lib/ghc-6.10.3/./package.conf: Cabal-1.6.0.3, HUnit-1.2.0.3, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), extensible-exceptions-0.1.1.0, filepath-1.1.0.2, (ghc-6.10.3), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1, old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.3, unix-2.3.2.0, xhtml-3000.2.0.1 /home/dougal/.ghc/i386-linux-6.10.3/package.conf: HTTP-4000.0.4, X11-1.4.5, X11-xft-0.3, benchpress-0.2.2.3, cairo-0.10.1, colour-2.3.0, cpphs-1.9, darcs-2.2.1, data-default-0.2, diagrams-0.2, gd-3000.4.0, gio-0.10.1, glib-0.10.1, gtk-0.10.1, hashed-storage-0.3.7, haskeline-0.6.1.6, haskell-src-exts-1.1.4, hscolour-1.15, mmap-0.4.1, soegtk-0.10.1, split-0.1.1, svgcairo-0.10.1, tagsoup-0.6, terminfo-0.2.2.1, terminfo-0.3.0.2, uniplate-1.2.0.3, utf8-string-0.3.4, xmonad-0.8.1, xmonad-contrib-0.8.1, zlib-0.5.0.0, zlib-0.5.2.0 You should get everything hanging about, installed system-wide or in your home directory. I assume this works much the same for Windows. D From joerg.rudnick at t-online.de Tue Sep 29 20:00:50 2009 From: joerg.rudnick at t-online.de (=?UTF-8?B?SsO2cmcgUm9tYW4gUnVkbmljaw==?=) Date: Tue Sep 29 19:39:01 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> Message-ID: <4AC29FB2.2060404@t-online.de> Alberto G. Corona wrote: > Most successful languages spread because they are part of a platform > which solves an IT problem. C was part of Unix, both brougth CPU > independence when this was necessary. Java is part of the Java > platform, that brougth OS independence and interoperability at the > right time. .Download-execution on the client was also a reason for > the initial success of Java in the Internet era. Javascript is part > of the web browser. The .NET languages are part of NET. Rubi and > Pyton came with libraries targeted to Rapid development of Internet > applications. > What is the vehicle that haskell can use to enter the mainstream?. I > think that the mere interest of the ideas in the language is not > enough. Many people will play with Haskell in the spare time, and > many of them will be permitted to develop some non critical > applications at work. But that is all. Java was not designed for the > Internet but it was re-targeted to it because some needed features > where already implemented in Java. Maybe something like that will > happen to Haskell. > > I think that all the current niches are filled, but new niches are > coming. specially with higher level programming that is made on top of > current sorware software infrastructure such are BPM, workflows, more > flexible scientific applicatins, creation of models in business > intelligence, as part of ERPs,.Data mining too. And higuer levels of > netwrok communications( for example, Google Wave robots) etc. I see one additional driver: Once a programming language community grows saturated, its members tend to become fastidious, 'sales people' enter the scene -- look at such Java etc. programmers proud to tell how much money they are making. This impacts the goal structure, 'success' becomes more important than 'doing interesting work' -- in consequence the spectrum of engagement narrows. IMHO, many customers just aren't involved into the language issue, just wanting to get things done -- getting the better conditions, they would not hesitate to adopt Haskell. John Hudak (e.g. see his book) proposed Haskell to be appropriate for the niche of for multimedia programming -- in fact, nowadays Anygma.com (see www.nazooka.com) is active in exactly this field, some quote from their side being interesting. At least, it is quite funny that Haskell (together with Clean & Mercury) after having long to struggle with exactly this issue, now can present the deepest understanding (by Monad & Co.) of IO, concurrency, state stransitions and the like, so for the future, there might be a grain of truth in it. All the time, I am astound in how so few people achieve so much in producing Haskell code! Keeping in mind that there are lots of semiautomatic quality assurance techniques, for which -- though having weaknesses in IDE's and refactoring browsing (how about the Portland hackathon?) -- in some parts (e.g. QuickCheck) plays a leading role. To me, Haskell seems to have proved one very important thing: To have emancipated programming from the highly industrialized mass production process focused upon huge organization and their hierarchy pyramids (with, usually, the coder at its base). It emancipated code (== Haskell (, although not Coq)) to serve as highest level of intellectual presentation -- what I want to say is people have some joy in expressing their special knowledge in a Haskell library. I am very interested what will happen if the parcours of competition will change from massively repeated but principally simple processes (shops, business portals, communities, maybe even ERP...) to less repetitive structures -- and inhowfar non-functional programming will become a pain then -- is that what you mean? > About the last point, sometimes a basically identical infrastructure > is re-engineered to a higher level, and a new language takes over. For > example, the architecture of many Internet applications in the 80s > was client-server based, where C, C++ was the king. This was > substituted by the web architecture with Java because Java was > involved in the gradual change by filling the holes of the new > architecture. It could be that in a few years, instead of Web sites > people could develop interoperable gadgets for aggregators such are > netvibes or IGoogle or, even more radical, robots and gadgets in > google Wave. Anyway, for sure, people will think and develop at a > higher level. > Financial applications are an example of higher level programming > where tasks usually performed by humans are now automatized and there > is no or few traditions about that. The need to think at a higher > level without being worried by side effects and other details are > specially needed in such kind of areas. That's where haskell could > have its own niche. This reminds me of the whole agent thing -- pretty much dominated by Java (e.g., Jade, Jason, Jack) nowadays --, for which I would bet lots things are done more straigthforward using Haskell -- especially those parts the Java coders are usually proud of... Let's maybe speak of *second order scalability*: As first order scalability would rather be a matter in space time load increased by repetitions, the concern of second order scalability would be more about a *fractal* expansion of concepts like a *closure* -- Haskell, already in a vivid exchange with interactive theorem proving (e.g. Coq adopts type classes from Haskell and dependent types vice versa) seems excellently prepared... :-) I ever tended to say financial applications are especially prone to be boring -- the prototype of repetitive IT, even for strategy the stupid 'traffic lights cockpits' or OLAP(!) ... But this problem is rather supply driven to me. Going into business with Haskell means two things to me: o communication: To many Haskellers this will mean going to people they just would not have met otherway and finding out inhowfar it's possible to build up a constructive relationship with those. This is emphasized for instance by the *XP / agile process* which harmonizes very well with Haskell. o experience: Once having begun, I bet Haskellers -- and the Haskell code base -- will learn at a fast pace. Outing myself, I admit I am using tools like HaRe, Yi, Leksah & the Eclipse plugin too seldom to allow my self doing contributions. Once these tools are in stronger use I expect them to evolve at a very fast pace. Under the bottom line, entering the medium sized project market with Haskell should be regarded as a matter of months, not years. ;-) All the best, Nick > > Regards > > 2009/9/29 J?rg Roman Rudnick > > > These problems are critical -- but not hopeless, I think: > > (1) A simple technical matter, any average Haskell programmer > (including myself...) can build a platform, e.g. in Happstack or > the like, to clear this up (given you want to do this in Haskell ;-). > > (4) This is a special one, which I have pondered on some time ago. > The customers' main concern seems to be "will this company still > support me in n years??" > o if the project is interesting enough, I see hope there might > be some academic unit willing to partake in this, as I have heard > enough complaint of not having enough examples to demonstrate > business relevance to students. Normally, the customer should have > no problem in believing an academic unit and its interests to last > some time. > o I would propose to pick up the insourcing concept -- as, what > I can confirm by my own teaching experiences, it sometimes is > easier to introduce Haskell to beginners (once the do have > sufficient OS experience) then to people who already are adherents > of some other language. Ok, we might need some more introductory > literature etc. > > (3) Yes, there seem to be lots of people organized at a smaller > level than what I described -- groups of one or very few members, > working on a limited time range. > > Yesterday, I would have written there should be remarkable > interest in greater projects, but, due to the poor resonance to my > mail, I feel wary to do so now. > > (3)&(2) Such a reserved reaction might indicate many Haskellers > are not motivated by the money but by the fame, and -- as the > lively succJava thread shows -- what could be greater fame > (besides the evaluation of 42) than stealing the Java etc. > community just another attractive project? ;-)) > > Do I go wrong in saying there's a good deal of competitive spirit > in the Haskell community interesting in taking claims away of > other programming cultures which have grown saturated over the > years? And, isn't the this *Haskeller bonus* indicating that doing > the step to larger project should not be as hard as for others? > > A remaining issue might be a need for some facility to find > cooperations and realize synergies -- see (1). > > Enough blah-blah. I got one email response (not posted to here) of > a highly qualified Haskeller whom I could name two projects which > might have interested him in his proximity, 80 miles and 75 miles > away (and I do not have so many...). My learning is that a > communication platform in this concern might be interesting to at > least some of us. There are larger projects possible -- if we pick > them up. > > > All the best, > > Nick > > > > John A. De Goes wrote: >> >> It's very difficult to find information on: >> >> 1. How many Haskell developers are out there; >> 2. What a typical salary is for a Haskell developer; >> 3. Whether or not the skills of a typical Haskell developer >> scale to large applications (most Haskell developers are >> "hobby" Haskellers and have only written tiny to small >> Haskell apps); >> 4. How many shops are capable of handling Haskell development >> & maintenance. >> >> >> These are the kinds of information one needs to make an informed >> decision about whether to introduce Haskell into the workplace. >> >> Regards, >> >> John A. De Goes >> N-Brain, Inc. >> The Evolution of Collaboration > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/d19d1423/attachment.html From caseyh at istar.ca Tue Sep 29 20:24:44 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Tue Sep 29 20:02:38 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. Message-ID: I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. If this is true, it needs to be pushed. And if by changing a few lines of source code one can develop a whole family of similar applications, that needs to be pushed, also. :) -- Regards, Casey From dagit at codersbase.com Tue Sep 29 21:19:08 2009 From: dagit at codersbase.com (Jason Dagit) Date: Tue Sep 29 20:57:05 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: Message-ID: On Tue, Sep 29, 2009 at 5:24 PM, Casey Hawthorne wrote: > I read somewhere that for 90% of a wide class of computing problems, > you only need 10% of the source code in Haskell, that you would in an > imperative language. > > If this is true, it needs to be pushed. > > And if by changing a few lines of source code one can develop a whole > family of similar applications, that needs to be pushed, also. > If you look through the archives here and elsewhere on the net, I think you'll see that technical superiority isn't the driving force for language adoption. It can help, but other factors seem to play a more significant role, usually dependent on context in which the languages became popular. At times it can seem like luck, but then I'm reminded of what Louis Pasteur said about luck and prepared minds. It is good that you're talking about Haskell though. Continue to discuss it with your peers and show them fun and cool things you've written using Haskell. I think this is more compelling for the uninitiated than statements about perceived technical power of the language. I've heard people explain this as, "showing is better than telling." Cheers, Jason -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090929/ecfa07a8/attachment.html From joerg.rudnick at t-online.de Tue Sep 29 21:29:19 2009 From: joerg.rudnick at t-online.de (=?UTF-8?B?SsO2cmcgUm9tYW4gUnVkbmljaw==?=) Date: Tue Sep 29 21:07:19 2009 Subject: [Haskell-cafe] Market Place for Haskell development teams? In-Reply-To: <4AC29FB2.2060404@t-online.de> References: <404396ef0909140746g6deb29aeic90ed2a1e14fee30@mail.gmail.com> <9d4d38820909280520w2eaa340doa65a5a2c1c190f1b@mail.gmail.com> <4AC0B399.8080105@t-online.de> <6431B928-5F7A-4CD6-93D4-D3ED6D79B15B@n-brain.net> <4AC1D804.7060608@t-online.de> <4AC29FB2.2060404@t-online.de> Message-ID: <4AC2B46F.8010905@t-online.de> SORRY... it's *far after midnight* here... of course: Paul Hudak: http://cs-www.cs.yale.edu/homes/hudak-paul/ From caseyh at istar.ca Tue Sep 29 21:36:06 2009 From: caseyh at istar.ca (Casey Hawthorne) Date: Tue Sep 29 21:14:00 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: References: Message-ID: <3ad5c5hi6r1nka2uee5221k5bcvlbf6jei@4ax.com> On Tue, 29 Sep 2009 18:19:08 -0700, you wrote: >On Tue, Sep 29, 2009 at 5:24 PM, Casey Hawthorne wrote: > >> I read somewhere that for 90% of a wide class of computing problems, >> you only need 10% of the source code in Haskell, that you would in an >> imperative language. >> >> If this is true, it needs to be pushed. >> >> And if by changing a few lines of source code one can develop a whole >> family of similar applications, that needs to be pushed, also. >> > >If you look through the archives here and elsewhere on the net, I think >you'll see that technical superiority isn't the driving force for language >adoption. It can help, but other factors seem to play a more significant >role, usually dependent on context in which the languages became popular. >At times it can seem like luck, but then I'm reminded of what Louis Pasteur >said about luck and prepared minds. > >It is good that you're talking about Haskell though. Continue to discuss it >with your peers and show them fun and cool things you've written using >Haskell. I think this is more compelling for the uninitiated than >statements about perceived technical power of the language. I've heard >people explain this as, "showing is better than telling." > >Cheers, >Jason Hmmmmmmm! Like those people that are paid to go into coffee houses with some new technology, and then people see what they're doing and wander over and ask them questions about it. >"showing is better than telling." It's even being used by marketers/sellers. :) -- Regards, Casey From pumpkingod at gmail.com Tue Sep 29 21:39:17 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Sep 29 21:17:14 2009 Subject: [Haskell-cafe] I read somewhere that for 90% of a wide class of computing problems, you only need 10% of the source code in Haskell, that you would in an imperative language. In-Reply-To: <3ad5c5hi6r1nka2uee5221k5bcvlbf6jei@4ax.com> References: <3ad5c5hi6r1nka2uee5221k5bcvlbf6jei@4ax.com> Message-ID: We should have GHC 6.12 launch parties like the Windows 7 ones ;) (if you haven't seen it, and are feeling masochistic: http://www.youtube.com/watch?v=1cX4t5-YpHQ) Dan On Tue, Sep 29, 2009 at 9:36 PM, Casey Hawthorne wrote: > On Tue, 29 Sep 2009 18:19:08 -0700, you wrote: > >>On Tue, Sep 29, 2009 at 5:24 PM, Casey Hawthorne wrote: >> >>> I read somewhere that for 90% of a wide class of computing problems, >>> you only need 10% of the source code in Haskell, that you would in an >>> imperative language. >>> >>> If this is true, it needs to be pushed. >>> >>> And if by changing a few lines of source code one can develop a whole >>> family of similar applications, that needs to be pushed, also. >>> >> >>If you look through the archives here and elsewhere on the net, I think >>you'll see that technical superiority isn't the driving force for language >>adoption. ?It can help, but other factors seem to play a more significant >>role, usually dependent on context in which the languages became popular. >>At times it can seem like luck, but then I'm reminded of what Louis Pasteur >>said about luck and prepared minds. >> >>It is good that you're talking about Haskell though. ?Continue to discuss it >>with your peers and show them fun and cool things you've written using >>Haskell. ?I think this is more compelling for the uninitiated than >>statements about perceived technical power of the language. ?I've heard >>people explain this as, "showing is better than telling." >> >>Cheers, >>Jason > > Hmmmmmmm! > > Like those people that are paid to go into coffee houses with some new > technology, and then people see what they're doing and wander over and > ask them questions about it. > >>"showing is better than telling." > > It's even being used by marketers/sellers. > > :) > -- > Regards, > Casey > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dnmehay at gmail.com Tue Sep 29 22:43:30 2009 From: dnmehay at gmail.com (DNM) Date: Tue Sep 29 22:21:28 2009 Subject: [Haskell-cafe] Problem with result-type context restrictions in typeclasses. Message-ID: N.B. I'm a newbie to Haskell, and this problem is a bit complex, so bear with me. I'm using typeclasses to implement a sort of common interface for all things -- call them things of type 'Cls' -- that can be expected to implement a set of functions -- an 'interface' in OOP-speak. (Yes, yes, I'm aware that typeclasses are subtly different and far superior, but my Haskell-ese is still a bit rudimentary.) Essentially, I want to have a typeclass that expects its instances to have an accessor function that results in something that is an instance of another typeclass whose instances can perform some operation. The ghc type-checker doesn't seem to like my code, though, and I can't seem to figure out why. To make it concrete, I've typed up some dummy typeclasses and a dummy function that uses their instances to illustrate what I mean, as well as the form of the ghc(i) error. ------------- BEGIN CODE ------------------ class Cls c where foo :: (Bar b) => c -> b class Bar b where toNum :: b -> Int -- | One implementation of Cls data D = D {fu :: FU} data FU = FU {num :: Int} instance Cls D where foo = fu instance Bar FU where toNum f = (num f) + 47 -- | Another implementation of Cls data E = E {fi :: FI} data FI = FI {nuum :: Int} instance Cls E where foo = fi instance Bar FI where toNum f = (nuum f) + 100 -- | Yet another (this one re-uses FI) data F = F {fii :: FI} instance Cls F where foo = fii -- | And one last one, just to stress that -- I really need to implement multiple -- instances of Cls. data G = G {fuu :: FU} instance Cls G where foo = fuu -- | Good. Now, the function 'useThisStuff' need -- not know anything about it's payload -- other than that it its args are Cls's -- (hence they are foo'able things that -- can be used to construct an Int answer). useThisStuff :: (Cls x, Cls y) => x -> y -> Int useThisStuff x y = (toNum $ foo x) + (toNum $ foo y) ------------- END CODE -------------------- When I type this up in a file and try to load it in ghci, I get the following error message(s): ------------- BEGIN ERROR MSG ---------- Prelude> :load Typeclasses.hs [1 of 1] Compiling Typeclasses ( Typeclasses.hs, interpreted ) Typeclasses.hs:14:10: Couldn't match expected type `b' against inferred type `FU' `b' is a rigid type variable bound by the type signature for `foo' at Typeclasses.hs:4:16 Expected type: D -> b Inferred type: D -> FU In the expression: fu In the definition of `foo': foo = fu Typeclasses.hs:23:10: Couldn't match expected type `b' against inferred type `FI' `b' is a rigid type variable bound by the type signature for `foo' at Typeclasses.hs:4:16 Expected type: E -> b Inferred type: E -> FI In the expression: fi In the definition of `foo': foo = fi Typeclasses.hs:31:10: Couldn't match expected type `b' against inferred type `FI' `b' is a rigid type variable bound by the type signature for `foo' at Typeclasses.hs:4:16 Expected type: F -> b Inferred type: F -> FI In the expression: fii In the definition of `foo': foo = fii Typeclasses.hs:39:10: Couldn't match expected type `b' against inferred type `FU' `b' is a rigid type variable bound by the type signature for `foo' at Typeclasses.hs:4:16 Expected type: G -> b Inferred type: G -> FU In the expression: fuu In the definition of `foo': foo = fuu Failed, modules loaded: none. ------------- END ERROR MSG ------------ It seems that ghc doesn't like the fact that I am saying 'foo' must return a class 'b' of typeclass 'Bar', while providing a function that returns a concrete data instance of 'Bar' (viz., FU or FI) later on when I implement 'foo' in each type classes. Repeated for convenience: class Cls c where foo :: (Bar b) => c -> b ... -- (e.g.) data G = G {fuu :: FU} instance Cls G where foo = fuu Does anyone have any clue as to what I'm doing wrong (language extensions that I may need, etc.)? Is is because I'm using context restrictions on the *result* type of a typeclass method? I've written other typeclasses with methods that say, essentially: class A a where blah :: (MonadPlus m) => a -> a -> m a with no issues. The restriction there is not on the return type a, but rather on some monadic 'wrapper' around it. This may be why that code works. Please advise. Any help is greatly appreciated. --D.N. (Dennis) From dnmehay at gmail.com Tue Sep 29 22:48:06 2009 From: dnmehay at gmail.com (DNM) Date: Tue Sep 29 22:26:03 2009 Subject: [Haskell-cafe] Re: Problem with result-type context restrictions in typeclasses. In-Reply-To: References: Message-ID: <0497b0ee-3024-4c26-a3a6-3959e5cb3081@j9g2000vbp.googlegroups.com> Correction by the author: > It seems that ghc doesn't like the fact that I am saying 'foo' must > return a class 'b' of typeclass 'Bar', while providing a function that > returns a concrete data instance of 'Bar' (viz., FU or FI) later on > when I implement 'foo' in each type classes. Should read: It seems that ghc doesn't like the fact that I am saying 'foo' must return something of TYPE 'b' implementing typeclass 'Bar', while providing a function that returns a concrete data instance of 'Bar' (viz., FU or FI) later on when I implement 'foo' in each type classes. On Sep 29, 10:43?pm, DNM wrote: > N.B. I'm a newbie to Haskell, and this problem is a bit complex, so > bear with me. > > I'm using typeclasses to implement a sort of common interface for all > things -- call them things of type 'Cls' -- that can be expected to > implement a set of functions -- an 'interface' in OOP-speak. ?(Yes, > yes, I'm aware that typeclasses are subtly different and far superior, > but my Haskell-ese is still a bit rudimentary.) > > Essentially, I want to have a typeclass that expects its instances to > have an accessor function that results in something that is an > instance of another typeclass whose instances can perform some > operation. ? The ghc type-checker doesn't seem to like my code, > though, and I can't seem to figure out why. > > To make it concrete, I've typed up some dummy typeclasses and a dummy > function that uses their instances to illustrate what I mean, as well > as the form of the ghc(i) error. > > ------------- BEGIN CODE ------------------ > class Cls c where > ? ? foo :: (Bar b) => c -> b > > class Bar b where > ? ? toNum :: b -> Int > > -- | One implementation of Cls > data D = D {fu :: FU} > data FU = FU {num :: Int} > > instance Cls D where > ? ? foo = fu > instance Bar FU ?where > ? ? toNum f = (num f) + 47 > > -- | Another implementation of Cls > data E = E {fi :: FI} > data FI = FI {nuum :: Int} > > instance Cls E where > ? ? foo = fi > instance Bar FI where > ? ? toNum f = (nuum f) + 100 > > -- | Yet another (this one re-uses FI) > data F = F {fii :: FI} > > instance Cls F where > ? ? foo = fii > > -- | And one last one, just to stress that > -- ? I really need to implement multiple > -- ?instances of Cls. > data G = G {fuu :: FU} > > instance Cls G where > ? ? foo = fuu > > -- | Good. Now, the function 'useThisStuff' need > -- ? not know anything about it's payload > -- ? other than that it its args are Cls's > -- ? (hence they are foo'able things that > -- ? can be used to construct an Int answer). > useThisStuff :: (Cls x, Cls y) => x -> y -> Int > useThisStuff x y = > ? ? (toNum $ foo x) + (toNum $ foo y) > ------------- END CODE -------------------- > > When I type this up in a file and try to load it in ghci, I get the > following error message(s): > > ------------- BEGIN ERROR MSG ---------- > Prelude> :load Typeclasses.hs > [1 of 1] Compiling Typeclasses ? ? ?( Typeclasses.hs, interpreted ) > > Typeclasses.hs:14:10: > ? ? Couldn't match expected type `b' against inferred type `FU' > ? ? ? `b' is a rigid type variable bound by > ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 > ? ? ? Expected type: D -> b > ? ? ? Inferred type: D -> FU > ? ? In the expression: fu > ? ? In the definition of `foo': foo = fu > > Typeclasses.hs:23:10: > ? ? Couldn't match expected type `b' against inferred type `FI' > ? ? ? `b' is a rigid type variable bound by > ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 > ? ? ? Expected type: E -> b > ? ? ? Inferred type: E -> FI > ? ? In the expression: fi > ? ? In the definition of `foo': foo = fi > > Typeclasses.hs:31:10: > ? ? Couldn't match expected type `b' against inferred type `FI' > ? ? ? `b' is a rigid type variable bound by > ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 > ? ? ? Expected type: F -> b > ? ? ? Inferred type: F -> FI > ? ? In the expression: fii > ? ? In the definition of `foo': foo = fii > > Typeclasses.hs:39:10: > ? ? Couldn't match expected type `b' against inferred type `FU' > ? ? ? `b' is a rigid type variable bound by > ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 > ? ? ? Expected type: G -> b > ? ? ? Inferred type: G -> FU > ? ? In the expression: fuu > ? ? In the definition of `foo': foo = fuu > Failed, modules loaded: none. > ------------- END ERROR MSG ------------ > > It seems that ghc doesn't like the fact that I am saying 'foo' must > return a class 'b' of typeclass 'Bar', while providing a function that > returns a concrete data instance of 'Bar' (viz., FU or FI) later on > when I implement 'foo' in each type classes. ?Repeated for > convenience: > > class Cls c where > ? ? foo :: (Bar b) => c -> b > ... > -- (e.g.) > data G = G {fuu :: FU} > instance Cls G where > ? ? foo = fuu > > Does anyone have any clue as to what I'm doing wrong (language > extensions that I may need, etc.)? > > Is is because I'm using context restrictions on the *result* type of a > typeclass method? ?I've written other typeclasses with methods that > say, essentially: > > class A a where > ? ? blah :: (MonadPlus m) => a -> a -> m a > > with no issues. The restriction there is not on the return type a, but > rather on some monadic 'wrapper' around it. ?This may be why that code > works. > > Please advise. ?Any help is greatly appreciated. > > --D.N. (Dennis) > _______________________________________________ > Haskell-Cafe mailing list > Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe From pumpkingod at gmail.com Tue Sep 29 22:58:40 2009 From: pumpkingod at gmail.com (Daniel Peebles) Date: Tue Sep 29 22:36:36 2009 Subject: [Haskell-cafe] Re: Problem with result-type context restrictions in typeclasses. In-Reply-To: <0497b0ee-3024-4c26-a3a6-3959e5cb3081@j9g2000vbp.googlegroups.com> References: <0497b0ee-3024-4c26-a3a6-3959e5cb3081@j9g2000vbp.googlegroups.com> Message-ID: In your class, you have: class Cls c where foo :: (Bar b) => c -> b There's an implicit forall for b, meaning that the caller of the method gets to choose what it wants for b (as long as it's an instance of Bar). For you to be able to write such a method you'd need to write functions that can return any instance of Bar. One solution to this is to turn on the GHC extension -XTypeFamilies, and then modify your code as follows: class Cls c where type Ret c :: * -- or a better name foo :: c -> Ret c instance Cls G where type Ret G = FU foo = fuu That should work (although I haven't tested it). What type families do in this case is allow you to write not only methods associated with typeclasses, but type functions associated with them too. In this case you can think of Ret as a function that takes a type (G in the instance above) and returns another type (FU). Each instance can define new mappings for Ret. Hope this helps! Dan On Tue, Sep 29, 2009 at 10:48 PM, DNM wrote: > Correction by the author: > >> It seems that ghc doesn't like the fact that I am saying 'foo' must >> return a class 'b' of typeclass 'Bar', while providing a function that >> returns a concrete data instance of 'Bar' (viz., FU or FI) later on >> when I implement 'foo' in each type classes. > > Should read: > > It seems that ghc doesn't like the fact that I am saying 'foo' must > return something of TYPE 'b' implementing typeclass 'Bar', while > providing > a function that returns a concrete data instance of 'Bar' (viz., FU or > FI) > later on when I implement 'foo' in each type classes. > > On Sep 29, 10:43?pm, DNM wrote: >> N.B. I'm a newbie to Haskell, and this problem is a bit complex, so >> bear with me. >> >> I'm using typeclasses to implement a sort of common interface for all >> things -- call them things of type 'Cls' -- that can be expected to >> implement a set of functions -- an 'interface' in OOP-speak. ?(Yes, >> yes, I'm aware that typeclasses are subtly different and far superior, >> but my Haskell-ese is still a bit rudimentary.) >> >> Essentially, I want to have a typeclass that expects its instances to >> have an accessor function that results in something that is an >> instance of another typeclass whose instances can perform some >> operation. ? The ghc type-checker doesn't seem to like my code, >> though, and I can't seem to figure out why. >> >> To make it concrete, I've typed up some dummy typeclasses and a dummy >> function that uses their instances to illustrate what I mean, as well >> as the form of the ghc(i) error. >> >> ------------- BEGIN CODE ------------------ >> class Cls c where >> ? ? foo :: (Bar b) => c -> b >> >> class Bar b where >> ? ? toNum :: b -> Int >> >> -- | One implementation of Cls >> data D = D {fu :: FU} >> data FU = FU {num :: Int} >> >> instance Cls D where >> ? ? foo = fu >> instance Bar FU ?where >> ? ? toNum f = (num f) + 47 >> >> -- | Another implementation of Cls >> data E = E {fi :: FI} >> data FI = FI {nuum :: Int} >> >> instance Cls E where >> ? ? foo = fi >> instance Bar FI where >> ? ? toNum f = (nuum f) + 100 >> >> -- | Yet another (this one re-uses FI) >> data F = F {fii :: FI} >> >> instance Cls F where >> ? ? foo = fii >> >> -- | And one last one, just to stress that >> -- ? I really need to implement multiple >> -- ?instances of Cls. >> data G = G {fuu :: FU} >> >> instance Cls G where >> ? ? foo = fuu >> >> -- | Good. Now, the function 'useThisStuff' need >> -- ? not know anything about it's payload >> -- ? other than that it its args are Cls's >> -- ? (hence they are foo'able things that >> -- ? can be used to construct an Int answer). >> useThisStuff :: (Cls x, Cls y) => x -> y -> Int >> useThisStuff x y = >> ? ? (toNum $ foo x) + (toNum $ foo y) >> ------------- END CODE -------------------- >> >> When I type this up in a file and try to load it in ghci, I get the >> following error message(s): >> >> ------------- BEGIN ERROR MSG ---------- >> Prelude> :load Typeclasses.hs >> [1 of 1] Compiling Typeclasses ? ? ?( Typeclasses.hs, interpreted ) >> >> Typeclasses.hs:14:10: >> ? ? Couldn't match expected type `b' against inferred type `FU' >> ? ? ? `b' is a rigid type variable bound by >> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >> ? ? ? Expected type: D -> b >> ? ? ? Inferred type: D -> FU >> ? ? In the expression: fu >> ? ? In the definition of `foo': foo = fu >> >> Typeclasses.hs:23:10: >> ? ? Couldn't match expected type `b' against inferred type `FI' >> ? ? ? `b' is a rigid type variable bound by >> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >> ? ? ? Expected type: E -> b >> ? ? ? Inferred type: E -> FI >> ? ? In the expression: fi >> ? ? In the definition of `foo': foo = fi >> >> Typeclasses.hs:31:10: >> ? ? Couldn't match expected type `b' against inferred type `FI' >> ? ? ? `b' is a rigid type variable bound by >> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >> ? ? ? Expected type: F -> b >> ? ? ? Inferred type: F -> FI >> ? ? In the expression: fii >> ? ? In the definition of `foo': foo = fii >> >> Typeclasses.hs:39:10: >> ? ? Couldn't match expected type `b' against inferred type `FU' >> ? ? ? `b' is a rigid type variable bound by >> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >> ? ? ? Expected type: G -> b >> ? ? ? Inferred type: G -> FU >> ? ? In the expression: fuu >> ? ? In the definition of `foo': foo = fuu >> Failed, modules loaded: none. >> ------------- END ERROR MSG ------------ >> >> It seems that ghc doesn't like the fact that I am saying 'foo' must >> return a class 'b' of typeclass 'Bar', while providing a function that >> returns a concrete data instance of 'Bar' (viz., FU or FI) later on >> when I implement 'foo' in each type classes. ?Repeated for >> convenience: >> >> class Cls c where >> ? ? foo :: (Bar b) => c -> b >> ... >> -- (e.g.) >> data G = G {fuu :: FU} >> instance Cls G where >> ? ? foo = fuu >> >> Does anyone have any clue as to what I'm doing wrong (language >> extensions that I may need, etc.)? >> >> Is is because I'm using context restrictions on the *result* type of a >> typeclass method? ?I've written other typeclasses with methods that >> say, essentially: >> >> class A a where >> ? ? blah :: (MonadPlus m) => a -> a -> m a >> >> with no issues. The restriction there is not on the return type a, but >> rather on some monadic 'wrapper' around it. ?This may be why that code >> works. >> >> Please advise. ?Any help is greatly appreciated. >> >> --D.N. (Dennis) >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From drcygnus at gmail.com Wed Sep 30 00:35:31 2009 From: drcygnus at gmail.com (Jonathan Daugherty) Date: Wed Sep 30 00:13:30 2009 Subject: [Haskell-cafe] ANNOUNCE: vty-ui 0.1 Message-ID: <20090930043530.GA31155@janrain.com> vty-ui is: An extensible library of user interface widgets for composing and laying out Vty user interfaces. This library provides a collection of widgets and a type class for rendering widgets to Vty Images. Get it from Hackage: http://hackage.haskell.org/package/vty-ui Or get the source with darcs: http://repos.codevine.org/vty-ui This package is motivated by the desire to create terminal user interfaces easily without having to worry about doing all of the structural book-keeping that so often comes with such an approach. Future releases will probably include more widget composition tools, more interesting widgets, and helper code for building interesting things. For now, the library contains some basic widgets (including horizontal and vertical box layout) and a List widget. See the vty-ui-demo program and source for an interactive demonstration of the available widgets. Future releases may also address performance, as I honestly don't have a very clear idea of how well my approach is going to scale for non-trivial interfaces. Please don't hesitate to send patches, feedback, and criticism directly to me at drcygnus AT gmail DOT com. Lastly, thanks a ton to the authors of Vty. It's a pleasure to use. Enjoy! -- Jonathan Daugherty From wren at freegeek.org Wed Sep 30 00:47:15 2009 From: wren at freegeek.org (wren ng thornton) Date: Wed Sep 30 00:25:14 2009 Subject: [Haskell-cafe] Type synonyms vs standard types In-Reply-To: References: <7ca3f0160909291258h1579adeak9939694734d19328@mail.gmail.com> Message-ID: <4AC2E2D3.4010002@freegeek.org> Olex P wrote: > This idea with new level of abstraction is good but in some cases it can > make things overcomplicated / less efficient. Does that mean "leave simple > built-in types as is"? That's what newtypes are for. A newtype is like a type alias, except that it is type checked. All newtype wrappering/unwrappering is compiled away so the representations are the same. The only performance difference is (== should be) that there can be overhead for strange ways of providing typeclass instances.[1] [1] By "strange ways" of providing typeclass instances I mean things like using class Peano p where ... data Z = Z newtype S n = S n instance Peano Z where ... instance Peano n => Peano (S n) where ... instead of a straightforward data ZorS = Z | S Peano instance Peano ZorS where ... Because of the newtype, the representation of (S n) is the same as the representation of Z, thus all peano numbers are the same size. However, we still need to keep that info around somewhere, and consequently the size of the (Peano n) dictionary is linear in n (because it needs a pointer to the (Peano (n-1)) dictionary, and so on until (Peano Z)). On the other hand, with the straightforward version, the size of (n :: ZorS) is linear in n, but the size of the (Peano ZorS) dictionary is constant. -- Live well, ~wren From dnmehay at gmail.com Wed Sep 30 01:25:04 2009 From: dnmehay at gmail.com (DNM) Date: Wed Sep 30 01:03:00 2009 Subject: [Haskell-cafe] Problem with result-type context restrictions in typeclasses. In-Reply-To: References: <0497b0ee-3024-4c26-a3a6-3959e5cb3081@j9g2000vbp.googlegroups.com> Message-ID: <25675199.post@talk.nabble.com> Dan, thanks again for the response. I changed my code to use type families to let each Cls instance (actually a more complicated instance in my code) determine which Bar instance type it will return, but this didn't seem to work. The problem is that the client of the typeclass instance methds ('useThisStuff', which calls on 'toNum' and 'foo' in the contrived example) expects some guarantee that (Ret c) is going to be an instance of Bar. The actual client code I'm using complains when it sees that the associated type doesn't guarantee that an instance of the appropriate class is instantiated. I don't see any way to guarantee this without adding a context restriction in the class-level definition of Ret c, something like: class Cls c where type Ret c :: (Bar *) => * -- or a better name foo :: c -> Ret c which isn't legal Haskell. What I want to say is "define Ret c however you want, but make sure it is an instance of Bar" in the *class-level definition of Ret c*, so that any client of 'Cls' will know that Ret c will be foo-able. Maybe I'm missing some subtlety of type families... Any suggestions? --D.N. Daniel Peebles wrote: > > In your class, you have: > > class Cls c where > foo :: (Bar b) => c -> b > > There's an implicit forall for b, meaning that the caller of the > method gets to choose what it wants for b (as long as it's an instance > of Bar). For you to be able to write such a method you'd need to write > functions that can return any instance of Bar. One solution to this is > to turn on the GHC extension -XTypeFamilies, and then modify your code > as follows: > > class Cls c where > type Ret c :: * -- or a better name > foo :: c -> Ret c > > instance Cls G where > type Ret G = FU > foo = fuu > > That should work (although I haven't tested it). > > What type families do in this case is allow you to write not only > methods associated with typeclasses, but type functions associated > with them too. In this case you can think of Ret as a function that > takes a type (G in the instance above) and returns another type (FU). > Each instance can define new mappings for Ret. > > Hope this helps! > > Dan > On Tue, Sep 29, 2009 at 10:48 PM, DNM wrote: >> Correction by the author: >> >>> It seems that ghc doesn't like the fact that I am saying 'foo' must >>> return a class 'b' of typeclass 'Bar', while providing a function that >>> returns a concrete data instance of 'Bar' (viz., FU or FI) later on >>> when I implement 'foo' in each type classes. >> >> Should read: >> >> It seems that ghc doesn't like the fact that I am saying 'foo' must >> return something of TYPE 'b' implementing typeclass 'Bar', while >> providing >> a function that returns a concrete data instance of 'Bar' (viz., FU or >> FI) >> later on when I implement 'foo' in each type classes. >> >> On Sep 29, 10:43?pm, DNM wrote: >>> N.B. I'm a newbie to Haskell, and this problem is a bit complex, so >>> bear with me. >>> >>> I'm using typeclasses to implement a sort of common interface for all >>> things -- call them things of type 'Cls' -- that can be expected to >>> implement a set of functions -- an 'interface' in OOP-speak. ?(Yes, >>> yes, I'm aware that typeclasses are subtly different and far superior, >>> but my Haskell-ese is still a bit rudimentary.) >>> >>> Essentially, I want to have a typeclass that expects its instances to >>> have an accessor function that results in something that is an >>> instance of another typeclass whose instances can perform some >>> operation. ? The ghc type-checker doesn't seem to like my code, >>> though, and I can't seem to figure out why. >>> >>> To make it concrete, I've typed up some dummy typeclasses and a dummy >>> function that uses their instances to illustrate what I mean, as well >>> as the form of the ghc(i) error. >>> >>> ------------- BEGIN CODE ------------------ >>> class Cls c where >>> ? ? foo :: (Bar b) => c -> b >>> >>> class Bar b where >>> ? ? toNum :: b -> Int >>> >>> -- | One implementation of Cls >>> data D = D {fu :: FU} >>> data FU = FU {num :: Int} >>> >>> instance Cls D where >>> ? ? foo = fu >>> instance Bar FU ?where >>> ? ? toNum f = (num f) + 47 >>> >>> -- | Another implementation of Cls >>> data E = E {fi :: FI} >>> data FI = FI {nuum :: Int} >>> >>> instance Cls E where >>> ? ? foo = fi >>> instance Bar FI where >>> ? ? toNum f = (nuum f) + 100 >>> >>> -- | Yet another (this one re-uses FI) >>> data F = F {fii :: FI} >>> >>> instance Cls F where >>> ? ? foo = fii >>> >>> -- | And one last one, just to stress that >>> -- ? I really need to implement multiple >>> -- ?instances of Cls. >>> data G = G {fuu :: FU} >>> >>> instance Cls G where >>> ? ? foo = fuu >>> >>> -- | Good. Now, the function 'useThisStuff' need >>> -- ? not know anything about it's payload >>> -- ? other than that it its args are Cls's >>> -- ? (hence they are foo'able things that >>> -- ? can be used to construct an Int answer). >>> useThisStuff :: (Cls x, Cls y) => x -> y -> Int >>> useThisStuff x y = >>> ? ? (toNum $ foo x) + (toNum $ foo y) >>> ------------- END CODE -------------------- >>> >>> When I type this up in a file and try to load it in ghci, I get the >>> following error message(s): >>> >>> ------------- BEGIN ERROR MSG ---------- >>> Prelude> :load Typeclasses.hs >>> [1 of 1] Compiling Typeclasses ? ? ?( Typeclasses.hs, interpreted ) >>> >>> Typeclasses.hs:14:10: >>> ? ? Couldn't match expected type `b' against inferred type `FU' >>> ? ? ? `b' is a rigid type variable bound by >>> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >>> ? ? ? Expected type: D -> b >>> ? ? ? Inferred type: D -> FU >>> ? ? In the expression: fu >>> ? ? In the definition of `foo': foo = fu >>> >>> Typeclasses.hs:23:10: >>> ? ? Couldn't match expected type `b' against inferred type `FI' >>> ? ? ? `b' is a rigid type variable bound by >>> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >>> ? ? ? Expected type: E -> b >>> ? ? ? Inferred type: E -> FI >>> ? ? In the expression: fi >>> ? ? In the definition of `foo': foo = fi >>> >>> Typeclasses.hs:31:10: >>> ? ? Couldn't match expected type `b' against inferred type `FI' >>> ? ? ? `b' is a rigid type variable bound by >>> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >>> ? ? ? Expected type: F -> b >>> ? ? ? Inferred type: F -> FI >>> ? ? In the expression: fii >>> ? ? In the definition of `foo': foo = fii >>> >>> Typeclasses.hs:39:10: >>> ? ? Couldn't match expected type `b' against inferred type `FU' >>> ? ? ? `b' is a rigid type variable bound by >>> ? ? ? ? ? the type signature for `foo' at Typeclasses.hs:4:16 >>> ? ? ? Expected type: G -> b >>> ? ? ? Inferred type: G -> FU >>> ? ? In the expression: fuu >>> ? ? In the definition of `foo': foo = fuu >>> Failed, modules loaded: none. >>> ------------- END ERROR MSG ------------ >>> >>> It seems that ghc doesn't like the fact that I am saying 'foo' must >>> return a class 'b' of typeclass 'Bar', while providing a function that >>> returns a concrete data instance of 'Bar' (viz., FU or FI) later on >>> when I implement 'foo' in each type classes. ?Repeated for >>> convenience: >>> >>> class Cls c where >>> ? ? foo :: (Bar b) => c -> b >>> ... >>> -- (e.g.) >>> data G = G {fuu :: FU} >>> instance Cls G where >>> ? ? foo = fuu >>> >>> Does anyone have any clue as to what I'm doing wrong (language >>> extensions that I may need, etc.)? >>> >>> Is is because I'm using context restrictions on the *result* type of a >>> typeclass method? ?I've written other typeclasses with methods that >>> say, essentially: >>> >>> class A a where >>> ? ? blah :: (MonadPlus m) => a -> a -> m a >>> >>> with no issues. The restriction there is not on the return type a, but >>> rather on some monadic 'wrapper' around it. ?This may be why that code >>> works. >>> >>> Please advise. ?Any help is greatly appreciated. >>> >>> --D.N. (Dennis) >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-C...@haskell.orghttp://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 > > -- View this message in context: http://www.nabble.com/Problem-with-result-type-context-restrictions-in-typeclasses.-tp25674141p25675199.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. From martin.hofmann at uni-bamberg.de Wed Sep 30 02:20:28 2009 From: martin.hofmann at uni-bamberg.de (Martin Hofmann) Date: Wed Sep 30 01:58:26 2009 Subject: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors In-Reply-To: <799D986A-33A8-4C4F-B1AB-01C650EA1094@dc