Re: [Haskell-cafe] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-21 Thread Ketil Malde

 fact 0 = 1
 fact n = n * fact (n-1)

 Now I ran it as fact 100 with signature Int - Int and with
 Integer - Integer

 In the first case I got 0 in about 3 seconds
  [...]
 And if that sounds like a unreal argument, consider representing and
 storing Graham's number.

So, since computers are finite anyway, we can just arbitrarily (well,
almost) redefine large constants, and set all factorials above some
threshold to zero?  Perhaps we should also set pi=3, that would simplify
lots of things :-)

 Pragmatically: 32-bits is unwise for a bank-balance, 64 should be a
 bit more safe

Please start a bank using modulo arithmetic, I'm looking forward to
overdrafting my account!  

 So yes, Haskell's Int, should have been called FastInt or Int29 or somethin'

On a more serious note, I accept that Int (and other limited precision
numbers) is a fact of life, and sometimes useful for performance
reasons.  

I would have liked, however, to have a compiler option or some other way
to make my programs throw an exception on overflow - even if this turned
out to be slower, I could at least use it when testing my programs,
which would have caught a few bugs.

-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] abs minBound (0 :: Int) negate minBound == (minBound :: Int)

2013-08-20 Thread Ketil Malde

Richard A. O'Keefe o...@cs.otago.ac.nz writes:

 I think a better argument for twos complement is that you're just
 doing all of your computations modulo 2^n (where n is 32 or 64 or
 whatever), and addition and multiplication work as expected modulo
 anything.

 To me, that's not a better argument.  It isn't even a _good_ argument.
 It amounts to saying if you do things wrong, you can justify it by
 saying you're really doing something else right, and it's the programmer's
 fault for wanting the wrong thing.

Not only that, but in Haskell, you don't really know 'n', it is only
specified to be at least 23, or something like that.  Which basically
means that any code that relies on this behaviour without rigorously
checking it basically is wrong.

-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] Compiling stringable with GHC 7.0.4

2013-08-20 Thread Ketil Malde

I took the liberty of implementing this fix and uploading
stringable-0.1.1.1 to HackageDB.  I tested it on GHC 7.0.4 (you know,
shipped with the cutting-edge Fedora distribution one year ago, but
ancient and no longer to be bothered with by Haskell standards :-) and
on 7.6.2.

-k

Ketil Malde ke...@malde.org writes:

 Hi,

 ---
 I don't think FlexibleInstances works with this GHC, I get:

 % cabal install --prefix=$G stringable
 Resolving dependencies...
 Configuring stringable-0.1.1...
 Building stringable-0.1.1...
 Preprocessing library stringable-0.1.1...
 [1 of 1] Compiling Data.Stringable  ( Data/Stringable.hs, 
 dist/build/Data/Stringable.o )

 Data/Stringable.hs:54:10:
 Illegal instance declaration for `Stringable String'
   (All instance types must be of the form (T t1 ... tn)
where T is not a synonym.
Use -XTypeSynonymInstances if you want to disable this.)
 In the instance declaration for `Stringable String'
 ---

 I changed the first line of Data/Stringable.hs to:

 {-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}

 and then it compiled.  Is there any reason not to retain the TSI pragma?

 -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


[Haskell-cafe] GHC and backwards compatibility

2013-08-19 Thread Ketil Malde

I recently encountered the following problem:


$ cabal install
Resolving dependencies...
Configuring array-0.4.0.1...
Building array-0.4.0.1...
Preprocessing library array-0.4.0.1...

Data/Array/IArray.hs:1:14: Unsupported extension: Trustworthy
cabal: Error: some packages failed to install:
array-0.4.0.1 failed during the building phase. The exception was:
ExitFailure 1
asmeval-0 depends on array-0.4.0.1 which failed to install.
binary-0.7.1.0 depends on array-0.4.0.1 which failed to install.
biocore-0.3.1 depends on array-0.4.0.1 which failed to install.
biofasta-0.0.3 depends on array-0.4.0.1 which failed to install.
biopsl-0.4 depends on array-0.4.0.1 which failed to install.
biosff-0.3.3 depends on array-0.4.0.1 which failed to install.
bytestring-0.10.2.0 depends on array-0.4.0.1 which failed to install.
containers-0.5.2.1 depends on array-0.4.0.1 which failed to install.
deepseq-1.3.0.1 depends on array-0.4.0.1 which failed to install.
hashable-1.2.0.10 depends on array-0.4.0.1 which failed to install.
stringable-0.1.1 depends on array-0.4.0.1 which failed to install.
system-filepath-0.4.7 depends on array-0.4.0.1 which failed to install.
text-0.11.3.1 depends on array-0.4.0.1 which failed to install.
unordered-containers-0.2.3.1 depends on array-0.4.0.1 which failed to install.


The installed GHC is 7.0.4, and yes, that's many major versions ago, but
then again, it's only two years old, and from what I understand, it is
shipped by some conservative Linux distributions.

The problems here are that:

a) the installation tries to install array, but current array requires
the Trustworthy extension, which appeared in 7.2.1.  Ideally, packages
should try to be backwards compatible, e.g. by using conditional
sections.

b) the output isn't very helpful in tracking down the cause of this
problem, it claims that all these packages depend on array-0.4.0.1,
which is a lie.  Somewhere, somehow, somethings depends on this (or at
least a newer version), but I have no clue how to figure out which,
except examining each of these packages and their dependencies manually.
 
It is also possible that array shouldn't be upgraded like this, but then
that needs to be made clear to cabal somehow, so that I don't spend ages
trying to.

Are there any solutions to this?  Advice on how to proceed?

-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] GHC and backwards compatibility

2013-08-19 Thread Ketil Malde

Joe Q headprogrammingc...@gmail.com writes:

 This is definitely an issue with the array package not setting the right
 minimum versions. You should email the maintainer.

Yes, that would be the thing to do, except that the maintainer is
librar...@haskell.org, whom I believe does not accept emails from me.
:-(

But if you (or anybody else) subscribes to the list, perhaps you could
forward?

In any case, one of the dependencies uses Stringable, which means that a
newer GHC is probably still required.

-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] ordNub

2013-07-16 Thread Ketil Malde

Francesco Mazzoli f...@mazzo.li writes:

 import qualified Data.HashSet as S
 
 nub :: Hashable a = [a] - [a]
 nub = S.toList . S.fromList

 Well, the above is not stable while Niklas’ is.  But I guess that’s not
 the point of your message :).

We could also implement Data.BloomFilter.nub, which removes equal
elements probabilistically (with a small but non-zero chance of removing
some unique elements) :-)

-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


[Haskell-cafe] Possible GSoC project

2013-04-04 Thread Ketil Malde

Hi,

I proposed a bioinformatics GSoC project involving Haskell using OSC as
the mentoring organization.  Typically, haskell.org projects concern
infrastructure rather than applications, and I don't know if I'm allowed
to submit both places :-)

Anyway, as this is a likely place to find prospective students and
(co-)mentors, I thought I'd mention it here.

But if anybody is interested, I think it makes for a quite focused,
solvable problem, which I belive would be quite useful.  It could also
likely result in a scientific publication of some sort.

A quick writeup (that I'll probably update) is here:

  http://biohaskell.org/Google_Summer_of_Code#optimizing-transalign

-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] Possible GSoC project

2013-04-04 Thread Ketil Malde
Mateusz Kowalczyk fuuze...@fuuzetsu.co.uk  wrote:

What would you say is the level of bioinformatics understanding that
one would have to have to even consider applying?

Not very much, some knowledge of string edit distance and dynamic programming 
would be good, but if not, it's something I can straighten out with a student 
in an afternoon, I think.

-k

-- 
De profundis ad te clamo.

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


Re: [Haskell-cafe] Lazy object deserialization

2013-03-15 Thread Ketil Malde

Scott Lawrence byt...@gmail.com writes:

 All the object serialization/deserialization libraries I could find (pretty 
 much just binary and cereal) seem to be strict with respect to the actual 
 data 
 being serialized. 

Binary became strict between 0.4.4 and 0.5, I think doing so improved
the speed of GHC.  I had a file format wrapper at the time which
depended on it being lazy, and was stuck at 0.4.4 for a long time, until
somebody helped me with a workaround.  Performance is a bit worse than
it was with 0.4.4, but I think it's better to stay with current code.

The code in question is in the darcs repository at:

  http://malde.org/~ketil/biohaskell/biosff

the relevant patch is named Update to use [...]

-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] Ticking time bomb

2013-01-31 Thread Ketil Malde

Ertugrul Söylemez e...@ertes.de writes:

 People are using Hackage!

+1. And I keep telling people to use it.  Sure, it'd be better if they
used .debs, .rpms, or whatever goes on Mac and Windows.  But that would
mean I would need to build those packages, including maintaining systems
with the respective OSes.  I haven't even managed to do it for the
systems I do use.

The most simple and obvious threat is here that some random evil person
gets a Hackage account, uploads a new version of a common package with a
trojan, and waits for unsuspecting users to download and install it.

 My proposal is:

   1. Build the necessary machinery into Cabal to allow signing [...]

*MY* proposal is that:

0. Hackage sends an email to the previous uploader whenever a new
   version of a package is uploaded by somebody else.

At least that way, I would be notified if it happened to my packages,
and I would be able to check up on the situation, and rectify it.

This is not to say that cryptographic signing is the wrong thing to do,
but a very simple thing like this, which would probably take all of five
minutes to implement, would reduce risk by a substantial amount.

-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] Ticking time bomb

2013-01-31 Thread Ketil Malde

Vincent Hanquez t...@snarc.org writes:

 On 01/31/2013 08:16 AM, Ketil Malde wrote:

 At least that way, I would be notified if it happened to my packages,
 and I would be able to check up on the situation, and rectify it.

 you wouldn't in real cases, 

I wouldn't what?  Be notified?  Rectify it?

 it just fix the most obvious and simple attack vector. 

 but consider:

Ah, those _real_ cases. Fine, let's see what you got.

 * someone intercepting your upload http stream, and replacing 
 dynamically your package.

 * someone gaining malicious access to hackage and planting stuff inside 
 packages.

 * a rogue hackage admin.

 * a rogue hackage mirror admin.

How often do these things happen, I wonder?  I guess a bit more rarely
than malware taking control of people's computers, which would simply
allow people access to upload passwords _and_ signing keys.  So much for
that perfect security scheme, huh?

Anyway: I don't want to sound negative here, so as a constructive
proposal, please replace one of my packages on Hackage, making use of
one of those techniques.  No hurry, I'll wait.

We have this discussion every now and then, and in spite of grand
schemes of crypto and signing and whatnot, we _still_ have security
holes you could drive a truck through.  Why not at least do _something_
to fix that, before we return to the more _interesting_ pursuit of the
Perfect Security Scheme?

-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] Ticking time bomb

2013-01-31 Thread Ketil Malde

Ertugrul Söylemez e...@ertes.de writes:

 And that may even be more harmful, because an insecure system with a
 false sense of security is worse than an insecure system alone.

Yes.  As is clear to all, the current low level of security means that
nobody are _actually_ downloading stuff of Hackage, thank God.  Hackage
just exists for...well, I forget, but certainly not to distribute
software.  Right.

Sarcasm aside, to some extent, this is true.  I used to have a cron job
'cabal install'ing my packages off Hackage to ensure that they would
compile with the current offering of their dependencies.  But I decided
it was way too risky, and don't do it anymore.

 Let's do it properly.

You mean like how it was decisively dealt with when this was discussed
in 2008?

  https://github.com/haskell/cabal/issues/207

Or maybe more the way it was firmly handled when it was brought up again
in 2010? 

  http://www.haskell.org/pipermail/haskell-cafe/2010-December/087050.html

This looks increasingly like that time of year when the problem is
pointed out, the crypto geeks get together to construct the Optimal
Solution, and then everybody lose interest and move on to greener
pastures for a while.  Well, I don't think the perfect solution exists, and 
even if
it could be identified, it might not be implemented, and even if
were implemented, it might not be used.

We've just been incredibly lucky that nothing really bad has happened so
far.  Let's hope it lasts.

-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] containers license issue

2012-12-17 Thread Ketil Malde

Mike Meyer m...@mired.org writes:

 Niklas Larsson metanik...@gmail.com wrote:
2012/12/15 Mike Meyer m...@mired.org:
 Only if Tanenbaum documented the internal behavior of Linux before
 it was written.

Tannenbaum wrote Minix, the operating system that Linus used (and
hacked on) before he did Linux. Minix contained lots of features that
was reimplemented in Linux.

 Ah, Minix isn't documentation.  And it has a radically different
 architecture

The point is that Linux read the source code to Minix before
implementing similar things - quite likely using the same algorithms,
for instance.  So if containers is a translation of FXT, then surely
Linux is a translation of Minix.

 That makes a successful lawsuit unlikely 

The point of the point is that neither of these are translations of
literary works, there is no precedence for considering them as such, and
that reading somebody's work (whether literary or source code) before
writing one's own does not imply that the 'somebody' will hold any
rights to the subsequent work.

Translations in software is what compilers do, not reimplementing
specific algorithms.

 it'll never go to court, so there isn't an infringement.  

Wot?

-k



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


Re: [Haskell-cafe] containers license issue

2012-12-17 Thread Ketil Malde

Mike Meyer m...@mired.org writes:

 As it's commonly understood, reverse engineering doesn't involve
 looking at the code. 

I guess I should make it clear that I don't use it in the strict sense -
I would call that clean-room reverse engineering.  (I'm not sure which
is the most commonly understood meaning, I think Wikipedia supports
both interpretations)

 That's why it's called reverse engineering instead of copying. 

I mean the process of reimplementing specific functionality from another
system, with or without knowledge of implementation details.  I would
use copying to mean verbatim cut-and-pasting, which is something else.

In particular when copyright is concerned, I believe that verbatim
copying in many cases will require a license to the original work, but
merly examining the original work to make use of algorithms, tricks, and
structures from it will not.

I suspect there's nothing magical about source code, if I extract a
component (algorithm or data structure, say) from a program and use it
in my own program, I'm not convinced it matters if I extract it from
object code, source code, or documentation - they're all copyrighted
works, and could be interpreted as translations of the same work.  I
could be wrong about that, though.

-k



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


Re: [Haskell-cafe] containers license issue

2012-12-15 Thread Ketil Malde

Clark Gaebel cgae...@uwaterloo.ca writes:

 I just did a quick derivation from
 http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 

A copyrighted work, you say?

 to get the highest bit mask, and did not reference FXT nor the containers
 implementation. Here is my code:

If copyright follows reimplementations of algorithms from other programs
(because they are considered translations of that program), then
surely it must also follow reimplementation from copyrighted
documentation?

I think this is wrong, copyright does not cover algorithms, and reverse
engineering is not literary translation.  The implications of anything
else would be draconian, simply documenting a program would be a breach
of its copyright, for instance, and Tanenbaum would hold the copyright
to Linux.  But in a court of law, anything is possible.

-k

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


Re: [Haskell-cafe] containers license issue

2012-12-15 Thread Ketil Malde

Ketil Malde ke...@malde.org writes:

 I just did a quick derivation from
 http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 

 A copyrighted work, you say?

Whoops, public domain, according to itself.  Of course, there's no way
to tell if the author read similar copyrighted programs, but maybe
you'll get off easier from claimin the infringement was not wilful?

(BTW, the concept Public Domain isn't recognized in some jurisdictions)

-k


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


Re: [Haskell-cafe] How to determine correct dependency versions for a library?

2012-11-16 Thread Ketil Malde
Aleksey Khudyakov alexey.sklad...@gmail.com writes:

 Adding more restrictive constraints does not work, the broken package will
 be on hackage forever, while adding a new version with relaxed constraints
 works well.

 That illustrate real problem It's not possible to specify correct
 version constraints when package is uploaded. So one have to choose
 between optimistic and conservative approach. Both have disadvantages.
 In ideal world one need ability to adjust version bounds after package
 upload.

+1. Metadata (i.e. the cabal file) chould be editable.  In addition to
adjusting dependency bounds, Hackage (or third party build servers)
could add Tested-With, and there could be a deprecated field added when
problems are discovered.

-k

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


Re: [Haskell-cafe] Hard drive thrashing with modern controllers

2012-11-12 Thread Ketil Malde
timothyho...@seznam.cz writes:

 import Control.Monad
 foo = do
   forever $ writeFile filename.foo Hello world!

I could be wrong, but I suspect this is unlikely to result in (hardly)
any disk operations at all, as long as there is _any_ write caching in
the system.

 will that destroy those sectors of my SSD after the rated 3000 write cycles?

The SSD firmware will even this out by shuffling around the exact flash
blocks that are used, so that's 3K write cycles for each block, spread
out over hundreds of thousands of blocks - so your SSD should survive
perhaps a billion writes in total.

 The reason I ask, is that I have a program here where I would like to save a
 set of files after every change/operation and I'm wondering if I should 
 check if the files I'm saving have actually changed or if this will be 
 handled by the OS...

Unless the loss of a file would be crucial, I wouldn't worry about it.
If/when you wear out the SSD, a replacement will probably be a trivial
cost.

-k

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


Re: [Haskell-cafe] Does anyone know where George Pollard is?

2012-11-08 Thread Ketil Malde
Myles C. Maxfield myles.maxfi...@gmail.com writes:

 Does anyone know where he is? 

On GitHub? https://github.com/Porges  One of the repos was apparently
updated less than a week ago.

 If not, is there an accepted practice to
 resolve this situation? Should I upload my own 'idna2' package?

You can always upload a fork, but unless you have a lot of new
functionality that won't fit naturally in the old package, you can
perhaps try a bit more to contact the original author.

-k

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


Re: [Haskell-cafe] Over general types are too easy to make.

2012-09-02 Thread Ketil Malde
timothyho...@seznam.cz writes:

 case largeMultiConstructorTypedValue of
Foo{blah=blah,brg=brg} -  Some large block...
Bar{lolz=lolz,foofoo=foofoo} - ...Another large block...
Frog{legs=legs,heads=heads} - Yet another large block...

 Where the obvious re-factor is:

 case largeMultiConstructorTypedValue of
foo@Foo - processFoo foo
bar@Bar - processBar bar
frog@Frog - processFrog frog

Hm - is that really so obvious?  To me, it seems like the definition
of processFoo will typically be:

  processFoo (Foo blah brg) = ...

deconstructing the Foo again.  If the Foo is very big, this might be
a good solution, but in many cases, I expect you can do:

  case largeMultiConstructorTypedValue of
 Foo {blah=blah,brg=brg} - processBlahBrg blah brg

and this would make the type more specific.

-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] Platform Versioning Policy: upper bounds are not our friends

2012-08-16 Thread Ketil Malde
Bryan O'Sullivan b...@serpentine.com writes:

 I propose that the sense of the recommendation around upper bounds in the
 PVP be reversed: upper bounds should be specified *only when there is a
 known problem with a new version* of a depended-upon package.

Another advantage to this is that it's not always clear what constitutes
an API change.  I had to put an upper bound on binary, since 0.5
introduced laziness changes that broke my program.  (I later got some
help to implement a workaround, but binary-0.4.4 is still substantially
faster).  Understandably, the authors didn't see this as a breaking API
change.

So, +1.

-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] Fixity declaration extension

2012-08-14 Thread Ketil Malde
AntC anthony_clay...@clear.net.nz writes:

 I agree. I don't declare operators very often, and when I do I always 
 struggle 
 to remember which way round the precedence numbers go.
   [...]
 (Anything else we can bikeshed about while we're at it?)

  infixl * before +

Perhaps before and after clearer than higher and lower?

-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] mutable arrays of tuples

2012-08-09 Thread Ketil Malde
David Feuer david.fe...@gmail.com writes:

 So I was thinking about a mutable array of tuples, but to avoid allocating
 tuples to modify their fields, I guess I really want an immutable array of
 tuples of STRefs. Just how much less efficient is this than a plain mutable
 array? might it even make sense to use parallel mutable arrays? The thought
 of that is disgusting to me, but at least one of the arrays could likely be
 made unboxed...

Maybe you could use a tuple of (unboxed) arrays instead?  Or if you use
Vector instead of Array, I think tuples are member of Unbox (as long as
the tuple elements are), and can be used directly in unboxed vectors.

-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] Knight Capital debacle and software correctness

2012-08-04 Thread Ketil Malde
Vasili I. Galchin vigalc...@gmail.com writes:

 I am going to make an assumption  except for Jane Street
 Capital all/most Wall Street software is written in an imperative
 language.

Tsuru Captial and Standard Chartered are also known to hire functional
programmers.

 Assuming this why is Wall Street not awaken to the dangers.

As an explanation, this is a bit simplistic, I think. But I think the
reason these companies are willing to use experimental technology (as
Haskell is considered to be in industry), is that the consequences of
error can be so high.  For most mainstream software, users have been
trained to accept unreliability, and/or are not willing to pay the
costs.

Other examples of expensive software faults is the Ariane 5 launch and
the Sleipner A oil rig (that collapsed and sunk when in tow due to a mistake
in FEA strength calculations).

The space (and defense) industry have a long history of working towards
software security, but I think they have focused more on the software
process than on technology - ADA notwithstanding.  And probably rightly
so, even though technology can help you write correct code, there is
still plenty of rope.

-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] ghci session slows down over time.

2012-06-25 Thread Ketil Malde
Jonathan Geddes geddes.jonat...@gmail.com writes:

 Is this a known issue? More importantly, is there a known workaround?

My experience is that ghci (typically run as an inferior Emacs process)
often retains a lot of memory.  Thus, I occasionally kill and
restart it. (Not sure if that counts as a workaround :-)

-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] Install a script with Cabal?

2012-06-05 Thread Ketil Malde
Rogan Creswick cresw...@gmail.com writes:

 I have a small project that installs a couple of Haskell tools and a
 script that uses these. Cabal will of course build and install the
 Haskell programs, but how can I get Cabal to install the script as
 well? There's a host of UserHooks available¹, but it'd probably be
 better to have an example than to try to experiment with the right
 configuration.

 I don't have an example handy, but I think you'll want preInts,
 instHook, or postInst.  I'd probably go with postInst unless you need
 data provided by instHook's type that isn't passed to preInst or
 postInst.

I found an example¹ using copyHook. However, this seems to be the wrong
thing, at least I am unable to get cabal to ever call this hook (or
preCopy, etc).

 LocalBuildInfo /probably/ has the details you need (eg: installDirTemplates).

I just printed out the contents of LocalBuildInfo, but that's 33 pages
(I counted) of output.  Redirected to a file, it makes it easier to
search to find the relevant needles in this haystack.

Okay, looking at installDirTemplates, I see `bindir` can extract this
data member.  It's of course an InstallDirTemplate, not a FilePath, but
I found 'fromPathTemplate', which has the right type.  Except it only
dumps the template, with $prefix and all.

Hoogle doesn't seem to know about any of the Cabal stuff, Hayoo has a *very*
annoying behavior where it cleans out everything you did if you use the
back button, and the source links it advertises seem to point into
the wide blue 404.  But using the latter, I managed to find a link to
'substPathTemplate', worked out that the PackageIdentifier it needs is a
member of PackageDescription, and tried to use that.  Except it gives
the same result, and doesn't appear to substitute anything.  I guess the
fact that it is undocumented is a hint that it's the wrong thing to use.

Reading some more, maybe 'absoluteInstallDirs' is what I'm looking for?
In addition to the usual heap of huge config structs, it needs a
CopyDest, though.  Since I have no idea what to use, I just put
NoCopyDest there.  Does that make sense?  Okay, it works now, in the
sense that I ran it once on my laptop, and it copied the file to
~/.cabal/bin.  Here is the code, comments welcome:

  #!/usr/bin/env runhaskell

  import Distribution.Simple (defaultMainWithHooks, 
simpleUserHooks,UserHooks(..))
  import Distribution.Simple.Setup (InstallFlags,CopyDest(..))
  import Distribution.Simple.Utils (rawSystemExit)
  import Distribution.PackageDescription (PackageDescription())
  import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..), 
InstallDirs(..), absoluteInstallDirs)
  import Distribution.Verbosity (normal)

  main :: IO ()
  main = defaultMainWithHooks simpleUserHooks
  { instHook = \pd lbi uh ifs - myinst pd lbi uh ifs  instHook 
simpleUserHooks pd lbi uh ifs }

  myinst :: PackageDescription - LocalBuildInfo - UserHooks - InstallFlags 
- IO ()
  myinst pd lbi _uh _fs = do
  let bin = bindir $ absoluteInstallDirs pd lbi NoCopyDest
  rawSystemExit normal cp [asmeval, bin]

PS: This was a rather frustrating excercise, and after wallowing through
a wilderness of modules, types, records and functions, I can't help but
feel that Cabal is a bit overengineered. Surely including a script or
similar in a package isn't all that outlandish? Could there conceivably
have been a simpler way?  Or at least, better documented?  I suspect the
fact that - with the sole exception of the link below -- I could find *no*
examples to help me out indicates that it is a bit too complicated.

-k

¹ http://blog.ezyang.com/2010/06/setting-up-cabal-the-ffi-and-c2hs/
-- 
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] Need inputs for a Haskell awareness presentation

2012-06-01 Thread Ketil Malde
C K Kashyap ckkash...@gmail.com writes:

 c) Where's my inheritance?

I was of the impression that OO has crawled our way, for instance
frowing upon (implementation) inheritance and mutable data structures.
Maybe you could find appropriate references?  Lots of language
development these days seems to be looking to functional languages for
inspiration.

 e) Static types - in this day and age - come on - productivity in X is
 so much more - and that's because they got rid of type mess.

Don't mention static types until later - show code without annotations.
Then later explain that things are statically typed even without
annotations, and that static types helps correctness, e.g. when
refactoring code, or building complex compositions of higher order functions.
Could you reasonalby do arrows or monads etc. in a dynamically typed
language? 

Moreover, I don't think STM is going to work without types separating
TVars from other data, and this shows our types are more powerful than
your grandfather's C-style type systems.

 g) Oh FP, as in Lisp, oh, that's AI stuff right ... we don't really do
 AI.

...and Java, that's imperative...like Fortran, isn't it?  Nah, we don't
calculate artillery tables, so...

Btw, maybe there could be a wiki section or something with stuff like
this - I think it would be useful to collect introductory resources for
settings like this - I know I'm often being asked about this Haskell
stuff from colleagues and friends.

-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] Most Important GHC extensions to learn/use?

2012-06-01 Thread Ketil Malde
wren ng thornton w...@freegeek.org writes:

 There are a bunch which are mostly just syntax changes. The important
 ones are:

Also, if you have new GHC, it will often tell you if/when you need to
enable extensions.  E.g.:

  Line 8: 1 error(s), 0 warning(s)

  `Pos' has no constructors (-XEmptyDataDecls permits this)
  In the data type declaration for `Pos'

-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] A functional programming solution for Mr and Mrs Hollingberry

2012-05-27 Thread Ketil Malde
Andreas Pauley apau...@gmail.com writes:

 Do you know of an exercise where classes would add value? Something
 fairly small, roughly similar in size to this exercise.

AFAICR, the motivating example for OO (in Simula) was simulating an
environment where different entities interact - I think the case was
queues in a post office, where object represents the door, customers,
tellers, etc.  Perhaps something along those lines?

-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] Parallel cooperative multithreading?

2012-05-24 Thread Ketil Malde
Benjamin Ylvisaker benjam...@fastmail.fm writes:

 The paper discusses implementations in Lua, C++ and C, but I think
 Haskell could be an awesome substrate for such a framework.  Has anyone
 thought about this?

I'm not convinced this will be better than using STM - the critique
against STM seems (as always) not to apply to implementations where
transactional data are segregated by the type system.  I'm not sure
about the non-composability of retry and orElse that the authors refer
to, anybody know?

-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] darcs patch dependencies in dot format

2012-05-14 Thread Ketil Malde
Sönke Hahn sh...@cs.tu-berlin.de writes:

 On 05/13/2012 03:13 AM, Felipe Almeida Lessa wrote:
 Truly amazing! 

Yes, nice work!

 I wonder it would fare with larger repositories. =)

 It does not scale well. [...]
 Somehow related questions are: What am I going to do with a dot-graph,
 that has more than 500 vertices? Is there an intelligent way to reduce
 the graph?

Lacking a solution for the problem of drawing large graphs, making the
graph smaller might be the second choice. :-) One option might be to
only track dependencies back to a specified tag? Or between tags? 

-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] Printing call site for partial functions

2012-04-30 Thread Ketil Malde
Michael Snoyman mich...@snoyman.com writes:

 I had a bug in a site of mine[1] for a few weeks, where it would just print:

 Prelude.head: empty list

 It took a long time to track down the problem

+1: I've been arguing this for something like ten years :-)

One half-baked quasi-solution is to use:

#define head (\xs - case xs of { (x:_) - x ; _ - error(head: empty list 
at++__FILE__++show __LINE__)})

Downsides are that it depends on CPP, and, CPP being a C preprocessor,
it doesn't blend well with lines with single apostrophes on them (e.g.:
head x') 

-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] static linking with ghc?

2012-04-25 Thread Ketil Malde
Johannes Waldmann waldm...@imn.htwk-leipzig.de writes:

 A similar thing is mentioned here (see Caveat)
 http://www.haskell.org/haskellwiki/Web/Literature/Static_linking

Another caveat is that shared linking isn't very useful on Linux, since
the C library loads various stuff dynamically anyway.  It'd be great to
be able to link to a different C library (maybe something from the
BSDs?).

-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] blog software in Haskell?

2012-03-30 Thread Ketil Malde

Reviving an old thread, since I owe some answers:

Jason Dagit dag...@gmail.com writes:

 If you find a cool solution, let us know.

I ended up with hakyll, but haven't had a lot of time to work on this.
Here are some small tweaks, though -- partly framed as a response to Twan van
Laarhoven's recent post:

  http://blog.malde.org/posts/hakyll-mods.html

-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] adding the elements of two lists

2012-03-29 Thread Ketil Malde
Richard O'Keefe o...@cs.otago.ac.nz writes:

 newtype PS a = PS [a] deriving (Eq, Show)

 u f (PS x)= PS $ map f x
 b f (PS x) (PS y) = PS $ zipWith f x y
 to_ps x   = PS (x : repeat 0)

BTW, isn't this a good candidate for an Applicative instance (similar to
ZipList)?

 u f p = f $ p  -- or u = fmap
 b f p1 p2 = f $ p1 * p2

Not a big deal for the Num instance, perhaps, but more general than u
and b, and it might make it easier to work with in other ways.

-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] a code that cannot compile with or without NoMonomorphismRestriction

2012-03-29 Thread Ketil Malde
Ting Lei tin...@hotmail.com writes:

 (f1, f2) =
 let commond_definitions = undefined in
 let f1 = id.show 
 f2 x = ( x) 
 in
   (f1, f2)

I think the type signatures should be:

  f1 :: Show a = a - String

and 

  f2 :: Ord b = b - b - Bool 

When I define these separately, this works:

  f1 :: Show a = a - String
  f1 = id . show

  f2 :: Ord b = b - b - Bool 
  f2 = flip ()


But when I define them as a pair

  f1 :: Show a = a - String
  f2 :: Ord b = b - b - Bool 
  (f1,f2) = (id . show, flip ())

I get an error message:

Line 9: 1 error(s), 0 warning(s)

Couldn't match expected type `forall a. Show a = a - String'
with actual type `a - String'
When checking that `f1'
  has the specified type `forall a1. Show a1 = a1 - String'

Defining the pair at once works:

  p :: (Show a, Ord b) = (a - String, b - b - Bool)
  p = (id . show, flip ())

I guess that didn't help a lot, somebody with deeper GHC-fu than me will
have to step in.

-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] Mathematics and Statistics libraries

2012-03-26 Thread Ketil Malde
Tom Doris tomdo...@gmail.com writes:

 If you're interested in UI work, ideally we'd have something similar
 to RStudio as an environment, a simple set of windows encapsulating an
 editor, a repl, a plotting panel and help/history, this sounds
 superficial but it really has an impact when you're exploring a data
 set and trying stuff out.

I agree, this sounds really nice.

 I really disagree that we need a data frame type structure; they're an
 abomination in R, they try to accommodate event records and time
 series, and do neither well.

Just to clarify (since I think the original suggestion was mine), I
don't want to copy R's data frame (which I never quite understood,
anyway), but I'd like some standardized data structure, ideally with an
option to label columns, and functions to slice and join.  The
underlying structure can just be a list of columns (Vector) or whatever.

-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


[Haskell-cafe] Install a script with Cabal?

2012-03-20 Thread Ketil Malde

Hi,

I have a small project that installs a couple of Haskell tools and a
script that uses these.  Cabal will of course build and install the
Haskell programs, but how can I get Cabal to install the script as
well?  There's a host of UserHooks available¹, but it'd probably be
better to have an example than to try to experiment with the right
configuration.

-k

¹ 
http://www.haskell.org/cabal/release/cabal-latest/doc/API/Cabal/Distribution-Simple.html#t%3AUserHooks
-- 
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] Theoretical question: are side effects necessary?

2012-03-17 Thread Ketil Malde
Ryan Ingram ryani.s...@gmail.com writes:

 You can emulate mutation with at most O(log(n)) penalty using a map.  Given
 that memory is of fixed size, log2(n) = 64, so for real-world programs
 this becomes O(1).

I'm not sure assuming fixed size memory is a good idea for a theoretical
discussion - your computer is no longer Turing complete, and one
type of implementation will likely be able to fit a different set of
programs in the given memory than the oher.

Another nit: this is O(log(n)) of working set, not input/problem size.
But I guess any algorithm must be at least O(working set size), so it's
still a log factor (or less) of the algorithmic complexity.

-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] Empty Input list

2012-03-13 Thread Ketil Malde
Kevin Clees k.cl...@web.de writes:

 Now my function looks like this: 

 tmp:: [(Int, Int)] - Int - (Int, Int)
 tmp [] y = (0,0)
 ^
 tmp xs y = xs !! (y-1)

 If the function returns (0,0) it will blocked by another  function. 

Personally, I think using special values like this is a code smell,
and indicates poor design.  There are many implicit assumptions, for
instance that (0,0) isn't already a member of the input list, and that
this is correctly handled by surrounding functions.  Generally, it's
much more desirable to encode this in the types, so I would vastly
prefer the Maybe solution in almost all cases, which makes these
assumptions explicit.

-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] Global Arrays

2012-03-12 Thread Ketil Malde
Clark Gaebel cgae...@csclub.uwaterloo.ca writes:

 In Haskell, what's the canonical way of declaring a top-level array
 (Data.Vector of a huge list of doubles, in my case)? Performance is
 key in my case.

 The straightforward way would just be something like:

 globalArray :: V.Vector Double
 globalArray = V.fromList [ huge list of doubles ]
 {-# NOINLINE globalArray #-}

 However, I don't want to have to run the fromList at runtime.

I think GHC will convert it to an array (and in general evaluate
constants) at compile time (probably requires -O).

-k

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


Re: [Haskell-cafe] If you'd design a Haskell-like language, what would you do different?

2012-03-09 Thread Ketil Malde
Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr writes:

 and the source of it power - if I might cite you - is that we don't see
 the difference between an object and the process which creates it.

Interestingly, according to Wikipedia's article on type system:

  A type system associates a type with each computed value.

but later cites Pierce:

  a tractable syntactic framework for classifying phrases according to
  the kinds of values they compute

While the former might be said to avoid _|_ by defining it to not be a
value that is computed, the latter clearly must include it, as a
the computation of a phrase might not terminate (as longs as the
language is Turing-complete, of course).

Anyway, I think also non-lazy languages has bottom inhabiting their
types, it's just that since it leads more immediately to failure, it's
not usually taken into account.

-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] xattr takeover

2012-02-13 Thread Ketil Malde
Deian Stefan haskell-c...@deian.net writes:

 I've been trying to get in touch with the maintainer (CC'd) about
 the xattr package for about a month. There are quite a few memory
 leaks (among other issues) for which I have a patch (see [1]). I
 would like to push the new version to Hackage, but the etiquette
 for taking over a package is unclear. Any suggestions?

If you've made a decent effort, I think you should just upload it with
the fix (and again CC the previous author).  Nobody benefits from having
buggy software out there.

-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] Cabal-1.10.1.0 and bytestring-0.9.2.1 hackage problem.

2012-02-03 Thread Ketil Malde


Alan Pogrebinschi alan...@gmail.com writes:

 That Cabal-1.10.1.0 bug seems to be back, now with bytestring-0.9.2.1
 just uploaded to hackage. 

Thanks for the link!  I was banging my head on against the virtual wall,
since all I'm getting is:

  % cabal install -v biopsl 
  Reading available packages...
  Resolving dependencies...
  cabal: Couldn't read cabal file bytestring/0.9.2.1/bytestring.cabal

It's not exactly obvious what this error message means.

 Same workaround as last time works

I.e:

  tar -f ~/.cabal/packages/hackage.haskell.org/00-index.tar --delete 
bytestring/0.9.2.1

This is the cabal-install shipped with Ubuntu 12.04 (i.e. the unreleased
beta, which will become the new LTS in April), so buggy or not, it ought
not to be broken if we can avoid it.  I've filed a bug:

  https://bugs.launchpad.net/ubuntu/+source/haskell-cabal-install/+bug/925967

-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] Data newtype differences. Today: strictness

2012-01-24 Thread Ketil Malde
Yves Parès yves.pa...@gmail.com writes:

 I had for long thought that data and newtype were equivalent, but then I
 spotted some differences when it comes to strictness.

 data Test = Test Int
 newtype TestN = TestN Int

Interesting.  I'd thought that 

  data Test = Test !Int

and

  newtype Test = Test Int

would be equivalent, but here you (well, I had to add the ! myself) show
a situation where they're not.

I guess 

  pm (Test _) = 12

is the same as

  pm = \x - case x of Test _ - 12

which perhaps makes it clearer why it breaks on undefined...

-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] black Wikipedia

2012-01-19 Thread Ketil Malde
John Meacham j...@repetae.net writes:

 now, you might say we can just move hackage out of the US

This might actually make things worse. The President's office is against
hurting US industry, and wants it to be mainly used to attack foreign
sites.  They will not only order takedowns, but use DNS and ICANN to
enforce this policy.

 Not only that, but the proponents are not just hollywood, it is anyone
 that feels they will have an advantage with the ability to bully
 internet sites. For instance, monster cable

The scientology church.  Politicians.  Apparently, Bush considered
bombing Al Jazeera, you can imagine how long it would take before it got
blocked for copyright violations.

The problem is bigger than just free speech (as if that isn't big
enough) - it's yet another presumed guilty, preemptive strike law.
Patents are similar, even if you do nothing wrong, heavyweights
(e.g. Google) can extort smaller players (e.g. me) by simply threatening
to sue.  Even if they have no chance to win, I simply cannot afford to
play, so I have no option except to comply with their demands.  SOPA is
just the latest and most blatant in the series, trying to secure the
entertainment industry the same power over the Internet.

That the American Congress is working so hard to place this kind of
power in the hands of a relatively small industry -- well, we can all
draw our own conclusions.

-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] STM atomic blocks in IO functions

2012-01-14 Thread Ketil Malde
Bryan O'Sullivan b...@serpentine.com writes:

 The question is a simple one. Must all operations on a TVar happen
 within *the same* atomically block, or am I am I guaranteed thread
 safety if, say, I have a number of atomically blocks in an IO
 function.

 If you want successive operations to see a consistent state, they must
 occur in the same atomically block.

I'm not sure I understand the question, nor the answer?  I thought the
idea was that state should be consistent on the entry and exit of each
atomically block.  So you can break your program into multiple
transactions, but each transaction should be a semantically complete
unit.

-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] On the purity of Haskell

2012-01-01 Thread Ketil Malde
Chris Smith cdsm...@gmail.com writes:

 I wonder: can writing to memory be called a “computational effect”? If  
 yes, then every computation is impure.

I wonder if not the important bit is that pure computations are unaffected by
other computations (and not whether they can affect other computations).
Many pure computations have side effects (increases temperature,
modifies hardware registers and memory, etc), but their effect can only
be observed in IO. 

(E.g. Debug.Trace.trace provides a non-IO interface by use of
unsafePerformIO which is often considered cheating, but in
this view it really is pure.)

-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] What happens if you get hit by a bus?

2011-12-16 Thread Ketil Malde
Michael Litchard mich...@schmong.org writes:

 One article addresses the question above. His answer was that he uses
 RoR which has a large community and he is therefore easily
 replaceable. My question, for freelancers in general, and web
 developers in particular is this: How do you address this question?

In this particular case, you could argue that more people know PHP and
Python than Ruby, so surely one should avoid Ruby as well.

Managers like to think of their company as a factory, and from this
perspective, it makes sense to build your factory from easily obtainable
parts.  But the factory mindset only works when you want to manufacture
stuff, nobody who takes a minute to actually think will say that you can
replace any programmer with any other, as long as they know the same
programming language or framework.

Anyway, here's something I found interesting in that respect:

  
http://www.dachisgroup.com/2011/12/cant-get-no-satisfaction-why-service-companies-cant-keep-their-promises/

(This probably turned out less helpful than I intended, sorry :-)

-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] Sharing on equality

2011-12-14 Thread Ketil Malde
Johan Brinch brin...@gmail.com writes:

 Can GHC eliminate one of two equal ByteStrings, when they are compared
 and turns out to be equal?

Not in general, there is no guarantee that a is identical to b, just
because a == b.

 Say i have a map, ByteString - Int.

  Data.Map.Map ByteString Int

 I now do a lookup on a ByteString and if it exists, I insert this
 ByteString into a list.

 Is it possible to avoid using more memory, than used by the keys in
 the map + the list structure?

 I guess, this could be done by having lookup return the key as well,
 and then insert this key into the list, however, that's a bit ugly and
 somewhat anti-intuitive.

I think this /is/ intuitive.  (Or you could replace the key in the map,
but that will still leave duplicates in the list).

-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] How did iteratees get their names?

2011-12-07 Thread Ketil Malde
Henrik Nilsson n...@cs.nott.ac.uk writes:

 Just like chatter and chattee, employer and employee, there is an
 iterator (usually as part of an enumerator/ee) and an iteratee.

 Thanks for the attempt to explain. But I, at least, remain mystified,
 and I agree with Douglas that the terminology is confusing.

FWIW, I always thought it was a kind of pun on the iterators in OO-land.

There, the iterator is a cursor-like object, and the program controls it to
iterate over the input -- typically a collection or similar.  Iteratees
invert this, the program is in the form of an iteratee, and it is
being iterated by the input (enumerator).  

So the iterator is actively controlling a passive (or reactive) input,
while the iteratee is reactively processing an active or controlling
input.

Or something, I'm hardly an authority on this.  I hope it makes sense.

-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] Poll: Do you want a mascot? -- please stop this

2011-11-24 Thread Ketil Malde
David Virebayre dav.vire+hask...@gmail.com writes:

 Also, this is café, right ? Aren't people subscribed to this list
 supposed to expect a broad range of topics ?

I don't mind a broad range of topics, but using it to collect polls is
IMHO abusing it.  I guess I can dust off the killfiling features in Gnus
to deal with this, but I still think it's very annoying.

-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] A Mascot

2011-11-22 Thread Ketil Malde
serialhex serial...@gmail.com writes:

 On Tue, Nov 22, 2011 at 12:22 AM, Jeremy Shaw jer...@n-heptane.com wrote:

  - honey badger - can't beat that for 'robust' and 'fearless',
 http://www.youtube.com/watch?v=wPKlryXwmXk

 i think you were referring to this vid:

Original channel with lots of other animals and similar
commentary. Certainly a refreshing alternative to the overly dramatic
Discovery/Animal Planet style.  And plenty of mascot material there:

  http://www.youtube.com/czg123

-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] transformers-base, transformers-abort, monad-abort-fd

2011-11-18 Thread Ketil Malde
Felipe Almeida Lessa felipe.le...@gmail.com writes:

 It's funny how we, haskellers, find 'm' and 'b' descriptive names.  I
 know many programmers who would cry after seeing this =).

It takes a bit of practice to get used to, but then they really are
descriptive.  The trick is to keep the number of entities - parameters,
types, etc low enough to keep mental track.  To me,
LongAndVeryDescripteNames is a code smell: your code is too
complicated.

Let them cry, I say!

-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] A Mascot

2011-11-18 Thread Ketil Malde
John Meacham j...@repetae.net writes:

 People tend to concentrate on the lambda which cooresponds to the
 functional aspect of haskell when designing logos. Not nearly enough
 attention is paid to the other striking feature, the 

What about types?  This is a distinguishing feature from many of the
other lambda-users out there, isn't \lambda_\tau used to signify that?

-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] blog software in Haskell?

2011-11-02 Thread Ketil Malde
Simon Michael si...@joyful.com writes:

 Did someone mention hakyll already? 

Yes, Mihai, but thanks for the link.  I'll probably check it out when
I'm back from vacation.

Alistair: I'm already using gitit, but I think it's usage is a bit
different.  

Jason: I know about the various services, but I prefer to host it myself.

Thanks for all the suggestions, I'll let you know how it goes!

-k 
(Shaver of yaks)
-- 
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] Hackage feature request: E-mail author when a package breaks

2011-11-01 Thread Ketil Malde
Yitzchak Gale g...@sefer.org writes:

 Gregory Crosswhite wrote:
 could [Hackage] have a feature where when a
 working package breaks with a new version of
 GHC the author is automatically e-mailed?

 This would be nice. However, there would have to be
 a way for it to be turned on and off by the author.
 (Spam is not nice.)

This is where it stranded the last time, IIRC.  That sentiment makes me
a bit uneasy; so you are the official maintainer of a package on
Hackage, but you do not want to hear about it when it fails to compile?

To me, this raises the question whether you should take on the
responsibility as maintainer at all.  Ideally, I think Hackage
should avoid being a dumping ground for non-working code, and I think
the key to high quality software is having active maintainers for each
package.  If the author of a package is unwilling to accept failure
reports, I suggest she could leave the Maintainer field blank, or fill
it with a dummy value (e.g. unmaintained).

-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] Hackage feature request: E-mail author when a package breaks

2011-11-01 Thread Ketil Malde
Max Bolingbroke batterseapo...@hotmail.com writes:

 This is where it stranded the last time, IIRC.  That sentiment makes me
 a bit uneasy; so you are the official maintainer of a package on
 Hackage, but you do not want to hear about it when it fails to compile?

 Don't forget that some packages fail to compile on Hackage even though
 they work fine, because e.g. they depend on a third-party C library
 that is not installed, or depend on some other package that Hackage
 cannot build.

True, in that case, it's harder to avoid getting one email every time
you upload a new version.  We should still strive to have stuff build on
Hackage (e.g. installing C libs or fixing the ohter packages); if the
build fails for one of these reasons, you never know if it fails for
other reasons as well.

So, I'd *love* to get an email when my packages fail to build, but I will
accept that other people have a more sensitive relationship with their
inbox.  (I assume that the people who raise this objection - Max
and Yitzchak - belong in this category?  It's not entirely clear from
your comments, and I do hope we're not avoiding useful functionality
based on a purely *hypothetical* problem.)

Conrad suggested creating a mailing list per package, another option
could be to automatically post to a single maintainers list,
highlighting the package (and preferably also maintainer) name in the
Subject. A decent MUA could then up-score the more relevant messages.

I'd really like to see Hackage move to a continuous integration type of
system, where everything is automatically built and tests are run on
every submission.  If somebody works out the software infrastructure,
I'll volunteer CPU cycles.  Next hackathon?

-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] Hackage feature request: E-mail author when a package breaks

2011-11-01 Thread Ketil Malde
Yitzchak Gale g...@sefer.org writes:

 I am just a little worried that if uploading to Hackage
 requires agreeing to unlimited uncontrollable
 spamming by a bot, 

The bot would, of course, be implemented in Haskell.  Anybody who still
worries about bugs, is free to implement a better one in Agda. :-)

 it may cause some good packages not to be uploaded by people who are
 hesitant to agree to that.

One solution could be to have a Maintainer field contain a name, but no
email address?  So I could do:

  Maintainer: Ketil Malde ke...@malde.org  -- send email to me

or 

  Maintainer: Ketil Malde   -- don't send email, Google me if you are
-- human and it's that important

or even

  Maintainer: Ketil Malde ketil at malde dot org  -- email me if you are human

Or of course

  Maintainer:  -- empty field means unmaintained, caveat emptor!

Generalizing from my sample of one, I think most people would stick with
the first option, but at least this policy would leave things open for
those preferring alternatives.

-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


[Haskell-cafe] blog software in Haskell?

2011-10-31 Thread Ketil Malde

Hi,

I just upgraded my server, and set up everything again.  Except
wordpress, as 1) I'm not too fond of its user interface, and 2) it's a
big pile of PHP, difficult to keep updated, and basically a disaster
waiting to happen (and in fact, it was hacked at one point).

Before I enable it again, is there any alternatives I should consider?
Preferably written in Haskell, of course, but other suggestions welcome
as well.

-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


[Haskell-cafe] STM program

2011-10-27 Thread Ketil Malde

Hi, Café,

I'm playing with STM a bit, and did a small writeup.  As I'm considering
to submit it, uh, tomorrow, I was wondering if anybody would care to
take a look?  I'm especially nervous about the accuracy and clarity
of my descriptions of monads and STM, which are terse and written in a
hurry. 

Anyway: I'd be most grateful for any feedback you care to give.
http://malde.org/~ketil/stmcluster.pdf  

-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] Package documentation complaints -- and a suggestion

2011-10-25 Thread Ketil Malde
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 Right, but first we need to define what all those terms _mean_... and
 it's no good saying your package is stable if you change the API in
 a large-scale fashion every release.

I think there are better criteria to use, like:

- do exported definition have Haddock comments?
- does the package have an automated test suite?
- is the package used by other packages?
- ...by different authors?
- has the package been recently updated?

I'm sure there are other things as well that could be added.  If this
could be automatically checked, and displayed alongside the package name
on Hackage (perhaps as adding one star per checklist item), it would
encourage authors to actually improve their packages, rather than just
label them stable.

-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] Package documentation complaints -- and a suggestion

2011-10-25 Thread Ketil Malde
Max Rabkin max.rab...@gmail.com writes:

 This is useful information, but to call it stability is not only
 misleading, but it also prevents the package from using that field to
 indicate whether or not it is stable!

Oh, right - I'm not much interested in the stability of a package.  What
I want to know, is which package to choose for some purpose.  By
highlighting stuff that is correlated with usefulness, I'll be able to
make a quicker, more informed decision.

Separating this from stability is a feature, not a bug, since it frees
the author to label the package stable or not - instead of encouraging
using stable to mean please use. :-)

-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] Efficient mutable arrays in STM

2011-10-25 Thread Ketil Malde
Ben Franksen ben.frank...@online.de writes:

 An array of TVars is certainly *much* too inefficient for what I have in 
 mind w.r.t. both memory and cpu time. 

You must be a lot more confident than I if you say this without
benchmarking first. :-) IME, there are (at least) two possible problems
here, 1) transactions scale (quadratically, I think) with the number of
TVars touched, so if any transaction touch a large part of the array,
it's going to cost you, and 2) every element of your array will have a
pointer to it, making GC potentially expensive.  Perhaps you can get
around the latter by tuning GC, e.g. +RTS -A100M might help.

 Or should I use a high-level approach, something like a Data.Sequence.Seq of 
 medium sized chunks (TVar (IOVector e))?

I'm not sure exactly what you mean here, but if you're going to touch
contigous segments of the array, why not TArray (Vector e) or similar?

-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: diagrams 0.4

2011-10-24 Thread Ketil Malde
Rustom Mody rustompm...@gmail.com writes:

 I remember (vaguely) a 'live page' ie where one could enter (into the
 browser) changes to the diagrams code and see the results immediately.
 Is that page there? (Or am I mixing up with something else?)

Chris Smith's web interface to Ben Lippmeier's Gloss, perhaps?
http://dac4.designacourse.com:8000/

-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] hello Haskell

2011-10-24 Thread Ketil Malde
Tom Murphy amin...@gmail.com writes:

 Blocking/unsubscribing people based on their email provider seems... sort of
 impolite or unwelcoming.
 A greylist could work.

Greylist, as in temporarily refuse a message, and wait for the sending
mail server to retry?  I don't see how it would work against hijacked
hotmail accounts, they most likely use the real hotmail service - which
would retry appropriately.  My own experience indicates that spammers
now often correctly retry deliveries, so greylisting is less effective
than it used to be.

 Given the relatively low volume of spam, my vote is for the original
 suggestion of first-message-moderated, with the ability to put an address
 back on moderation if their account is hacked.

+1

-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] ANNOUNCE: vector-bytestring-0.0.0.0

2011-10-19 Thread Ketil Malde
Michael Snoyman mich...@snoyman.com writes:

 sense to try and pursue something like what you're suggesting, but I
 think the default Show (Vector Word8) should be the one most useful,
 most of the time, and I think the general consensus seems to be the
 current ByteString instance fits that role.

Hm.  I think it is slightly weird to display a numeric value (Word8) as
a Char.  Also, I would prefer a representation making the type explicit
(but unlike ByteString, vector seems to add a type annotation.)  Would
you still support the truncating behavior for 'read' and values above 255?  

(ByteString has two interfaces, ByteString and .Char8, but as there can
be only one Show instance, I see why it works the way it does.)

-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] The best way to call Java from Haskell?

2011-10-11 Thread Ketil Malde
Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr writes:

 Don't worry, my friend. Haskell is lazy, so there is no problem in 
 handling those infinite modules. It will just take you an infinite
 amount of time before you get any money from such a work. But this is
 a general problem elsewhere as well.

I guess you must be thinking of Haskell being increasingly used in
banks?  It must have been some bank manager who, after hiring one too
many Haskell programmers, invented a scheme that would generate an
infinite amount of money.  He didn't realize before it was too late that
the actual value of the scheme would be bottom...

-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] Three questions to graphviz

2011-10-10 Thread Ketil Malde
kaffeepause73 kaffeepaus...@yahoo.de writes:

 Thanks for the quick reply - it works now. - I wasted quite a bit time on
 this.

Alternatively, you can turn on overloaded strings, which allows constructing
text values (along with other types that are instances of IsString) from
string constants.  Add 

{-# Language OverloadedStrings #-}

at the top of your source file to enable it.

 I guess the internal bit in the compiler message confused me.

It is a common idiom to put internals -- e.g. data type definitions --
in a module called Internal.

-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] SMP parallelism increasing GC time dramatically

2011-10-05 Thread Ketil Malde

I don't know if this is relevant to your problems, but I'm currently
struggling to get some performance out of a parallel - or rather,
concurrent - program.

Basically, the initial thread parses some data into an IntMap, and then
multiple threads access this read-only to do the Real Work.

Now, there appears to be a lot of overhead incurred when using multiple
threads, and I suspect that this is caused by the map storing
unevaluated thunks, which then are forced by accesses by the worker
threads.  Ideally, the evaluation should be performed in parallel, but
perhaps there are issues (of synchronization, say) that makes this less
performant?

-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: OpenCL 1.0.1.3 package

2011-10-04 Thread Ketil Malde
Luis Cabellos cabel...@ifca.unican.es writes:

  * The main reason is that I'm not comfortable with the license
 you're using.  The original code by Jeff Heard was BSD3 with an
 additional copyright notice.  Your code is AGPL3.  The GPL is known to
 cause problems with Haskell code due to cross module inlining.  I
 don't know how the A in AGPL changes things.

I don't think inlining matters in this case.  If you distribute a work
incorporating GPL code, you must allow the recipient to redistribute it
(including all sources) under the GPL.  Clearly, GPL code is not
suitable when you wish to redistribute it along with proprietary code,
but it should be unproblematic for most open source projects.

For *L*GPL code, the intention is that it can apply to a library,
distributed as a separate unit, and allowing it to be *used* as such,
also by proprietary applications.  Inlining through static linking may
affect this, as it incorporates actual code from the LGPL
library in a program that is then distributed as a propietary, binary
object.

 I understand your point. I didn't know the problems with cross module
 inlining that Haskell suffers. I learned the BSD3, I think is a good  and
 I'll change it on github and I'll put in the next release.

If you are happy with BSD3, that license is the one which will make your
code most generally useful.  The intent behind the GPL family is to make the
code useful to those who reciprocate the sentiment, and less useful to
those who don't.  In practice, it is rare that BSD3 licensed libraries
are made proprietary, it is often to everybody's benefit that thinks are
maintained in the open.  The general sentiment in the Haskell community
is a preference for BSD.

-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] Is it possible to represent such polymorphism?

2011-10-03 Thread Ketil Malde
sdiy...@sjtu.edu.cn writes:

 This has nothing to do with OOP or being imperative. It's just about types.

Of course, it's not necessarily linked to OOP, but OO languages - to the
extent they have types - tend towards ad-hoc polymorphism instead of
parametric polymorphism.  There are different trade-offs, one is the
lack of return-type overloading in C++.

-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] Static linking for machines that don't have Haskell

2011-10-02 Thread Ketil Malde
Roshan James rpja...@umail.iu.edu writes:

 This gives me several warnings of the form:
 */usr/lib/haskell-packages/ghc6/lib/network-2.2.1.7/ghc-6.12.3/libHSnetwork-2.2.1.7.a(BSD.o):
 In function `sw4B_info':*
 *(.text+0x584c): warning: Using 'getservbyport' in statically linked
 applications requires at runtime the shared libraries from the glibc version
 used for linking*

Yes, the Linux libc doesn't really support static linking, and in fact
actively subverts it by dynamically loading other libraries from
hardwired paths. I'm sure there's a good reason for it.

Some things can be worked around by setting environment variables etc,
but generally, try to compile on the oldest system you can find (since
backwards compatibility is better supported than forward), and use the
same distribution.  Use strace to see what dynamic libraries your
executable tries to load, and Google to see what can be done about
them.

The best solution would be to use a different libc.

-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] mapM is supralinear?

2011-09-27 Thread Ketil Malde

Here's my feeble understanding of GC:

1. GC runs when after some specified amount of allocations
2. GC runs in time proportional to the live heap, which it needs to
   traverse.

This means that for a long running mapM, like any other computation
generating a long list, (1) GC will run a number of times proportional to
the length of the list, and (2) each run will have a cost
proportional to the length of the list.  I.e. a linear algorithm is now
quadratic.

A lazy mapM (or mapM_), consuming the list as fast as it is generated,
will of course keep the list short/heap small, and thus the cost of each
GC is constant (for some value of constant).

I suppose generational GC will help in practice, since the young
generation gets to start near the end of the list, but it will still be
linear in generated length, and you still need major GCs too,
occasionally.

Also, I guess mapM is more vulnerable to this, since the operations (IO,
say) involved in building the list likely do short-lived allocations,
triggering more GCs than simpler, pure computations would.

Do let me know if this is probably a terribly naive view.

-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] instance Enum Double considered notentirelygreat?

2011-09-27 Thread Ketil Malde
Iavor Diatchki iavor.diatc...@gmail.com writes:

 last ([0.1, 0.2 .. 0.5]) == 0.5
 False

 last (map fromRational [0.1, 0.2 .. 0.5]) == 0.5
 True

 As Ross pointed out in a previous e-mail the instance for Rationals is
 also broken:

 last (map fromRational [1,3 .. 20])
 21.0

But only because it tries to mimic the behavior of Float/Double, I
think.  Rational could easily have produced 19 here.

-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] instance Enum Double considered not entirely great?

2011-09-21 Thread Ketil Malde
Daniel Fischer daniel.is.fisc...@googlemail.com writes:

 Btw, -0.0 can be problematic too.

 How so? As far as I can tell Ord and Eq treat it as equal to 0.0 in
 every way,

 Yes. Which can be inconvenient if you are interested in whether you got a 
 -0.0, so if that's the case, you can't simply use (== -0.0).

For instance, somebody might have the idea to store floating point
values in a HashSet, which might (or might not) produce a different
result from the regular Set in this case.  Conversely, you might get
different values out of the set than the ones you put into it, which
could be surprising. IMO, it's definitely a good practice to avoid
otherwise distinguishable values comparing as equal.

-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] stack overflow pain

2011-09-21 Thread Ketil Malde
Tim Docker t...@dockerz.net writes:

 mapM_ applyAction sas

Maybe you could try a lazy version of mapM?  E.g., I think this would do
it:

  import System.IO.Unsafe (unsafeInterleaveIO)

  :

  mapM' f = sequence' . map f
where sequence' ms = foldr k (return []) ms
  k m m' = do { x - m; xs - unsafeInterleaveIO m'; return (x:xs) }

-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] instance Enum Double considered not entirely great?

2011-09-20 Thread Ketil Malde
Chris Smith cdsm...@gmail.com writes:

 It would be a shame if we lost an occasionally useful and easy to read

You forgot confusing?  Expecting Enum to enumerate all inhabitants of
a type seems very reasonable to me, and seems to hold for all
non-floating point types.  A numeric range [a..a+n] might be expected
to have a+n+1 elements, but that doesn't hold either for Float and
Double.  I think Enum for floating point values is broken - but it is
reality, so we need to deal with it.

 Instead, perhaps the issue should be brought up with the fixed-point
 number library you're using, and they could fix their Enum instance to
 be more helpful.

Or just avoid Enum, and define range or something similar instead.

-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] The applicative instances for Either?

2011-09-19 Thread Ketil Malde

Daniel Fischer daniel.is.fisc...@googlemail.com writes:

 Is there any information, or otherwise accessible source specifying
 exactly when this was changed,

 Checking the sources, it wasn't in base-4.2.0.2 (ghc-6.12.3), but it was in 
 base-4.3.1.0 (ghc-7.0.2), so it was introduced with base-4.3

Thanks to you, and everybody else who replied.  Now, it turns out, both
me (who get this instance from imports) and my user (who doesn't) are
using base-4.2.0.2, so it has to be elsewhere.  
The duplicate instance reports Control.Monad.Trans.Error - hackage
insists this is part of transformers, which I don't use, but maybe mtl
imports and reexports the instances?

Apparently this is the case, I tried to ghc-pkg hide mtl-2, and then I
could load a file declaring an instance for Error e = Applicative
(Either e) using mtl-1.

So it appears I should require mtl = 2 (and possibly base = 4.3 as an
alternative, but I guess mtl-2 is not too draconian).

(This case was a bit opaque for me, I'm not sure how it could be made
easier to trace down conflicts like this, perhaps I just don't know the
right tools.)

-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


[Haskell-cafe] The applicative instances for Either?

2011-09-17 Thread Ketil Malde

Hi,

I have a program that makes use of the applicative instance for Either
String.  I used to define these instances locally, but at some point,
they became part of Control.Applicative.  I have limited the
dependencies to 'base = 4', but apparently, some version 4s of base
include this instance, some do not, and it causes problems for people
trying to compile the program.

Is there any information, or otherwise accessible source specifying
exactly when this was changed, so that I can have more precise
dependencies?  And is there a simple way to handle this conditionally,
either within cabal, or using CPP?

-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] Data structure

2011-09-01 Thread Ketil Malde
yrazes yra...@gmail.com writes:

 I want to compare data structure between Haskell, Java, Lisp and C. I am
 wondering if I could compare list comprehention in haskell with the vector
 class in Java, macros in common lisp and dynamic arrays in C.

You /can/ compare them, of course, but they are very different
concepts.  I'd classify list comprehensions and macros as control
structures, rather than data structures, for instance.

Wouldn't it be more appropriate to compare Haskell's algebraic data
types with C structs, Java classes, and Lisp S-expressions?

-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] 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] ping haskell.org timeout

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

 On Thu, Aug 25, 2011 at 2:39 PM, Greg Fitzgerald gari...@gmail.com wrote:
 cabal update hangs.  ping haskell.org times out.  But haskell.org and
 hackage webpages are loading just fine.  What's going on?

 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.

 so ping isn't as reliable as it once was for detecting when a server is
 running.

Looks like haskell.org isn't one of them.

CON:~ % ping haskell.org
PING haskell.org (78.46.100.180) 56(84) bytes of data.
64 bytes from lambda.haskell.org (78.46.100.180): icmp_req=1 ttl=48 time=53.8 ms
64 bytes from lambda.haskell.org (78.46.100.180): icmp_req=2 ttl=48 time=52.4 ms
64 bytes from lambda.haskell.org (78.46.100.180): icmp_req=3 ttl=48 time=52.5 ms
^C
--- haskell.org ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 52.451/52.935/53.804/0.670 ms

 I'm not sure why cabal update would hang.

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?

-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] Invitation to connect on LinkedIn

2011-08-14 Thread Ketil Malde
Andrew Smith B.Sc(Hons),MBA asmith9...@gmail.com writes:

 I'd like to add you to my professional network on LinkedIn.

Since LinkedIn tends to spam even more ambitiously than the other social
network sites, I have a procmail rule sending any mail from Linkedin to
/dev/null.  But it doesn't work when it's sent via other mailing lists,
when some person of dubious faculty and questionable morals wants to add
an entire list to his professional network... 

-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] partial inheritance

2011-07-18 Thread Ketil Malde
Patrick Browne patrick.bro...@dit.ie writes:

 Is it possible to model partial inheritance using Haskell type classes?
 For example, if the class Bird has a flying method can we represent
 Penguins as a sub-class of Bird without a flying method?

I'm not sure the question makes sense, if fly is a method of class
Bird, then it can't also be a member of class Penguin.

You can of course make instances of Bird without implementing the fly
method (whether they are also instances of Penguin or not), or by
implementing it as undefined.

-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] NLP libraries and tools?

2011-07-10 Thread Ketil Malde

Perhaps this is interesting?  On the relationship between exploratory
(a.k.a. sloppy or theoretical) and rigorous math.

http://arxiv.org/pdf/math/9307227v1

-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] Call for GUI examples - Functional Reactive Programming

2011-07-08 Thread Ketil Malde

[snip haskell@, leaving -café]

Heinrich Apfelmus apfel...@quantentunnel.de writes:

 Do you know any *small GUI programs* that you would *like* to see
 *implemented with Functional Reactive Programming?*

I don't know if this fits the bill, but a tool that I'd like to see is
plotting for one or more live streams of data.  I guess I want something
similar to timeplot, but listening on an input stream and
updating/scrolling the plot.  Think 'tail -f /var/log/messages | awk
something | liveplot options'.

-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] Diagnose stack space overflow

2011-07-08 Thread Ketil Malde
Max Bolingbroke batterseapo...@hotmail.com writes:

 Stack space overflow: current size 8388608 bytes.
 Use `+RTS -Ksize -RTS' to increase it.

 I want to find out the culprit function and rewrite it tail-recursively. Is
 there a way to find out which function is causing this error other
 than reviewing the code manually?

 It's possible that building your program with profiling and then
 running with +RTS -xc will print a useful call stack.

Does this help, really?  I've tried that occasionally, but can't really
say it's ever helped pinpoint the problem.  (Not complaining, stack
traces are hard in Haskell.)

I generally heap-profile (often with the -hd option), most stack
overflows will also retain heap data (i.e. a stack of (+) operations
will point to all the numbers as well), which should give you an idea of
where to look.

-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] Diagnose stack space overflow

2011-07-08 Thread Ketil Malde
John Lato jwl...@gmail.com writes:

 I want to find out the culprit function and rewrite it tail-recursively. Is
 there a way to find out which function is causing this error other
 than reviewing the code manually?

 I'd like to point out that a stack-space overflow in Haskell isn't quite the
 same thing as in other functional languages.  In particular, it's possible
 for tail-recursive functions to overflow the stack because of laziness.

..in fact, you often want to *avoid* tail recursion (e.g. as implemented in
foldl) and use something that is not tail recursive (e.g. foldr) but
more laziness-friendly.  Or use strictness (foldl').

-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] Patterns for processing large but finite streams

2011-07-01 Thread Ketil Malde

Eugene Kirpichov ekirpic...@gmail.com writes:
 2011/7/1 Heinrich Apfelmus apfel...@quantentunnel.de:
 Eugene Kirpichov wrote:

 I'm rewriting timeplot to avoid holding the whole input in memory, and
 naturally a problem arises:

 Plain old lazy lists?

Heretic! :-)

I generally have written a bunch of programs that do things that way,
and I think it works pretty well with a couple of caveats:

 1. Make sure you collect data into strict data structures.  Dangerous
 operations are addition and anything involving Data.Map.  And use
 foldl'.

 2. If you plan on working on multiple files, extra care might be needed
 to close them, or you'll run out of file descriptors.

As long as you avoid these pitfalls, the advantage is very clean and
simple code.

 Plain old lazy lists do not allow me to combine multiple concurrent
 computations, e.g. I cannot define average from sum and length.

Yes, this is clunky.  I'm not aware of any good solution.

-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] Best platform for development with GHC?

2011-06-16 Thread Ketil Malde
Dmitri O.Kondratiev doko...@gmail.com writes:

 Let me know if you would like opinions on Emacs vs vi!

 I know vi, but it is just that I got used to Emacs which is my main IDE for
 most PL that I work with and for many years already )

No, no! Stop, it was just a joke, really.  I regret it already. :-)

-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] Best platform for development with GHC?

2011-06-16 Thread Ketil Malde
John D. Ramsdell ramsde...@gmail.com writes:

 Developers should be using older versions of GHC because they cannot
 be sure users will have an up-to-date GHC.  

I wonder, how hard would it be to have, say Amazon images of various
Linux distributions with ghc and cabal-install available?  Currently, I
have a discontious integration server that checks my stuff by pulling
off hackage, but this is a bit limited, as well as a security risk.  I'd
consider running something off Amazon instead - perhaps it could
even be automated, so that I could do 'cabal install whatever' in
parallel on a slew of configurations?  And, although I could probably
pay for my own stuff, perhaps Amazon could contribute (som of) the CPU
time?

-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] Best platform for development with GHC?

2011-06-15 Thread Ketil Malde
Dmitri O.Kondratiev doko...@gmail.com writes:

 Which platform - Mac OS X, Linux or Win32 is best for development with GHC
 today?

I think most developers use Linux, which tends to ensure that more stuff
will work there.  Most developers will also tend to use recent versions
of everything, so go with Fedora or Ubuntu or Debian testing, rather
than Debian stable or RHEL.

In general, Haskell seems to be quite portable (in contrast to Java,
say), and difficulties seem to be mostly around stuff that requires
interaction with specific C libraries.

 How are things with Ubuntu?

I use Ubuntu.  Most stuff is fairly up-to-date, but even with six-month
releases, it's lagging the cutting edge, and GHC is still 6.12.  Thus, I
tend to install development stuff via Cabal these days, which at least
partly evens out the playing ground between different distributions.

In general, I like Ubuntu for adding a regular schedule to Debian, and
making recommended choices (e.g., which SMTP server to choose?).  I also
like the expermients with the user interface, although I don't use them
myself (xmonad is still less obstrusive and much smaller and faster :-)
Downsides is the huge bug database, where bugs seldom seem to be dealt
with.

(Also, I'm constantly annoyed at all the nice bits that are missing from
 our RHEL/CentOS servers.)

An alternative for me might be Debian testing.

 I don't want to start religious wars,

I tried to be non-flammable.  Let me know if you would like opinions on
Emacs vs vi!

-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] Data.List / Map: simple serialization?

2011-06-10 Thread Ketil Malde
Dmitri O.Kondratiev doko...@gmail.com writes:

xss2 - read `fmap` readFile output.txt

 Two questions:
 1) Why to use 'fmap' at all if a complete file is read in a single line of
 text?

Because it's not 'map', it's more generalized.  So the argument ('read'
here) is applied to whatever is inside the second argument ('readFile
...').   Here

xss2 - read `fmap` readFile output.txt

is equivalent to

xss2 - return . read = readFile output.txt

or 

tmp - readFile output.txt
let xss2 = read tmp

 2) Trying to use 'fmap' illustrates 1) producing an error (see below):
 main = do
  let xss = [[1,2,3],[4,5,6],[7,8],[9]]
  writeFile output.txt (show xss)
  xss2 - fmap read (readFile output.txt) :: [[Int]]
  print xss2

   fmap read (readFile output.txt)

is of type IO [[Int]], not [[Int]].

-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] Comment Syntax

2011-06-08 Thread Ketil Malde
Guy guytsalmave...@yahoo.com writes:

 Out of interest, is there any other language where the comment
 delimiter is invalid if immediately followed by a symbol? 

Another quaint example, in shell scripts, lines starting with '#' are
comments, except when the first line starts with '#!'.  Admittedly, this
is still a comment as far as the shell is concerned, it's the OS
that is intercepting the comment's contents and acting on it.

-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] Comment Syntax

2011-06-08 Thread Ketil Malde
Ivan Lazar Miljenovic ivan.miljeno...@gmail.com writes:

 And #! in the first line is also treated as a comment in Haskell code
 so that you can run it as a script.

True.  But then you're allowed to add arbitrary symbols after it, I
think.  At least, GHC seems happy about it.

-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] Comment Syntax

2011-06-07 Thread Ketil Malde

Guy guytsalmave...@yahoo.com writes:

 Out of interest, is there any other language where the comment
 delimiter is invalid if immediately followed by a symbol? 

Perl has a rather infamous example where the comment syntax may depend
on run-time properties - would that count?

  whatever  / 25 ; # / ; die this dies!;

Depending on the definition of 'whatever', the # might introduce a
comment - or it might not.

Anyway, I think very few languages allow definition of new symbolic
operators, so it's hard to make a useful comparison.

-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] Iteratees again

2011-06-03 Thread Ketil Malde
dm-list-haskell-c...@scs.stanford.edu writes:

 leaking file descriptors

...until they are garbage collected.  I tend to consider the OS fd
limitation an OS design error - I've no idea why there should be some
arbitrary limit on open files, as long as there is plenty of memory
around to store them.  But, well, yes, it is a real concern.

 parsers that parse every possible input and never fail.  

I guess I need to look into how iteratees handle parse failure.
Generally, for me a parse failure means program failure - either the
data is corrupt, or the program is incorrect.

 Thus, for anything other than a toy program, your code actually has to
 be: 

   readFoo path = bracket (hOpen path) hclose $
   hGetContents = (\s - return $! decodeFoo s)

No, I can't do that in general, because I want to process a Foo (which
typically is or contains a list of records) incrementally.  I can't
assume the file or its data are smalle enough to fit in memory.  It is
important that readFoo returns a structure that can be consumed lazily
- or perhaps it can be iteratee all the way up.

 Which is still not guaranteed to work if Foo contains thunks, so then
 you end up having to write:

   readFoo path = bracket (hOpen path) hclose $ \h - do
 s - hGetContents h
 let foo = decodeFoo s
 deepseq foo $ return foo

I think this - or rather, having Foo's records be strict - is a good
idea anyway.  The previous discussion about frequency counts seems to
indicate that this goes equally well for iteratees.

Thanks for the elaborate answer.

-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] *GROUP HUG*

2011-06-03 Thread Ketil Malde
Michael Litchard mich...@schmong.org writes:

 I disagree. I'm by no means proficient in Haskell. And, I never
 bothered learning PHP. I will when I need to. PHP programmers are a
 dime a dozen. 

..and since PHP programmers are a dime a dozen, any decent manager (who,
after all, has an MBA and knows that employees¹ are expendable and
interchangeable means of production) will select PHP as the technology
for her next project. 

Gresham's law states roughly that bad money drives out good.  I thus
propose a corollary: bad languages drive out good.

 It's been my experience that Haskell is a tool one may
 use to distinguish oneself from the hoi-poloi. This is important when
 you live in an area where the baker down the street has a CS degree.

Are you saying CS degrees are a dime a baker's dozen?

-k

¹) With the sole exception of managers, of course.
-- 
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] How on Earth Do You Reason about Space?

2011-06-02 Thread Ketil Malde

Since frequency counts are an important use of map-like data structures,
I did a brief test of the available options.  First using regular
strings for input, and Data.Map.fromListWith - i.e. the operational bit being:

  freqs :: [String] - M.Map String Int
  freqs = M.fromListWith (+) . map (,1)

This runs on a 14M corpus consisting of King James Bible, collected
works of Shakespeare, and War and Peace.

./freqstr1 +RTS -s 
   5,093,386,368 bytes allocated in the heap
   2,682,667,904 bytes copied during GC
 261,110,368 bytes maximum residency (20 sample(s))
   9,018,000 bytes maximum slop
 623 MB total memory in use (10 MB lost due to fragmentation)
./freqstr1 +RTS -s  21.43s user 0.78s system 99% cpu 22.285 total

Kinda expensive, 250MB to store word frequencies of 14MB text.

Now, changing to 

  freqs :: [String] - M.Map String Int
  freqs = foldl' (\m w - M.insertWith' (+) w 1 m) M.empty

i.e. using strict insertion, avoiding the buildup of lazy thunks for the
counts.

./freqstr2 +RTS -s  -- strings, using strict insertion
   4,754,110,096 bytes allocated in the heap
   2,089,527,240 bytes copied during GC
  27,039,112 bytes maximum residency (66 sample(s))
 613,192 bytes maximum slop
  80 MB total memory in use (2 MB lost due to fragmentation)
./freqstr2 +RTS -s  17.48s user 0.13s system 99% cpu 17.665 total

This reduced maximam memory consumption to one tenth, still bigger than
input corpus, but clearly not too bad.  A bit faster, too, in spite of
probably doing more work.

Using ByteStrings instead, first fromListWith:

./freq +RTS -s
(Just 77432,113931)
   3,880,059,568 bytes allocated in the heap
   1,467,507,808 bytes copied during GC
 174,573,752 bytes maximum residency (14 sample(s))
   8,222,600 bytes maximum slop
 385 MB total memory in use (6 MB lost due to fragmentation)
./freq +RTS -s  14.26s user 0.49s system 99% cpu 14.798 total

About half the memroy of Strings, and 25% faster.  With strict insertion:

./freq2 +RTS -s   -- map using strict insertion
   3,761,614,312 bytes allocated in the heap
 849,806,000 bytes copied during GC
  23,950,328 bytes maximum residency (35 sample(s))
   2,376,904 bytes maximum slop
  58 MB total memory in use (1 MB lost due to fragmentation)
./freq2 +RTS -s  11.14s user 0.13s system 99% cpu 11.295 total

Parallel to the String case, this is a lot more frugal with memory, and
30% faster.  Now, I tried Data.HashMap from the hashmap library:

./freqH1 +RTS -s-- hashmap using fromListWith
   4,552,922,784 bytes allocated in the heap
   2,990,287,536 bytes copied during GC
 401,247,912 bytes maximum residency (14 sample(s))
  42,098,016 bytes maximum slop
 957 MB total memory in use (15 MB lost due to fragmentation)
./freqH1 +RTS -s  15.68s user 1.53s system 99% cpu 17.277 total

./freqH2 +RTS -s   -- hashmap using foldl' insertWith
   4,518,146,968 bytes allocated in the heap
   2,986,973,352 bytes copied during GC
 394,502,832 bytes maximum residency (14 sample(s))
  41,020,040 bytes maximum slop
 957 MB total memory in use (15 MB lost due to fragmentation)
./freqH2 +RTS -s  15.86s user 1.62s system 99% cpu 17.537 total

HashMap doesn't provide a strict insertWith, so this is similar to the
lazy insertions above.  A bit worse, actually, probably due to the
overhead of hashing.

Then, I discovered that Johan's hashmap is a different library, and
thought I'd try that too for completeness.

./freqHS +RTS -s  -- hashmap strict (unordered-containers)
   2,628,628,752 bytes allocated in the heap
 945,571,872 bytes copied during GC
  26,635,744 bytes maximum residency (32 sample(s))
   2,433,504 bytes maximum slop
  66 MB total memory in use (1 MB lost due to fragmentation)

./freqHS +RTS -s  6.90s user 0.16s system 99% cpu 7.082 total

Memory residency like the other strict versions, but really fast,
probably due to faster comparisons of hash values vs comparisons of
strings. 

Conclusion: make sure you are using a strict map, and if your keys are
strings or otherwise have expensive comparisons, unordered-containers is
the library for you.

-k

PS: I also tried mapping 'copy' on the input words to avoid storing
large slices of the input, but it only worsened things:

./freqHS3 +RTS -s 
(Just 77432,113931)
   3,109,585,024 bytes allocated in the heap
 936,724,184 bytes copied during GC
  87,831,888 bytes maximum residency (19 sample(s))
   8,835,440 bytes maximum slop
 164 MB total memory in use (3 MB lost due to fragmentation)
./freqHS3 +RTS -s  12.71s user 0.31s system 99% cpu 13.060 total

Perhaps if you managed to only copy new words it would look better?

PPS: I tried to be careful juggling the results around, but there's
always the possiblity of a mistake.  Caveat lector!  (Or should that be
'cave scriptor'?)

PPPS: There are some small interface annoyances around, it'd be nice 

  1   2   3   4   5   6   7   8   9   10   >