[Haskell-cafe] Re: generalized list comprehensions
Well, my original post wasn't that negative ... Indeed then f [by e] seems a nice idea *but* the point was that I'd like to have this in any monad. The type of f in then f should be m a - m b, not just m a - m a, because then you don't need special syntax for group, which is somewhat like [a] - [[a]] ? J.W. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] announcing darcs 2.1.1rc2
Hi everybody, The release candidate for darcs 2.1.1 is now available at http://darcs.net/darcs-2.1.1rc2.tar.gz This release is very much intended to be darcs 2.1.0 plus GHC 6.10.1 support. We have also thrown in some simplifications to the regression testing suite and a Windows bugfix (which we pulled in because of a dependency and retained because it was a small and useful). Please give this a try, especially those of you on GHC 6.10 or Windows, and let us know how things work out. Because we have only selected a very small subset of changes to include (using darcs's cherry-picking abilities, of course!), I am confident that we can get by on a reduced release cycle. If all goes well, the official release date for darcs 2.1.1 will be 2008-11-17. Thanks! Eric darcs (2.1.1rc2) * Portability: Removed accidental QuickCheck 2.1 configure check. Note that it may be required in a future version of darcs. -- Eric Kow [EMAIL PROTECTED] Mon, 10 Nov 2008 11:17:00 GMT darcs (2.1.1rc1) * Portability: GHC 6.10.1 support (Petr Ročkai, Eric Kow) * Bug Fix: Fix file handle leak and check for exceptions on process running on Windows (issue784, Salvatore Insalaco) * Quality Assurance: Consolidated regression test suites using shell scripts only (Eric Kow, Tommy Petterson, Matthias Kilian) -- Eric Kow [EMAIL PROTECTED] Mon, 10 Nov 2008 09:49:00 GMT -- Eric Kow http://www.nltg.brighton.ac.uk/home/Eric.Kow PGP Key ID: 08AC04F9 pgpZvPr8RH3iA.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A video of Frag
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Nov 10, 2008, at 3:15 AM, Hugo Pacheco wrote: Perhaps this effort could be targeted at creating a cabal package in Hackage It's already there. :) http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag - - Jake -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkkYQ5wACgkQye5hVyvIUKkZCACgwy3VdzBfVTf8aIKxk67PAzgt yyEAnjrbiaZTBQFqfI3jUSEn96Iv16GP =Jwyf -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Trouble installing ghc-6.10.1 on linux
I'm trying to install ghc 6.10.1 on a machine with the crux distro. libc version 2.3.6 gcc 4.0.3 linux version 2.6.15.6 First I tried the binary version ghc-6.10.1-i386-unknown-linux.tar.bz2 and I very quickly get this error: $ ./configure checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu Which we'll further canonicalise into: i386-unknown-linux checking for path to top of build tree... configure: error: cannot determine current directory $ Next I tried building the source version ghc-6.10.1-src.tar.bz2 using ghc 6.6 that is already installed. configure works but make eventually dies with: ... Configuring ghc-6.10.1... cabal-bin: At least the following dependencies are missing: Cabal -any, base 3, filepath =1 1.2, haskell98 -any, hpc -any, template-haskell -any, unix -any make[2]: *** [boot.stage.2] Error 1 Any ideas? Thanks, Bit ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Histogram creation
Hello! I'm tryig to write efficient code for creating histograms. I have following requirements for it: 1. O(1) element insertion 2. No reallocations. Thus in place updates are needed. accumArray won't go because I need to fill a lot of histograms (hundrends) from vely long list of data (possibly millions of elements) and it will traverse input data for each histogram. It seems that I need to use mutable array and/or ST monad or something else. Sadly both of them are tricky and difficult to understand. So good examples or any other ideas greatly appreciated. -- Alexey Khudyakov ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A video of Frag
Yes, I installed it via cabal-install.I am using GHC 6.10.1 now, but it had the same results in 6.6 (if I remember well) before. It may be a Mac issue. On Mon, Nov 10, 2008 at 1:39 PM, Korcan Hussein [EMAIL PROTECTED]wrote: Sorry I have no idea, which version of GHC are you using? did you try using cabal-install? ( http://hackage.haskell.org/trac/hackage/wiki/CabalInstall) -- Date: Mon, 10 Nov 2008 10:46:45 + From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] A video of Frag Oh, sorry I haven't noticed.Trying to compile in my OS X machine, all compiles ok via cabal, but then I get $ ./frag ../share/frag-1.1.2/leveleg Bus error I remember compiling frag 1/2 years ago and getting the same result. It is not windows, but do you have any hint? On Mon, Nov 10, 2008 at 10:12 AM, Korcan Hussein [EMAIL PROTECTED]wrote: Actually such a package already exists, it's quite a simple procedure as long as you have the right tools and and setup but for windows platform this information is a bit scattered/dispersed and there is no central information about getting such a thing up and running from complete scratch. This is what i'm referring to in my comment. -- Date: Mon, 10 Nov 2008 09:15:14 + From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] A video of Frag CC: haskell-cafe@haskell.org I read on your youtube post that you are planning to write a build-it-yourself tutorial. Perhaps this effort could be targeted at creating a cabal package in Hackage (I do not know the implications of that, just speaking out loud). Cheers, hugo 2008/11/10 Korcan Hussein [EMAIL PROTECTED] I don't understand why there is no video of Frag online so I made one here: http://uk.youtube.com/watch?v=0jYdu2u8gAU -- Click here for FREE customisable desktop wallpapers. Get them Now!http://wallpapers.msn.com/?ocid=%5BB001MSN42A0716B%5D ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- www.di.uminho.pt/~hpacheco http://www.di.uminho.pt/%7Ehpacheco -- Click here for FREE customisable desktop wallpapers. Get them Now!http://wallpapers.msn.com/?ocid=%5BB001MSN42A0716B%5D -- www.di.uminho.pt/~hpacheco http://www.di.uminho.pt/%7Ehpacheco -- Get the best wallpapers on the Web - FREE. Click here!http://wallpapers.msn.com/?ocid=[B001MSN42A0716B] -- www.di.uminho.pt/~hpacheco ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] generalized list comprehensions
Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) You definitely should! Take a look at the Uniplate paper for some wonderful concise uses of list comprehensions for abstract syntax tree traversals. If you use a language like F# they become even more common - due to a clunkier syntax for lambdas, less library functions and no operator sections. In my F# I rarely use a map at all. But my faviourite list comprehension trick was shown to me by Colin Runciman: prettyPrint b (lhs :+: rhs) = ['('|b] ++ f lhs ++ + ++ f rhs ++ [')'|b] Imagine b represents whether something should be bracketed or not. In general: if boolean then [value] else [] Can be written as: [value | boolean] Thanks Neil == Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html == ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Derek Elkins wrote: As far as I can tell, no one actually uses parallel list comprehensions. With any luck, the same will be true for generalized list comprehensions. Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) When I first started with Haskell I kind of had the idea that list comprehensions were just for beginners and that 'real' hackers used just concatMaps and filters. A couple years later I 'rediscovered' list comprehensions and I now use them frequently. There are many cases in real programs where simple and not-so-simple list comprehensions are the clearest way of expressing the solution. In particular the easy support for refutable pattern matching in the generators allows some succinct and clear code. Just a random example out of Cabal: warn verbosity $ This package indirectly depends on multiple versions of the same ++ package. This is highly likely to cause a compile failure.\n ++ unlines [ package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) | (name, uses) - inconsistencies , (pkg, ver) - uses ] Pretty concise and clear I think. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: FFI documentation?
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. foreign import blah blah just gives me undefined references. One well documented and compiler independent way to do that is to use Cabal packages: http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html as used on Hackage: http://hackage.haskell.org If you have never done that, you will take some time to understand the role of the setup file (which in your case will problably be something like: import Distribution.Simple; main=defaultMain) and the details of .cabal files. (The problem you are concerned with is detailed in 3.1.4: Build Information. You'll see you can also list C files to be compiled with your code, and if you are using some library that implements the pkg-config standard then everything is really, really easy. I advise you to also understand well how 'build-depends' works and how to list language features out of Haskell 98 — in your situation, at least 'extensions: ForeignFunctionInterface'.) Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Histogram creation
Alexey Khudyakov wrote: Hello! I'm tryig to write efficient code for creating histograms. I have following requirements for it: 1. O(1) element insertion 2. No reallocations. Thus in place updates are needed. accumArray won't go because I need to fill a lot of histograms (hundrends) from vely long list of data (possibly millions of elements) and it will traverse input data for each histogram. That's just not true, for GHC's implementation of accumArray at least, which goes via the ST monad. It creates a mutable array, fills it, traversing the input list exactly once, and finally freezes the array and returns it. This is just what you suggest below. If you still run into performance problems, try out unboxed arrays. If that isn't enough, unsafeAccumArray from Data.Base may help. I'd try both before using the ST monad directly. It seems that I need to use mutable array and/or ST monad or something else. Sadly both of them are tricky and difficult to understand. So good examples or any other ideas greatly appreciated. http://www.haskell.org/haskellwiki/Shootout/Nsieve_Bits perhaps. There must be better examples out there. I can think of two common problems with mutable arrays and ST: 1) You need to specify a type signature for the array being created, because the compiler can't guess the MArray instance that you want. For example, from the shootout entry: arr - newArray (0,m) False :: IO (IOUArray Int Bool) In ST, this is slightly trickier, because the phantom 's' type parameter has to be mirrord in the ST*Array type constructor. You can use scoped type variables, which allow you to write {-# LANGUAGE ScopedTypeVariables #-} import Control.Monad.ST import Data.Array.ST foo :: forall s . ST s () foo = do arr - newArray (0,42) False :: ST s (STUArray s Int Bool) ... Alternatively you can define helper functions to specify just the part of the type signature that you care about. stuArray :: ST s (STUArray s i e) - ST s (STUArray s i e) stuArray = id foo :: ST s () foo = do arr - stuArray $ newArray (0,42 :: Int) False ... 2) runST $ foo bar doesn't work. You have to write runST (foo bar) But in the end it's just imperative array programming with a rather verbose syntax -- you can do only one array access per statement, and 'readArray' and 'writeArray' are rather long names. HTH, Bertram ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A video of Frag
I read on your youtube post that you are planning to write a build-it-yourself tutorial.Perhaps this effort could be targeted at creating a cabal package in Hackage (I do not know the implications of that, just speaking out loud). Cheers, hugo 2008/11/10 Korcan Hussein [EMAIL PROTECTED] I don't understand why there is no video of Frag online so I made one here: http://uk.youtube.com/watch?v=0jYdu2u8gAU -- Click here for FREE customisable desktop wallpapers. Get them Now!http://wallpapers.msn.com/?ocid=[B001MSN42A0716B] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- www.di.uminho.pt/~hpacheco ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Histogram creation
On Mon, Nov 10, 2008 at 9:05 AM, Bertram Felgenhauer [EMAIL PROTECTED] wrote: 2) runST $ foo bar doesn't work. You have to write runST (foo bar) Isn't that fixed in GHC6.10? That was the impression I got from the FPH talk at ICFP. -- ryan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
Duncan Coutts wrote: On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) When I first started with Haskell I kind of had the idea that list comprehensions were just for beginners and that 'real' hackers used just concatMaps and filters. A couple years later I 'rediscovered' list comprehensions and I now use them frequently. There are many cases in real programs where simple and not-so-simple list comprehensions are the clearest way of expressing the solution. In particular the easy support for refutable pattern matching in the generators allows some succinct and clear code. I don't actually use *lists* all that much - or at least not list transformations. And if I'm going to do something complicated, I'll usually write it as a do-expression rather than a comprehension. Just a random example out of Cabal: warn verbosity $ This package indirectly depends on multiple versions of the same ++ package. This is highly likely to cause a compile failure.\n ++ unlines [ package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) | (name, uses) - inconsistencies , (pkg, ver) - uses ] Pretty concise and clear I think. Erm... yeah, it's not too bad once I change all the formatting to make it clear what's what. Wouldn't it be a lot easier as a do-block though? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] download haskell?
This is nit-picking, but ... when I go to haskell.org, there is a link (top in the left menu) Download Haskell. Is this for readers who don't know the meaning of the word implementation (a few lines below)? Ah, it must be modelled after the perl.org start page... - J.W. signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: FieldTrip library (functional 3D) and mailing list
Conal Elliott wrote: FieldTrip [1] is a library for functional 3D graphics. It is intended for building static, animated, and interactive 3D geometry, efficient enough for real-time synthesis and display. Since FieldTrip is functional, one describes what models are, not how to render them (being rather than doing). Surfaces are described as functions from 2D space to 3D space. As such, they are intrinsically curved rather than faceted. Surface rendering tessellates adaptively, caching tessellations in an efficient, infinite data structure (from the MemoTrie library) for reuse. Surface normals are computed automatically and exactly, using the derivative tools in the vector-space library. For animation or interaction, FieldTrip can be used with the Reactive [2] library for functional reactive programming (and possibly other animation frameworks). By design, FieldTrip is completely orthogonal to any formulation or implementation of FRP. The reactive-fieldtrip [3] library links Reactive and FieldTrip. FieldTrip now has a mailing list [4] and a feature/bug tracker [5]. Sounds very interesting, but... what, no pictures? From a library especially designed for generating pictures? :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] download haskell?
2008/11/10 Johannes Waldmann [EMAIL PROTECTED]: This is nit-picking, but ... when I go to haskell.org, there is a link (top in the left menu) Download Haskell. I think it's missing the words to your brain. And the link goes to the wrong place. Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
Because expressions are treated as guards in list comprehensions. I.e.: [ foo | x - a, b, y - c, d ] Is interpreted as: do x - a guard b y - c guard d return foo Luke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? Is there any specific reason to dis-allow it? The grammar here looks something like (NB: I didn't double-check the report): list_compr ::= [ value | generator* ] generator ::= boolean | pat - list | let binds One particular special case is where there is exactly one generator, which has three further special cases: [ value | boolean ] [ value | pat - expr ] [ value | let binds ] These are all valid because they are special cases of the general list comprehension syntax; the de-sugarings are all just special cases of the general list comprehension de-sugaring rules: [ value | ] = [ value ] [ value | boolean, generators ] = if boolean then [ value | generators ] else [] [ value | pat - expr, generators ] = expr = \ x - case x of pat - [ value | generators ]; _ - [] [ value | let binds, generators ] = let binds in [ value | generators ] So the special cases simplify to [ value | boolean ] = if boolean then [ value ] else [] [ value | pat - expr ] = expr = \ x - case x of pat - [ value ]; _ - [] [ value | let binds ] = let binds in [ value ] Why wouldn't this work? jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:19 +, Andrew Coppin wrote: Duncan Coutts wrote: On Sun, 2008-11-09 at 19:18 +, Andrew Coppin wrote: Generalised? Heck, I don't use list comprehension at all! :-P Perhaps you should! :-) When I first started with Haskell I kind of had the idea that list comprehensions were just for beginners and that 'real' hackers used just concatMaps and filters. A couple years later I 'rediscovered' list comprehensions and I now use them frequently. There are many cases in real programs where simple and not-so-simple list comprehensions are the clearest way of expressing the solution. In particular the easy support for refutable pattern matching in the generators allows some succinct and clear code. I don't actually use *lists* all that much - or at least not list transformations. And if I'm going to do something complicated, I'll usually write it as a do-expression rather than a comprehension. Just a random example out of Cabal: warn verbosity $ This package indirectly depends on multiple versions of the same ++ package. This is highly likely to cause a compile failure.\n ++ unlines [ package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) | (name, uses) - inconsistencies , (pkg, ver) - uses ] Pretty concise and clear I think. Erm... yeah, it's not too bad once I change all the formatting to make it clear what's what. Wouldn't it be a lot easier as a do-block though? This was my first thought, too: warn verbosity $ This package indirectly depends on multiple versions of the same ++ package. This is highly likely to cause a compile failure.\n ++ do (name, uses) - inconsistencies (pkg, ver) - uses package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) ++ \n is equivalent; it's at least clearer in that the generators come before the value, rather than after. jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
Jonathan Cast wrote: On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? Is there any specific reason to dis-allow it? The grammar here looks something like (NB: I didn't double-check the report): list_compr ::= [ value | generator* ] generator ::= boolean | pat - list | let binds Hmm, that's interesting. I didn't know that a Boolean was a valid generator. (Presumably this has the effect of filtering?) The only time I use list comprehensions is when I quickly want a Cartesian product. I wasn't really aware it could filter as well. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? It is due to the rules for the translation of list comprehensions: [ e | True ] = [ e ] [ e | q ]= [ e | q, True ] [ e | b, Q ] = if b then [ e | Q ] else [] [ e | p - l, Q ]= let ok p = [ e | Q ] ok _ = [] in concatMap ok l [ e | let decls, Q ] = let decls in [ e | Q ] So [ value | boolean ] matches the second rule giving us [value | boolean, True] which matches the third rule if boolean then [value | True] else [] which can be simplified via the first rule to if boolean then [value] else [] These rules are slightly more complex than necessary because they avoid using a null base case. We could simplify the first two rules if we were to allow the degenerate list comprehension [ e | ] and let Q match nothing. Then we'd use the rule: [ e | ] = [ e ] and translate [ value | boolean ] via the original 3rd rule with Q as nothing: if boolean then [value | ] else [] and directly to: if boolean then [value ] else [] If you meant, why is it allowed rather than banned then I guess the answer is because it is orthogonal. The rules naturally handle that case and there was no particular reason to ban it, even if it is somewhat unusual. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:19 +, Andrew Coppin wrote: I don't actually use *lists* all that much - or at least not list transformations. And if I'm going to do something complicated, I'll usually write it as a do-expression rather than a comprehension. Just a random example out of Cabal: warn verbosity $ This package indirectly depends on multiple versions of the same ++ package. This is highly likely to cause a compile failure.\n ++ unlines [ package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) | (name, uses) - inconsistencies , (pkg, ver) - uses ] Pretty concise and clear I think. Erm... yeah, it's not too bad once I change all the formatting to make it clear what's what. Wouldn't it be a lot easier as a do-block though? I don't think so: ++ unlines $ do (name, uses) - inconsistencies (pkg, ver) - uses return $ package ++ display pkg ++ requires ++ display (PackageIdentifier name ver) Of course reasonable people may disagree. It's mostly aesthetics. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:48 +, Andrew Coppin wrote: Jonathan Cast wrote: On Mon, 2008-11-10 at 18:20 +, Andrew Coppin wrote: Mitchell, Neil wrote: In general: if boolean then [value] else [] Can be written as: [value | boolean] Is there any specific reason why this is valid? Is there any specific reason to dis-allow it? The grammar here looks something like (NB: I didn't double-check the report): list_compr ::= [ value | generator* ] generator ::= boolean | pat - list | let binds Hmm, that's interesting. I didn't know that a Boolean was a valid generator. (Presumably this has the effect of filtering?) The only time I use list comprehensions is when I quickly want a Cartesian product. I wasn't really aware it could filter as well. Funny. About the only time I use list comprehensions is when I want a generalized filter. Serious computations get the do-notation, instead. (And sometimes I *have* to use do-notation for filtering, because I need an error monad (usually Maybe) for other reasons). jcc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Histogram creation
On Mon, 2008-11-10 at 18:05 +0100, Bertram Felgenhauer wrote: Alexey Khudyakov wrote: Hello! I'm tryig to write efficient code for creating histograms. I have following requirements for it: 1. O(1) element insertion 2. No reallocations. Thus in place updates are needed. accumArray won't go because I need to fill a lot of histograms (hundrends) from vely long list of data (possibly millions of elements) and it will traverse input data for each histogram. That's just not true, for GHC's implementation of accumArray at least, which goes via the ST monad. Perhaps I misunderstood but I think Alexey means that he wants to accumulate several different histograms (ie different arrays) but to only make one pass over the input data. The form of accumArray does not make that possible (unless one managed to pack the different histograms into different parts of the same array). If a fold using a pure persistent map type really is too slow then it should still be possible to do an ST implementation in a reasonably elegant way using a foldr on the input list, accumulating an ST action. Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] download haskell?
waldmann: This is nit-picking, but ... when I go to haskell.org, there is a link (top in the left menu) Download Haskell. Is this for readers who don't know the meaning of the word implementation (a few lines below)? Ah, it must be modelled after the perl.org start page... - J.W. Exactly. One less thing to learn. For a similar reason, we don't motivate the language in terms of higher-order, purely functional with monadic effects, but instead rapid development of robust, concise, correct software Keep things simple. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: FieldTrip library (functional 3D) and mailing list
Thanks for the prod, Andrew. (And thanks to Don S for prodding yesterday.) Now there's a picture on the FieldTrip page [1]. The shading is done using normals generated via derivatives from the vector-space package [2]. [1] http://haskell.org/haskellwiki/FieldTrip [2] http://haskell.org/haskellwiki/vector-space - Conal On Mon, Nov 10, 2008 at 10:27 AM, Andrew Coppin [EMAIL PROTECTED] wrote: Conal Elliott wrote: FieldTrip [1] is a library for functional 3D graphics. It is intended for building static, animated, and interactive 3D geometry, efficient enough for real-time synthesis and display. Since FieldTrip is functional, one describes what models are, not how to render them (being rather than doing). Surfaces are described as functions from 2D space to 3D space. As such, they are intrinsically curved rather than faceted. Surface rendering tessellates adaptively, caching tessellations in an efficient, infinite data structure (from the MemoTrie library) for reuse. Surface normals are computed automatically and exactly, using the derivative tools in the vector-space library. For animation or interaction, FieldTrip can be used with the Reactive [2] library for functional reactive programming (and possibly other animation frameworks). By design, FieldTrip is completely orthogonal to any formulation or implementation of FRP. The reactive-fieldtrip [3] library links Reactive and FieldTrip. FieldTrip now has a mailing list [4] and a feature/bug tracker [5]. Sounds very interesting, but... what, no pictures? From a library especially designed for generating pictures? :-) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: FieldTrip library (functional 3D) and mailing list
Conal Elliott wrote: Thanks for the prod, Andrew. (And thanks to Don S for prodding yesterday.) Now there's a picture on the FieldTrip page [1]. The shading is done using normals generated via derivatives from the vector-space package [2]. Mmm, nice. :-) (Actually... I just like shiny things!) What is the rendering backend? OpenGL? Or something else? Do you have any simple example code around? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: generalized list comprehensions
2008/11/10 Johannes Waldmann [EMAIL PROTECTED]: Well, my original post wasn't that negative ... Indeed then f [by e] seems a nice idea *but* the point was that I'd like to have this in any monad. The type of f in then f should be m a - m b, not just m a - m a, because then you don't need special syntax for group, which is somewhat like [a] - [[a]] ? Hi Johannes, I'm not sure what it would mean for f to have type m a - m b. The point of the parametric polymorphism in the type forall a. m a - m b is that the f function is guarenteed not to inspect the structure of the (list/monad) element. This allows the compiler to choose a representation for the intermediate tuples used in the desugaring freely. The group syntax really does desugar differently from then because the compiler inserts an extra unzip_n that the user could not have written, given that parametric polymorphism. All the best, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News: Issue 92 - November 8, 2008
Brent Yorgey wrote: --- Haskell Weekly News http://sequence.complete.org/hwn/20081108 Issue 92 - November 08, 2008 --- GHC version 6.10.1. Ian Lynagh [2]announced the release of [3]GHC version 6.10.1! This new major release features a number of significant changes, including wild-card patterns, punning, and field disambiguation in record syntax; generalised quasi-quotes; generalised SQL-like list comprehensions; view patterns; a complete reimplementation of type families; parallel garbage collection; a new extensible exception framework; a more user-friendly API; included Data Parallel Haskell (DPH); and more! See [4]the full release notes for more information. Were it not for this message, I might never have noticed! :-} (Presumably the main announcement was on one of the other Haskell lists...) Anyway, I don't see it anywhere in the release notes, but I get the vibe that type families are supposed to be fully working now. Is that correct? If so, why no mention anywhere? Also, the release notes tantelisingly hint that the long-awaited parallel-array stuff is finally working in this release, but I can't find any actual description of how to use it. All the DPH stuff seems on the wiki was last updated many months ago. You would have thought that such a big deal would be well-documented. It must have taken enough effort to get it to work! You'd think somebody would want to shout about it... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: FieldTrip library (functional 3D) and mailing list
We're using OpenGL as a rendering back-end. I've now added some sample code to the wiki page (http://haskell.org/haskellwiki/FieldTrip). It's very fast on my two-year-old machine. More examples are in src/Test.hs in the reactive-fieldtrip package. - Conal On Mon, Nov 10, 2008 at 11:32 AM, Andrew Coppin [EMAIL PROTECTED] wrote: Conal Elliott wrote: Thanks for the prod, Andrew. (And thanks to Don S for prodding yesterday.) Now there's a picture on the FieldTrip page [1]. The shading is done using normals generated via derivatives from the vector-space package [2]. Mmm, nice. :-) (Actually... I just like shiny things!) What is the rendering backend? OpenGL? Or something else? Do you have any simple example code around? ___ 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] Histogram creation
Alexey Khudyakov wrote: Hello! I'm tryig to write efficient code for creating histograms. I have following requirements for it: 1. O(1) element insertion 2. No reallocations. Thus in place updates are needed. accumArray won't go because I need to fill a lot of histograms (hundrends) from vely long list of data (possibly millions of elements) and it will traverse input data for each histogram. Sorry, Duncan is right. I misread here. My first idea would still be to use accumArray though, or rather, accum, processing the input data in chunks of an appropriate size (which depends on the histogram sizes.) But actually, the ST code isn't bad (I hope this isn't homework): import Control.Monad.ST import Control.Monad import Data.Array.ST import Data.Array.Unboxed stuArray :: ST s (STUArray s i e) - ST s (STUArray s i e) stuArray = id -- Create histograms. -- -- Each histogram is described by a pair (f, (l, u)), where 'f' maps -- a data entry to an Int index, and l and u are lower and upper bounds -- of the indices, respectively. -- mkHistograms :: [(a - Int, (Int, Int))] - [a] - [UArray Int Int] mkHistograms hs ds = runST collect where -- Why is the type signature on 'collect' required here? collect :: ST s [UArray Int Int] collect = do -- create histogram arrays of appropriate sizes histograms - forM hs $ \(_, range) - do stuArray $ newArray range 0 -- iterate through the data forM_ ds $ \d - do -- iterate through the histograms forM_ (zip hs histograms) $ \((f, _), h) - do -- update appropriate entry writeArray h (f d) . succ = readArray h (f d) -- finally, freeze the histograms and return them -- (using unsafeFreeze is ok because we're done modifying the -- arrays) mapM unsafeFreeze histograms test = mkHistograms [((`mod` 3), (0,2)), ((`mod` 5), (0,4))] [0..10] -- test returns -- [array (0,2) [(0,4),(1,4),(2,3)], -- array (0,4) [(0,3),(1,2),(2,2),(3,2),(4,2)]] Bertram P.S. Ryan is right, too - I'm not sure where I got confused there. runST $ foo didn't work in ghc 6.6; I knew that it works in ghc 6.8.3, but I thought this was changed again. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN (sorta): OpenGL with extra type safety
I recently modified the hOpenGL (and GLFW) source tree to force extra type checking on its various IO actions using the -XGeneralizedNewtypeDeriving extension (see http://hackage.haskell.org/trac/ghc/ticket/736). The main motivation was for writing concurrent OpenGL applications. Here its important to know what functions contain OpenGL commands so they can be directed to the proper threads (ones with active rendering contexts). Plus it aids in partitioning work that can be offloaded or done asynchronously. The second motivation was to enforce static type checking on commands that can only be executed in certain OpenGL contexts (sending vertex data for example). As it is now, there are 3 new monads (their names will probably change): OpenGLM: the basic opengl command PrimitiveM: commands that can only be issued between begin/end() class MonadGL: commands that can be issued in any GL context Now for the big question: Does anyone care? If so, should i make it a new hackageDB package, or try to merge it into the official GL package. Ideally, it'd be nice to get some more input on the API changes, since they're more or less a rough draft as is. Also, the GLU modules were all placed in the OpenGLM monad, which is probably wrong, assuming some commands can be called between begin/end. I'll post the code later if anyone is interested. class MonadIO m = MonadGL m instance MonadGL OpenGLM instance MonadGL PrimitiveM newtype OpenGLM a = OpenGLM (IO a) deriving (Functor, Monad, MonadIO) newtype PrimitiveM a = PrimitiveM (IO a) deriving (Functor, Monad, MonadIO) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN (sorta): OpenGL with extra type safety
wqeqweuqy: I recently modified the hOpenGL (and GLFW) source tree to force extra type checking on its various IO actions using the -XGeneralizedNewtypeDeriving extension (see http://hackage.haskell.org/trac/ghc/ticket/736). The main motivation was for writing concurrent OpenGL applications. Here its important to know what functions contain OpenGL commands so they can be directed to the proper threads (ones with active rendering contexts). Plus it aids in partitioning work that can be offloaded or done asynchronously. The second motivation was to enforce static type checking on commands that can only be executed in certain OpenGL contexts (sending vertex data for example). As it is now, there are 3 new monads (their names will probably change): OpenGLM: the basic opengl command PrimitiveM: commands that can only be issued between begin/end() class MonadGL: commands that can be issued in any GL context Now for the big question: Does anyone care? If so, should i make it a new hackageDB package, or try to merge it into the official GL package. Yes, make a new package. Put it on hackage. Don't waste work, when it can be archived at the very least. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Exporting a Type Class for Type Signatures
In the crypto package, I have two functions encrypt :: AESKey a = a - Word128 - Word128 decrypt :: AESKey a = a - Word128 - Word128 which are exported. I also have class (Bits a, Integral a) = AESKey a instance AESKey Word128 instance AESKey Word192 instance AESKey Word256 unexported which stops you using invalid keys. Someone has asked me to export AESKey as they want to write an explicit type signature for a function they are creating e.g. foo :: AESKey a = a - Word128 - Word128 foo x y = encrypt x y but this generates an error. Is there a way of allowing someone to use AESKey in a type signature but not allow them to declare new instances? Thanks, Dominic. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Exporting a Type Class for Type Signatures
Hello Dominic, Monday, November 10, 2008, 10:56:37 PM, you wrote: but this generates an error. Is there a way of allowing someone to use AESKey in a type signature but not allow them to declare new instances? afaik module AES (class AESKey,...) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] catting to cat gets stuck at 135K
I've put together a simple test case for a rather annoying problem. I've got a program that drives other programs. For example, it can drive `cat`: :; Simple cat a-file When the file is a little bit greater than 135060 bytes, this program fails to produce any output at all -- I need to use ^C to get my console back. I have a similar program that encounters the same issue a little after 139192 bytes. The inconsistency is one baffling feature of this bug. If I remove the `hClose`, the example program just hangs, no matter the size of the input. It is entirely possible that I have overlooked some subtle feature of pipe semantics -- indeed, I hope that is the case. -- _jsn import Data.ByteString.Lazy import System.Process import System.Environment import System.IO (hClose) import Prelude hiding (writeFile, readFile) main = do exe:file:_- getArgs bytes - readFile file foo - simple exe bytes [] writeFile (file ++ .foo) foo -- Manufactures a simple stream handler from a command line utility. simple :: String - ByteString - [String] - IO ByteString simple exe bytes args= do (i, o, e, p)- runInteractiveProcess exe args Nothing Nothing hPut i bytes s - hGetContents o hClose i return s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
On 2008 Nov 10, at 16:29, Jason Dusek wrote: I've put together a simple test case for a rather annoying problem. I've got a program that drives other programs. For example, it can drive `cat`: :; Simple cat a-file When the file is a little bit greater than 135060 bytes, this program fails to produce any output at all -- I need to use ^C to get my console back. If you are feeding it input and collecting output, you need to forkIO one or both. In particular, the sequence feed input read output waitForProcess will deadlock if at any point the input or output pipe fills: one side will be blocked on write() waiting for the other side to read() from the pipe, while the read() side is blocked waiting for write() on the other pipe, which won't be read() because that's the first side. (There are other variants of this, but that's the general form: processes blocked each waiting for the other side to do something.) If I remove the `hClose`, the example program just hangs, no matter the size of the input. That's another symptom of it, yes, made worse because the pipe close is now implicit and the other side won't stop read()ing until the pipe is close()d by the first side. simple exe bytes args= do (i, o, e, p)- runInteractiveProcess exe args Nothing Nothing hPut i bytes s - hGetContents o hClose i return s Yep, that's your problem. forkIO the hPut. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] download haskell?
Keep things simple. well I get the drift but for me, download haskell is a type error. you cannot download a programming language (imagine download C). anyway, I actually downloaded haskell today and built the shiny new ghc-6.10.1. best regards - J.W. signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC 6.10 / Mac OS X / Library problem
Hello, I've got a problem when I want to install pcre-light on OS X, with the latest version of GHC (binary package from haskell.org). It is not clear to me which flags to pass to ghc, to tell it to look at /opt/local/include for the pcre-light.h header. Any suggestions ? thanks, Pieter :cabal-install-0.6.0 pieter$ sudo cabal install pcre-light Password: Resolving dependencies... 'pcre-light-0.3.1' is cached. Configuring pcre-light-0.3.1... Preprocessing library pcre-light-0.3.1... Base.hsc:103:18: error: pcre.h: No such file or directory Base.hsc: In function 'main': Base.hsc:401: error: 'PCRE_ANCHORED' undeclared (first use in this function) Base.hsc:401: error: (Each undeclared identifier is reported only once Base.hsc:401: error: for each function it appears in.) Base.hsc:404: error: 'PCRE_AUTO_CALLOUT' undeclared (first use in this function) Base.hsc:407: error: 'PCRE_CASELESS' undeclared (first use in this function) Base.hsc:410: error: 'PCRE_DOLLAR_ENDONLY' undeclared (first use in this function) Base.hsc:413: error: 'PCRE_DOTALL' undeclared (first use in this function) Base.hsc:416: error: 'PCRE_DUPNAMES' undeclared (first use in this function) Base.hsc:419: error: 'PCRE_EXTENDED' undeclared (first use in this function) Base.hsc:422: error: 'PCRE_EXTRA' undeclared (first use in this function) Base.hsc:425: error: 'PCRE_FIRSTLINE' undeclared (first use in this function) Base.hsc:428: error: 'PCRE_MULTILINE' undeclared (first use in this function) Base.hsc:431: error: 'PCRE_NEWLINE_CR' undeclared (first use in this function) Base.hsc:434: error: 'PCRE_NEWLINE_CRLF' undeclared (first use in this function) Base.hsc:437: error: 'PCRE_NEWLINE_LF' undeclared (first use in this function) Base.hsc:440: error: 'PCRE_NO_AUTO_CAPTURE' undeclared (first use in this function) Base.hsc:443: error: 'PCRE_UNGREEDY' undeclared (first use in this function) Base.hsc:446: error: 'PCRE_UTF8' undeclared (first use in this function) Base.hsc:449: error: 'PCRE_NO_UTF8_CHECK' undeclared (first use in this function) Base.hsc:621: error: 'PCRE_NOTBOL' undeclared (first use in this function) Base.hsc:624: error: 'PCRE_NOTEOL' undeclared (first use in this function) Base.hsc:627: error: 'PCRE_NOTEMPTY' undeclared (first use in this function) Base.hsc:633: error: 'PCRE_PARTIAL' undeclared (first use in this function) Base.hsc:631: error: 'PCRE_ERROR_NOMATCH' undeclared (first use in this function) Base.hsc:634: error: 'PCRE_ERROR_NULL' undeclared (first use in this function) Base.hsc:637: error: 'PCRE_ERROR_BADOPTION' undeclared (first use in this function) Base.hsc:640: error: 'PCRE_ERROR_BADMAGIC' undeclared (first use in this function) Base.hsc:643: error: 'PCRE_ERROR_UNKNOWN_NODE' undeclared (first use in this function) Base.hsc:646: error: 'PCRE_ERROR_NOMEMORY' undeclared (first use in this function) Base.hsc:649: error: 'PCRE_ERROR_NOSUBSTRING' undeclared (first use in this function) Base.hsc:652: error: 'PCRE_ERROR_MATCHLIMIT' undeclared (first use in this function) Base.hsc:655: error: 'PCRE_ERROR_CALLOUT' undeclared (first use in this function) Base.hsc:658: error: 'PCRE_ERROR_BADUTF8' undeclared (first use in this function) Base.hsc:661: error: 'PCRE_ERROR_BADUTF8_OFFSET' undeclared (first use in this function) Base.hsc:664: error: 'PCRE_ERROR_PARTIAL' undeclared (first use in this function) Base.hsc:667: error: 'PCRE_ERROR_BADPARTIAL' undeclared (first use in this function) Base.hsc:670: error: 'PCRE_ERROR_INTERNAL' undeclared (first use in this function) Base.hsc:673: error: 'PCRE_ERROR_BADCOUNT' undeclared (first use in this function) Base.hsc:676: error: 'PCRE_ERROR_DFA_UITEM' undeclared (first use in this function) Base.hsc:679: error: 'PCRE_ERROR_DFA_UCOND' undeclared (first use in this function) Base.hsc:682: error: 'PCRE_ERROR_DFA_UMLIMIT' undeclared (first use in this function) Base.hsc:685: error: 'PCRE_ERROR_DFA_WSSIZE' undeclared (first use in this function) Base.hsc:688: error: 'PCRE_ERROR_DFA_RECURSE' undeclared (first use in this function) Base.hsc:691: error: 'PCRE_ERROR_RECURSIONLIMIT' undeclared (first use in this function) Base.hsc:665: error: 'PCRE_INFO_OPTIONS' undeclared (first use in this function) Base.hsc:668: error: 'PCRE_INFO_SIZE' undeclared (first use in this function) Base.hsc:671: error: 'PCRE_INFO_CAPTURECOUNT' undeclared (first use in this function) Base.hsc:674: error: 'PCRE_INFO_BACKREFMAX' undeclared (first use in this function) Base.hsc:677: error: 'PCRE_INFO_FIRSTBYTE' undeclared (first use in this function) Base.hsc:680: error: 'PCRE_INFO_FIRSTCHAR' undeclared (first use in this function) Base.hsc:683: error: 'PCRE_INFO_FIRSTTABLE' undeclared (first use in this function) Base.hsc:686: error: 'PCRE_INFO_LASTLITERAL' undeclared (first use in this function) Base.hsc:689: error: 'PCRE_INFO_NAMEENTRYSIZE' undeclared (first use in this function) Base.hsc:692: error: 'PCRE_INFO_NAMECOUNT' undeclared (first use in this function) Base.hsc:695: error: 'PCRE_INFO_NAMETABLE' undeclared
Re: [Haskell-cafe] Are arbitrary rank types and existentials equivalent?
Ryan Ingram schrieb: There's a natural relation between higher rank types and existentials; one way to think about it is this: if you have some existential type t (subject to some constraints), you cannot operate on it except with some function that accepts any type t subject to those constraints. There is a simple encoding of existential types using higher rank types: Given data E a1..an = forall e1...en. (constraints) = E t1..tn where t1..tn are types in terms of a1..an, we replace with data E' a1..an = E' (forall b. (forall e1..en. t1 - t2 - ... - tn - b) - b) Can you please put this on the Wiki? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generalized list comprehensions
On Mon, 2008-11-10 at 18:50 +, Duncan Coutts wrote: [...] If you meant, why is it allowed rather than banned then I guess the answer is because it is orthogonal. The rules naturally handle that case and there was no particular reason to ban it, even if it is somewhat unusual. Unusual? This is the motivation of list comprehensions. In naive set theory, set comprehensions are one way of an equivalence between predicates and sets. It's the Cartesian product aspect that should be considered unusual if anything. The binding aspect of list generators corresponds to naming the parameters of the predicate and then the Cartesian product aspect is simply the fact that a binary predicate, say, is a unary predicate on a binary Cartesian product. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Exporting a Type Class for Type Signatures
Bulat Ziganshin wrote: Hello Dominic, Monday, November 10, 2008, 10:56:37 PM, you wrote: but this generates an error. Is there a way of allowing someone to use AESKey in a type signature but not allow them to declare new instances? afaik module AES (class AESKey,...) This seems not to work on ghc6.8.2 at least. $ cat AClass.hs ; ghc AClass.hs module AClass (class A) where class A a where f :: a - () instance A () where f = id AClass.hs:1:15: parse error on input `class' Alas I don't know of any way to export a class for type signatures without exporting it for instantiation (corrections welcome :) There is, however, a fairly canonical hack if you're only concerned with the correctness of the code in your own library. You create an extra (empty) public class which is only an indirection for the real private class; and make sure your library only uses the real class. This way, even though clients can make new instances on the public class, that won't affect your own code. If your goal is to try to ensure the correctness of client code (not just the correctness of the library code), this trick doesn't help though. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.10 / Mac OS X / Library problem
it is however. the same happened to me.you just need to run cabal install pcre-light --extra-include-dirs=/opt/local/include --extra-lib-dirs=/opt/local/lib My location is /opt/local, since I installed pcre via macports sudo port install pcre Bue I think pcre is installed by default in /Developer/SDKs/MacOSX10.5.sdk/usr/ Just check it out and report back. Good luck, hugo On Mon, Nov 10, 2008 at 10:12 PM, Don Stewart [EMAIL PROTECTED] wrote: pieter: Hello, I've got a problem when I want to install pcre-light on OS X, with the latest version of GHC (binary package from haskell.org). It is not clear to me which flags to pass to ghc, to tell it to look at /opt/local/include for the pcre-light.h header. Looks like pcre.h (the libpcre C library ) isn't installed. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- www.di.uminho.pt/~hpacheco ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] GHC 6.10, strange behaviour when profiling?
Hello, I'm experiencing some strange behaviour with GHC 6.10 and would like an explanation why. Here's the problem. With GHC 6.8.[23] memory usage of a program was about 250mb (computing pi to 10^6 decimals). Now I tried recompiling and running with GHC 6.10 and I got more than 1.4gb before I killed it, so naturally I tried profiling but here's the strangeness. When I compile for profiling with -prof -auto-all and run with +RTS -p -RTS memory use is still about the same as before ( 1.4gb), but when I try running with +RTS -hc -RTS memory only reaches about 250mb. What is the explanation for this behaviour? I would send a program but it requires HERA, which is not on hackage ... Here is the output of -s ./Test 10 +RTS -s 47,467,176 bytes allocated in the heap 18,046,776 bytes copied during GC 9,215,104 bytes maximum residency (6 sample(s)) 711,520 bytes maximum slop 80 MB total memory in use (11 MB lost due to fragmentation) Generation 0:84 collections, 0 parallel, 0.01s, 0.01s elapsed Generation 1: 6 collections, 0 parallel, 0.01s, 0.01s elapsed INIT time0.00s ( 0.00s elapsed) MUT time3.66s ( 3.71s elapsed) GCtime0.02s ( 0.02s elapsed) RPtime0.00s ( 0.00s elapsed) PROF time0.00s ( 0.00s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time3.68s ( 3.73s elapsed) %GC time 0.5% (0.6% elapsed) Alloc rate12,982,553 bytes per MUT second Productivity 99.5% of total user, 97.9% of total elapsed ./Test 10 +RTS -s -hc 47,471,160 bytes allocated in the heap 18,637,752 bytes copied during GC 13,580,144 bytes maximum residency (37 sample(s)) 810,712 bytes maximum slop 33 MB total memory in use (7 MB lost due to fragmentation) Generation 0:85 collections, 0 parallel, 0.02s, 0.02s elapsed Generation 1:37 collections, 0 parallel, 0.00s, 0.01s elapsed INIT time0.00s ( 0.00s elapsed) MUT time3.67s ( 3.73s elapsed) GCtime0.02s ( 0.03s elapsed) RPtime0.00s ( 0.00s elapsed) PROF time0.00s ( 0.00s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time3.70s ( 3.77s elapsed) %GC time 0.6% (0.8% elapsed) Alloc rate12,941,165 bytes per MUT second Productivity 99.2% of total user, 97.4% of total elapsed -- Best regards, Aleš ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 6.10, strange behaviour when profiling?
Could you please file this as a bug at this address, http://hackage.haskell.org/trac/ghc/newticket?type=bug Cheers, Don ales.bizjak0: Hello, I'm experiencing some strange behaviour with GHC 6.10 and would like an explanation why. Here's the problem. With GHC 6.8.[23] memory usage of a program was about 250mb (computing pi to 10^6 decimals). Now I tried recompiling and running with GHC 6.10 and I got more than 1.4gb before I killed it, so naturally I tried profiling but here's the strangeness. When I compile for profiling with -prof -auto-all and run with +RTS -p -RTS memory use is still about the same as before ( 1.4gb), but when I try running with +RTS -hc -RTS memory only reaches about 250mb. What is the explanation for this behaviour? I would send a program but it requires HERA, which is not on hackage ... Here is the output of -s ./Test 10 +RTS -s 47,467,176 bytes allocated in the heap 18,046,776 bytes copied during GC 9,215,104 bytes maximum residency (6 sample(s)) 711,520 bytes maximum slop 80 MB total memory in use (11 MB lost due to fragmentation) Generation 0:84 collections, 0 parallel, 0.01s, 0.01s elapsed Generation 1: 6 collections, 0 parallel, 0.01s, 0.01s elapsed INIT time0.00s ( 0.00s elapsed) MUT time3.66s ( 3.71s elapsed) GCtime0.02s ( 0.02s elapsed) RPtime0.00s ( 0.00s elapsed) PROF time0.00s ( 0.00s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time3.68s ( 3.73s elapsed) %GC time 0.5% (0.6% elapsed) Alloc rate12,982,553 bytes per MUT second Productivity 99.5% of total user, 97.9% of total elapsed ./Test 10 +RTS -s -hc 47,471,160 bytes allocated in the heap 18,637,752 bytes copied during GC 13,580,144 bytes maximum residency (37 sample(s)) 810,712 bytes maximum slop 33 MB total memory in use (7 MB lost due to fragmentation) Generation 0:85 collections, 0 parallel, 0.02s, 0.02s elapsed Generation 1:37 collections, 0 parallel, 0.00s, 0.01s elapsed INIT time0.00s ( 0.00s elapsed) MUT time3.67s ( 3.73s elapsed) GCtime0.02s ( 0.03s elapsed) RPtime0.00s ( 0.00s elapsed) PROF time0.00s ( 0.00s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time3.70s ( 3.77s elapsed) %GC time 0.6% (0.8% elapsed) Alloc rate12,941,165 bytes per MUT second Productivity 99.2% of total user, 97.4% of total elapsed -- Best regards, Aleš ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Weekly News: Issue 92 - November 8, 2008
Anyway, I don't see it anywhere in the release notes, but I get the vibe that type families are supposed to be fully working now. Is that correct? If so, why no mention anywhere? Type families have been completely reimplemented and should be stable now, but there are some bugs - notably equality constraints in superclasses are not supported in GHC 6.10.1, i.e. class (F a ~ b) = C a b where type F a As indicated by this bug report: http://hackage.haskell.org/trac/ghc/ticket/2715 And here: http://haskell.org/haskellwiki/GHC/Indexed_types#Equality_constraints Also, the release notes tantelisingly hint that the long-awaited parallel-array stuff is finally working in this release, but I can't find any actual description of how to use it. All the DPH stuff seems on the wiki was last updated many months ago. You would have thought that such a big deal would be well-documented. It must have taken enough effort to get it to work! You'd think somebody would want to shout about it... I put up a DPH version of the binarytrees benchmark in the shootout: http://haskell.org/haskellwiki/Shootout/Parallel/BinaryTreesDPH There are some notes there; the only documentation I really used was the documentation built by the GHC build process on the 'dph-*' libraries (you can see them in 6.10 by just doing 'ghc-pkg list' and looking through it.) I was thinking of porting more of the parallel shootout entries to use DPH, but I'm busy right now - results could be interesting. Austin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
Yep, that's your problem. forkIO the hPut. I can see the that thing biting a lot of people. Maybe there should be a warning in docs that this particular combination: feed input read output waitForProcess is just likely to produce deadlocks? All best Christopher Skrzętnicki ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
simple exe bytes args= do (i, o, e, p)- runInteractiveProcess exe args Nothing Nothing hPut i bytes s - hGetContents o hClose i return s Yep, that's your problem. forkIO the hPut. Maybe I didn't do enough here -- just wrapping in `forkIO` does not seem to actually help. -- _jsn import Data.ByteString.Lazy import System.Process import System.Environment import System.IO (hClose) import Control.Concurrent import Prelude hiding (writeFile, readFile) main = do exe:file:_- getArgs bytes - readFile file foo - simple exe bytes [] writeFile (file ++ .foo) foo -- Manufactures a simple stream handler from a command line utility. simple :: String - ByteString - [String] - IO ByteString simple exe bytes args= do (i, o, e, p) - runInteractiveProcess exe args Nothing Nothing forkIO $ hPut i bytes s - hGetContents o return s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] A video of Frag
Okay so i've written a blog on how to build and run frag on windows @ http://monadickid.blogspot.com/2008/11/haskell-eye-for-windows-guy.html CC: [EMAIL PROTECTED]; haskell-cafe@haskell.org From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [Haskell-cafe] A video of Frag Date: Mon, 10 Nov 2008 08:22:20 -0600 -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Nov 10, 2008, at 3:15 AM, Hugo Pacheco wrote: Perhaps this effort could be targeted at creating a cabal package in Hackage It's already there. :) http://hackage.haskell.org/cgi-bin/hackage-scripts/package/frag - - Jake -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkkYQ5wACgkQye5hVyvIUKkZCACgwy3VdzBfVTf8aIKxk67PAzgt yyEAnjrbiaZTBQFqfI3jUSEn96Iv16GP =Jwyf -END PGP SIGNATURE- _ See the most popular videos on the web http://clk.atdmt.com/GBL/go/115454061/direct/01/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
This does not work either. It should cover all the bases, right? Fork off input, pull things from ouput as they are ready, stop when we reach end of file. If you remove the line `print partial`, the program loops forever; if you keep it, the program stops right there. -- _jsn import Data.ByteString.Lazy hiding (putStrLn) import System.Process import System.Environment import System.IO (putStrLn, hClose, hWaitForInput) import System.IO.Error import Control.Concurrent import Prelude hiding (writeFile, readFile) main = do exe:file:_- getArgs bytes - readFile file foo - simple exe bytes [] writeFile (file ++ .foo) foo -- Manufactures a simple stream handler from a command line utility. simple :: String - ByteString - [String] - IO ByteString simple exe bytes args= do (i, o, e, p) - runInteractiveProcess exe args Nothing Nothing pushAndPull i o bytes pushAndPull i o bytes= do putStrLn Working with: print bytes forkIO $ hPut i bytes putStrLn forked readUntilDone empty where readUntilDone soFar= do (const $ return soFar) `hctac` do putStrLn hctac hWaitForInput o 0 -- Wait as long as it takes. putStrLn waited partial - hGetContents o putStrLn contents: print partial readUntilDone $ append soFar partial where hctac= flip catch ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
On 2008 Nov 10, at 19:04, Jason Dusek wrote: simple exe bytes args= do (i, o, e, p)- runInteractiveProcess exe args Nothing Nothing hPut i bytes s - hGetContents o hClose i return s Yep, that's your problem. forkIO the hPut. Maybe I didn't do enough here -- just wrapping in `forkIO` does not seem to actually help. *sigh* I hate the ghc runtime... it works in ghci, or compiled with - threaded. Otherwise you still get the deadlock because it only switches threads under limited circumstances (garbage collections?) which isn't nearly often enough. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED] system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED] electrical and computer engineering, carnegie mellon universityKF8NH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: download haskell?
On Mon, 10 Nov 2008 19:20:09 +0100, Johannes Waldmann [EMAIL PROTECTED] wrote: This is nit-picking, but ... when I go to haskell.org, there is a link (top in the left menu) Download Haskell. Is this for readers who don't know the meaning of the word implementation (a few lines below)? Ah, it must be modelled after the perl.org start page... - J.W. Although in order truly to model the perl.org start page, in line with their following link: download@ % perl Haskell's corresponding link should probably be (somewhat facetiously): download :: Click - HaskellCompiler download GHC -- Benjamin L. Russell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
That was just me being absent-minded -- I have threaded in my Cabal file but was not using it on the command line for my little test script. Thank you for calling it to my attention. -- _jsn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
Jason Dusek [EMAIL PROTECTED] writes: simple exe bytes args= do (i, o, e, p)- runInteractiveProcess exe args Nothing Nothing hPut i bytes s - hGetContents o hClose i return s Yep, that's your problem. forkIO the hPut. Maybe I didn't do enough here -- just wrapping in `forkIO` does not seem to actually help. What GHC version are you using? Bugs #1780, #1936, and #2155 might be relevant. -- Daniel Franke [EMAIL PROTECTED] http://www.dfranke.us || =|\ || * | -|-\- Man is free at the instant he wants to be. -| =| \ /// --Voltaire ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] catting to cat gets stuck at 135K
I am using 6.8.3 -- it is almost exciting to realize how close I came to 'impossible' instead of 'annoying'. Living on the edge with UNIX IO! -- _jsn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Closed type classes [was: Exporting a Type Class for Type Signatures]
Dominic Steinitz wrote: In the crypto package, I have two functions encrypt :: AESKey a = a - Word128 - Word128 decrypt :: AESKey a = a - Word128 - Word128 but the class AESKey is not exported, to prevent the user from adding more instances to it. Since AESKey is not exported, the users cannot write signatures that mention that class constraint. The question is, how to export a _closed_ class -- a class the user cannot extend. Chung-chieh Shan and I had a similar problem in our TFP2007 paper: the classes that implement type-level arithmetic must be closed, to prevent the user from declaring that 1+1=1. It seems the best method is to use class aliases: In the implementation of AES, introduce class AESKey a = AESKeyExport a instance AESKey a = AESKeyExport a -- the only instance and now export AESKeyExport (but leave AESKey hidden). If the user needs to write the signature for their function: foo :: AESKeyExport a = a - Word128 - Word128 foo x y = encrypt x y they should use the constraint AESKeyExport a. That constraint entails AESKey a, which they cannot mention. The users can try to extend the class ESKeyExport a, but that would do them no good: the library uses the instances of AESKey rather than AESKeyExport. The TFP2007 paper explains that in a bit more detail: http://okmij.org/ftp/Computation/resource-aware-prog/tfp.pdf (Section 2.1). It also mentions a different method, relying on partial type signatures. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] reliable (bi)directional pipe to a process
I'd like to point out a reliable, proven and simple way of interacting with another process, via unidirectional or bidirectional pipes. The method supports Unix sockets, pipes, and TCP sockets. I too have noticed insidious bugs in GHC run-time when communicating with another process via a pipe. I tried to use runInteractiveProcess; it worked -- up to file sizes of about 300Kb. Then GHC run-time seems to `loses synchronization' -- and corrupts IO buffers, receiving stuff that cannot have been possibly sent. This is because handle operations are asynchronous and the GHC scheduler seems to have race conditions. That behavior was totally unacceptable. I was writing a production code, and can't afford such errors. Therefore, I wrote a simple foreign function interface to the code sys_open that I have been using for about fifteen years. This code does work, in production, for very large file sizes and long-running processes, on many Unix and Unix-like systems. I was told once about a Cygwin port. http://okmij.org/ftp/syscall-interpose.html#Application http://okmij.org/ftp/packages/sys_open.c http://okmij.org/ftp/Haskell/MySysOpen.hs Please see the test at the end of the file MySysOpen.hs. The test interacts with another process over a bi-directional pipe, repeatedly sending and receiving data. The amount of received data is large (about 510K). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] reliable (bi)directional pipe to a process
oleg: I'd like to point out a reliable, proven and simple way of interacting with another process, via unidirectional or bidirectional pipes. The method supports Unix sockets, pipes, and TCP sockets. I too have noticed insidious bugs in GHC run-time when communicating with another process via a pipe. I tried to use runInteractiveProcess; it worked -- up to file sizes of about 300Kb. Then GHC run-time seems to `loses synchronization' -- and corrupts IO buffers, receiving stuff that cannot have been possibly sent. This is because handle operations are asynchronous and the GHC scheduler seems to have race conditions. That behavior was totally unacceptable. I was writing a production code, and can't afford such errors. Did you file a bug report!? Can you follow up with information we can use to chase this down. Therefore, I wrote a simple foreign function interface to the code sys_open that I have been using for about fifteen years. This code does work, in production, for very large file sizes and long-running processes, on many Unix and Unix-like systems. I was told once about a Cygwin port. http://okmij.org/ftp/syscall-interpose.html#Application http://okmij.org/ftp/packages/sys_open.c http://okmij.org/ftp/Haskell/MySysOpen.hs Please see the test at the end of the file MySysOpen.hs. The test interacts with another process over a bi-directional pipe, repeatedly sending and receiving data. The amount of received data is large (about 510K). To file a bug, go here, http://hackage.haskell.org/trac/ghc/newticket?type=bug -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe