[Haskell-cafe] Review request for my permutations implementation

2010-01-07 Thread CK Kashyap
Hi All, I've written this piece of code to do permutations - perms :: String -> [String] perms []= [] perms (x:[])= [[x]] perms (x:xs)= concat (f [x] (perms xs)) spread :: String -> String -> [String] -- interpolate first string at various positions of second string spread str1 str2 = _spread s

Re: [Haskell-cafe] Review request for my permutations implementation

2010-01-07 Thread Jochem Berndsen
CK Kashyap wrote: > I've written this piece of code to do permutations - First off, this is a recurring topic. If you search the archives, you'll find some more topics about it. > perms :: String -> [String] Why this type? Since a String is just a list of Char, and you don't use the fact that yo

Re: [Haskell-cafe] Problem with cabal install zlib

2010-01-07 Thread Ozgur Akgun
Oh! I was pretty sure that I made these patches correctly. But guess what, the added flags to hsc2hs are different from the others. And I did a bling copy/paste. Thanks for reminding it Gregory. Best, 2010/1/6 Gregory Collins > Ozgur Akgun writes: > > > Just to check, anyone running Snow Leo

[Haskell-cafe] Re: FASTER primes

2010-01-07 Thread Heinrich Apfelmus
Will Ness wrote: > Heinrich Apfelmus writes: > >> Concerning lists as producer/consumer, I think that's exactly what lazy >> evaluation is doing. Neither filter , map or span evaluate and >> store more list elements that strictly necessary. > > I laways suspected as much, but was once told th

Re: [Haskell-cafe] Review request for my permutations implementation

2010-01-07 Thread Daniel Fischer
Am Donnerstag 07 Januar 2010 09:37:42 schrieb CK Kashyap: > Hi All, > > I've written this piece of code to do permutations - > > perms :: String -> [String] Nothing in the algorithm needs the list elements to be Chars, there's no type class involved, so it should be perms :: [a] -> [[a]] > per

[Haskell-cafe] ANNOUNCE: safer-file-handles-0.1

2010-01-07 Thread Bas van Dijk
Hello, I'm happy to announce another member in the 'monadic regions' family: safer-file-handles: http://hackage.haskell.org/package/safer-file-handles-0.1 The package uses my 'regions' and 'explicit-iomodes' packages to add two safety features on top of the regular System.IO file handles and ope

Re: [Haskell-cafe] Review request for my permutations implementation

2010-01-07 Thread Rafael Gustavo da Cunha Pereira Pinto
Hi, Is there an entry in the haskell wiki for permutations? Since this is a recurring topic, as primes, shouldn't we create a topic for that in the wiki? Regards, Rafael On Thu, Jan 7, 2010 at 08:46, Daniel Fischer wrote: > Am Donnerstag 07 Januar 2010 09:37:42 schrieb CK Kashyap: > > > Hi A

[Haskell-cafe] dph and ghc-6.12 ?

2010-01-07 Thread Johannes Waldmann
Dear all, I'd love to use Data Parallel Haskell (for now, just as a demonstration, in a lecture). I want to convince my students (and myself) that this thing "really works". What would be an easy-to-understand, but still impressive enough benchmark? (to be run on 8 core amd64)? What is the curr

[Haskell-cafe] looking for origin of quote on preprocessors and language design

2010-01-07 Thread Johannes Waldmann
Dear all, It's not exactly Haskell-specific, but ... I am trying to track down the origin of the proverb "the existence (or: need for) a preprocessor shows omissions in (the design of) a language." I like to think that in Haskell, we don't need preprocessors since we can manipulate programs pro

Re: [Haskell-cafe] looking for origin of quote on preprocessors and language design

2010-01-07 Thread Bulat Ziganshin
Hello Johannes, Thursday, January 7, 2010, 3:32:03 PM, you wrote: > "the existence (or: need for) a preprocessor > shows omissions in (the design of) a language." yes, that's the common opinion. the same true for comments and identifiers :D shortly speaking, preprocessor is just another languag

[Haskell-cafe] Re: Review request for my permutations implementation

2010-01-07 Thread Maciej Piechotka
On Thu, 2010-01-07 at 00:37 -0800, CK Kashyap wrote: > Hi All, > > I've written this piece of code to do permutations - > I assume that it's training piece not real code as in such I'd recommend: > import Data.List > perms = permutations > perms :: String -> [String] > perms []= [] As pointed

Re[2]: [Haskell-cafe] looking for origin of quote on preprocessors and language design

2010-01-07 Thread Bulat Ziganshin
Hello Bulat, Thursday, January 7, 2010, 4:03:07 PM, you wrote: >> "the existence (or: need for) a preprocessor >> shows omissions in (the design of) a language." forget to add: for language designers, analysis of typical preprocessor usage and adding analogous features to language instead is a g

Re: [Haskell-cafe] Re: Review request for my permutations implementation

2010-01-07 Thread Daniel Fischer
Am Donnerstag 07 Januar 2010 14:04:20 schrieb Maciej Piechotka: > > As pointed out perms [] = [[]]. You can note that: > length . perms == factorial Surely you meant genericLength . perms == factorial . (genericLength :: [a] -> Integer) ___ Haskell-Ca

[Haskell-cafe] Re: looking for origin of quote on preprocessors and language design

2010-01-07 Thread Maciej Piechotka
On Thu, 2010-01-07 at 13:32 +0100, Johannes Waldmann wrote: > Dear all, > > It's not exactly Haskell-specific, but ... > I am trying to track down the origin of the proverb > > "the existence (or: need for) a preprocessor > shows omissions in (the design of) a language." > > > I like to think t

[Haskell-cafe] Re: Re: Review request for my permutations implementation

2010-01-07 Thread Maciej Piechotka
On Thu, 2010-01-07 at 14:12 +0100, Daniel Fischer wrote: > Am Donnerstag 07 Januar 2010 14:04:20 schrieb Maciej Piechotka: > > > > > > As pointed out perms [] = [[]]. You can note that: > > > length . perms == factorial > > Surely you meant > > genericLength . perms == factorial . (genericLeng

Re: [Haskell-cafe] looking for origin of quote on preprocessors and language design

2010-01-07 Thread MightyByte
It strikes me that this question may be related (perhaps distantly) to Godel's incompleteness theorem. Anyone else see similarities here? On Thu, Jan 7, 2010 at 7:32 AM, Johannes Waldmann wrote: > Dear all, > > It's not exactly Haskell-specific, but ... > I am trying to track down the origin of

[Haskell-cafe] ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Bas van Dijk
Hello, As I explained in my announcement of 'safer-file-handles', I discovered a serious lack of expressive power in my 'regions' package. I have now solved that problem in the way I envisaged by removing the 'resource' parameter from 'RegionT' and using existential quantification to bring the 're

[Haskell-cafe] Re: ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Bas van Dijk
BTW As can be seen from the documentation of 'safer-file-handles', I'm currently not satisfied at all about my implementation of the standard files (stdin, stdout and stderr). To quote the docs: BIG WARNING: I'm not satisfied with my current implementation of the standard handles (stdin, stdout

Re: [Haskell-cafe] ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Felipe Lessa
On Thu, Jan 07, 2010 at 04:00:31PM +0100, Bas van Dijk wrote: > As I explained in my announcement of 'safer-file-handles', I > discovered a serious lack of expressive power in my 'regions' package. > I have now solved that problem in the way I envisaged by removing the > 'resource' parameter from '

Re: [Haskell-cafe] Re: ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Bulat Ziganshin
Hello Bas, Thursday, January 7, 2010, 6:25:34 PM, you wrote: > So now I'm confused... are these standard file handles always open on > program startup or are there abnormal situations when they are closed? afaik, parent process may close them before executing your program, it's used in particula

Re: [Haskell-cafe] Explicit garbage collection

2010-01-07 Thread Miguel Mitrofanov
Damn. Seems like I really need (True, False, True) as a result of "test". On 7 Jan 2010, at 08:52, Miguel Mitrofanov wrote: Seems very nice. Thanks. On 7 Jan 2010, at 08:01, Edward Kmett wrote: Here is a slightly nicer version using the Codensity monad of STM. Thanks go to Andrea Vezzosi

[Haskell-cafe] Distinct types in a list

2010-01-07 Thread rodrigo.bonifacio
Hi all, I have a family of parsers that return either (Success t) or (Fail), using the following data type: > data ParserResult a = Success a | Fail String > deriving (Read, Show, Eq, Ord) > > isSuccess (Success _) = True > isSuccess (Fail _) = False > ... I want to add the results of differen

Re: [Haskell-cafe] Distinct types in a list

2010-01-07 Thread Ozgur Akgun
If I understand you correctly, what you want is very similar to catMaybes isSuccess' (Success a) = Just a isSuccess' _ = Nothing result = catMaybes $ map isSuccess ps This should do the trick. 2010/1/7 rodrigo.bonifacio > Hi all, > > I have a family of parsers that return either (Success t)

Re: [Haskell-cafe] Distinct types in a list

2010-01-07 Thread Khudyakov Alexey
В сообщении от Четверг 07 января 2010 21:35:10 rodrigo.bonifacio написал: > Hi all, > > I have a family of parsers that return either (Success t) or (Fail), using the following data type: > > data ParserResult a = Success a | Fail String > > deriving (Read, Show, Eq, Ord) > > > > isSuccess (Succ

[Haskell-cafe] Re: Distinct types in a list

2010-01-07 Thread Christian Maeder
You could cast your parser result "a" to Dynamic using Data.Dynamic.toDyn (and derive Typeable instances for all involved types). http://www.haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-Dynamic.html Using an existential types may be another alternative. Cheers Christian rodrigo.

Re: [Haskell-cafe] Re: FASTER primes

2010-01-07 Thread Daniel Fischer
Am Donnerstag 07 Januar 2010 17:13:38 schrieb Daniel Fischer: >     compos :: [a] -> [a] >     compos = vips . itfold mergeSP . multip Sigh! That's what I get for editing the code in the mail editor. I decided to change the really stupid 'itfold' to 'smartfold' and forgot this occurrence. __

[Haskell-cafe] Re: Why doesn't laziness save the day here?

2010-01-07 Thread Dale Jordan
o...@okmij.org wrote: The others have already pointed out the problem with the imperative solution, which used the mutation of the global state with the new random seed. Imperative approach is indeed often a problem. As Daniel Fischer pointed out, my immediate problem was that iterateR never f

Re: [Haskell-cafe] ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Bas van Dijk
On Thu, Jan 7, 2010 at 5:15 PM, Felipe Lessa wrote: > On Thu, Jan 07, 2010 at 04:00:31PM +0100, Bas van Dijk wrote: >> As I explained in my announcement of 'safer-file-handles', I >> discovered a serious lack of expressive power in my 'regions' package. >> I have now solved that problem in the way

Re: [Haskell-cafe] pcre-light install fails with undefined reference to _impure_ptr

2010-01-07 Thread Joachim Breitner
Hi, Am Sonntag, den 27.12.2009, 09:50 + schrieb Stephen Tetley: > > I'll try next with MinGW to see if that works... > > Aye, it builds fine under MinGW. > > I built and installed PCRE (c & c++ library) from the source > (./configure, make, make install), though I think there is a package >

Re: [Haskell-cafe] Re: ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Bas van Dijk
On Thu, Jan 7, 2010 at 5:18 PM, Bulat Ziganshin wrote: > Hello Bas, > > Thursday, January 7, 2010, 6:25:34 PM, you wrote: > >> So now I'm confused... are these standard file handles always open on >> program startup or are there abnormal situations when they are closed? > > afaik, parent process m

Re: [Haskell-cafe] Explicit garbage collection

2010-01-07 Thread Edward Kmett
Thats a shame, I was rather fond of this monad. To get that last 'True', you'll really have to rely on garbage collection to approximate reachability for you, leaving the weak reference solution the best you can hope for. -Edward Kmett On Thu, Jan 7, 2010 at 12:39 PM, Miguel Mitrofanov wrote: >

Re: [Haskell-cafe] Re: Distinct types in a list

2010-01-07 Thread Keith Sheppard
Hello, My impression is that using existential types where possible will result in more complete type checking than Data.Dynamic but I'm not sure since I haven't yet tried Data.Dynamic in my own code. Can someone confirm if this is right? Best Keith On Thu, Jan 7, 2010 at 2:02 PM, Christian Maede

Re[2]: [Haskell-cafe] Re: Distinct types in a list

2010-01-07 Thread Bulat Ziganshin
Hello Keith, Thursday, January 7, 2010, 11:26:51 PM, you wrote: existential types has more limited usage compared to dynamics, but in the cases they work they allow to have compile-time type-checking instead of run-time one > Hello, My impression is that using existential types where possible >

[Haskell-cafe] Example of sending headers/cookies with Network.HTTP.simpleHTTP or Network.Browser?

2010-01-07 Thread Matt Brown
Hi all, Does anyone know of a good/simple example of sending cookies and other headers in an HTTP request via simpleHTTP or Browser? I know what the cookies should be (i.e. I don't want them to be sent by the server). More specifically, I'm looking for an analogue to curl's -b and -H flags. tha

Re: [Haskell-cafe] Approaches to dependent types (DT)

2010-01-07 Thread pbrowne
Hi, I am attempting to explain an example of dependent types to computing practitioners who do not have any background in functional programming. My goal is to explain the example rather than implement or improve it. I have been told in previous postings that the approach below is a bit dated. Any

[Haskell-cafe] Testing for statistical properties

2010-01-07 Thread Gregory Crosswhite
Hey everyone! I have some computations that satisfy statistical properties which I would like to test --- that is, the result of the computation is non-deterministic, but I want to check that it is sampling the distribution that it should be sampling. Is anyone aware of a Haskell library out t

Re: [Haskell-cafe] Explicit garbage collection

2010-01-07 Thread Miguel Mitrofanov
I liked it too. Seems like I have to show some real code, and my apologies for a long e-mail. Well, that's what I'm actually trying to do and what I've managed to achieve so far. > module Ask where > import Control.Monad > import Data.IORef > import Data.Maybe > import System.IO.Unsafe -- Y

Re: [Haskell-cafe] Explicit garbage collection

2010-01-07 Thread Edward Kmett
That is kind of what I thought you were doing. Retooling to see if we can get any better performance out of collecting, it seems that System.Mem.PerformGC does a foreign call out to performMajorGC to ask for a global collection. But I would hazard that you might be able to get most of the benefit

Re: [Haskell-cafe] Explicit garbage collection

2010-01-07 Thread Miguel Mitrofanov
Hmm, interesting. Seems like I have to take a closer look at GHC's garbage collection. Thanks! On 8 Jan 2010, at 00:53, Edward Kmett wrote: That is kind of what I thought you were doing. Retooling to see if we can get any better performance out of collecting, it seems that System.Mem.Perfo

Re: [Haskell-cafe] ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Felipe Lessa
On Thu, Jan 07, 2010 at 08:39:59PM +0100, Bas van Dijk wrote: > Another solution might be to encode the resources that a region opens > as constraints. I think 'control-monad-exception' uses a similar > technique to encode all the exceptions that a monadic computation may > throw. Yes, yes, that's

[Haskell-cafe] Re: darcs 2.4 beta 1 release

2010-01-07 Thread Trent W. Buck
Ivan Lazar Miljenovic writes: > I consider it "show-stopping" in the sense that I keep having people > on #gentoo-haskell asking me why they can't compile darcs 2.3.1 > because that error comes up, and I have to explain to either disable > documentation or downgrade Cabal (if they're still using h

Re: [Haskell-cafe] darcs 2.4 beta 1 release

2010-01-07 Thread zaxis
Both darcs and xmonad are only great product i know! thanks! Reinier Lamers-2 wrote: > > Hi all, > > The darcs team would like to announce the immediate availability of darcs > 2.4 > beta 1. darcs 2.4 will contain many improvements and bugfixes compared to > darcs 2.3.1. Highlights are the fa

Re: [Haskell-cafe] Re: darcs 2.4 beta 1 release

2010-01-07 Thread Ivan Lazar Miljenovic
t...@cybersource.com.au (Trent W. Buck) writes: > Does Gentoo's cabal set "documentation: True" by default? On Debian, > "cabal install foo" will not build documentation; it's only when > building a .deb with CDBS that documentation is built. No, but a lot of people have USE=doc which builds the

Re: [Haskell-cafe] Review request for my permutations implementation

2010-01-07 Thread CK Kashyap
Thanks everyone, Thanks Daniel for this really detailed explanation - thank you very much. Regards, Kashyap > >From: Daniel Fischer >To: haskell-cafe@haskell.org >Cc: CK Kashyap >Sent: Thu, January 7, 2010 4:16:33 PM >Subject: Re: [Haskell-cafe] Review request for my permutations implementation

Re: [Haskell-cafe] Re: ANNOUNCE: New versions of ALL the monadic regions packages

2010-01-07 Thread Brandon S. Allbery KF8NH
On Jan 7, 2010, at 14:44 , Bas van Dijk wrote: On Thu, Jan 7, 2010 at 5:18 PM, Bulat Ziganshin wrote: Thursday, January 7, 2010, 6:25:34 PM, you wrote: So now I'm confused... are these standard file handles always open on program startup or are there abnormal situations when they are closed

[Haskell-cafe] ANNOUNCE: system-uuid-1.2.0

2010-01-07 Thread Jason Dusek
Patched by Antoine S. Latter to interoperate with UUID. http://hackage.haskell.org/package/system-uuid-1.2.0 -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] Testing for statistical properties

2010-01-07 Thread Lee Pike
Greg, Hey everyone! I have some computations that satisfy statistical properties which I would like to test --- that is, the result of the computation is non-deterministic, but I want to check that it is sampling the distribution that it should be sampling. Is anyone aware of a Haskell