Re: [Haskell-cafe] Re: Parallel Pi
On Mar 18, 2010, at 21:25 , Xiao-Yong Jin wrote: On Fri, 19 Mar 2010 01:22:58 +0100, Daniel Fischer wrote: core id : 0 cpu cores : 1 It is one of those pathetic single core pentium4 with so called hyper-threading enabled. You should have checked the intel product spreadsheet before investing such an old cpu. I'm a little surprised it's using both; I thought Linux (and other OSes) had disabled HTT by default because of the cache sniffing attacks. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Parallel Pi
On Mar 18, 2010, at 21:58 , Daniel Fischer wrote: Am Freitag 19 März 2010 02:25:47 schrieb Xiao-Yong Jin: On Fri, 19 Mar 2010 01:22:58 +0100, Daniel Fischer wrote: core id : 0 cpu cores : 1 It is one of those pathetic single core pentium4 with so called hyper-threading enabled. 'kay, but why does it say processor : 0 ... processor : 1 ? Because that's how Linux presents what amounts to CPU resources, whether real (multiple cores) or virtual (HTT). You need to scan down to the core information to see if they're real or not. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Performance question
Arnoldo Muller arnoldomul...@gmail.com wrote: Right now, the bottleneck of my program is in binarySearch', the function must be called a few billion times. Do you have any ideas on how to improve the performance of this function? The fastest way to do a binary search is to reify it into code using TH, in Van Emde Boas layout if it's a big enough search (so that you get less cache misses) This might of course get tricky if your tree isn't compile-time static, but if you're really doing gazillions of lookups, occasionally compiling+dynamically linking code might well be worth it. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] installing Haskell
I am sorry to trouble you but I have problems to install Haskell. Things run smoothly when I do the command ‘./configure’, But some errors appeared when I run the command ‘make’. The details are as follows(in red font): Distribution/Client/HttpUtils.hs:127:49: Couldn't match expected type `network-2.2.1.2:Network.URI.URI' against inferred type `URI' In the fourth argument of `AuthBasic', namely `uri' In the first argument of `Just', namely `(AuthBasic usr pwd uri)' In the expression: Just (AuthBasic usr pwd uri) Distribution/Client/HttpUtils.hs:135:37: Couldn't match expected type `network-2.2.1.2:Network.URI.URI' against inferred type `URI' In the `rqURI' field of a record In the expression: Request {rqURI = uri, rqMethod = GET, rqHeaders = [Header HdrUserAgent userAgent], rqBody = ByteString.empty} In the definition of `mkRequest': mkRequest uri = Request {rqURI = uri, rqMethod = GET, rqHeaders = [Header HdrUserAgent userAgent], rqBody = ByteString.empty} where userAgent = cabal-install/ ++ display Paths_cabal_install.version Error: Building the cabal-install-0.6.2 package failed make: *** [build.stamp] Error 2 If I install cabal-install manually, the errors will be: # /usr/bin/runhaskell Setup configure Configuring cabal-install-0.6.2... Warning: This package indirectly depends on multiple versions of the same package. This is highly likely to cause a compile failure. package HTTP-4000.0.6 requires network-2.2.1.2 package cabal-install-0.6.2requires network-2.2.1.4___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
On 19 March 2010 04:35, 国平张 zhangguop...@gmail.com wrote: Sorry to bother again. I just cannot figure out how it could compile. I got compile errors. Can someone point out what is right code to use a do notion to make a Parser works. It looks like the p parser may have the wrong indentation - although this might be due to either your mail client or my client formatting wrongly: p :: Parser (Char,Char) p = do x - item item y - item return (x,y) Try - with white space all aligned to the start character /x/ of the first statement in the do: p :: Parser (Char,Char) p = do x - item item y - item return (x,y) Or with braces and semis: p :: Parser (Char,Char) p = do { x - item ; item ; y - item ; return (x,y) } Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Parallel Pi
On 18/03/10 22:52, Daniel Fischer wrote: Am Donnerstag 18 März 2010 22:44:55 schrieb Simon Marlow: On 17/03/10 21:30, Daniel Fischer wrote: Am Mittwoch 17 März 2010 19:49:57 schrieb Artyom Kazak: Hello! I tried to implement the parallel Monte-Carlo method of computing Pi number, using two cores: move But it uses only on core: snip We see that our one spark is pruned. Why? Well, the problem is that your tasks don't do any real work - yet. piMonte returns a thunk pretty immediately, that thunk is then evaluated by show, long after your chance for parallelism is gone. You must force the work to be done _in_ r1 and r2, then you get parallelism: Generation 0: 2627 collections, 2626 parallel, 0.14s, 0.12s elapsed Generation 1: 1 collections, 1 parallel, 0.00s, 0.00s elapsed Parallel GC work balance: 1.79 (429262 / 240225, ideal 2) MUT time (elapsed) GC time (elapsed) Task 0 (worker) :0.00s( 8.22s) 0.00s( 0.00s) Task 1 (worker) :8.16s( 8.22s) 0.01s( 0.01s) Task 2 (worker) :8.00s( 8.22s) 0.13s( 0.11s) Task 3 (worker) :0.00s( 8.22s) 0.00s( 0.00s) SPARKS: 1 (1 converted, 0 pruned) INIT time0.00s ( 0.00s elapsed) MUT time 16.14s ( 8.22s elapsed) GCtime0.14s ( 0.12s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time 16.29s ( 8.34s elapsed) %GC time 0.9% (1.4% elapsed) Alloc rate163,684,377 bytes per MUT second Productivity 99.1% of total user, 193.5% of total elapsed But alas, it is slower than the single-threaded calculation :( INIT time0.00s ( 0.00s elapsed) MUT time7.08s ( 7.10s elapsed) GCtime0.08s ( 0.08s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time7.15s ( 7.18s elapsed) It works for me (GHC 6.12.1): SPARKS: 1 (1 converted, 0 pruned) INIT time0.00s ( 0.00s elapsed) MUT time9.05s ( 4.54s elapsed) GCtime0.12s ( 0.09s elapsed) EXIT time0.00s ( 0.01s elapsed) Total time9.12s ( 4.63s elapsed) wall-clock speedup of 1.93 on 2 cores. Is that Artyom's original code or with the pseq'ed length? Your fixed version. And, with -N2, I also have a productivity of 193.5%, but the elapsed time is larger than the elapsed time for -N1. How long does it take with -N1 for you? The 1.93 speedup was compared to the time for -N1 (8.98s in my case). What hardware are you using there? 3.06GHz Pentium 4, 2 cores. I have mixed results with parallelism, some programmes get a speed-up of nearly a factor 2 (wall-clock time), others 1.4, 1.5 or so, yet others take about the same wall-clock time as the single threaded programme, some - like this - take longer despite using both cores intensively. I suspect it's something specific to that processor, probably cache-related. Perhaps we've managed to put some data frequently accessed by both CPUs on the same cache line. I'd have to do some detailed profiling on that processor to find out though. If you're have the time and inclination, install oprofile and look for things like memory ordering stalls. Have you tried changing any GC settings? I've played around a little with -qg and -qb and -C, but that showed little influence. Any tips what else might be worth a try? -A would be the other thing to try. Cheers, Simon Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Parallel Pi
Daniel Fischer daniel.is.fisc...@web.de writes: 3.06GHz Pentium 4, 2 cores. [I.e. a single-core hyperthreaded CPU] I have mixed results with parallelism, some programmes get a speed-up of nearly a factor 2 (wall-clock time), others 1.4, 1.5 or so, yet others take about the same wall-clock time as the single threaded programme, some - like this - take longer despite using both cores intensively. Given the negative press around HT, I'm surprised you see this good results on many programs. I thought the main benefit from Intel's HT was to reduce the impact of memory latency, that is, when one thread was blocking on memory, it could switch immediately to anther, ready-to-run, thread. (I may be misunderstanding this, though). I think the general consensus was a 10-15% speedup from HT. Anyway, the thing to get these days is of course Nehalem, A.K.A. Core i{3,5,7}, which seems to give a nice speedup over Core 2. Among other things, it dynamically overclocks the busy cores (using the more market-friendly term turbo mode), making it even harder to compare performance reliably. Interesting times. -k -- If I haven't seen further, it is by standing in the footprints of giants ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
Sorry. The same error, This is new stuff. --- newtype Parser a = P { parse :: (String - [(a,String)]) } instance Monad Parser where return v = P (\s - [(v,s)]) p = f = P (\s - case parse p s of []- [] [(v,str)] - parse (f v) str) fail _ = P (\_ - []) item :: Parser Char item = \inp - case inp of [] - [] (x:xs) - [(x,xs)] p :: Parser (Char,Char) p = do { x - item ; item ; y - item ; return (x,y) } --- I got following: Prelude :load c:\b.hs [1 of 1] Compiling Main ( C:\b.hs, interpreted ) C:\b.hs:13:7: The lambda expression `\ inp - ...' has one argument, but its type `Parser Char' has none In the expression: \ inp - case inp of { [] - [] (x : xs) - [...] } In the definition of `item': item = \ inp - case inp of { [] - [] (x : xs) - ... } Failed, modules loaded: none. 2010/3/19 Stephen Tetley stephen.tet...@gmail.com: On 19 March 2010 04:35, 国平张 zhangguop...@gmail.com wrote: Sorry to bother again. I just cannot figure out how it could compile. I got compile errors. Can someone point out what is right code to use a do notion to make a Parser works. It looks like the p parser may have the wrong indentation - although this might be due to either your mail client or my client formatting wrongly: p :: Parser (Char,Char) p = do x - item item y - item return (x,y) Try - with white space all aligned to the start character /x/ of the first statement in the do: p :: Parser (Char,Char) p = do x - item item y - item return (x,y) Or with braces and semis: p :: Parser (Char,Char) p = do { x - item ; item ; y - item ; return (x,y) } Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
2010/3/19 国平张 zhangguop...@gmail.com: Sorry. The same error, This is new stuff. Ah indeed - I didn't spot that one as I only read the code rather than ran it. With the change the parser type to use /newtype/ all the primitive parsers have to be encoded inside the newtype's constructor (primitive parsers being ones that have to look directly at the input stream). item :: Parser Char item = Parser $ \inp - case inp of [] - [] (x:xs) - [(x,xs)] Or in a more prosaic style item :: Parser Char item = Parser (\inp - case inp of [] - [] (x:xs) - [(x,xs)]) This is slightly tiresome. Fortunately once you have defined a small set of primitive parsers, many more parsers can be derived by combining the primitives rather than looking at the input stream - this is the power of the monadic style. The p parser you defined with the do ... notation is one such derived parser. Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: explicit big lambdas
Paul Brauner wrote: is there a way in some haskell extension to explicit (system F's) big lambdas and (term Type) applications in order to help type inference? Actually, yes: newtype constructor introductions may act as a big lambda, with constructor elimination acting as type applications: http://okmij.org/ftp/Haskell/types.html#some-impredicativity Newtypes are also handy for turning type functions (defined by type families) into real lambdas. For example, given the following code {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE TypeFamilies, EmptyDataDecls #-} {-# LANGUAGE ScopedTypeVariables #-} module S where data Z data S a class Nat a where nat :: a - Int instance Nat Z where nat _ = 0 instance Nat n = Nat (S n) where nat _ = succ (nat (undefined::n)) type family Add a b type instance Add Z b = b type instance Add (S a) b = S (Add a b) we would like to compose the type function Add (S (S Z)) twice. We may first try * newtype F2 f x = F2{unF2 :: f (f x)} * tf1 :: F2 (Add (S (S Z))) (S Z) * tf1 = undefined alas, without success: Type synonym `Add' should have 2 arguments, but has been given 1 In the type signature for `tf1': tf1 :: F2 (Add (S (S Z))) (S Z) Indeed, type functions defined via type families can't be turned into closures. Newtypes help, introducing the needed Lambda behind the scenes: newtype A2 a = A2{unA2 :: Add (S (S Z)) a} appA2 :: x - A2 x appA2 = undefined -- Now we can compose the type function, many times tc = unA2 . appA2 . unA2 . appA2 -- Inferred type: -- tc :: a - Add (S (S Z)) (Add (S (S Z)) a) tcrun = nat $ tc (undefined::S Z) -- 5 One can see from the inferred type of tc that the type-checker has composed the partially applied Add function. I'll show a bit more elaborate example next week. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
Sorry :-). I am using Hugs, anything I did wrong ? newtype Parser a = P { parse :: (String - [(a,String)]) } instance Monad Parser where return v = P (\s - [(v,s)]) p = f = P (\s - case parse p s of []- [] [(v,str)] - parse (f v) str) fail _ = P (\_ - []) item :: Parser Char item = Parser (\inp - case inp of [] - [] (x:xs) - [(x,xs)]) p :: Parser (Char,Char) p = do { x - item ; item ; y - item ; return (x,y) } -- Prelude :load c:\b.hs [1 of 1] Compiling Main ( C:\b.hs, interpreted ) C:\b.hs:12:7: Not in scope: data constructor `Parser' Failed, modules loaded: none. Prelude 在 2010年3月19日 下午6:01,Stephen Tetley stephen.tet...@gmail.com 写道: 2010/3/19 国平张 zhangguop...@gmail.com: Sorry. The same error, This is new stuff. Ah indeed - I didn't spot that one as I only read the code rather than ran it. With the change the parser type to use /newtype/ all the primitive parsers have to be encoded inside the newtype's constructor (primitive parsers being ones that have to look directly at the input stream). item :: Parser Char item = Parser $ \inp - case inp of [] - [] (x:xs) - [(x,xs)] Or in a more prosaic style item :: Parser Char item = Parser (\inp - case inp of [] - [] (x:xs) - [(x,xs)]) This is slightly tiresome. Fortunately once you have defined a small set of primitive parsers, many more parsers can be derived by combining the primitives rather than looking at the input stream - this is the power of the monadic style. The p parser you defined with the do ... notation is one such derived parser. Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
国平张 wrote: Sorry :-). I am using Hugs, anything I did wrong ? item :: Parser Char item = Parser (\inp - case inp of ^^^ the second Parser should be a P, which is a data constructor. Cheers, Jochem -- Jochem Berndsen | joc...@functor.nl ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] stuck with a sample of programming in haskell
Hi I'm sorry about that, I should have check the last message runs, but I typed it from a computer that I don't develop on. The code below should run as I've tested it this time. newtype Parser a = P { parse :: (String - [(a,String)]) } instance Monad Parser where return v = P (\s - [(v,s)]) p = f = P (\s - case parse p s of []- [] [(v,str)] - parse (f v) str) fail _ = P (\_ - []) item :: Parser Char item = P (\inp - case inp of [] - [] (x:xs) - [(x,xs)]) p :: Parser (Char,Char) p = do { x - item ; item ; y - item ; return (x,y) } For the record - the error in the last code I sent was that the newtype Parser has a different constructor name /P/ to its type name /Parser/ - I hadn't spotted that in the untested code. Apologies again Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Intermediate type variables
Hi! How can I specify intermediate type variables to help the compiler do its job? The following, simple, code does not compile because the compiler cannot infer that the type variable a' is CInt; this makes sense, because finding that out would be quite hard. How can I tell the compiler that a' is CInt? {-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances, FlexibleContexts, EmptyDataDecls, ScopedTypeVariables, TypeOperators, TypeSynonymInstances #-} class C a a' where convert :: a - a' class F a b where apply :: a - b class S s a where select :: s - a data CInt = CInt Int instance S (Int,String) Int where select (i,_) = i instance C Int CInt where convert = CInt instance F CInt Int where apply (CInt i) = i + 1 f :: forall s a a' b . (S s a, C a a', F a' b) = s - b f s = let v = select s :: a v' = convert v :: a' y = apply v' :: b in y x :: Int x = f (10,foo) Thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Performance question
Thank you all, I will apply your suggestions to my function. Thank you for making the process of learning Haskell much easier! Arnoldo On Fri, Mar 19, 2010 at 4:21 PM, Achim Schneider bars...@web.de wrote: Arnoldo Muller arnoldomul...@gmail.com wrote: Right now, the bottleneck of my program is in binarySearch', the function must be called a few billion times. Do you have any ideas on how to improve the performance of this function? The fastest way to do a binary search is to reify it into code using TH, in Van Emde Boas layout if it's a big enough search (so that you get less cache misses) This might of course get tricky if your tree isn't compile-time static, but if you're really doing gazillions of lookups, occasionally compiling+dynamically linking code might well be worth it. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Iteratee performance
I think this is a bit easier to write with iteratee-HEAD. There are some significant changes from the 0.3 version, and not all the old functions are implemented yet, however the cnt iteratee can be written as: cnt :: Monad m = I.Iteratee S.ByteString m Int cnt = I.liftI (step 0) where step acc (I.Chunk bs) | S.null bs = I.icont (step acc) Nothing step acc (I.Chunk bs) = let acc' = acc + S.count '\n' bs in acc' `seq` I.icont (step acc') Nothing step acc str = I.idone acc str One significant change is that the kind of the first parameter to the Iteratee type has changed, so now it should be a fully-applied type instead of a type function. This means that ByteString can be used directly. idone, icont, and liftI simplify creation of iteratees, and it's usually not necessary to pattern match on the EOF constructor any more. The first step definition above can be left out for a small performance penalty. I wouldn't recommend basing any production code on iteratee-HEAD, as the interface isn't quite finalized yet. With this version of cnt and iteratee-HEAD, the iteratee version runs in about 2.2 seconds for the same tests as I used below. Changing the enumFd buffer size to 32K gives the following results: a 460MB input file (generated by cp Tiff.hs long.txt; cat long.txt long.txt): MusDept-MacBook-1:Examples johnlato$ time wc -l long.txt 12024249 long.txt real0m0.997s MusDept-MacBook-1:Examples johnlato$ time ./test_bs long.txt 12024249 real0m1.161s MusDept-MacBook-1:Examples johnlato$ time ./test_iter long.txt 12024249 real0m1.154s All time values are averages of 3 runs. The first run for the bytestring version was a bit long, otherwise run times were very consistent, within 0.004s for each executable. I don't see any reason the buffer size needs to be fixed at compile time. I'll make this change in the next major release. John From: Vasyl Pasternak vasyl.paster...@gmail.com Subject: Re: [Haskell-cafe] Iteratee performance To: Gregory Collins g...@gregorycollins.net Gregory, Thank you, your code helps, now my it runs in the speed of lazy bytestring test but uses less memory with it. I've only added to your code more strictness in the recursion, my version is below. BTW, I think it is more useful to let user set the chunk size for reading, so I'd like to see this possibility in the iteratee package. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] RFC: only-read-or-write-vars
Hello, I've written a tiny package for restricting access to mutable variables to be read-only or write-only: http://code.haskell.org/~basvandijk/code/only-read-or-write-vars/ This is a Request For Comments, so any comments / patches / +1s / -1s about anything are more than welcome before I upload it to hackage (sometime this weekend). regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Strange typing?
Hi Cafe! Disclaimer: I know what I'm going to ask is now available as a language feature normally. And sorry for the subject of this message, I couldn't compe up with a gooddescriptive subject. Is there any way to limit a functions type, not by a data type but by a group of constructors of a data type? If not, what would be the *right* thing to do to achieve this level of type safety? data DT1 = X | Y | Z data DT2 = A | B | C | D func1 :: DT1 - DT2 -- instead of this func1' :: (X|Y) - (B|C) -- i want sth. like this. (| means or) Only think I can think of is having the constructors, as seperate data types, introducing new type classes to group every possible subset of [X,Y,Z] and [A,B,C,D] and use those type classes when defining the functions. But as you can imagine, this is not the only place I want to use this thing, and the code will start to look cryptic if I do so. I must add, I want to use this *disjunction of constructors* thingy in data type declerations as well. A little bit brainstorming maybe? Thanks in advance, -- Ozgur Akgun ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] explicit big lambdas
On Fri, Mar 19, 2010 at 4:03 AM, Nicolas Frisby nicolas.fri...@gmail.com wrote: Alternatively: let f :: some type involving a f = ... f' :: a - some type involving a f' _ = f in f' (undefined :: Int) normal f arguments Or use Edward Kmett's tagged library: http://hackage.haskell.org/packages/archive/tagged/0.0/doc/html/Data-Tagged.html so you don't have to use bottom values: let f :: some type involving a f = ... f' :: Tagged a some type involving a f' = Tagged f regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: GLFW on OS X
Am 17.03.10 17:34, schrieb Paul L: Just tried it, same configuration OS X 10.6.2, GHC 6.12.1, GLFW 4.2, etc. Fresh install. No problem at all, and no work around needed. Thank you. After your message I retried and got the same result as you. I had booted the machine in between, probably something had been messed up. Carsten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Template Haskell
I was reading the good old template haskell paper by Sheard and Peyton Jones [1]. It looks like some API have changed, but things seems to be more or less the same. I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a dynamic generated string for the format, but that's not a practical drawback (I can't think of a practical reason for using anything other than a string literal for format anyway). Anyhow, what is gained by the template programming in that case is really the flexibility in the type system. You can generate the function with the correct type on the fly, during compiling. That's nice enough, but the article keeps saying that templates are nice for implementing your own custom compiler optimizations. I can see that you really can do so, but I fail to think of a good practical example where templates would be hands down the best approach. Perhaps haskellers with more experience have real life examples they've bumped into. So, please, share your experience with us. [1] http://research.microsoft.com/en-us/um/people/simonpj/papers/meta-haskell/meta-haskell.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell
On Mar 19, 2010, at 12:01 , Rafael Almeida wrote: I got the printf example to run, and it is an alright example of something to do with template haskell. You lose the ability to use a dynamic generated string for the format, but that's not a practical drawback (I can't think of a practical reason for using anything other than a string literal for format anyway). Localization via message files. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RFC: only-read-or-write-vars
http://code.haskell.org/~basvandijk/code/only-read-or-write-vars/ This is a Request For Comments, so any comments / patches / +1s / -1s about anything are more than welcome before I upload it to hackage (sometime this weekend). +1 - I like it, I've used this technique in some private projects I wonder if this would be a place to add a function returning the pair of the read and write capabilities (for the lack of a better word) of a value. something like: rwPair:: v α - (ReadOnly v α , WriteOnly v α) rwPair a = (readOnly a, writeOnly a) sorry for the lame name, but my name game is off today. This particular function comes handy when playing with passing channels or pointers around. It might be worth it to have a dedicated type for that as well. Vlado ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Why no instance of Happstack.Data.Default.Default for Data.ByteString.Lazy
Hi Why is that Happstack has: instance Happstack.Data.Default.Default Data.ByteString But not one for: instance Happstack.Data.Default.Default Data.ByteString.Lazy I am trying to make a HTTP proxy using Happstack and the client part with the Network.HTTP (see Hackage). Network.HTTP.simpleHttp returns a lazy Bytestring when given a lazy Bytestring (which makes sense). Happstack on the other hand contains a lazy ByteString in its request type: data Request = Request { ... rqHeaders :: Headers, ... rqBody :: RqBody ... } newtype RqBody = Body Data.ByteString.Lazy.Internal.ByteString which Happstack.Server.SimpleHttp.simpleHTTP feeds into my application. However Happstack.Server.SimpleHttp.simpleHTTP expects something returned which is an instance of Happstack.Data.Default.Default which lazy ByteString is not. Confused? So am I. Who thought String handling could be so complex. Greetings, Mads Lindstrøm signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange typing?
Hi Ozgur, Perhaps you can have a look at what discussion there was about non-empty lists. Seems (slightly) related to me. Matthias. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why does `flip` cause function type so different ?
Every question is welcome on haskell-cafe . The goal of haskell-beginners is to encourage answers that are tailored to beginners, i.e. no scary existential multi-parameter category theory type class monads there. :) Do you get warm fuzzy existential multi-parameter category theory type class things there? Matthias. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell (Byte)Strings - wrong to separate content from encoding?
Hi More and more libraries use ByteStrings these days. And it is great that we can get fast string handling in Haskell, but is ByteString the right level of abstractions for most uses? It seems to me that libraries, like the Happstack server, should use a string-type which contains both the content (what ByteString contains today) and the encoding. After all, data in a ByteString have no meaning if we do not know its encoding. An example will illustrate my point. If your web-app, implemented with Happstack, receives a request it looks like http://happstack.com/docs/0.4/happstack-server/Happstack-Server-HTTP-Types.html#t%3ARequest : data Request = Request { ... rqHeaders :: Headers, ... rqBody :: RqBody ... } newtype RqBody = Body ByteString To actually read the body, you need to find the content-type header, use some encoding-conversion package to actually know what the ByteString means. Furthermore, some other library may need to consume the ByteString. Now you need to know which encoding the consumer expects... But all this seems avoidable if Happstack returned a string-type which included both content and encoding. I could make a similar story about reading text-files. If some data structure contains a lot of small strings, having both encoding and content for each string is wasteful. Thus, I am not suggesting that ByteString should be scraped. Just that ordinarily programmers should not have to think about string encodings. An alternative to having a String type, which contains both content and encoding, would be standardizing on some encoding like UTF-8. I realize that we have the utf8-string package on Hackage, but people (at least Happstack and Network.HTTP) seem to prefer ByteString. I wonder why. Greetings, Mads Lindstrøm signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell (Byte)Strings - wrong to separate content from encoding?
On Fri, 2010-03-19 at 18:45 +0100, Mads Lindstrøm wrote: Hi More and more libraries use ByteStrings these days. And it is great that we can get fast string handling in Haskell, but is ByteString the right level of abstractions for most uses? It seems to me that libraries, like the Happstack server, should use a string-type which contains both the content (what ByteString contains today) and the encoding. After all, data in a ByteString have no meaning if we do not know its encoding. An example will illustrate my point. If your web-app, implemented with Happstack, receives a request it looks like http://happstack.com/docs/0.4/happstack-server/Happstack-Server-HTTP-Types.html#t%3ARequest : data Request = Request { ... rqHeaders :: Headers, ... rqBody :: RqBody ... } newtype RqBody = Body ByteString To actually read the body, you need to find the content-type header, use some encoding-conversion package to actually know what the ByteString means. Furthermore, some other library may need to consume the ByteString. Now you need to know which encoding the consumer expects... But all this seems avoidable if Happstack returned a string-type which included both content and encoding. I guess that problem is that... body does not necessary have to be a text. It can as well be a gif, an mp3 etc. So you would need to have something like: data RqBody = Text MIME String | Binary MIME ByteString I could make a similar story about reading text-files. If some data structure contains a lot of small strings, having both encoding and content for each string is wasteful. Thus, I am not suggesting that ByteString should be scraped. Just that ordinarily programmers should not have to think about string encodings. In network programming you have to think about encoding - there is (was) too much sites encoded in IBM codepages (not much problem for English-speaking users). What worst I read some HTML tutorials which suggested that adding meta content-type automatically changes it to ISO encoding ;) An alternative to having a String type, which contains both content and encoding, would be standardizing on some encoding like UTF-8. I realize that we have the utf8-string package on Hackage, but people (at least Happstack and Network.HTTP) seem to prefer ByteString. I wonder why. Greetings, Mads Lindstrøm Hopefully most of problems are gone as world is moving into utf-8. But still: - Other Unicode coding are used (for example with fixed length of character) - Other data types are used (like binary) In many cases you cannot depend on MIME to be always correct. In some cases you don't need to have character recoding anyway (you store directly to db, you want to compress it). Additionally you may want to compute checksum of string. However recoding UTF-16 - ... - UTF16 may change the contents (direction bytes at the beginning) and therefore checksum. Regards signature.asc Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Template Haskell
Hi Rafael There is a paper describing a variant of Conal Elliott's Pan implemented with Template Haskell - PanTH - which you might find interesting: Optimising Embedded DSLs using Template Haskell Sean Seefried, Manuel Chakravarty, and Gabriele Keller http://www.haskell.org/th/papers/th-pan.ps Best wishes Stephen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: hdbc-mysql on windows
Roderick, thanks for passing this along. To be honest, I haven't tried to build this on Windows yet. I have an old PC that I keep meaning to get things going on. If you're able to get things working, I'd be more than happy to integrate any changes that you want to send along... patches are very much appreciated! :) thanks! chris On Mar 18, 2010, at 1:46 PM, Roderick Ford wrote: Hello, In order to build (cabal install HDBC-mysql) the HDBC-mysql package, I am having to make the following changes: (1) I had to change the mysql (5.1.45 community distrib msi) to use a wrapper exe on the mysql_config.pl and put this in c:\program files\mysql\bin since although the c:\program files\mysql\scripts\, where mysql_config.pl resides, was in the path, even the commandline call to it was not finding or using it...very strange. This of course doesn't directly have to do with the HDBC-mysql package. --The quick wrapper was: import System.Environment(getArgs) import System.Process(readProcessWithExitCode) import System.Exit(exitWith,ExitCode(ExitSuccess)) main = do args - getArgs (ecode,out,err) - readProcessWithExitCode c:\\Perl64\\bin\\perl.exe (C:\\Program Files\\MySQL\\scripts\\mysql_config.pl : args) if ecode == ExitSuccess then mapM_ putStrLn (lines out) else mapM_ putStrLn (lines err) exitWith ecode -- so now the output is: C:\Program Files\MySQL\lib\mysqlclient.lib wsock32.lib advapi32.lib user3 2.lib (2) Once that was done, the cabal install HDBC-mysql call was able to find the mysql_config. However, it was splitting the values returned by mysql_config on space, and thus failed to find mysql.h, as the resulting command was: C:\Program Files (x86)\Haskell Platform\2009.2.0.2\gcc.exe -c -BC:\ Program Files (x86)\Haskell Platform\2009.2.0.2\gcc-lib -IC:\Program Files (x86) \Haskell Platform\2009.2.0.2\include\mingw -D__GLASGOW_HASKELL__=610 -IIC:\Program -Iles\MySQL\include\mysql ... -- then I tried taking the -I out of the mysql_config.pl script and got the following from the cabal install HDBC-mysql command was: C:\Program Files (x86)\Haskell Platform\2009.2.0.2\gcc.exe -c -BC:\ Program Files (x86)\Haskell Platform\2009.2.0.2\gcc-lib -IC:\Program Files (x86) \Haskell Platform\2009.2.0.2\include\mingw -D__GLASGOW_HASKELL__=610 -I:\Program -Iles\MySQL\include\mysql ... blah blah blah cabal: Error: some packages failed to install: HDBC-mysql-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 ... so finally I am downloading your package to see if I can figure out a fix for windows boxes. Just thought I would give you a heads up on this windows-related bug. Thanks, Roderick ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange typing?
On Fri, Mar 19, 2010 at 8:15 AM, Ozgur Akgun ozgurak...@gmail.com wrote: Hi Cafe! Disclaimer: I know what I'm going to ask is now available as a language feature normally. Did you mean not available? I don't know of a Haskell language feature for this, so if you really did mean now then I'd love to learn about the feature you're thinking of. Only think I can think of is having the constructors, as seperate data types, introducing new type classes to group every possible subset of [X,Y,Z] and [A,B,C,D] and use those type classes when defining the functions. But as you can imagine, this is not the only place I want to use this thing, and the code will start to look cryptic if I do so. I must add, I want to use this *disjunction of constructors* thingy in data type declerations as well. It looks to me like you want dependent types. You might look at Agda. It's similar to Haskell but features dependent types and other interesting things. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trace
Hi, I'm a new Haskell programmer and am trying to output the values of some of the variables (for debugging) as the program executes. At the moment to output the value of the function I use: f x y z = trace (show moves) moves where moves = [complicated expression of x y z] But really what I want is to be able to write: f x y z = trace2 [complicated expression of x y z] Is there a standard function to do this? I tried: trace2 a = trace (show a) a But I got the error: Couldn't match expected type `t1 - t' against inferred type `String' In the expression: (show a) a In the definition of `trace2': trace2 a = (show a) a How do I fix it? Thanks, Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Parallel Pi
On 19/03/10 09:00, Ketil Malde wrote: Daniel Fischerdaniel.is.fisc...@web.de writes: 3.06GHz Pentium 4, 2 cores. [I.e. a single-core hyperthreaded CPU] Ah, that would definitely explain a lack of parallelism. I'm just grateful we don't have another one of those multicore cache-line performance bugs, becuase they're a nightmare to track down. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange typing?
On Fri, Mar 19, 2010 at 03:15:02PM +, Ozgur Akgun wrote: Hi Cafe! Disclaimer: I know what I'm going to ask is now available as a language feature normally. And sorry for the subject of this message, I couldn't compe up with a gooddescriptive subject. Is there any way to limit a functions type, not by a data type but by a group of constructors of a data type? If not, what would be the *right* thing to do to achieve this level of type safety? data DT1 = X | Y | Z data DT2 = A | B | C | D func1 :: DT1 - DT2 -- instead of this func1' :: (X|Y) - (B|C) -- i want sth. like this. (| means or) The standard way to do this is with GADTs and phantom type parameters. Something like this: data XY data NotXY data BC data NotBC data DT1 a where X :: DT1 XY Y :: DT1 XY Z :: DT1 NotXY data DT2 a where A :: DT1 NotBC ... etc. func1 :: DT1 XY - DT2 BC ... Every value of DT1 is tagged with an extra piece of information at the type level saying whether it is X or Y, or not. These extra types are known as phantom type parameters since nothing of those types actually show up in the values of the data type (indeed, XY, NotXY, and so on have no values) but they are only there to provide some extra information at the type level. Of course, the only problem with this approach is that if you want another function that only takes Y or Z, you are out of luck without some fancier type hackery. However, if you wish to know about a nice approach to said fancier type hackery, see Wouter Swierstra's paper Data Types a la Carte [1]. -Brent [1] http://www.cs.nott.ac.uk/~wss/Publications/DataTypesALaCarte.pdf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trace
On Fri, Mar 19, 2010 at 04:03:52PM -0400, Ben Derrett wrote: trace2 a = trace (show a) a In the definition of `trace2': trace2 a = (show a) a These don't match. It looks like maybe you forgot the call to trace in your definition of trace2? -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Trace
Hi, I'm a new Haskell programmer and am trying to output the values of some of the variables (for debugging) as the program executes. Debugging? Use the GHCi debugger. Cheers, Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] installing Haskell
love_pku wrote: I am sorry to trouble you but I have problems to install Haskell. You already asked this question on the beginners list. A number of people there asked you to provide more information so they could better respond to your question. Since you started this on the beginners list and you had people there willing to respond I suggest you go back to that list and answer their questions. Above all, if you are installing Haskell for the first time, I would highly recommend that you install precompiled binaries for your platform (you still haven't told us what that is). The Haskell Platform: http://hackage.haskell.org/platform/ is highly recommended, especially for beginners to Haskell as it contains the compiler and a large number of useful libraries all in one package. Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Takusen and iteratee problem
Hello Cafe. Today I stuck with the following problem: I want to read a file with iteratee package, and but it to database through Takusen package, but it doesn't work. The `Takusen` was built with `mtl` package, and `iteratee` - with `transformers`, so they are conflicting when used simultaneously. To be concrete, I want to run the code, that looks like: withSession (connect dbname.db) (do execDDL (sql create table x (value string)) fillFromFile file.dat ) fillFromFile fname = fileDriverFd iter fname iter = iterator that uses execDML (sql Insert into ) I have no ideas how to solve the problem, so appreciate any recommendations, that will make it possible. Thanks, Vasyl ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why no instance of Happstack.Data.Default.Default for Data.ByteString.Lazy
sloppiness probably. If you submit a patch that adds an instance I will apply it. That said, I am not sure it is going to solve your particular problem. simpleHTTP requires something that is an instance of ToMessage. ToMessage is a class that turns values into a Response. It happens that anything that is an instance of Xml is also an instance of ToMessage. And to be an instance of Xml it needs to be an instance of Default. So that is where the Default requirement is coming from. Since there is no explicit ByteString instance for ToMessage, it is trying to use the general Xml instance instead. I often wish the Xml instance for ToMessage did not exist. I am not sure anyone uses it, and I might remove it someday.. Ultimately what you need to do is get the value returned by Network.HTTP converted into a value of type Response. If you pass that to simpleHTTP, then everything should be fine, since Response is an instance of ToMessage. Now, if you just want to directly echo the Response from Network.HTTP to the output socket with no munging around, then the current Response type might not be so friendly, because it expects that you are going to set the http response code, the headers, and the body separately. So, you would have to parse the bytestring into a Response just to turn it back into the the same bytestring. But if your proxying requires munging some headers anyway, then that is not a big deal. We could consider adding another constructor to the Response type that just takes a lazy bytestring that is supposed to represent a fully-formed response.. - jeremy On Fri, Mar 19, 2010 at 12:18 PM, Mads Lindstrøm mads_lindstr...@yahoo.dkwrote: Hi Why is that Happstack has: instance Happstack.Data.Default.Default Data.ByteString But not one for: instance Happstack.Data.Default.Default Data.ByteString.Lazy I am trying to make a HTTP proxy using Happstack and the client part with the Network.HTTP (see Hackage). Network.HTTP.simpleHttp returns a lazy Bytestring when given a lazy Bytestring (which makes sense). Happstack on the other hand contains a lazy ByteString in its request type: data Request = Request { ... rqHeaders :: Headers, ... rqBody :: RqBody ... } newtype RqBody = Body Data.ByteString.Lazy.Internal.ByteString which Happstack.Server.SimpleHttp.simpleHTTP feeds into my application. However Happstack.Server.SimpleHttp.simpleHTTP expects something returned which is an instance of Happstack.Data.Default.Default which lazy ByteString is not. Confused? So am I. Who thought String handling could be so complex. Greetings, Mads Lindstrøm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: explicit big lambdas
On Fri, 19 Mar 2010, o...@okmij.org wrote: Paul Brauner wrote: is there a way in some haskell extension to explicit (system F's) big lambdas and (term Type) applications in order to help type inference? Actually, yes: newtype constructor introductions may act as a big lambda, with constructor elimination acting as type applications: http://okmij.org/ftp/Haskell/types.html#some-impredicativity Newtypes are also handy for turning type functions (defined by type families) into real lambdas. For example, given the following code Isn't this the equivalent of explicitly naming a function rather than making an anonymous one with lambda? Cheers, Ganesh ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Takusen and iteratee problem
On Fri, Mar 19, 2010 at 2:17 PM, Vasyl Pasternak vasyl.paster...@gmail.comwrote: Hello Cafe. Today I stuck with the following problem: I want to read a file with iteratee package, and but it to database through Takusen package, but it doesn't work. The `Takusen` was built with `mtl` package, and `iteratee` - with `transformers`, so they are conflicting when used simultaneously. To be concrete, I want to run the code, that looks like: withSession (connect dbname.db) (do execDDL (sql create table x (value string)) fillFromFile file.dat ) fillFromFile fname = fileDriverFd iter fname iter = iterator that uses execDML (sql Insert into ) I have no ideas how to solve the problem, so appreciate any recommendations, that will make it possible. I'm a bit of a Takusen newbie, but I've been maintaining some code recently that makes use of it. I've coded up some trivial examples using the iteratees package. Based on my very shallow understanding, I think the problem is just that both packages define iteratees but differently. Assuming that's correct, then I think you need a way to transform between the two types of iteratees. Perhaps that can be done with an enumerator that fetches values from your fillFromFile iteratee and turns that into the type of iteratee that Takusen uses? Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] RE: hdbc-mysql on windows
For those interested, the patch for parsing the paths that contain spaces (windows installs of mysql), I passed along the changes for Setup.lhs so that the split skips spaces inside quotes: mysqlBuildInfo :: LocalBuildInfo - IO BuildInfo mysqlBuildInfo lbi = do let mysqlConfig = rawSystemProgramStdoutConf verbosity mysqlConfigProgram (withPrograms lbi) includeDirs - return . map (dropWhile (\x - elem x -I) ) . split = mysqlConfig [--include] ldOptions - return . split = mysqlConfig [--libs] return emptyBuildInfo { ldOptions = ldOptions, includeDirs = includeDirs } where verbosity = normal -- honestly, this is a hack split :: [Char] - [[Char]] split xs@(l:lx) = if (elem '\' xs) then let x = dropWhile (== '') xs y = takeWhile (/= '') x in y : split ( dropWhile (\n - elem n \ \r\n\t) (drop (length y) x)) else let x = takeWhile (\n - not (elem n \r\n\t) ) xs in x : split ( dropWhile (\n - elem n \r\n\t) (drop (length x) xs)) split [] = [] This hasn't fixed everything, such that I have a complete install of HDBC-mysql on Windows, but it is a step. Roderick Subject: Re: hdbc-mysql on windows From: water...@maubi.net Date: Fri, 19 Mar 2010 11:18:20 -0700 CC: haskell-cafe@haskell.org To: develo...@live.com Roderick, thanks for passing this along. To be honest, I haven't tried to build this on Windows yet. I have an old PC that I keep meaning to get things going on. If you're able to get things working, I'd be more than happy to integrate any changes that you want to send along... patches are very much appreciated! :) thanks! chris On Mar 18, 2010, at 1:46 PM, Roderick Ford wrote: Hello, In order to build (cabal install HDBC-mysql) the HDBC-mysql package, I am having to make the following changes: (1) I had to change the mysql (5.1.45 community distrib msi) to use a wrapper exe on the mysql_config.pl and put this in c:\program files\mysql\bin since although the c:\program files\mysql\scripts\, where mysql_config.pl resides, was in the path, even the commandline call to it was not finding or using it...very strange. This of course doesn't directly have to do with the HDBC-mysql package. --The quick wrapper was: import System.Environment(getArgs) import System.Process(readProcessWithExitCode) import System.Exit(exitWith,ExitCode(ExitSuccess)) main = do args - getArgs (ecode,out,err) - readProcessWithExitCode c:\\Perl64\\bin\\perl.exe (C:\\Program Files\\MySQL\\scripts\\mysql_config.pl : args) if ecode == ExitSuccess then mapM_ putStrLn (lines out) else mapM_ putStrLn (lines err) exitWith ecode -- so now the output is: C:\Program Files\MySQL\lib\mysqlclient.lib wsock32.lib advapi32.lib user3 2.lib (2) Once that was done, the cabal install HDBC-mysql call was able to find the mysql_config. However, it was splitting the values returned by mysql_config on space, and thus failed to find mysql.h, as the resulting command was: C:\Program Files (x86)\Haskell Platform\2009.2.0.2\gcc.exe -c -BC:\ Program Files (x86)\Haskell Platform\2009.2.0.2\gcc-lib -IC:\Program Files (x86) \Haskell Platform\2009.2.0.2\include\mingw -D__GLASGOW_HASKELL__=610 -IIC:\Program -Iles\MySQL\include\mysql ... -- then I tried taking the -I out of the mysql_config.pl script and got the following from the cabal install HDBC-mysql command was: C:\Program Files (x86)\Haskell Platform\2009.2.0.2\gcc.exe -c -BC:\ Program Files (x86)\Haskell Platform\2009.2.0.2\gcc-lib -IC:\Program Files (x86) \Haskell Platform\2009.2.0.2\include\mingw -D__GLASGOW_HASKELL__=610 -I:\Program -Iles\MySQL\include\mysql ... blah blah blah cabal: Error: some packages failed to install: HDBC-mysql-0.6.1 failed during the building phase. The exception was: exit: ExitFailure 1 ... so finally I am downloading your package to see if I can figure out a fix for windows boxes. Just thought I would give you a heads up on this windows-related bug. Thanks, Roderick ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why does `flip` cause function type so different ?
Heinrich Apfelmus apfel...@quantentunnel.de writes: Ivan Miljenovic wrote: Also, there's a haskell-beginners mailing list. You may wish to post there rather than asking us every question you get whilst learning Haskell. Every question is welcome on haskell-cafe . The goal of haskell-beginners is to encourage answers that are tailored to beginners, i.e. no scary existential multi-parameter category theory type class monads there. :) Well, yes; except that recently zaxis has been asking quite a few of these beginner-level questions to the list, and I figured that haskell-beginners was catering more for the type of questions he had. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why does `flip` cause function type so different ?
On Fri, Mar 19, 2010 at 5:10 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Heinrich Apfelmus apfel...@quantentunnel.de writes: Ivan Miljenovic wrote: Also, there's a haskell-beginners mailing list. You may wish to post there rather than asking us every question you get whilst learning Haskell. Every question is welcome on haskell-cafe . The goal of haskell-beginners is to encourage answers that are tailored to beginners, i.e. no scary existential multi-parameter category theory type class monads there. :) Well, yes; except that recently zaxis has been asking quite a few of these beginner-level questions to the list, and I figured that haskell-beginners was catering more for the type of questions he had. The IRC channels for haskell on freenode, such as #haskell and #haskell-in-depth, might also be good places to ask. You tend to get a quick turn around on simply stated questions. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HTTP package freezes on Windows 7
On Tue, Mar 16, 2010 at 3:12 PM, Phil phil.beadl...@googlemail.com wrote: On 16/03/2010 01:05, Phil wrote: Scrap my original query - the problem isn't as black white as I thought. The below works fine - I've changed the response type from json to xml strange, but for some reason downloading json doesn't work it's fine on Linux. I'm guessing this is more likely to be a Windows issue rather than a Haskell issue - any ideas? A bit more testing - this is not a Windows issue per se. It seems to be a limitation of the HTTP library running on Windows. I've ran what I consider to be identical commands (in terms of functional use, both perform a HTTP GET on the location given) in Haskell and Python from each of their consoles on the same computer. The Python one correctly returns exactly what the Haskell one does on Linux. The Haskell on Windows just hangs. However as mentioned earlier SOME http requests do work from Haskell so I don't think it's a problem with my build of HTTP or Network libs. The simplest example is to replace 'json' with 'xml' in the below query. The best guess I can make is that XML is deemed renderable, but for some reason JSON is considered to be binary/file data? If you check the type of: simpleHTTP (getRequest http://maps.google.com/maps/api/geocode/json?address=Londonsensor=false;) You'll see that it is, :: IO (Network.Stream.Result (Response String)) In other words, I think the HTTP request is going to return the literal text of the request. I think this means you're just getting an arbitrary chunk of text back as far as it's concerned. I started looking through the source to see if this is true. You can get to it from the haddocks: http://hackage.haskell.org/package/HTTP-4000.0.9 I found this: http://hackage.haskell.org/packages/archive/HTTP/4000.0.9/doc/html/src/Network-HTTP-HandleStream.html#sendMain Looks like some versions of HTTP could wait forever with bad servers. I think it's a red herring though. That code looks to be disabled. What I would suggest next for you, is to sniff the network traffic. Find out if it's spinning but not doing any IO or maybe it's making many requests that come back with 100 Continue and it's doing just that. Can anyone confirm this behaviour I only have one 1 Windows PC, so I can't test on another machine. If it is a wide problem, I reckon it warrants a bug ticket on the library. I tried it on OSX 10.5.8 and it behaved correctly here. Do you have any sort of interesting proxies or otherwise non-vanilla setup? Is it possible that Windows access controls are blocking it? Firewall software? Good luck! Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe