Re: [Haskell-cafe] ping haskell.org timeout

2011-08-26 Thread Ketil Malde
Jason Dagit dag...@gmail.com writes:

 Lots of servers turn off ICMP packet responses these days

 Because users don't really need error messages, that's privileged
 information for system administrators.

 Besides, if someone is trying to debug http protocol issues using
 ICMP, they're taking an awfully indirect route.

Yes, first thing would be to check the log files.  Oh, wait, users don't
have read permissions for those...

 I think the reason it gets disabled is typically well intentioned.

And we all know where that road leads - to frustration and low quality
services, that's where.

Sorry for my grumpiness - this is a constant struggle for me. :-)

 It takes a while to complete with no visual feedback.  Perhaps the
 network is just slow?  Or perhaps the web pages are cached somewhere
 along the way?

 All of those are plausible [..]

Perhaps 'cabal update' should provide some visual feedback by default?
There's -v, but there's still a noticable pause (15 seconds on a fairly
beefy computer and a good connection) between Downloaded to [..] and
Reading available packages

The index is 3MB, it's probably not big enough that a smarter protocol
(rsync/rdiff?) would improve things?  Except perhaps checking that it
has been updated since the last update - that'd probably save a ton of
bandwidth if/when people do automatic updates.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

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


Re: [Haskell-cafe] ANN: shelltestrunner 1.1

2011-08-26 Thread Magnus Therning
On Thu, Aug 25, 2011 at 20:56, Simon Michael si...@joyful.com wrote:
 I'm pleased to announce shelltestrunner 1.1.

 shelltestrunner tests command-line programs or arbitrary shell
 commands.  It reads simple declarative tests specifying a command,
 some input, and the expected output, error output and exit status.
 Tests can be run selectively, in parallel, with a timeout, in color,
 and/or with differences highlighted. Projects using it include
 hledger, yesod, and berp. shelltestrunner is free software released
 under GPLv3+.

 New in 1.1:

  * bump process dependency to allow building with GHC 7.2.1

  * new `-a/--all` flag shows all failure output without truncating

 Home page: http://joyful.com/shelltestrunner

 Install: $ cabal install shelltestrunner

Excellent, my strategy worked. I've been expecting this email. ;)

/M

-- 
Magnus Therning                      OpenPGP: 0xAB4DFBA4
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe               http://therning.org/magnus

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


[Haskell-cafe] hoogle data no connection to host http://code.galois.com/darcs/haskell-platform ...

2011-08-26 Thread informationen

Hi,

i installed Hoogle succesfullly with
cabal install hoogle

then i try to run
hoogle data

but the connection to 
http://code.galois.com/darcs/haskell-platform/haskell-platform.cabal
times out. 


How can i download the data needed for the hoogle command line
tool?

Greetings
Chris

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


Re: [Haskell-cafe] hoogle data no connection to host http://code.galois.com/darcs/haskell-platform ...

2011-08-26 Thread Thomas DuBuisson
The Galois link works fine for me now - it also worked for me earlier
today when I ran hoogle data for my own system.  I suggest you try
again, possibly with a better internet connection?

Cheers,
Thomas

On Fri, Aug 26, 2011 at 12:39 AM, informationen informatio...@gmx.de wrote:
 Hi,

 i installed Hoogle succesfullly with
 cabal install hoogle

 then i try to run
 hoogle data

 but the connection to
 http://code.galois.com/darcs/haskell-platform/haskell-platform.cabal
 times out.
 How can i download the data needed for the hoogle command line
 tool?

 Greetings
 Chris

 ___
 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] a minor bug (memory leak) in ListLike package

2011-08-26 Thread Sebastian Fischer
On Wed, Aug 24, 2011 at 3:47 PM, Ivan Lazar Miljenovic
ivan.miljeno...@gmail.com wrote:
 I was just trying to remember some of the tricks Daniel Peebles (aka
 {co}pumpkin) used to do in #haskell with Data.List.genericLength.
 I've never really used ListLike, but was just trying to guess why the
 default implementation was as it is.

Maybe he used lazy implementations of Num and Ord in combination with
a definition like

length [] = 0
length (_:xs) = 1 + length xs

But as John observed, the accumulating version of length does not
provide such laziness and the accumulator might as well be made
strict.

Sebastian

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


[Haskell-cafe] Dynamic loading of module

2011-08-26 Thread Arnaud Bailly
Hello,
I stumbled upon this blog post describing a method from dynamically loading
modules using GHC api.

While trying to test the given method, I got the following error which
obviously tells me my packages are not correctly installed but I have no
idea how to fix this.

D:\projets\ghc -package ghc main.hs --make
command line: cannot satisfy -package ghc:
ghc-7.0.3-fc75cf67c86ba2c0d64b07024a18d3b4 is unusable due to missing or
recursive dependencies:
  template-haskell-2.5.0.0-7d9b1443ac5ab69e5ed705a487990deb
(use -v for more information)

When I run ghc-pkg check, I got which obviously is bad.

There are problems in package test-framework-0.3.3:
  dependency regex-posix-0.94.4-7963833a181f95ba404a78e3e76d835a doesn't
exist
There are problems in package QuickCheck-2.4.0.1:
  dependency template-haskell-2.5.0.0-e5fd973432385747440288b48f6a6a5a
doesn't exist
There are problems in package snap-0.5.1:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency cereal-0.3.3.0-81dac2655ecff64c5fc69671490df093 doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package snap-server-0.5.1:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency
attoparsec-enumerator-0.2.0.3-d5a7e5b640b4b27be4c6d0c9a314dd0a doesn't
exist
  dependency binary-0.5.0.2-72c84eaab351d41e936261d8d5d416f5 doesn't exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package snap-core-0.5.1:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency
attoparsec-enumerator-0.2.0.3-d5a7e5b640b4b27be4c6d0c9a314dd0a doesn't
exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package heist-0.5.2:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
There are problems in package xmlhtml-0.1.5:
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
There are problems in package authenticate-0.9.0.1:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package http-enumerator-0.6.5.1:
  dependency attoparsec-0.8.6.1-3d4c24cfa94f97cbeb7d6cf43ef70284 doesn't
exist
  dependency
attoparsec-enumerator-0.2.0.3-d5a7e5b640b4b27be4c6d0c9a314dd0a doesn't
exist
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package zlib-enum-0.2.1:
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package yesod-static-0.1.0:
  dependency cereal-0.3.3.0-81dac2655ecff64c5fc69671490df093 doesn't exist
  dependency pureMD5-2.1.0.3-cb7a7a936930b56c62f9207838b99efb doesn't
exist
There are problems in package yesod-form-0.1.0.1:
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency data-default-0.2.0.1-14197e607852c0357951d749c098bd34 doesn't
exist
There are problems in package yesod-core-0.8.2:
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency cereal-0.3.3.0-81dac2655ecff64c5fc69671490df093 doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package warp-0.4.0.1:
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package wai-extra-0.4.0.1:
  dependency blaze-builder-0.3.0.1-157e8a92bc5ef27895f938613ecfdcb1
doesn't exist
  dependency case-insensitive-0.2.0.1-6cb260512f91ae60284372c0208aa00e
doesn't exist
  dependency enumerator-0.4.10-d65a90206db2a5203c1c906e6f58a6c9 doesn't
exist
There are problems in package wai-app-static-0.1.0:
  dependency 

[Haskell-cafe] Make shared library - questions

2011-08-26 Thread Sergiy Nazarenko
Hi !

I'm trying to compile shared library. This library will use as part of
plugin for some program.
If I compile library with option -dynamic my library has links for HS
libraries like libHSbase-4.2.0.2-ghc6.12.3.so and so on.
But program has crashed constantly.

Is it possible to make shared library without -dynamic flag? I want to try
to make library without dependencies.

According to http://www.well-typed.com/blog/30 theoretically I can do this
but I found this impossible -
http://hackage.haskell.org/trac/ghc/ticket/3704
My options to compile:
ghc -O2 --make -no-hs-main -dynamic -shared -fPIC -optl '-shared' -optc
'-DMODULE=MyLib' -o MyLib.so MyLib.hs module_init.c  -optl-Wl
-lHSrts-ghc6.12.3

If I try compile without -dynamic I get error:
/usr/bin/ld:
/usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a(Conc__270.o):
relocation R_X86_64_32 against
`base_GHCziConc_ensureIOManagerIsRunning1_closure' can not be used when
making a shared object; recompile with -fPIC
/usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a: could not read
symbols: Bad value
collect2: ld returned 1 exit status



My system is:
Cenos 5.6
ghc6.12.3
gcc-4.2.1

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


Re: [Haskell-cafe] Make shared library - questions

2011-08-26 Thread Max Bolingbroke
On 26 August 2011 13:52, Sergiy Nazarenko nazarenko.ser...@gmail.com wrote:
 /usr/local/lib/ghc-6.12.3/base-4.2.0.2/libHSbase-4.2.0.2.a(Conc__270.o):
 relocation R_X86_64_32 against
 `base_GHCziConc_ensureIOManagerIsRunning1_closure' can not be used when
 making a shared object; recompile with -fPIC

So it looks like you will have to recompile the base libraries with
-fPIC (or try this on Windows, where PIC is unnecessary).

The way I would do this personally is to recompile all of GHC, and in
mk/build.mk set the GhcLibHcOpts to -fPIC. There may be a way to just
recompile the base library (and dependents) using Cabal, but I'm less
sure about that path.

Note that using -fPIC will probably impose a performance penalty on
the library code.

Max

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


[Haskell-cafe] Ambiguous module name `System.Directory'

2011-08-26 Thread informationen

Hi,

i am using ghc version 7.0.3 and a pretty recent version of the
haskell-platform.

Whenever i use the System.Directory module, i run into this
conflict:

Ambiguous module name `System.Directory':
it was found in multiple packages:
system-fileio-0.2.1 directory-1.1.0.0

How can i resolve this conflict permamently (i know about 
:set -hide-package ... )? And shouldn't there be a rule in the

haskell platform which forbids modules of the same name?

Greetings 
Chris



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


Re: [Haskell-cafe] Ambiguous module name `System.Directory'

2011-08-26 Thread Christopher Done
On 26 August 2011 18:00, informationen informatio...@gmx.de wrote:
 Hi,

 i am using ghc version 7.0.3 and a pretty recent version of the
 haskell-platform.

 Whenever i use the System.Directory module, i run into this
 conflict:

 Ambiguous module name `System.Directory':
        it was found in multiple packages:
            system-fileio-0.2.1 directory-1.1.0.0

 How can i resolve this conflict permamently (i know about :set -hide-package
 ... )? And shouldn't there be a rule in the
 haskell platform which forbids modules of the same name?

1) Use PackageImports:
http://www.haskell.org/ghc/docs/7.0.3/html/users_guide/syntax-extns.html#package-imports

import network Network.Socket

2) Use cabal-dev ghci which will only have packages available that you
specify in your .cabal file.

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


Re: [Haskell-cafe] hledger subcommand detection, RFC

2011-08-26 Thread Simon Michael
Thanks Conrad! Those are some great links.

 I wrapped up some manpage generation code in a package called
 ui-command, which is kind of orthogonal to cmdargs (ui-command just
 deals with subcommands). Example commands are often useful, so I added

Interesting. Have you tried using both ui-command and cmdargs together ?


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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Andrew Coppin

On 26/08/2011 02:40 AM, Daniel Peebles wrote:

And as Daniel mentioned earlier, it's not at all obvious what we mean by
bits used when it comes to negative numbers.


I guess part of the problem is that the documentation asserts that 
bitSize will never depend on its argument. (So would will write things 
like bitSize undefined :: ThreadID or similar.)


I can think of several possible results one might want from a bit size 
query:


1. The number of bits of precision which will be kept for values of this 
type. (For Word16, this is 16. For Integer, this is [almost] infinity.)


2. The amount of RAM that this value is using up. (But that would surely 
be measured in bytes, not bits. And processor registors make the picture 
more complicated.)


3. The bit count to the most significant bit, ignoring sign.

4. The bit count to the sign bit.

Currently, bitSize implements #1. I'm not especially interested in #2. I 
would usually want #3 or #4.


Consider the case of 123 (decimal). The 2s complement representation of 
+123 is


...000011

The 2s complement representation of -123 is

...111101

For query #3, I would expect both +123 and -123 to yield 7. For query 
#4, I would expect both to yield 8. (Since if you truncate both of those 
strings to 8 bits, then the positive value starts with 0, and the 
negative one start with 1.)


Then of course, there's the difference between count of the bits and 
bit index, which one might expect to be zero-based. (So that the Nth 
bit represents 2^N.)


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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Daniel Fischer
On Friday 26 August 2011, 19:24:37, Andrew Coppin wrote:
 On 26/08/2011 02:40 AM, Daniel Peebles wrote:
  And as Daniel mentioned earlier, it's not at all obvious what we mean
  by bits used when it comes to negative numbers.
 
 I guess part of the problem is that the documentation asserts that
 bitSize will never depend on its argument. (So would will write things
 like bitSize undefined :: ThreadID or similar.)

I don't think that's a problem, it's natural for what bitSize does. And it 
would be bad if bitSize did something different for Integer than for Int, 
Word, ...

 
 I can think of several possible results one might want from a bit size
 query:

Yup, though for some there are better names than bitSize would be.

 
 1. The number of bits of precision which will be kept for values of this
 type. (For Word16, this is 16. For Integer, this is [almost] infinity.)

Not almost infinity, what your RAM or Int allow, whichever cops out 
first, or enough, unless you [try to] do really extreme stuff.

 
 2. The amount of RAM that this value is using up. (But that would surely
 be measured in bytes, not bits. And processor registors make the picture
 more complicated.)
 
 3. The bit count to the most significant bit, ignoring sign.
 
 4. The bit count to the sign bit.
 
 Currently, bitSize implements #1. I'm not especially interested in #2. I
 would usually want #3 or #4.

I'd usually be more interested in #2 than in #4.

 
 Consider the case of 123 (decimal). The 2s complement representation of
 +123 is
 
 ...000011
 
 The 2s complement representation of -123 is
 
 ...111101
 
 For query #3, I would expect both +123 and -123 to yield 7.

One could make a case for the answer 3 for -123, I wouldn't know what to 
expect without it being stated in the docs.

 For query
 #4, I would expect both to yield 8. (Since if you truncate both of those
 strings to 8 bits, then the positive value starts with 0, and the
 negative one start with 1.)

#4 would then generally be #3 + 1 for signed types, I think, so not very 
interesting, but for unsigned types?

 
 Then of course, there's the difference between count of the bits and
 bit index, which one might expect to be zero-based. (So that the Nth
 bit represents 2^N.)

Yes, but that shouldn't be a problem with good names.

So, which of them are useful and important enough to propose for inclusion?

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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Steve Schafer
On Fri, 26 Aug 2011 18:24:37 +0100, you wrote:

I would usually want #3 or #4.

Out of curiosity, what for? While I do occasionally need to get a
logarithmic size estimate of a number (which is basically what #3 and
#4 are), the specific requirements in each case tend to vary, enough so
that it's unlikely that a single function (other than simply taking the
logarithm) can handle the majority of applications.

-Steve Schafer

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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Andrew Coppin

On 26/08/2011 07:36 PM, Steve Schafer wrote:

On Fri, 26 Aug 2011 18:24:37 +0100, you wrote:


I would usually want #3 or #4.


Out of curiosity, what for? While I do occasionally need to get a
logarithmic size estimate of a number (which is basically what #3 and
#4 are), the specific requirements in each case tend to vary, enough so
that it's unlikely that a single function (other than simply taking the
logarithm) can handle the majority of applications.


You wouldn't want to know how many bits you need to store on disk to 
reliably recreate the value? Or how many bits of randomness you need to 
compute a value less than or equal to this one?


I suppose I could use a binary logarithm. I'm just concerned that it 
would be rather slow. After all, I'm not interested in the exact 
logarithm (which is fractional), just the number of bits (which is a 
small integer)...


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


[Haskell-cafe] RFC: decodeFloat

2011-08-26 Thread Daniel Fischer
Occasionally, the behaviour of decodeFloat and its consequences causes 
concern and/or bug reports (e.g. 
http://hackage.haskell.org/trac/ghc/ticket/3898).

The main problem is the treatment of NaNs and infinities (that it doesn't 
distinguish between 0.0 and -0.0 is a minor thing), which are converted as 
if they were ordinary finite values.

Thus, for example, decodeFloat (1/0 :: Double) = (2^52,972) and 
consequently

floor (1/0 :: Double) = 2^1024 (corresponding for round, truncate, ceiling, 
properFraction),
significand (1/0 :: Double) = 0.5,
Prelude uncurry encodeFloat (decodeFloat (1/0 :: Float)) :: Double
3.402823669209385e38

and similar meaningless/nonsensical results for NaNs.

At its type, decodeFloat :: RealFloat a = a - (Integer, Int), I see only 
two reasonable options,

1. leave the behaviour as it is, just warn about the exceptional cases in 
the documentation,

2. let decodeFloat raise an error when its argument is a NaN or infinite.

Both options have disadvantages, 1. makes it easy to get meaningless 
results when there's a non-finite value around, 2. incurs a nontrivial 
performance penalty.

Paying that performance penalty when dealing only with known-to-be-good 
values is undesirable, but so are meaningless results.


A third option would be providing both behaviours by adding a function.
That could take several forms,

a) leave decodeFloat as is and add safeDecodeFloat outside the RealFloat 
class, that would check the value first and then either raise an error on 
NaN/Infinity or return a Maybe (Integer, Int),

b) add a function to the RealFloat class, either leave decodeFloat as is 
and add safeDecodeFloat with the behaviour as in a) or change decodeFloat 
according to 2. and add unsafeDecodeFloat with the current behaviour.

The drawback of a) is that safeDecodeFloat would have to perform two 
checks, while with IEEE Doubles/Floats, the result could be determined by 
one check (which would also be simpler than each of isNaN and isInfinite).
Also, which module should export it?

The drawback of b) is adding a function to RealFloat, as if that wasn't big 
enough already. Since both behaviours allow a default definition in terms 
of the other, only code that by chance uses the new name would break.

What would be the community's preferred way to handle this issue?

Cheers,
Daniel

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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Daniel Fischer
On Friday 26 August 2011, 21:30:02, Andrew Coppin wrote:
 You wouldn't want to know how many bits you need to store on disk to 
 reliably recreate the value? Or how many bits of randomness you need to 
 compute a value less than or equal to this one?
 
 I suppose I could use a binary logarithm. I'm just concerned that it 
 would be rather slow. After all, I'm not interested in the exact 
 logarithm (which is fractional), just the number of bits (which is a 
 small integer)...

As of GHC-7.2, there's GHC.Integer.Logarithms in both, integer-gmp and 
integer-simple, providing

integerLog2# :: Integer - Int#

(integer-* lives before base, so there's no Int yet) which exploits the 
representation of Integers and should be fast enough [at least for
integer-gmp, where it's bounded time for normally represented values, the 
representation of Integers in integer-simple forces it to be O(log n)].

Caution: integerLog2# expects its argument to be positive, havoc might 
ensue if it isn't.

GHC.Float exports

integerLogBase :: Integer - Integer - Int

also before 7.2, now it calls the above if the base is 2, so should have 
decent performance. (It requires that the base is  1 and the second 
argument positive, of course.)

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


Re: [Haskell-cafe] Dynamic loading of module

2011-08-26 Thread Albert Y. C. Lai

On 11-08-26 04:51 AM, Arnaud Bailly wrote:

D:\projets\ghc -package ghc main.hs --make
command line: cannot satisfy -package ghc:
 ghc-7.0.3-fc75cf67c86ba2c0d64b07024a18d3b4 is unusable due to
missing or recursive dependencies:
   template-haskell-2.5.0.0-7d9b1443ac5ab69e5ed705a487990deb
 (use -v for more information)

When I run ghc-pkg check, I got which obviously is bad.


[...]

There are problems in package QuickCheck-2.4.0.1:
   dependency
template-haskell-2.5.0.0-e5fd973432385747440288b48f6a6a5a doesn't exist


For a 100%-accurate answer, one would need the full history of what you 
did to your computer, which no one knows.


For a 99%-accurate answer, the outputs of ghc -v and ghc-pkg list -v 
are very good post-mortem information.


A 90%-accurate answer: Given the incomplete information (that's right, 
ghc-pkg check is incomplete), there is 90% probability that you lost 
template-haskell, and you must reinstall haskell platform. (No, building 
a new instance of template-haskell is not enough. Generally, replacing 
or overriding libs that come with GHC does not work. See my 
http://www.vex.net/~trebla/haskell/sicp.xhtml )


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


Re: [Haskell-cafe] Ambiguous module name `System.Directory'

2011-08-26 Thread Albert Y. C. Lai

On 11-08-26 12:00 PM, informationen wrote:

How can i resolve this conflict permamently (i know about :set
-hide-package ... )? And shouldn't there be a rule in the
haskell platform which forbids modules of the same name?


Two permanent resolutions, choose one:

ghc-pkg hide system-fileio

ghc-pkg unregister system-fileio

Haskell platform has never included system-fileio, so it contains no 
ambiguous module name.


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


Re: [Haskell-cafe] bitSize

2011-08-26 Thread Steve Schafer
On Fri, 26 Aug 2011 20:30:02 +0100, you wrote:

You wouldn't want to know how many bits you need to store on disk to 
reliably recreate the value?

I can't say that I have cared about that sort of thing in a very long
time. Bits are rather cheap these days. I store data on disk, and the
space it occupies is whatever it is; I don't worry about it.

Or how many bits of randomness you need to compute a value less than or
equal to this one?

I'm not sure I understand this one. I generally don't need _any_
randomness to compute a value. On the other hand, if the desire is to
take an integer n and generate a set of pseudorandom numbers ranging
from 0 to n-1, that's easily done using the standard random number
methods.

-Steve Schafer

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


[Haskell-cafe] Project Euler: request for comments

2011-08-26 Thread Oscar Picasso
Hi,

I order to improve my Haskell skills I started (again) to solve the
project euler problems with this language.
I am now at problem 11 and would really appreciate any comment about
my code in order to make it more elegant or efficient.

My solutions can be found here: http://fp.opicasso.com/tag/projecteuler

Oscar Picasso

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


Re: [Haskell-cafe] Project Euler: request for comments

2011-08-26 Thread KC
Is Problem 11 the 4 consecutive #'s problem?

If so what must be true for 4 #'s to have a large product?

Hint: x * y * z * 2 is that going to be larger?

-- 
--
Regards,
KC

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


Re: [Haskell-cafe] How to make callCC more dynamic

2011-08-26 Thread bob zhang
Thank you, there is also a nice link here :-)
http://stackoverflow.com/questions/7178919/how-to-make-callcc-more-dynamic
and for this type,
ContT {runContT :: forall r1 . (forall r2 . a- m r2) - m r1}
callCC can be defined, however, you can not run it, and reset couldn't
type check
于 11-8-25 上午1:53, o...@okmij.org 写道:
 bob zhang wrote:
 I thought the right type for ContT should be
 newtype ContT m a = ContT {runContT :: forall r. (a- m r) - m r}
 and
 other control operators
 shift :: Monad m = (forall r . (a- ContT m r) - ContT m r) - ContT m a
 reset :: Monad m = ContT m a - ContT m a
 callCC :: ((a- (forall r . ContT m r)) - ContT m a) - ContT m a
 unfortunately, I can not make callCC type check, and don't know how to
 do it.
 Precisely that problem was discussed in  
   http://okmij.org/ftp/continuations/undelimited.html#proper-contM

 Your ContT is CPS1 in the above article. The article shows why you
 cannot write callCC with the above type of ContT. The article talks
 about other types. BTW, if you faithfully defined the monad for
 undelimited control than shift/reset cannot be expressed. Undelimited
 continuations are strictly less expressible than delimited ones. The
 above page gives the pointers to the papers with the proof.




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