Re: [Haskell-cafe] Two GET HTTP requests
Hi nwn, I had the following error: Run: Network/Socket/Internal.hsc:(298,2)-(314,60): Non-exhaustive patterns in case. The code for those lines look like this: peekSockAddr p = do family - (#peek struct sockaddr, sa_family) p case family :: CSaFamily of #if defined(DOMAIN_SOCKET_SUPPORT) (#const AF_UNIX) - do str - peekCString ((#ptr struct sockaddr_un, sun_path) p) return (SockAddrUnix str) #endif (#const AF_INET) - do addr - (#peek struct sockaddr_in, sin_addr) p port - (#peek struct sockaddr_in, sin_port) p return (SockAddrInet (PortNum port) addr) #if defined(IPV6_SOCKET_SUPPORT) (#const AF_INET6) - do port - (#peek struct sockaddr_in6, sin6_port) p flow - (#peek struct sockaddr_in6, sin6_flowinfo) p addr - (#peek struct sockaddr_in6, sin6_addr) p scope - (#peek struct sockaddr_in6, sin6_scope_id) p return (SockAddrInet6 (PortNum port) flow addr scope) #endif Thanks for all your help. I'll first upgrade to a new GHC and then try again. -chris On 9 feb 2010, at 06:41, Yusaku Hashimoto wrote: Try to reinstall HTTP package also. I think your HTTP package is still linked with old broken network package. HTTP depends on network. And network is a binding for network API of OS. These API is for C-language. When ghc builds such binding packages, It runs gcc for some purpose. gcc thinks you need 64bit binary (from SL, I believe.) and works for 64bit environment. But ghc on Mac can only build 32bit binaries. So it causes the problem. You can check if network package was correctly built by running this. This takes a host name, and gets the root document of the host via HTTP using a socket. Build and try `./this_program haskell.org` import Network.Socket import System.IO import System.Environment getAddr :: HostName - IO AddrInfo getAddr host = head `fmap` (getAddrInfo (Just defaultHints { addrSocketType = Stream }) (Just host) (Just http)) connected :: HostName - IO Socket connected host = do addrinfo - getAddr host sock - socket (addrFamily addrinfo) (addrSocketType addrinfo) (addrProtocol addrinfo) connect sock (addrAddress addrinfo) return sock httpGet :: HostName - IO String httpGet host = do h - flip socketToHandle ReadWriteMode = connected host hSetBuffering h NoBuffering hPutStr h GET / HTTP/1.0\r\n\r\n hGetContents h main = fmap head getArgs = httpGet = putStr I should have mentioned them in my last mail. Sorry. By the way, ghc-6.12 on Mac still can not build 64bit binaries. So upgrading ghc won't solve it. --nwn On Mon, Feb 8, 2010 at 12:50 AM, Chris Eidhof ch...@eidhof.nl wrote: Thanks. Unfortunately, it didn't help. The thing that frustrates me is that it's quite hard to debug. I guess I'll upgrade my GHC to 6.12, hopefully that'll solve it. -chris On 7 feb 2010, at 16:07, Yusaku Hashimoto wrote: Hello, On Sat, Feb 6, 2010 at 2:51 AM, Chris Eidhof ch...@eidhof.nl wrote: Approach 3: I used the simpleHTTP function from the HTTP package. This crashed, after I dug a little deeper into the code, it threw an error on calling the parseURI function (openFile: no such file exists). I installed the latest network package and upgraded my HTTP package, and the parseURI error went away. I felt like I was almost there, and tried the following: simpleHTTP (getRequest http://haskell.org;) This failed with just the text Bus error. I searched the HTTPBis git repository, but couldn't find the text Bus error. I don't have a clue of how to fix this. Try reinstall network package with `cabal install --reinstall --hsc2hs-options=--cflag=-m32 --lflag=-m32`. See also: http://hackage.haskell.org/trac/ghc/ticket/3681 Hope this helps. --nwn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generate random UArray in constant memory space.
Hi all, To summarize everything in this thread I've tested mwc-random, System.Random and mersenne random numbers (mersenne-random-pure64). Here the score table: [THIRD PLACE] Generic Random Number Generator. Is the slowest and allocates too much memory in the heap. The total memory usage is constant and very low. [SECOND PLACE] MWC-RANDOM. The fastest random number generator ever. But it uses O(n) memory for generate random numbers. Thought it isn't possible to calculate a really large set of random numbers (my PC stuck with calculating 500 millions random numbers with memory usage above 3,5Gb). The memory usage for me is more important than time, because I can easily wait additional 5-10-15 mins, but I cant so easily put additional memory to my PC. Thus this is only second place. [FIRST PLACE] Mercenne Random number generator. Approx 10 times faster than generic and two times slower than mwc. But it works in constant memory space, so theoretically it could generate infinite list of numbers. It also uses 6 time less total allocations, than generic RNG. NOTE: These tests didn't test the quality of the random sequences, only speed/memory. Thanks to everyone, who helped me with this code, it seems, that now I understand optimizations much better, than a day ago. Best regards, Vasyl 2010/2/10 Felipe Lessa felipe.le...@gmail.com: On Tue, Feb 09, 2010 at 04:27:57PM -0800, Bryan O'Sullivan wrote: It creates and returns a vector, so if you ask it to give you a billion items, it's going to require north of 8 gigabytes of memory. This should not come as a surprise, I'd hope :-) Assuming that's not what you actually want, you should look at other entry points in the API, which you can use to generate a single value at a time in constant space. He thought the vector would be fused away by the library, which is one of the selling points of uvector. Sadly the implementation of uniformArray wasn't done with this purpose in mind. -- Felipe. ___ 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] Using Cabal during development
Don't you simply need to do what the error message says, and add (*in the Executable section*, at the end of the file): build-depends: SFML ? Limestraël wrote: I think I must be dumb or something. I did my SFML.cabal exactly the way the packager of vty-ui did vty-ui.cabal, and I still have got the error when building: hs_src/SFML/Direct/Graphics.hs:51:7: Could not find module `SFML.Direct.Types.Enums': It is a member of the hidden package `SFML-1.5'. Perhaps you need to add `SFML' to the build-depends in your .cabal file. it is a hidden module in the package `SFML-1.5' Use -v to see a list of the files searched for. My cabal file is http://old.nabble.com/file/p27522604/SFML.cabal here . Il you get to know why it doesn't work, please tell me, because I'm lost... I have a hs_src directory, which contains an SFML directory (the lib) and a demo.hs file. (the simple main) It's the way vty-ui package is done. Jonathan Daugherty-4 wrote: Then how does the 'Executable' section of your .cabal look like? That's what I can't get working. Executable vty-ui-demo Hs-Source-Dirs: src Main-is: Demo.hs Build-Depends: mtl = 1.1 1.2 The Main-is refers to src/Demo.hs. This example is from: http://hackage.haskell.org/packages/archive/vty-ui/0.2/vty-ui.cabal The package description link on any Hackage package page will link to the release's cabal file, so you can see how other folks have written their Executable sections. Hope that helps, -- Jonathan Daugherty ___ 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: sendfile leaking descriptors on Linux?
On Feb 9, 2010, at 6:47 PM, Thomas Hartman wrote: Matt, have you seen this thread? Jeremy, are you saying this a bug in the sendfile library on hackage, or something underlying? I'm saying that the behavior of the sendfile library is buggy. But it could be due to something underlying.. Either threadWaitWrite is buggy and should be fixed. Or threadWaitWrite is doing the right thing, and sendfile needs to be modified some how to account for the behavior. But I don't know which is the case or how to implement a solution to either option. - jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
I do. On Feb 10, 2010, at 6:59 PM, Jason Dusek wrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek ___ 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] How many Haskell Engineer I/II/IIIs are there?
On Wed, Feb 10, 2010 at 9:59 AM, Jason Dusek jason.du...@gmail.com wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? While I don't suspect the number is large at the moment, the same thing could have been said several years ago of the language I use at my current job and used at my last job: Python. I get the same industrial incubation period vibe (for lack of a better term) from Haskell that I once got from Python -- although perhaps I'm biased in that I simply *like* these languages, too. :p ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
I used Haskell for some Research Development work at Deutsche Bahn, earlier. (But my program was not integrated with their other systems.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
Not using it yet, but there's been a large amount of interest and willingness to work with it from management. We're contractors, so it depends on us finding some one who will allow us to use the language or asks for it explicitly. On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek jason.du...@gmail.com wrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek ___ 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] How many Haskell Engineer I/II/IIIs are there?
Using it at the day job currently... like I need to get back to it. On Wed, Feb 10, 2010 at 8:22 AM, John Van Enk vane...@gmail.com wrote: Not using it yet, but there's been a large amount of interest and willingness to work with it from management. We're contractors, so it depends on us finding some one who will allow us to use the language or asks for it explicitly. On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek jason.du...@gmail.comwrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
I wonder how many people actually write Haskell, principally or exclusively, at work? I suppose you're implying non-academic jobs by that statement, but most of the people in my research group develop programs in Haskell on a daily basis. You'll find a number of libraries on Hackage from us. http://www.cs.uu.nl/staff/cur/IDX/sds.html As a shameless plug, I will also add that we have a great master's program in which you can get your fill of Haskell and compilers, among other things. http://www.cs.uu.nl/wiki/Master/ As second (but related) shameless plug, we also have a two-week-long summer school which is an excellent way to jump-start the above master's program or to get quickly up to speed on Haskell for business or pleasure. The course is in August, and the deadline is May 1. http://www.utrechtsummerschool.nl/index.php?type=coursescode=H9 Regards, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Cabal during development
Neil Brown-7 wrote: Don't you simply need to do what the error message says, and add (*in the Executable section*, at the end of the file): Nope, just check my previous message (my issue (2)): Limestrael wrote: (2) well, then, when building, if I don't specify that my executable depends on my lib, I got: SFML/Direct/Graphics.hs:51:7: Could not find module `SFML.Direct.Types.Enums': It is a member of the hidden package `HSFML-1.5'. Perhaps you need to add `HSFML' to the build-depends in your .cabal file. it is a hidden module in the package `HSFML-1.5' Use -v to see a list of the files searched for. and if I do what it asks me to do (to add the line 'Build-Depends: HSFML' in the 'Executable' section of my .cabal file), I'm told when 'cabal build'ing: cabal: internal error: could not construct a valid install plan. The proposed (invalid) plan contained the following problems: The following packages are involved in a dependency cycle HSFML-1.5 -- View this message in context: http://old.nabble.com/Using-Cabal-during-development-tp27515446p27534455.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
[Haskell-cafe] vector to uvector and back again
hi, i've been using the vector [1] library for implementing some signal processing algorithms, but now i'd like to use the statistics [2] package on my data, which is based on the uvector [3] library. is there a (straightforward) way of converting between vectors and uvectors, preferrably O(1)? thanks, sk [1] http://hackage.haskell.org/package/vector [2] http://hackage.haskell.org/package/statistics [3] http://hackage.haskell.org/package/uvector ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector to uvector and back again
I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? On Wed, Feb 10, 2010 at 9:59 AM, stefan kersten s...@k-hornz.de wrote: hi, i've been using the vector [1] library for implementing some signal processing algorithms, but now i'd like to use the statistics [2] package on my data, which is based on the uvector [3] library. is there a (straightforward) way of converting between vectors and uvectors, preferrably O(1)? thanks, sk [1] http://hackage.haskell.org/package/vector [2] http://hackage.haskell.org/package/statistics [3] http://hackage.haskell.org/package/uvector ___ 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] How many Haskell Engineer I/II/IIIs are there?
Hello Jason, Wednesday, February 10, 2010, 6:59:42 PM, you wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? i work on commercial program. once it will start selling, i will publish here the story -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Using Cabal during development
Am Mittwoch 10 Februar 2010 18:16:42 schrieb Limestraël: Neil Brown-7 wrote: Don't you simply need to do what the error message says, and add (*in the Executable section*, at the end of the file): Nope, just check my previous message (my issue (2)): I think http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html might help, example 3, a package containing a library and executable programs Name:TestPackage Version: 0.0 Cabal-Version: = 1.2 License: BSD3 Author: Angela Author Synopsis:Package with library and two programs Build-Type: Simple Library Build-Depends: HUnit Exposed-Modules: A, B, C Executable program1 Main-Is: Main.hs Hs-Source-Dirs: prog1 Other-Modules: A, B Executable program2 Main-Is: Main.hs Hs-Source-Dirs: prog2 Other-Modules: A, C, Utils For the executable, you have to specify the source dirs and the modules *from the library you are developing* it needs. A little inconvenient, admittedly. Limestrael wrote: (2) well, then, when building, if I don't specify that my executable depends on my lib, I got: SFML/Direct/Graphics.hs:51:7: Could not find module `SFML.Direct.Types.Enums': It is a member of the hidden package `HSFML-1.5'. Perhaps you need to add `HSFML' to the build-depends in your .cabal file. it is a hidden module in the package `HSFML-1.5' Use -v to see a list of the files searched for. and if I do what it asks me to do (to add the line 'Build-Depends: HSFML' in the 'Executable' section of my .cabal file), I'm told when 'cabal build'ing: cabal: internal error: could not construct a valid install plan. The proposed (invalid) plan contained the following problems: The following packages are involved in a dependency cycle HSFML-1.5 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
2010/02/10 Tom Tobin korp...@korpios.com: On Wed, Feb 10, 2010 at 9:59 AM, Jason Dusek jason.du...@gmail.com wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? While I don't suspect the number is large at the moment, the same thing could have been said several years ago of the language I use at my current job and used at my last job: Python. I get the same industrial incubation period vibe (for lack of a better term) from Haskell that I once got from Python -- although perhaps I'm biased in that I simply *like* these languages, too. :p I completely agree. I'm just trying to figure out where on the growth curve we are :) I am also interested in what industries tend to aggregate Haskell programmers. Within the Bay Area webosphere, Haskell is not much liked though Scala is gaining some traction. I think this has a lot to do with the fact that web programming is very much a let's go shopping kind of discipline -- no point in troubling oneself over correctness when the users haven't weighed in on the worth of your site. Of course this attitude leads to a long maintenance phase of Crazy Stuff®, like writing a PHP compiler; but by then you have piles of money to throw at the problem! Such is the theory, anyways. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
I think this has a lot to do with the fact that web programming is very much a let's go shopping kind of discipline -- no point in troubling oneself over correctness when the users haven't weighed in on the worth of your site. Of course this attitude leads to a long maintenance phase of Crazy Stuff®, like writing a PHP compiler; but by then you have piles of money to throw at the problem! Such is the theory, anyways. Or have sold your startup to some other company. Matthias. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: sendfile leaking descriptors on Linux?
Jeremy Shaw wrote: On Feb 9, 2010, at 6:47 PM, Thomas Hartman wrote: Matt, have you seen this thread? Jeremy, are you saying this a bug in the sendfile library on hackage, or something underlying? I'm saying that the behavior of the sendfile library is buggy. But it could be due to something underlying.. Either threadWaitWrite is buggy and should be fixed. Or threadWaitWrite is doing the right thing, and sendfile needs to be modified some how to account for the behavior. But I don't know which is the case or how to implement a solution to either option. IMO, in the interests of correctness over speed, an interim release of sendfile which simply uses the portable code on Linux should be put out. The CPU overhead of the portable method doesn't matter that much for servers which aren't extremely busy. I've also been contemplating some solutions, but I cannot see any solutions to this problem which could reasonably be implemented outside of GHC itself. GHC lacks a threadWaitError, so there's no way to detect the problem except by timeout or polling. Solutions involving timeouts and polling are bad in this case because they arbitrarily restrict the client connection rate. Cheers, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector to uvector and back again
On Wed, Feb 10, 2010 at 10:03 AM, Bryan O'Sullivan b...@serpentine.comwrote: I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? I like the vector API much better than the uvector one. * no U suffixes on functions (go namespaces!) and * no cryptic names (what's an UAE?). Cheers, Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
Jason Dusek wrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? I usually estimate the answer to this question by looking up how many employees WellTyped.com and Galois.com have between them, under the simplifying assumption that the number of other people using Haskell is probably so utterly insignificant that it doesn't matter. I'd love to see Haskell become popular, but it doesn't seem to be in any rush to happen just yet. (Then again, I gather 10 years ago things were far, far worse than they are today...) Some people (especially C programmers) have tried to tell me that Haskell is too slow. Others have claimed it's too incomprehensible. People inherantly thing sequentially, not set-theoretically they say. (Last time I checked, nobody's complaining about SQL being unintuitive...) People don't think recursively is another commonly-sited objection. Still others point out that Haskell is a *pure* functional language, and all the most popular languages are hybrids. Eiffel is a pure-OO language, but the hybrids like Java and C++ far vastly more popular. I myself might point out the comparative immaturity of things on Windows (the single biggest target platform on the market), and the rough edges on tools like Darcs, Haddock and Cabal. If enough people become interested, all these things could (and hopefully would) be fixed. It's a question of whether we reach the necessary critical mass or not... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type arithmetic with ATs
OK, so I sat down today and tried this, but I can't figure out how. There are various examples of type-level arithmetic around the place. For example, http://www.haskell.org/haskellwiki/Type_arithmetic (This is THE first hit on Google, by the way. Haskell is apparently THAT popular!) But this does type arithmetic using functional dependencies; what I'm trying to figure out is how to do that with associated types. Any hints? (I know for a fact that other people have done this - rule 34 requires it.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] lazy'foldl
Hello, I have implemented the following function: lazy'foldl :: (a - b - Maybe a) - Maybe a - [b] - Maybe a lazy'foldl _ Nothing _ = Nothing lazy'foldl _ m[] = m lazy'foldl f (Just y) (x:xs) = lazy'foldl f (f y x) xs After hoogling its type, I found that Control.Monad.foldM :: (a - b - Maybe a) - a - [b] - Maybe a seems like a perfect replacement because lazy'foldl f (Just x) xs == foldM f x xs holds for all finite lists xs. Here is an inductive proof: lazy'foldl f (Just x) [] == Just x == foldM f x [] lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Nothing)== lazy'foldl f Nothing ys == Nothing == Nothing = \z - foldM f z ys == f x y = \z - foldM f z ys == foldM f x (y:ys) lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Just z) == lazy'foldl f (Just z) ys (induction) == foldM f z ys == Just z = \z - foldM f z ys == f x y = \z - foldM f z ys == foldM f x (y:ys) I think the above equation holds even for infinite lists xs. Both functions terminate on infinite lists, if the accumulator is eventually Nothing. Do you see any differences in terms of strictness, i.e., a counter example to the above equation that involves bottom? I don't. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek jason.du...@gmail.com wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? Roel and I use Haskell at work. We develop embedded software in Haskell (not real-time) that controls a scientific instrument. We will probably write something more detailed about this project some time from now. regards, Roel and Bas van Dijk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] lazy'foldl
For the reference: foldM is defined as foldM :: Monad m = (a - b - m a) - a - [b] - ma foldM _ a [] = return a foldM f a (x:xs) = f a x = \fax - foldM f fax xs Let's define foldM' f x xs = lazy'foldl f (Just x) xs We can check that foldM' satisfies the same equations as foldM: foldM' f a [] = lazy'foldl f (Just a) [] = Just a = return a f a x = \fax - foldM' f fax xs = case f a x of {Nothing - Nothing; Just fax - foldM' f fax xs} = case f a x of {Nothing - Nothing; Just fax - lazy'foldl f (Just fax) xs} = case f a x of {Nothing - lazy'foldl f Nothing xs; Just fax - lazy'foldl f (Just fax) xs} = (*) lazy'foldl f (f a x) xs = lazy'foldl f (Just a) (x:xs) = foldM' f a (x:xs) (*) this holds, because lazy'foldl actually does pattern match on it's second argument This means, that foldM' as at least as defined as foldM (meaning, roughly, that if foldM gives a meaningful, non-undefined value, foldM' produces the same value; if foldM gives (_|_), foldM' is free to produce anything). Therefore, lazy'foldl f (Just x) xs is at least as defined as foldM f x xs. On the other hand, let's define lazyf f mx xs = case mx of {Nothing - Nothing, Just x - foldM f x xs} lazyf satisfies the same equations as lazy'foldl: lazyf f Nothing xs = Nothing lazyf f (Just y) (x:xs) = foldM f y (x:xs) = f y x = \fyx - foldM f fyx xs = f y x = \fyx - lazyf f (Just fyx) xs = case f y x of {Nothing - Nothing; Just fyx - lazyf f (Just fyx) xs} = case f y x of {Nothing - lazyf f Nothing xs; Just fyx - lazyf f (Just fyx) xs} = (*) lazyf f (f y x) xs (*) again, lazyf does pattern-match on it's second argument, so this is valid lazyf f mx [] = case mx of {Nothing - Nothing, Just x - foldM f x []} = case mx of {Nothing - Nothing, Just x - return x} = case mx of {Nothing - Nothing, Just x - Just x} = mx The last equality holds because there are only three kinds of values mx can have: Nothing, Just x, or (_|_); in all three cases pattern- matching produces the same value. That means, that lazyf is at least as defined as lasy'foldl, so foldM f x xs = lazyf f (Just x) xs is at least as defined as lazyfoldl' f (Just x) xs. All this means that lazy'foldl f (Just x) xs coincides with foldM f x xs exactly, for all possible f, x, and xs. On 10 Feb 2010, at 22:35, Sebastian Fischer wrote: Hello, I have implemented the following function: lazy'foldl :: (a - b - Maybe a) - Maybe a - [b] - Maybe a lazy'foldl _ Nothing _ = Nothing lazy'foldl _ m[] = m lazy'foldl f (Just y) (x:xs) = lazy'foldl f (f y x) xs After hoogling its type, I found that Control.Monad.foldM :: (a - b - Maybe a) - a - [b] - Maybe a seems like a perfect replacement because lazy'foldl f (Just x) xs == foldM f x xs holds for all finite lists xs. Here is an inductive proof: lazy'foldl f (Just x) [] == Just x == foldM f x [] lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Nothing)== lazy'foldl f Nothing ys == Nothing == Nothing = \z - foldM f z ys == f x y = \z - foldM f z ys == foldM f x (y:ys) lazy'foldl f (Just x) (y:ys) == lazy'foldl f (f x y) ys (if f x y == Just z) == lazy'foldl f (Just z) ys (induction) == foldM f z ys == Just z = \z - foldM f z ys == f x y = \z - foldM f z ys == foldM f x (y:ys) I think the above equation holds even for infinite lists xs. Both functions terminate on infinite lists, if the accumulator is eventually Nothing. Do you see any differences in terms of strictness, i.e., a counter example to the above equation that involves bottom? I don't. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) ___ 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] How many Haskell Engineer I/II/IIIs are there?
In my previous job, which recently ended, we used Haskell for at least half of our code, and most of our core stuff. I ended up writing a lot of Java, too, but you take the good, you take the bad. -James On Wed, Feb 10, 2010 at 10:59 AM, Jason Dusek jason.du...@gmail.com wrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? -- Jason Dusek ___ 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] Type arithmetic with ATs
On Wed, Feb 10, 2010 at 2:29 PM, Andrew Coppin andrewcop...@btinternet.com wrote: OK, so I sat down today and tried this, but I can't figure out how. There are various examples of type-level arithmetic around the place. For example, http://www.haskell.org/haskellwiki/Type_arithmetic (This is THE first hit on Google, by the way. Haskell is apparently THAT popular!) But this does type arithmetic using functional dependencies; what I'm trying to figure out is how to do that with associated types. Any hints? (I know for a fact that other people have done this - rule 34 requires it.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe With type families, something like: type family Add m n type instance Add (Succ n) (Succ m) = Succ (Succ (Add n m)) type instance Add Zero (Succ m) = (Succ m) type instance Add (Succ m) Zero = (Succ m) type instance Add Zero Zero = Zero is this what you are after? There's also the tfp library on hackage which has much more type level arithmetic, using type families. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
jason.dusek: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? Galois is a 100% Haskell shop, and we're around 40 people now - not all are engineers though. At the Commercial Users of FP workshop this year, when asked to raise their hands what FP languages people used at work, the majority of the room (60 people? / 120 in the room -- check the video) said they'd used Haskell at work. More than any of the other FP langs present (we also asked about Erlang, OCaml, Scheme, F#). -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
v.dijk.bas: On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek jason.du...@gmail.com wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? Roel and I use Haskell at work. We develop embedded software in Haskell (not real-time) that controls a scientific instrument. We will probably write something more detailed about this project some time from now. This is a great thread. Perhaps more users could add their details to http://haskell.org/haskellwiki/Haskell_in_industry and consider presenting at CUFP this year. http://cufp.galois.com (new website to be launched soon!) -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
On Wed, Feb 10, 2010 at 9:50 PM, Don Stewart d...@galois.com wrote: ... Perhaps more users could add their details to http://haskell.org/haskellwiki/Haskell_in_industry ... done ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
We could/should probably all just start our own collective (corporate) entity to produce software, based on the premises that 1) software built with Haskell will be more robust, and 2) software built by developers who have an affinity and aptitude for this language will tend to write better software. When the products themselves gain a positive reputation with the general public, then the corporation itself and those invested will benefit. cheers heard across the world A U.S. president would probably subsidize such a job-creating endeavor too! Nay-sayers are probably predominately composed of those who do not understand it or its benefits. Date: Wed, 10 Feb 2010 19:26:22 + From: andrewcop...@btinternet.com To: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there? Jason Dusek wrote: Although I'm fond of Haskell, in practice I am not a Haskell programmer -- I'm paid for Ruby and Bourne shell programming. Many of the jobs posted on this list end up being jobs for people who appreciate Haskell but will work in C# or O'Caml or some-such. I wonder how many people actually write Haskell, principally or exclusively, at work? I usually estimate the answer to this question by looking up how many employees WellTyped.com and Galois.com have between them, under the simplifying assumption that the number of other people using Haskell is probably so utterly insignificant that it doesn't matter. I'd love to see Haskell become popular, but it doesn't seem to be in any rush to happen just yet. (Then again, I gather 10 years ago things were far, far worse than they are today...) Some people (especially C programmers) have tried to tell me that Haskell is too slow. Others have claimed it's too incomprehensible. People inherantly thing sequentially, not set-theoretically they say. (Last time I checked, nobody's complaining about SQL being unintuitive...) People don't think recursively is another commonly-sited objection. Still others point out that Haskell is a *pure* functional language, and all the most popular languages are hybrids. Eiffel is a pure-OO language, but the hybrids like Java and C++ far vastly more popular. I myself might point out the comparative immaturity of things on Windows (the single biggest target platform on the market), and the rough edges on tools like Darcs, Haddock and Cabal. If enough people become interested, all these things could (and hopefully would) be fixed. It's a question of whether we reach the necessary critical mass or not... ___ 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] How many Haskell Engineer I/II/IIIs are there?
consider presenting at CUFP this year Any word on when this will be? On Wed, Feb 10, 2010 at 3:50 PM, Don Stewart d...@galois.com wrote: v.dijk.bas: On Wed, Feb 10, 2010 at 4:59 PM, Jason Dusek jason.du...@gmail.com wrote: I wonder how many people actually write Haskell, principally or exclusively, at work? Roel and I use Haskell at work. We develop embedded software in Haskell (not real-time) that controls a scientific instrument. We will probably write something more detailed about this project some time from now. This is a great thread. Perhaps more users could add their details to http://haskell.org/haskellwiki/Haskell_in_industry and consider presenting at CUFP this year. http://cufp.galois.com (new website to be launched soon!) -- Don ___ 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] If monads are single/linearly threaded, doesn't that reduce parallelism?
On Tue, 9 Feb 2010 21:56:49 +, you wrote: Monads are not commutative. A structure that would tell the compiler that it's commutative, would give it more leeway for optimization (and parallel execution). Thank you. Not commutative was the phrase I was looking for. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector to uvector and back again
On 11/02/2010, at 05:03, Bryan O'Sullivan wrote: I'm thinking of switching the statistics library over to using vector. uvector is pretty bit-rotted in comparison to vector at this point, and it's really seeing no development, while vector is The Shiny Future. Roman, would you call the vector library good enough to use in production at the moment? Yes, with the caveat that I haven't really used it in production code (I have tested and benchmarked it, though). BTW, I'll release version 0.5 as soon as get a code.haskell.org account and move the repo there. Roman On Wed, Feb 10, 2010 at 9:59 AM, stefan kersten s...@k-hornz.de wrote: hi, i've been using the vector [1] library for implementing some signal processing algorithms, but now i'd like to use the statistics [2] package on my data, which is based on the uvector [3] library. is there a (straightforward) way of converting between vectors and uvectors, preferrably O(1)? thanks, sk [1] http://hackage.haskell.org/package/vector [2] http://hackage.haskell.org/package/statistics [3] http://hackage.haskell.org/package/uvector ___ 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] Using Cabal during development
On Tue, Feb 9, 2010 at 8:48 AM, Limestraël limestr...@gmail.com wrote: Cabal/cabal-install are good tools for distribution and installation, but I was wondering -- as I was starting to learn how to use Cabal -- how do usually Haskell developpers build their softwares I add the enclosed Makefile to the directory that contains the .cabal file, and then in emacs, run M-x compile. To move to location of an error, type C-x `. I bind compile to M-C-y in my .emacs.el file with: (global-set-key \M-\C-y 'compile) --- Makefile # Haskell/Cabal Makefile # Requires GNU Make # The all target creates a default configuration if need be. PACKAGE := $(wildcard *.cabal) CONFIG = dist/setup-config SETUP = runhaskell Setup.hs all:$(CONFIG) $(SETUP) build Makefile: @echo make $@ $(PACKAGE): @echo make $@ $(CONFIG): $(PACKAGE) $(SETUP) configure --ghc --user --prefix=${HOME} %: force $(SETUP) $@ .PHONY: all force ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
2010/02/10 Roderick Ford develo...@live.com: A U.S. president would probably subsidize such a job-creating endeavor too! The US government generally subsidizes these kinds of things through DoD spending (and a few NSF grants). That is probably hard to get into. -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?
John Van Enk: consider presenting at CUFP this year Any word on when this will be? It'll be before or after (I suspect the later) ICFP http://www.icfpconference.org/icfp2010/, which is September 27-29 in Baltimore, Maryland. Manuel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Using Cabal during development
Another great thread. I'm another who uses both make and cabal. I try to automate a lot of things and find a makefile easier for quick scripting. Perhaps at some point I'll get by with just cabal. Here's an example: http://joyful.com/repos/hledger/Makefile An unusual feature, I think, is the use of the little-known sp tool for auto-recompiling (see ci rule). Typically I leave make ci running in an emacs shell window, where I can watch the errors as I edit and save source. I don't have clickable errors currently, I get by with linum-mode. When I need to explore I'll run ghci in another shell window. After reading this thread, I'm going to try using C-c C-l more. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] trouble with HDBC-mysql on Mac OS X
I'm having trouble with HDBC-mysql on Mac OS X (10.6, Snow Leopard). It compiles and builds fine, but when loaded (into ghci), the dynamic loader complains about not being able to find libmygcc.dylib. The issue is, MySQL's libmygcc is a static lib, not a dynamic one, so of course it won't find it. I've checked the build sequence that HDBC-mysql uses, and it calls upon mysql_config to generate the lib options. I've checked those and they are correct, expressly listing libmygcc statically (!). I've tried building against both the 64bit and 32bit versions of MySQL libs. (Suspect that only the 32bit should work.) Anyone have HDBC-mysql running on 10.6? Any ideas for me to try would be appreciated. - Mark Mark Lentczner http://www.ozonehouse.com/mark/ IRC: mtnviewmark ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe