Re: [Haskell-cafe] ANNOUNCE: iteratee-compress 0.2.0.0

2011-04-25 Thread Conrad Parker
On 23 April 2011 19:29, Maciej Piechotka uzytkown...@gmail.com wrote:
 Iteratee-compress provides compressing and decompressing enumerators
 including flushing (using John Lato's implementation). Currently only
 gzip and bzip is provided but LZMA is planned.

 Changes from previous version:
  - Add BZip support


Cool :)

I notice the haddocks on hackage have not been generated; would this
be due to libbz2-dev missing on the hackage server?

Conrad.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] converting prefixes of CString - String

2011-04-25 Thread Eric Stansifer
I have been reading Foreign.C.String but it does not seem to provide
the functionality I was looking for.

Let 'c2h' convert CStrings to Haskell Strings, and 'h2c' convert
Haskell Strings to CStrings.  (If I understand correctly, c2h . h2c
=== id, but h2c . c2h is not the identity on all inputs;  or perhaps
c2h is not defined for all CStrings.  Probably this is all locale
dependent.)

I have an infinite Haskell String transferred byte-wise over a
network;  I would like to convert some prefix of the bytes received
into a prefix of the String I started with.  However, if I understand
correctly, if s is a Haskell String it is not necessarily true that
c2h (take n (h2c s)) is a prefix of s for all n.  So I have two
questions:

Given a CString of the form cs = take n (h2c s), how do I know
whether c2h cs is a prefix of s or not?  Is there a way to recognize
whether a CString is valid as opposed to truncated in the middle of
a code point, or is this impossible?  Better yet, given a CString cs
= take n (h2c s), is there a way to find the maximal prefix cs' of cs
such that c2h cs' is a prefix of s?

If s == s1 ++ s2, is it necessarily true that s == (c2h (h2c s1)) ++
(c2h (h2c s2))?  If so, then I can perform my conversion a bit at a
time, otherwise I'd need to start from the beginning of the cstring
each time I receive additional data.

In practice, I think my solution will come down to restricting my
program to only using the lower 128 characters, but I'd like to know
how to handle this problem in full generality.

Thanks,
Eric

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] More ideas for controlled mutation

2011-04-25 Thread Heinrich Apfelmus

Edward Z. Yang wrote:

Laziness can be viewed as a form of controlled mutation, where
we overwrite a thunk with its actual value, thus only running
the code once and reaping great time benefits.

[..]

Hash tables take advantage of this fact by simply chaining together values
in a linked list if they land in the same bucket.  Could we have similarly
bucketized memoization?  What we want here is for a *thunk to possibly
evaluate to different values, but calls to the API be observationally
equivalent.*  That is, if the only way I can inspect a dictionary list
is do a lookup, I don't care if my representation is [(1,4),(2,2)] or
[(2,2),(1,4)].  An obvious way to do this is to use unsafePerformIO to
read out an IORef stating the value currently being looked up, and
have the thunk evaluate to the pair of that key and the result.  There
are some synchronization concerns, of course: ideally we would only
take out a lock on the thunk once we realize that the value doesn't
already exist in the memotable, but I don't think there's a way in GHC Haskell
to observe if a value is a thunk or not (maybe such a mechanism would be
useful?)


The thing is that lazy evaluation is referentially transparent while I 
don't care about [(1,4),(2,2)] vs [(2,2),(1,4)] is not. In the latter 
case, you have a proof obligation to the compiler that your API does not 
expose the difference between these two values. But in Haskell, you have 
no way of convincing the compiler that you fulfilled that proof 
obligation! (At least, I don't see any obvious one. Maybe a clever abuse 
of parametricity helps.) It might be an option in Agda, though.


In that light, it is entirely reasonable that you have to use 
unsafePerformIO .



Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A small Darcs anomoly

2011-04-25 Thread Andrew Coppin

On 24/04/2011 06:33 PM, Jason Dagit wrote:



On Sun, Apr 24, 2011 at 2:05 AM, Andrew Coppin
andrewcop...@btinternet.com mailto:andrewcop...@btinternet.com wrote:

So I was a little surprised to discover that... Darcs doesn't
actually support doing this. Darcs is only really interested in the
result of applying *all* changes in a repo.

It seems daft to me that you would design a sophisticated system for
splitting history into independent chunks, and then not let me
manipulate them independently.


This is because of a deliberate choice that was made by David Roundy.
In darcs, you never have multiple branches within a single darcs
repository directory tree.


Yes, this seems clear. I'm just wondering whether or not it's the best 
design choice.



To get the effect you want, you simply
create two repositories.  One having only the patches for ghc 6.6 and
one having the patches of ghc 7.0 and then you pull just the patches you
want from 7.0 into 6.6.  There are options to 'darcs get' that help you
select the right set of patches to help you create the two repositories.


It does mean that you duplicate information. You have [nearly] the same 
set of patches stored twice, and you're not really storing the history 
of the relationship between two branches, only the history of the branch 
itself.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] How to keep cabal and ghci package versions in sync?

2011-04-25 Thread Henning Thielemann
Gracjan Polak schrieb:
 Hi all,
 
 I have a project with a .cabal file listing package dependencies using
 the usual version constraints ==X.Y.* Z.W or =K.J syntax.
 Standard route cabal configure; cabal build works correctly as it is able
 to select working set of package versions.

You can manually select packages for GHCi with '-package' option.
However I do not know a way to automatically syncronise this with the
dependencies from the Cabal file.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente

Hi,

I'm reading The Craft of Functional Programming and I found something 
I don't understand in page 185.


It says:

Suppose first that we want to write a curried version of a function g, 
which is itself uncurried and of type (a,b) - c.


curry g

This funtion expects its arguments as a pair, but its curried version, 
curry g, will take them separately - we therefore have to form them into 
a pair before applying g to them:


curry :: ((a,b) - c) - (a - b - c)
curry g x y = g (x,y)

curry multiplyUC will be exactly the same function as multiply.

OK, I have tried it and it works, but I don't understand the syntax for 
curry. Until now I have encountered only functions that take the same 
number of arguments as the function definition or less (partial 
application), but this syntax looks a bit new to me. curry is supposed 
to have as its argument one function of type (a,b) - c and produce 
another function, but then the second line gives three arguments to 
curry, the function itself and the variables x and y.


What I'm missing here?

Thanks a lot,
Ángel de Vicente
--
http://www.iac.es/galeria/angelv/

High Performance Computing Support PostDoc
Instituto de Astrofísica de Canarias
-
ADVERTENCIA: Sobre la privacidad y cumplimiento de la Ley de Protección de 
Datos, acceda a http://www.iac.es/disclaimer.php
WARNING: For more information on privacy and fulfilment of the Law concerning 
the Protection of Data, consult http://www.iac.es/disclaimer.php?lang=en


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Ozgur Akgun
On 25 April 2011 14:11, Angel de Vicente ang...@iac.es wrote:

 curry :: ((a,b) - c) - (a - b - c)


is the same as:

curry :: ((a,b) - c) - a - b - c

HTH,
Ozgur
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Stephen Tetley
On 25 April 2011 14:11, Angel de Vicente ang...@iac.es wrote:

 curry :: ((a,b) - c) - (a - b - c)
 curry g x y = g (x,y)

Is expressing curry this way more illuminating?

curry :: ((a,b) - c) - (a - b - c)
curry g = \x y - g (x,y)

That is, curry is a function taking one argument that produces a
result function taking two arguments.

In Haskell - the type signature:

 curry :: ((a,b) - c) - (a - b - c)

... can mean either form.

Though this is a quirk of Haskell, in the language Clean, for
example, the parens in the type signature mean what they say so only
only my second definition is allowed, the first version won't compile.

Best wishes

Stephen

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Benedict Eastaugh
On 25 April 2011 14:11, Angel de Vicente ang...@iac.es wrote:

 OK, I have tried it and it works, but I don't understand the syntax for
 curry. Until now I have encountered only functions that take the same number
 of arguments as the function definition or less (partial application), but
 this syntax looks a bit new to me. curry is supposed to have as its argument
 one function of type (a,b) - c and produce another function, but then the
 second line gives three arguments to curry, the function itself and the
 variables x and y.

 What I'm missing here?

You can think of all functions in Haskell as taking only one argument.
So curry has one argument, which is a function that takes a pair (in
this case g). The value of curry g is another function (the curried
version of g) which takes two arguments.

This is clearer when written out like so:

g :: (a, b) - c

h :: a - b - c
h = curry g

h x y = g (x, y)

So by simple substitution we can see that

curry g x y = g (x, y)

It might be even clearer if we add parentheses, since function
application associates to the left:

(curry g) x y = g (x, y)

Hope this clears things up. For more information you could have a look
at the Gentle Introduction's section on functions:

http://www.haskell.org/tutorial/functions.html

Benedict.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente

Hi,

On 25/04/11 14:20, Ozgur Akgun wrote:

On 25 April 2011 14:11, Angel de Vicente ang...@iac.es
mailto:ang...@iac.es wrote:

curry :: ((a,b) - c) - (a - b - c)


is the same as:

curry :: ((a,b) - c) - a - b - c


thanks, it makes sense now. Somehow I thought that adding the 
parenthesis in ...- (a - b - c) was something special and that I 
couldn't get rid of them (in the same sense as I cannot get rid of the 
parenthesis in the first part and write:


curry :: (a,b) - c - a - b - c

Thanks,
Ángel
--
http://www.iac.es/galeria/angelv/

High Performance Computing Support PostDoc
Instituto de Astrofísica de Canarias
-
ADVERTENCIA: Sobre la privacidad y cumplimiento de la Ley de Protecci�n de 
Datos, acceda a http://www.iac.es/disclaimer.php
WARNING: For more information on privacy and fulfilment of the Law concerning 
the Protection of Data, consult http://www.iac.es/disclaimer.php?lang=en


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Trouble with currying and uncurrying...

2011-04-25 Thread Angel de Vicente

Hi,

On 25/04/11 14:21, Stephen Tetley wrote:

On 25 April 2011 14:11, Angel de Vicenteang...@iac.es  wrote:


curry :: ((a,b) -  c) -  (a -  b -  c)
curry g x y = g (x,y)


Is expressing curry this way more illuminating?

curry :: ((a,b) -  c) -  (a -  b -  c)
curry g = \x y -  g (x,y)

That is, curry is a function taking one argument that produces a
result function taking two arguments.

In Haskell - the type signature:


curry :: ((a,b) -  c) -  (a -  b -  c)


... can mean either form.

Though this is a quirk of Haskell, in the language Clean, for
example, the parens in the type signature mean what they say so only
only my second definition is allowed, the first version won't compile.


This was my first encounter with this syntax, but it was a bit confusing.
curry :: ((a,b) - c) - a - b - c

is much clearer to me, and once partial application is understood it is 
no problem to see what curry f  or curry f x y mean. But to me (at this 
point in my Haskell trip) it would make more sense that once you put 
the parentheses as in the original definition, no partial application is 
allowed and so the lambda notation is required.


Thanks a lot,
Ángel de Vicente
--
http://www.iac.es/galeria/angelv/

High Performance Computing Support PostDoc
Instituto de Astrofísica de Canarias
-
ADVERTENCIA: Sobre la privacidad y cumplimiento de la Ley de Protección de 
Datos, acceda a http://www.iac.es/disclaimer.php
WARNING: For more information on privacy and fulfilment of the Law concerning 
the Protection of Data, consult http://www.iac.es/disclaimer.php?lang=en


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Storing failing testcases for QuickCheck

2011-04-25 Thread Sönke Hahn
Roel van Dijk wrote:

 On 24 April 2011 01:49, wren ng thornton w...@freegeek.org wrote:
 I would *love* there to be a tool which (a) automatically saves failing
 QuickCheck values to disk, and (b) automates using HUnit to load those in
 and test them. I'm not so sure that QuickCheck should be doing the second
 step of that since that'd really mess with the QuickCheck infrastructure;
 once you have the code for reading from disk, it'd be trivial to just use
 HUnit.
 
 Maybe this is a job for test-framework? I think the API's of
 QuickCheck and HUnit expose enough information for this to be
 possible.

I've hacked something together: [1]. It doesn't use neither HUnit nor test-
framework, but I can see, why that would probably be better. It seems to do 
the job for me at the moment.

[1] https://patch-tag.com/r/shahn/QuickCheckStore/home



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
I started mindlessly pasting in the output, and the following lept out at me:

,



package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
due to missing or recursive dependencies:

There's more of the same I'm leaving out.

I'm going to see if I can go somewhere with these error messages. If I
totally hose things, I'll let you guys know.


On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
Following the install trail I run into this problem

mlitchard@apotheosis:~$ cab install JSONb-1.0.2
Resolving dependencies...
Configuring JSONb-1.0.2...
Preprocessing library JSONb-1.0.2...
Preprocessing executables for JSONb-1.0.2...
Building JSONb-1.0.2...
[1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
dist/build/Text/JSON/Escape.o )
[2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
dist/build/Text/JSONb/Simple.o )
[3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
dist/build/Text/JSONb/Decode.o )

Text/JSONb/Decode.hs:56:33:
Ambiguous occurrence `number'
It could refer to either `Text.JSONb.Decode.number', defined at
Text/JSONb/Decode.hs:118:0
  or `Attoparsec.number', imported from
Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
cabal: Error: some packages failed to install:
JSONb-1.0.2 failed during the building phase. The exception was:
ExitFailure 1


How do I clear up this ambiguity?

On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org wrote:
 I started mindlessly pasting in the output, and the following lept out at me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
So it appears this is a bug with JSONb-1.0.2. There's a new version
out. IS the answer to use that, or to patch this version?

On Mon, Apr 25, 2011 at 1:48 PM, Michael Litchard mich...@schmong.org wrote:
 Following the install trail I run into this problem

 mlitchard@apotheosis:~$ cab install JSONb-1.0.2
 Resolving dependencies...
 Configuring JSONb-1.0.2...
 Preprocessing library JSONb-1.0.2...
 Preprocessing executables for JSONb-1.0.2...
 Building JSONb-1.0.2...
 [1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
 dist/build/Text/JSON/Escape.o )
 [2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
 dist/build/Text/JSONb/Simple.o )
 [3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
 dist/build/Text/JSONb/Decode.o )

 Text/JSONb/Decode.hs:56:33:
    Ambiguous occurrence `number'
    It could refer to either `Text.JSONb.Decode.number', defined at
 Text/JSONb/Decode.hs:118:0
                          or `Attoparsec.number', imported from
 Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
 cabal: Error: some packages failed to install:
 JSONb-1.0.2 failed during the building phase. The exception was:
 ExitFailure 1


 How do I clear up this ambiguity?

 On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org wrote:
 I started mindlessly pasting in the output, and the following lept out at me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Rogan Creswick
On Mon, Apr 25, 2011 at 2:44 PM, Michael Litchard mich...@schmong.org wrote:
 So it appears this is a bug with JSONb-1.0.2. There's a new version
 out. IS the answer to use that, or to patch this version?

If there is a new version, and you indeed need JSONb for something,
then you should use the newer version (yesod doesn't depend on it, so
I'm a bit unsure why it came up...).

--Rogan



 On Mon, Apr 25, 2011 at 1:48 PM, Michael Litchard mich...@schmong.org wrote:
 Following the install trail I run into this problem

 mlitchard@apotheosis:~$ cab install JSONb-1.0.2
 Resolving dependencies...
 Configuring JSONb-1.0.2...
 Preprocessing library JSONb-1.0.2...
 Preprocessing executables for JSONb-1.0.2...
 Building JSONb-1.0.2...
 [1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
 dist/build/Text/JSON/Escape.o )
 [2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
 dist/build/Text/JSONb/Simple.o )
 [3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
 dist/build/Text/JSONb/Decode.o )

 Text/JSONb/Decode.hs:56:33:
    Ambiguous occurrence `number'
    It could refer to either `Text.JSONb.Decode.number', defined at
 Text/JSONb/Decode.hs:118:0
                          or `Attoparsec.number', imported from
 Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
 cabal: Error: some packages failed to install:
 JSONb-1.0.2 failed during the building phase. The exception was:
 ExitFailure 1


 How do I clear up this ambiguity?

 On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org 
 wrote:
 I started mindlessly pasting in the output, and the following lept out at 
 me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.




 ___
 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] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
I think something that yesod uses, uses JSONb. Also, I think I have
borked my haskell  environment to the point where it may be best to
zap it and start over.

On Mon, Apr 25, 2011 at 3:05 PM, Rogan Creswick cresw...@gmail.com wrote:
 On Mon, Apr 25, 2011 at 2:44 PM, Michael Litchard mich...@schmong.org wrote:
 So it appears this is a bug with JSONb-1.0.2. There's a new version
 out. IS the answer to use that, or to patch this version?

 If there is a new version, and you indeed need JSONb for something,
 then you should use the newer version (yesod doesn't depend on it, so
 I'm a bit unsure why it came up...).

 --Rogan



 On Mon, Apr 25, 2011 at 1:48 PM, Michael Litchard mich...@schmong.org 
 wrote:
 Following the install trail I run into this problem

 mlitchard@apotheosis:~$ cab install JSONb-1.0.2
 Resolving dependencies...
 Configuring JSONb-1.0.2...
 Preprocessing library JSONb-1.0.2...
 Preprocessing executables for JSONb-1.0.2...
 Building JSONb-1.0.2...
 [1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
 dist/build/Text/JSON/Escape.o )
 [2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
 dist/build/Text/JSONb/Simple.o )
 [3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
 dist/build/Text/JSONb/Decode.o )

 Text/JSONb/Decode.hs:56:33:
    Ambiguous occurrence `number'
    It could refer to either `Text.JSONb.Decode.number', defined at
 Text/JSONb/Decode.hs:118:0
                          or `Attoparsec.number', imported from
 Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
 cabal: Error: some packages failed to install:
 JSONb-1.0.2 failed during the building phase. The exception was:
 ExitFailure 1


 How do I clear up this ambiguity?

 On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org 
 wrote:
 I started mindlessly pasting in the output, and the following lept out at 
 me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.




 ___
 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] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread Skirmantas Kligys
Hi,

I am learning iteratees, and as a starter project I wanted to use expat-
enumerator to parse a 2 gigabyte XML file.

I expected to be able to do what SAX does in Java, i.e. to avoid loading the
whole 2 gigabytes into memory.  For warm-up, I wrote an iteratee to count lines
in the file, and it does load the whole file into memory!  After profiling, I
see that the problem was Data.Enumerator.Text.utf8, it allocates up to 60
megabytes when run on a 40 megabyte test file.

Any suggestions how to fix Text.utf8, or what people do for parsing UTF-8
encoded text files with iteratees?

Thanks!

Here is my code and profiling results:

http://i.imgur.com/XEI1v.png
http://hpaste.org/46037/counting_lines_with_iteratees
http://hpaste.org/46038/counting_lines_with_iteratees

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
Oh yeah, this began while trying to install by hand
authenticate-0.8.2.2


On Mon, Apr 25, 2011 at 3:10 PM, Michael Litchard mich...@schmong.org wrote:
 I think something that yesod uses, uses JSONb. Also, I think I have
 borked my haskell  environment to the point where it may be best to
 zap it and start over.

 On Mon, Apr 25, 2011 at 3:05 PM, Rogan Creswick cresw...@gmail.com wrote:
 On Mon, Apr 25, 2011 at 2:44 PM, Michael Litchard mich...@schmong.org 
 wrote:
 So it appears this is a bug with JSONb-1.0.2. There's a new version
 out. IS the answer to use that, or to patch this version?

 If there is a new version, and you indeed need JSONb for something,
 then you should use the newer version (yesod doesn't depend on it, so
 I'm a bit unsure why it came up...).

 --Rogan



 On Mon, Apr 25, 2011 at 1:48 PM, Michael Litchard mich...@schmong.org 
 wrote:
 Following the install trail I run into this problem

 mlitchard@apotheosis:~$ cab install JSONb-1.0.2
 Resolving dependencies...
 Configuring JSONb-1.0.2...
 Preprocessing library JSONb-1.0.2...
 Preprocessing executables for JSONb-1.0.2...
 Building JSONb-1.0.2...
 [1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
 dist/build/Text/JSON/Escape.o )
 [2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
 dist/build/Text/JSONb/Simple.o )
 [3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
 dist/build/Text/JSONb/Decode.o )

 Text/JSONb/Decode.hs:56:33:
    Ambiguous occurrence `number'
    It could refer to either `Text.JSONb.Decode.number', defined at
 Text/JSONb/Decode.hs:118:0
                          or `Attoparsec.number', imported from
 Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
 cabal: Error: some packages failed to install:
 JSONb-1.0.2 failed during the building phase. The exception was:
 ExitFailure 1


 How do I clear up this ambiguity?

 On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org 
 wrote:
 I started mindlessly pasting in the output, and the following lept out at 
 me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.




 ___
 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] errors while installing yesod 0.8

2011-04-25 Thread Rogan Creswick
On Mon, Apr 25, 2011 at 3:10 PM, Michael Litchard mich...@schmong.org wrote:
 I think something that yesod uses, uses JSONb.

Odd.  I just checked the transitive dependencies of yesod-0.8.0 (with
cab) and it doesn't seem to have that dependency.  It could be
system-specific, though.

It would be nice to figure out what is depending on that version of
JSONb so we could better determine if upgrading will break anything.

--Rogan


 Also, I think I have
 borked my haskell  environment to the point where it may be best to
 zap it and start over.

 On Mon, Apr 25, 2011 at 3:05 PM, Rogan Creswick cresw...@gmail.com wrote:
 On Mon, Apr 25, 2011 at 2:44 PM, Michael Litchard mich...@schmong.org 
 wrote:
 So it appears this is a bug with JSONb-1.0.2. There's a new version
 out. IS the answer to use that, or to patch this version?

 If there is a new version, and you indeed need JSONb for something,
 then you should use the newer version (yesod doesn't depend on it, so
 I'm a bit unsure why it came up...).

 --Rogan



 On Mon, Apr 25, 2011 at 1:48 PM, Michael Litchard mich...@schmong.org 
 wrote:
 Following the install trail I run into this problem

 mlitchard@apotheosis:~$ cab install JSONb-1.0.2
 Resolving dependencies...
 Configuring JSONb-1.0.2...
 Preprocessing library JSONb-1.0.2...
 Preprocessing executables for JSONb-1.0.2...
 Building JSONb-1.0.2...
 [1 of 7] Compiling Text.JSON.Escape ( Text/JSON/Escape.hs,
 dist/build/Text/JSON/Escape.o )
 [2 of 7] Compiling Text.JSONb.Simple ( Text/JSONb/Simple.hs,
 dist/build/Text/JSONb/Simple.o )
 [3 of 7] Compiling Text.JSONb.Decode ( Text/JSONb/Decode.hs,
 dist/build/Text/JSONb/Decode.o )

 Text/JSONb/Decode.hs:56:33:
    Ambiguous occurrence `number'
    It could refer to either `Text.JSONb.Decode.number', defined at
 Text/JSONb/Decode.hs:118:0
                          or `Attoparsec.number', imported from
 Data.Attoparsec.Char8 at Text/JSONb/Decode.hs:25:0-52
 cabal: Error: some packages failed to install:
 JSONb-1.0.2 failed during the building phase. The exception was:
 ExitFailure 1


 How do I clear up this ambiguity?

 On Mon, Apr 25, 2011 at 1:24 PM, Michael Litchard mich...@schmong.org 
 wrote:
 I started mindlessly pasting in the output, and the following lept out at 
 me:

 ,



 package authenticate-0.8.2.2-cc3ed2c523ecbf1ad123c3468785149e is
 unusable due to missing or recursive dependencies:
  http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271
 package http-enumerator-0.3.1-719bcd77e1dcb62efc9cf9b4f0b72271 is
 unusable due to missing or recursive dependencies:
  attoparsec-enumerator-0.2.0.3-4978ab2dc4d87b7b724534bbfdcb07f1
 package json-enumerator-0.0.1-7d4b724ae8c9b5ffa92da26856c4e1f1 is
 unusable due to missing or recursive dependencies:
  blaze-builder-enumerator-0.2.0.1-23e6e1f270358d3329f627e3a5ce8838
 package wai-extra-0.3.2-f8378ad4a5cc6f375d96b718876384fa is unusable
 due to missing or recursive dependencies:

 There's more of the same I'm leaving out.

 I'm going to see if I can go somewhere with these error messages. If I
 totally hose things, I'll let you guys know.


 On Tue, Apr 19, 2011 at 4:45 PM, Daniel Fischer
 daniel.is.fisc...@googlemail.com wrote:
 On Wednesday 20 April 2011 01:22:20, Michael Litchard wrote:
 So what else can I try?

 $ cabal install -v3 monad-control

 That should give some hints at which point exactly things fail.




 ___
 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] errors while installing yesod 0.8

2011-04-25 Thread Bas van Dijk
On 26 April 2011 00:20, Rogan Creswick cresw...@gmail.com wrote:
 It would be nice to figure out what is depending on that version of
 JSONb so we could better determine if upgrading will break anything.

Maybe the following helps:

http://bifunctor.homelinux.net/~roel/cgi-bin/hackage-scripts/revdeps/JSONb

Bas

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Leksah 0.10.0

2011-04-25 Thread Daniel Fischer
On Friday 22 April 2011 12:40:17, Hamish Mackenzie wrote:
 Yesterday we uploaded our official 0.10.0 release (0.10.0.4) to Hackage

I'm trying to try it, but I run into a couple of problems.
Most are probably me looking in the wrong places, so let's begin with 
those.

By default, the editor pane is on the left hand side and the module browser 
or whatnot on the right. Very irritating. How do I switch the positions?
I tried swapping LeftP and RightP in Edit Prefs - Initial Pane positions, 
but to no avail.

Autocomplete starts at the first letter of any new word, so writing a 
function definition

bar j
  | j == 0 = whatever
  | otherwise = somethingElse

requires paying attention and taking some action to not end up with

bar join| j == whatever ...

How do I configure autocompletion to only begin after three or four letters 
have been typed?

Decreasing indentation via backspace goes one column per backspace, how can 
I configure it to go to the next (previous) tab position on backspace in 
the leading whitespace of a line?

Now, those configuration questions out of the way:
On first startup, I pointed leksah to ~/.cabal/packages/hackage.haskell.org 
for sources (hoping it would know to unpack them and copy them to 
~/.leksah-0.10/packageSources, run haddock on them and what else it needs). 
It did indeed copy a bunch of sources there and invoked cabal and ghc a 
number of times, but it left out about half of the installed packages.
It used an awful lot of memory to do that, peak about 1300MB virtual, 800MB 
resident, which means swapping and thrashing (unless I shut down 
practically everything else - I have only 1G of RAM).
Okay, for collecting metadata on the first startup, I could live with that 
(though, if it handled packages sequentially, it should use less memory).

But on the second startup and the third, although it didn't invoke cabal or 
ghc anymore,  the memory usage was about the same, effectively knocking out 
my system for more than ten minutes.
On the third, I had not enough patience and killed it, leksah-server showed 
no signs of stopping within two minutes after kill -TERM, so I had to kill 
-KILL it.

What can I do to make leksah a good memory-citizen?
With the current behaviour, it is unusable for me, unfortunately.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell from SML - referrential Transparency?!

2011-04-25 Thread Ryan Ingram
I've been working on Haskell for quite a while and it's not too often that a
beginner shows me a new trick--this trick with trace seems really cool and I
hadn't seen it before.

f x | trace (f  ++ show x) False = undefined
f ... -- rest of regular definition

Makes it really easy to add the trace and then later comment it out.  One
problem I always have with traces the usual way is that adding/removing them
is kind of annoying--it can change the indentation of your code, etc.  So
this trick is really useful!

Thanks Gregory!

  -- ryan


On Tue, Apr 19, 2011 at 12:38 PM, Gregory Guthrie guth...@mum.edu wrote:

 Oops;
 No - my (further) mistake. It is not IO() - f1 returns a data structure
 which implements Show, and the test is really:

Test1 = do print Test1:
  print f1
 (etc..)

 Thanks for the alert on trace.

 I used it like this:
 allocate :: Store - (Store, Location)
 allocate ( Store(bot,top,sto) ) |
 trace(allocate ++ show bot ++ show top)
  False = undefined
 allocate ( Store(bot,top,sto) )  =
let newtop  = top+1

 and it does seem to show every allocation on the first run of f1, but then
 nothing on the second.
 SO it is not just a first call to allocate, but all calls under an
 invocation of f1 that don't show.
 Makes me wonder if f1 is even being re-evaluated.

 I did post the code - but don't expect anyone to really wade through and
 debug for me!  :-)
 (The issues that I am asking about are a9b, a9bb at line 435, 438)
 http://hpaste.org/45851/haskell_from_sml_question

 thanks for the help.
 ---

  -Original Message-
  From: Daniel Fischer [mailto:daniel.is.fisc...@googlemail.com]
  Sent: Tuesday, April 19, 2011 2:16 PM
  To: haskell-cafe@haskell.org
  Cc: Gregory Guthrie
  Subject: Re: [Haskell-cafe] Haskell from SML - referrential
 Transparency?!
 
  On Tuesday 19 April 2011 21:10:09, Gregory Guthrie wrote:
   I am pretty new to Haskell, so need some clarification.
   I am porting some code from SML, and getting a result that surprises
 me.
  
   I basically have some functions which work like this:
   f1 =  fa fb fc
   test1 = do print test1:
f1
 
  So f1 :: IO something
 
  Being an IO-action, f1 can return different things in different
 invocations since the world in
  which it runs has changed (it might read a file which was modified
 between the first and the
  second invocation, for example).
 
  
   But I ran a few tests, and got odd results - so I ran the same  test
   function twice, and got different results - that was my surprise. I
   did
   this:
   f1 =  fa fb fc
   f2 =  fa fb fc
   test2 = do print test1:
f1
f2
  
   and I get different results from the two executions (f1,f2), even
   though they have exactly the same definition. Reversing their order,
   gives the exact same results (i.e. the results are still different, and
 in the
   same original order as f2;f1). Even doing   (f1;f1) gives two different
   results.
 
  Depending on what f1 does, that may be perfectly normal or a serious bug.
  We'd need to see more of the code to determine which.
 
  
   Seems to me that by referential transparency, I should always get the
   same result from the function(s).
  
   So, I added some Debug.trace to the argument functions which are used,
   and I get a trace from the first call(s), but none from the second
   one(s), although I do get the result from each.
 
  Did you do it in the form
 
  fa = trace (fa) realFa
 
  ?
 
  Then the trace is only evaluated the first time fa is evaluated, even if
 fa is called later
  again.
 
  
   It is as if because of the laziness, it someone cached some of the
   intermediate results, so did not re-invoke the functions.
  
   Anyway, totally confused. I must be missing something significant here.
   Thanks for any clarification! (The original code is a bit long, so I
   did not include here...)
 
  http://hpaste.org/
 
  perhaps?
 ___
 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] ANN: Leksah 0.10.0

2011-04-25 Thread jutaro

Daniel Fischer wrote:
 
 On Friday 22 April 2011 12:40:17, Hamish Mackenzie wrote:
 Yesterday we uploaded our official 0.10.0 release (0.10.0.4) to Hackage
 
 I'm trying to try it, but I run into a couple of problems.
 Most are probably me looking in the wrong places, so let's begin with 
 those.
 
 By default, the editor pane is on the left hand side and the module
 browser 
 or whatnot on the right. Very irritating. How do I switch the positions?
 I tried swapping LeftP and RightP in Edit Prefs - Initial Pane positions, 
 but to no avail.
 

Well, it is a bit more intricate to invert the sides. After 
* swapping LeftP and RightP in Edit Prefs - Initial Pane positions
* Close all panes and pane groups. (You may leave an editor window open,
so that you better see what happens in the next steps).
* Collapse all (Hit Ctrl-1 - 2 times)
* Split vertical (Hit Ctrl-2), put the focus to the left, split horizontal
(Hit Ctrl-3)
* Go to Panes Menu and reopen the Log and the Browser and an editor Window
* Configure tabs as you like
* Save the session or restart Leksah 


Daniel Fischer wrote:
  
 Autocomplete starts at the first letter of any new word, so writing a 
 function definition
 
 bar j
   | j == 0 = whatever
   | otherwise = somethingElse
 
 requires paying attention and taking some action to not end up with
 
 bar join| j == whatever ...
 
 How do I configure autocompletion to only begin after three or four
 letters 
 have been typed?
 
Go to Edit Prefs - GUI Options, and select Complete only on Hotkey, then
hit
Ctrl-Space if you want completion.


Daniel Fischer wrote:
  
 Decreasing indentation via backspace goes one column per backspace, how
 can 
 I configure it to go to the next (previous) tab position on backspace in 
 the leading whitespace of a line?
 
You can't do this currently, but you can post a wish for enhancement to our
issue tracker.


Daniel Fischer wrote:
  
 Now, those configuration questions out of the way:
 On first startup, I pointed leksah to
 ~/.cabal/packages/hackage.haskell.org 
 for sources (hoping it would know to unpack them and copy them to 
 ~/.leksah-0.10/packageSources, run haddock on them and what else it
 needs). 
 

Please try to run Leksah with the default config
(~/.leksah-0.10/packageSources) 


Daniel Fischer wrote:
  
 It did indeed copy a bunch of sources there and invoked cabal and ghc a 
 number of times, but it left out about half of the installed packages.
 It used an awful lot of memory to do that, peak about 1300MB virtual,
 800MB 
 resident, which means swapping and thrashing (unless I shut down 
 practically everything else - I have only 1G of RAM).
 Okay, for collecting metadata on the first startup, I could live with that 
 (though, if it handled packages sequentially, it should use less memory).
 
 But on the second startup and the third, although it didn't invoke cabal
 or 
 ghc anymore,  the memory usage was about the same, effectively knocking
 out 
 my system for more than ten minutes.
 On the third, I had not enough patience and killed it, leksah-server
 showed 
 no signs of stopping within two minutes after kill -TERM, so I had to kill 
 -KILL it.
 
 What can I do to make leksah a good memory-citizen?
 With the current behaviour, it is unusable for me, unfortunately.
 

Indeed leksah may use more memory on the first run (actually it is ghc,
which uses it).
But on consecutive starts it may use about/up to 150MB, but not the numbers
you give.
So please try to run Leksah with the default config, and see if the problem
remains.

Jürgen

--
View this message in context: 
http://haskell.1045720.n5.nabble.com/ANN-Leksah-0-10-0-tp4332741p4339787.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


Re: [Haskell-cafe] errors while installing yesod 0.8

2011-04-25 Thread Michael Litchard
In case this ever gets googled ...

I'm pretty sure this problem had to do with my environment. I removed
$HOME/.cabal and $HOME/.ghc, and upgraded to the latest stable haskell
platform. yesod 0.8 has installed fine. I'm not sure what the exact
problem was however.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] ANN: Leksah 0.10.0

2011-04-25 Thread Hamish Mackenzie
On 26 April 2011 11:03, Daniel Fischer daniel.is.fisc...@googlemail.com wrote:
 Decreasing indentation via backspace goes one column per backspace, how can
 I configure it to go to the next (previous) tab position on backspace in
 the leading whitespace of a line?

shifttab works, but it is a bit dumb.

Changing backspace is on my wish list too.  I think we should make
it look at the text above to find the correct indentation points.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Inputs to classic FRP: unsafeInterleaveIO/unsafePerformIO

2011-04-25 Thread Edward Amsden
As far as I can tell, with classic FRP implementations (those which
use behaviors as a first-class abstraction), the only way to create a
behavior or
event based on some external input (for instance keypresses or
microphone input) is to do something with unsafePerformIO or
unsafeInterleaveIO. A behavior is a value, which when evaluated at a
specific time would have to either block its evaluation until input
could be read, or check the input at that particular time.

Is there any other way of implementing external behaviors besides that?

-- 
Edward Amsden
Student
Computer Science
Rochester Institute of Technology
www.edwardamsden.com

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread Felipe Almeida Lessa
[CC'ing John Millikin, enumerator's maintainer]

On Mon, Apr 25, 2011 at 7:10 PM, Skirmantas Kligys
skirmantas.kli...@gmail.com wrote:
 I expected to be able to do what SAX does in Java, i.e. to avoid loading the
 whole 2 gigabytes into memory.  For warm-up, I wrote an iteratee to count 
 lines
 in the file, and it does load the whole file into memory!  After profiling, I
 see that the problem was Data.Enumerator.Text.utf8, it allocates up to 60
 megabytes when run on a 40 megabyte test file.

It seems to me that this is a bug in enumerator's strict fold not
being strict at all =).  The current version 0.4.9.1 of
Data.Enumerator.List.fold is

-- | Consume the entire input stream with a strict left fold, one element
-- at a time.
--
-- Since: 0.4.8
fold :: Monad m = (b - a - b) - b
   - Iteratee a m b
fold step = continue . loop where
f = L.foldl' step
loop acc stream = case stream of
Chunks [] - continue (loop acc)
Chunks xs - continue (loop (f acc xs))
EOF - yield acc EOF

Note that the list fold is strict (f = Data.List.foldl' step),
*however* the acc parameter of loop isn't strict at all!  It just
creates a big, fat thunk with references to all of you input =(.

But the fix is extremely easy, just change the 'Chunks xs' line to

Chunks xs - continue (loop $! f acc xs)

Using only your iterLinesWc test with a 105 MiB file (a movie I had
lying around), with enumerator's definition it takes 220 MiB of memory
and 1.3~1.5 seconds according to +RTS -s.  By doing only this very
change above, it takes 2 MiB of memory (100x improvement :P) and
0.8~0.9 seconds.

John Millikin, could you please apply the attached patch? =)

Cheers,

-- 
Felipe.
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: felipe.le...@gmail.com-20110426020019-mad7rofbt62zwt49
# target_branch: http://john-millikin.com/branches/enumerator/0.4/
# testament_sha1: ff7491ebbe8698c6cad156203566aabd5aed
# timestamp: 2011-04-25 23:01:15 -0300
# base_revision_id: jmilli...@gmail.com-20110329181202-\
#   pzq011f39m787xld
# 
# Begin patch
=== modified file 'enumerator/src/list-analogues.anansi'
--- enumerator/src/list-analogues.anansi	2011-03-29 05:24:03 +
+++ enumerator/src/list-analogues.anansi	2011-04-26 02:00:19 +
@@ -19,7 +19,7 @@
 	f = L.foldl' step
 	loop acc stream = case stream of
 		Chunks [] - continue (loop acc)
-		Chunks xs - continue (loop (f acc xs))
+		Chunks xs - continue (loop $! f acc xs)
 		EOF - yield acc EOF
 :
 
@@ -29,7 +29,7 @@
   - Iteratee a m b
 foldM step = continue . loop where
 	f = CM.foldM step
-	
+
 	loop acc stream = acc `seq` case stream of
 		Chunks [] - continue (loop acc)
 		Chunks xs - lift (f acc xs) = continue . loop
@@ -134,7 +134,7 @@
 concatMapM f = checkDone (continue . step) where
 	step k EOF = yield (Continue k) EOF
 	step k (Chunks xs) = loop k xs
-	
+
 	loop k [] = continue (step k)
 	loop k (x:xs) = do
 		fx - lift (f x)
@@ -180,7 +180,7 @@
 concatMapM f = checkDone (continue . step) where
 	step k EOF = yield (Continue k) EOF
 	step k (Chunks xs) = loop k (BL.unpack (BL.fromChunks xs))
-	
+
 	loop k [] = continue (step k)
 	loop k (x:xs) = do
 		fx - lift (f x)
@@ -206,7 +206,7 @@
 concatMapM f = checkDone (continue . step) where
 	step k EOF = yield (Continue k) EOF
 	step k (Chunks xs) = loop k (TL.unpack (TL.fromChunks xs))
-	
+
 	loop k [] = continue (step k)
 	loop k (x:xs) = do
 		fx - lift (f x)
@@ -222,7 +222,7 @@
 mapAccum f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = case f s x of
 		(s', ai) - k (Chunks [ai]) ==
@@ -233,7 +233,7 @@
 mapAccumM f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = do
 		(s', ai) - lift (f s x)
@@ -247,7 +247,7 @@
 mapAccum f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = case B.uncons x of
 		Nothing - loop s k xs
@@ -260,7 +260,7 @@
 mapAccumM f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = case B.uncons x of
 		Nothing - loop s k xs
@@ -276,7 +276,7 @@
 mapAccum f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = case T.uncons x of
 		Nothing - loop s k xs
@@ -289,7 +289,7 @@
 mapAccumM f s0 = checkDone (continue . step s0) where
 	step _ k EOF = yield (Continue k) EOF
 	step s k (Chunks xs) = loop s k xs
-	
+
 	loop s k [] = continue (step s k)
 	loop s k (x:xs) = case T.uncons x of
 		Nothing - 

Re: [Haskell-cafe] Inputs to classic FRP: unsafeInterleaveIO/unsafePerformIO

2011-04-25 Thread Ryan Ingram
Of course, you could have the 'interpretation' function be non-pure.

For example:

-- Library functions for a hypothetical FRP system
pollEvent :: IO [a] - Event a
behavior :: a - Event a - Behavior a
accumB :: b - (b - a - b) - Event a - Behavior b
accumE :: b - (b - a - b) - Event a - Event b
union :: Event a - Event a - Event a
runFRP :: (a - IO Bool) - Behavior a - IO ()
-- Event  Behavior become instances of Functor  Applicative

-- and now a hypothetical implementation
data Event a where
   Event :: s -- initial state
   - (s - IO ([a], s))  -- tick
   - Event a
data Behavior a = Behavior a (Event a)

pollEvent act = Event () $ \() - do
 xs - act
 return (xs, ())

behavior = Behavior

union (Event sL0 tickL) (Event sR0 tickR) = Event (sL0,sR0) tick where
tick (sL, sR) = do
(ls, sL') - tickL sL
(rs, sR') - tickR sR
return (ls ++ rs, (sL', sR'))

accumB b0 f e = Behavior b0 $ accumE b f e

accumE b0 f (Event s0 tickE) = Event (b0, s0) tick where
tick (b, s) = do
(as, s') - tickE s
let bs = scanl f b as
return (bs, (last bs, s'))

-- Functor, Applicative instances are pretty easy and left as an exercise

runFRP tick (Behavior b0 (Event s0 e)) = runFRP' b0 s0 where
runFRP' b s = do
(bs, s') - e s0
let val = last (b:bs)
k - tick b
when k $ runFRP tick (Behavior

k - tick b




-- sample application
keypress :: Event Char
keypress = pollEvent getCurrentPressedKeys where
   getCurrentPressedKeys = undefined -- exercise for the reader







On Mon, Apr 25, 2011 at 5:28 PM, Edward Amsden eca7...@cs.rit.edu wrote:

 As far as I can tell, with classic FRP implementations (those which
 use behaviors as a first-class abstraction), the only way to create a
 behavior or
 event based on some external input (for instance keypresses or
 microphone input) is to do something with unsafePerformIO or
 unsafeInterleaveIO. A behavior is a value, which when evaluated at a
 specific time would have to either block its evaluation until input
 could be read, or check the input at that particular time.

 Is there any other way of implementing external behaviors besides that?

 --
 Edward Amsden
 Student
 Computer Science
 Rochester Institute of Technology
 www.edwardamsden.com

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Inputs to classic FRP: unsafeInterleaveIO/unsafePerformIO

2011-04-25 Thread Ryan Ingram
Mail fail, haha.  Code fixed.
For example:

-- Library functions for a hypothetical FRP system
pollEvent :: IO [a] - Event a
behavior :: a - Event a - Behavior a
accumB :: b - (b - a - b) - Event a - Behavior b
accumE :: b - (b - a - b) - Event a - Event b
union :: Event a - Event a - Event a
runFRP :: (a - IO Bool) - Behavior a - IO ()
-- Event  Behavior become instances of Functor  Applicative

-- and now a hypothetical implementation
data Event a where
   Event :: s -- initial state
   - (s - IO ([a], s))  -- tick
   - Event a
data Behavior a = Behavior a (Event a)

pollEvent act = Event () $ \() - do
 xs - act
 return (xs, ())

behavior = Behavior

union (Event sL0 tickL) (Event sR0 tickR) = Event (sL0,sR0) tick where
tick (sL, sR) = do
(ls, sL') - tickL sL
(rs, sR') - tickR sR
return (ls ++ rs, (sL', sR'))

accumB b0 f e = Behavior b0 $ accumE b f e

accumE b0 f (Event s0 tickE) = Event (b0, s0) tick where
tick (b, s) = do
(as, s') - tickE s
let bs = scanl f b as
return (bs, (last bs, s'))

-- Functor, Applicative instances are pretty easy and left as an exercise

runFRP tick (Behavior b0 (Event s0 e)) = runFRP' b0 s0 where
runFRP' b s = do
(bs, s') - e s0
let b' = last (b:bs)
k - tick b'
when k $ runFRP' b' s'

-- sample application
keypress :: Event Char
keypress = pollEvent getCurrentPressedKeys where
   getCurrentPressedKeys = undefined -- exercise for the reader

-- application prints the last key you pressed until you press 'q'
main = runFRP tick keypress where
tick k = print k  return (k /= 'q')
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread Skirmantas Kligys
Yay, much better!

Now iterLinesWc works within 4 kilobytes, and iterLinesMine within 22
kilobytes, both nicely bounded.

Thanks a lot for your help, Felipe!


On Mon, Apr 25, 2011 at 7:03 PM, Felipe Almeida Lessa
felipe.le...@gmail.com wrote:
 [CC'ing John Millikin, enumerator's maintainer]

 On Mon, Apr 25, 2011 at 7:10 PM, Skirmantas Kligys
 skirmantas.kli...@gmail.com wrote:
 I expected to be able to do what SAX does in Java, i.e. to avoid loading the
 whole 2 gigabytes into memory.  For warm-up, I wrote an iteratee to count 
 lines
 in the file, and it does load the whole file into memory!  After profiling, I
 see that the problem was Data.Enumerator.Text.utf8, it allocates up to 60
 megabytes when run on a 40 megabyte test file.

 It seems to me that this is a bug in enumerator's strict fold not
 being strict at all =).  The current version 0.4.9.1 of
 Data.Enumerator.List.fold is

 -- | Consume the entire input stream with a strict left fold, one element
 -- at a time.
 --
 -- Since: 0.4.8
 fold :: Monad m = (b - a - b) - b
       - Iteratee a m b
 fold step = continue . loop where
        f = L.foldl' step
        loop acc stream = case stream of
                Chunks [] - continue (loop acc)
                Chunks xs - continue (loop (f acc xs))
                EOF - yield acc EOF

 Note that the list fold is strict (f = Data.List.foldl' step),
 *however* the acc parameter of loop isn't strict at all!  It just
 creates a big, fat thunk with references to all of you input =(.

 But the fix is extremely easy, just change the 'Chunks xs' line to

                Chunks xs - continue (loop $! f acc xs)

 Using only your iterLinesWc test with a 105 MiB file (a movie I had
 lying around), with enumerator's definition it takes 220 MiB of memory
 and 1.3~1.5 seconds according to +RTS -s.  By doing only this very
 change above, it takes 2 MiB of memory (100x improvement :P) and
 0.8~0.9 seconds.

 John Millikin, could you please apply the attached patch? =)

 Cheers,

 --
 Felipe.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread John Millikin
*sigh*

Another fine entry for john-millikin-is-an-idiot.txt

Thank you for the patch Felipe, and for the bug report Skirmantas. I
have uploaded 0.4.10 to Hackage.

My sincere apologies for the inconvenience.

On Mon, Apr 25, 2011 at 19:03, Felipe Almeida Lessa
felipe.le...@gmail.com wrote:
 [CC'ing John Millikin, enumerator's maintainer]

 On Mon, Apr 25, 2011 at 7:10 PM, Skirmantas Kligys
 skirmantas.kli...@gmail.com wrote:
 I expected to be able to do what SAX does in Java, i.e. to avoid loading the
 whole 2 gigabytes into memory.  For warm-up, I wrote an iteratee to count 
 lines
 in the file, and it does load the whole file into memory!  After profiling, I
 see that the problem was Data.Enumerator.Text.utf8, it allocates up to 60
 megabytes when run on a 40 megabyte test file.

 It seems to me that this is a bug in enumerator's strict fold not
 being strict at all =).  The current version 0.4.9.1 of
 Data.Enumerator.List.fold is

 -- | Consume the entire input stream with a strict left fold, one element
 -- at a time.
 --
 -- Since: 0.4.8
 fold :: Monad m = (b - a - b) - b
       - Iteratee a m b
 fold step = continue . loop where
        f = L.foldl' step
        loop acc stream = case stream of
                Chunks [] - continue (loop acc)
                Chunks xs - continue (loop (f acc xs))
                EOF - yield acc EOF

 Note that the list fold is strict (f = Data.List.foldl' step),
 *however* the acc parameter of loop isn't strict at all!  It just
 creates a big, fat thunk with references to all of you input =(.

 But the fix is extremely easy, just change the 'Chunks xs' line to

                Chunks xs - continue (loop $! f acc xs)

 Using only your iterLinesWc test with a 105 MiB file (a movie I had
 lying around), with enumerator's definition it takes 220 MiB of memory
 and 1.3~1.5 seconds according to +RTS -s.  By doing only this very
 change above, it takes 2 MiB of memory (100x improvement :P) and
 0.8~0.9 seconds.

 John Millikin, could you please apply the attached patch? =)

 Cheers,

 --
 Felipe.


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread Felipe Almeida Lessa
On Tue, Apr 26, 2011 at 12:06 AM, John Millikin jmilli...@gmail.com wrote:
 *sigh*

 Another fine entry for john-millikin-is-an-idiot.txt

 Thank you for the patch Felipe, and for the bug report Skirmantas. I
 have uploaded 0.4.10 to Hackage.

 My sincere apologies for the inconvenience.

But I am sure that john-millikin-is-great.txt must be increasing like
a memory leak ;).  Thanks for the quick upload, and there's no need
for apologies.

Cheers,

-- 
Felipe.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Data.Enumerator.Text.utf8 not constant memory?

2011-04-25 Thread Skirmantas Kligys
John,

Thanks for a very quick fix, and thanks for making the enumerator library.

I tried to learn iteratees first from iteratee library but got
hopelessly confused within minutes.  Now with your library and
Snoyman's 3 part tutorial
(http://www.yesodweb.com/blog/enumerators-tutorial-part-1) I at least
have some basic understanding I can build on.



On Mon, Apr 25, 2011 at 8:06 PM, John Millikin jmilli...@gmail.com wrote:
 *sigh*

 Another fine entry for john-millikin-is-an-idiot.txt

 Thank you for the patch Felipe, and for the bug report Skirmantas. I
 have uploaded 0.4.10 to Hackage.

 My sincere apologies for the inconvenience.

 On Mon, Apr 25, 2011 at 19:03, Felipe Almeida Lessa
 felipe.le...@gmail.com wrote:
 [CC'ing John Millikin, enumerator's maintainer]

 On Mon, Apr 25, 2011 at 7:10 PM, Skirmantas Kligys
 skirmantas.kli...@gmail.com wrote:
 I expected to be able to do what SAX does in Java, i.e. to avoid loading the
 whole 2 gigabytes into memory.  For warm-up, I wrote an iteratee to count 
 lines
 in the file, and it does load the whole file into memory!  After profiling, 
 I
 see that the problem was Data.Enumerator.Text.utf8, it allocates up to 60
 megabytes when run on a 40 megabyte test file.

 It seems to me that this is a bug in enumerator's strict fold not
 being strict at all =).  The current version 0.4.9.1 of
 Data.Enumerator.List.fold is

 -- | Consume the entire input stream with a strict left fold, one element
 -- at a time.
 --
 -- Since: 0.4.8
 fold :: Monad m = (b - a - b) - b
       - Iteratee a m b
 fold step = continue . loop where
        f = L.foldl' step
        loop acc stream = case stream of
                Chunks [] - continue (loop acc)
                Chunks xs - continue (loop (f acc xs))
                EOF - yield acc EOF

 Note that the list fold is strict (f = Data.List.foldl' step),
 *however* the acc parameter of loop isn't strict at all!  It just
 creates a big, fat thunk with references to all of you input =(.

 But the fix is extremely easy, just change the 'Chunks xs' line to

                Chunks xs - continue (loop $! f acc xs)

 Using only your iterLinesWc test with a 105 MiB file (a movie I had
 lying around), with enumerator's definition it takes 220 MiB of memory
 and 1.3~1.5 seconds according to +RTS -s.  By doing only this very
 change above, it takes 2 MiB of memory (100x improvement :P) and
 0.8~0.9 seconds.

 John Millikin, could you please apply the attached patch? =)

 Cheers,

 --
 Felipe.



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] -- Extension for Pearls of Functional Algorithm Design by Richard Bird, 2010, page 25 #Haskell

2011-04-25 Thread caseyh

-- Extension for Pearls of Functional Algorithm Design by Richard Bird,
-- 2010, page 25 #Haskell

-- This version assumes 3 disjoint ordered sets represented as lists.
-- So either: xy XOR xy
-- Since it uses lists it is no faster than the divide and conquer approach.

-- I might try to convert this version to sorted arrays for
-- O(log|X|+log|Y|+log|Z|) performance
-- If I can figure out how to do it without suffering from indexitis.



smallest3'' :: Ord a = Int - ([a], [a], [a]) - a

smallest3'' k ([],[],ts) = ts !! k
smallest3'' k (zs,[],[]) = zs !! k
smallest3'' k ([],ws,[]) = ws !! k

smallest3'' k ([],ws,ts) = smallest'' k (ws,ts)
smallest3'' k (zs,[],ts) = smallest'' k (zs,ts)
smallest3'' k (zs,ws,[]) = smallest'' k (zs,ws)

smallest3'' k (zs,ws,ts) =
case (ab, bc, ac) of
~~(True, True, True)- smallest3h'' k  
((zs,p,ys),(ws,q),(ts,o,rs)) -- abc
~~(True, False, True)   - smallest3h'' k  
((zs,p,ys),(ts,o),(ws,q,us)) -- acb
~~(False, True, True)   - smallest3h'' k  
((ws,q,vs),(zs,p),(ts,o,rs)) -- bac
~~(False, True, False)  - smallest3h'' k  
((ws,q,vs),(ts,o),(zs,p,xs)) -- bca
~~(True, False, False)  - smallest3h'' k  
((ts,o,ss),(zs,p),(ws,q,us)) -- cab
~~(False, False, False) - smallest3h'' k  
((ts,o,ss),(ws,q),(zs,p,xs)) -- cba


where
~~p = (length zs) `div` 2
~~q = (length ws) `div` 2
~~o = (length ts) `div` 2

~~(xs, a : ys)  = splitAt p zs
~~(us, b : vs)  = splitAt q ws
~~(rs, c : ss)  = splitAt o ts

~~smallest3h'' k ((zs,p,ys),(ws,q),(ts,o,rs)) =
case (k=p+q+o) of
~~(True)- smallest3'' k (zs,ws,rs)
~~(False)   - smallest3'' (k-p-1) (ys,ws,ts)




smallest'' :: Ord a = Int - ([a], [a]) - a
smallest'' k ([],ws) = ws !! k
smallest'' k (zs,[]) = zs !! k
smallest'' k (zs,ws) =
case (ab, k=p+q) of
~~(True, True)  - smallest'' k (zs,us)
~~(True, False) - smallest''(k-p-1) (ys,ws)
~~(False, True) - smallest'' k (xs,ws)
~~(False, False)- smallest''(k-q-1) (zs,vs)
where
~~p = (length zs) `div` 2
~~q = (length ws) `div` 2
~~(xs, a : ys)  = splitAt p zs
~~(us, b : vs)  = splitAt q ws




___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] plugins and cabal build

2011-04-25 Thread Michael Snoyman
Hi all,

I'm experimenting with using the plugins package for yesod devel
server. The basic approach is to use cabal for building the object
files, and then load them with plugins. I can get everything to work
when I compile with ghc --make, but I believe name mangling is
getting in the way with the cabal build route. Can someone give some
guidance on how to properly mangle the function names so that plugins
can load them?

Thanks,
Michael

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Haskell from SML - referrential Transparency?!

2011-04-25 Thread Colin Adams
On 26 April 2011 00:53, Ryan Ingram ryani.s...@gmail.com wrote:

 I've been working on Haskell for quite a while and it's not too often that
 a beginner shows me a new trick--this trick with trace seems really cool and
 I hadn't seen it before.

 f x | trace (f  ++ show x) False = undefined
 f ... -- rest of regular definition

 Makes it really easy to add the trace and then later comment it out.  One
 problem I always have with traces the usual way is that adding/removing them
 is kind of annoying--it can change the indentation of your code, etc.  So
 this trick is really useful!


Yes. It would be much better if trace were a primitive, whose semantics were
to ignore the first argument and yield the second argument as a value. But
these semantics would be changed by supplying an argument to the runtime (so
you could turn tracing on-and-off between runs).

Actually, this still isn't very convenient. Better would be to have another
String argument - the trace key. Then the runtime argument would list those
trace keys for which tracing should be performed.


This way you never have to edit the code to add and remove tracing (though
you may want to remove many trace statements when you are convinced the code
is thoroughly debugged).
-- 
Colin Adams
Preston, Lancashire, ENGLAND
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe