Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Stephen Tetley
On 23 February 2011 05:31, Johan Tibell johan.tib...@gmail.com wrote: Can someone come up with a real world example where O(1) size is important? Tangentially - if you changed the API so the size function was called 'count' rather than 'size' or 'length', there would be no shame what's so ever

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Max Bolingbroke
On 23 February 2011 05:31, Johan Tibell johan.tib...@gmail.com wrote: On Tue, Feb 22, 2011 at 9:19 PM, Johan Tibell johan.tib...@gmail.com wrote: Initial numbers suggest that lookup gets 3% slower and insert/delete 6% slower. The upside is O(1) size. Can someone come up with a real world

Re: [Haskell-cafe] Either instance of Monad?

2011-02-23 Thread Yves Parès
I am using mtl-2. Importing Control.Monad.Error doesn't work, I have to explicitly import Control.Monad.Instances. 2011/2/22 Daniel Fischer daniel.is.fisc...@googlemail.com: On Tuesday 22 February 2011 23:07:05, Yves Parès wrote: Hello, When importing Control.Monad.Error, it shows me that

Re: [Haskell-cafe] best way to deal with #defines when developing ffi's

2011-02-23 Thread Bas van Dijk
On 23 February 2011 06:47, bri...@aracnet.com wrote: Hi all, I'm working on an FFI and as usual there are lots of defines in the header files. What's the best way to make these available to the haskell code ? Ideally it could be done automagically, or at least pseudo-magically so that

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Alberto G. Corona
I took a rapid look and they seem a replacement for pure Map's, but not for mutable HashTable's. Sorry if it isn't the case. I don´t know if Data.HashTable has improved, but the performance used to be very poor in comparison with other languages. The point is that pure data structures can not be

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread Chris Dornan
Thanks John, The simple answer is that I need to be able to use HDBC in proprietary products and the LGPL makes this awkward - the most serious issue being that owners of the code base don't want GNU licensed parts being linked into their code base. Packaging and delivery also gets

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Gregory Collins
On Wed, Feb 23, 2011 at 12:30 PM, Alberto G. Corona agocor...@gmail.com wrote: For this reason I think that an inprovement/mutable-replacement of Data.HashTable is needed. If this hasn´t been done already. Are there some improvements on it that I don't know? I've been working on one lately,

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Roman Leshchinskiy
Johan Tibell wrote: I'm working on a patch that provides O(1) size right now. The trick is to define HashMap as: data HashMap k v = HM {-# UNPACK #-} !Int !(Tree k v) Another possibility is: data HashMap k v = HM Int !(Tree k v) hashMap t = HM (treeSize t) t That way size is O(n) on first

Re: [Haskell-cafe] Either instance of Monad?

2011-02-23 Thread Daniel Fischer
On Wednesday 23 February 2011 09:58:56, Yves Parès wrote: I am using mtl-2. Importing Control.Monad.Error doesn't work, I have to explicitly import Control.Monad.Instances. Weird. Control.Monad.Error imports Control.Monad.Instances (), so it ought to be visible. What exact versions of mtl,

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Victor Nazarov
On Sat, Feb 19, 2011 at 4:38 AM, Johan Tibell johan.tib...@gmail.com wrote: Hi all, I am delighted to announce the release of preview versions of two new packages: unordered-containers 0.1 Efficient hashing-based container types. http://hackage.haskell.org/package/unordered-containers

Re: [Haskell-cafe] Either instance of Monad?

2011-02-23 Thread Yves Parès
The latest, I think : GHC 7.0.1, mtl-2.0.1.0, base-4.3.0.0 2011/2/23 Daniel Fischer daniel.is.fisc...@googlemail.com: On Wednesday 23 February 2011 09:58:56, Yves Parès wrote: I am using mtl-2. Importing Control.Monad.Error doesn't work, I have to explicitly import Control.Monad.Instances.

Re: [Haskell-cafe] Either instance of Monad?

2011-02-23 Thread Daniel Fischer
On Wednesday 23 February 2011 14:14:46, Yves Parès wrote: The latest, I think : GHC 7.0.1, mtl-2.0.1.0, base-4.3.0.0 Hmm, that's exactly what I have. Weirder and weirder. For the moment, I'm out of ideas. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Emil Axelsson
2011-02-23 13:56, Victor Nazarov skrev: Also I think that value of hash functions is obviously a Monoid and it will be convenient to have Monoid instance newtype Hash = Hash Int instance Monoid Hash where mempty = Hash 0 Hash a `mappend` Hash b = Hash (a `combine` b)

Re: [Haskell-cafe] help for the usage on mfix

2011-02-23 Thread Ryan Ingram
Just write a loop: let loop gs gu | Just z - find_obj gu usyms = do ... (gs', gu') - handle_obj_ar ... loop gs' gu' | otherwise = return (gs,gu) (gs, gu) - loop def undef mfix is for when you have mutually recursive data but you want the IO operation

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Antoine Latter wrote: As the error says, compiling with the flag '-XFlexibleInstances' will make the message go away. You can also add a language pragma to the top of your source file: {-# LANGUAGE FlexibleInstances #-} Antoine When I enable that flag, I then also have to enable

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Max Bolingbroke
On 23 February 2011 12:05, Gregory Collins g...@gregorycollins.net wrote: I've been working on one lately, some preliminary benchmarks:    https://gist.github.com/826935 It's probably a month or two away from a releasable state, but my work-in-progress is substantially faster (4-6X) than

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Gregory Collins
On Wed, Feb 23, 2011 at 3:49 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: On 23 February 2011 12:05, Gregory Collins g...@gregorycollins.net wrote: I've been working on one lately, some preliminary benchmarks:    https://gist.github.com/826935 It's probably a month or two away from

Re: [Haskell-cafe] Cabal things

2011-02-23 Thread Antoine Latter
On Wed, Feb 23, 2011 at 8:48 AM, Volker Wysk p...@volker-wysk.de wrote: Hello I'm new to Cabal, and I'm trying to Cabalize my library HsShellScript, with help by Howard Golden. I'm using the Simple Build Infrastructure. 1. I'm irritated by the fact, that calling the Cabal with runhaskell

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Chris Smith
On Wed, 2011-02-23 at 08:42 -0600, Kurt Stutsman wrote: When I was reviewing the Haskell language specification on haskell.org, it certainly looked like what I was doing was supported by the language. I found some comments on GHC's site about the reasoning behind these flags, but I couldn't

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Daniel Fischer
On Wednesday 23 February 2011 15:42:46, Kurt Stutsman wrote: Antoine Latter wrote: As the error says, compiling with the flag '-XFlexibleInstances' will make the message go away. You can also add a language pragma to the top of your source file: {-# LANGUAGE FlexibleInstances #-}

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Daniel Fischer wrote: No, it's not. The language report says an instance head must have the form (tyCon a1 ... an), where tyCon is a type constructor and a1 ... an are *distinct* type variables (appropriate in number so that the head has the correct kind). In instance (Enum e) = Test e

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Stephen Tetley
On 23 February 2011 15:40, Kurt Stutsman kstuts...@gmail.com wrote: instance Enum e = Serializable e where   get mask = {- convert mask to Int and then to a BitSet -}   put bitset = {- convert BitSet to Int and then to String -} I looks like all you need is for objects to be enumerable, i.e

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread Leon Smith
This seems a timely email, as I've been submitting a steady-ish trickle of patches to HDBC-postgresql lately. Honestly, I'm rather dissatisfied with HDBC in many respects, but I don't have a very good idea of what a (low-level) database access library for Haskell *should* be, and I've found

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
Thanks for the examples. Point 3 is interesting but most of the gain there could probably be had by telling the user to use (bigmap `union` smallmap). My guess is that the user has a good idea which argument is larger/smaller. On Wed, Feb 23, 2011 at 12:45 AM, Max Bolingbroke

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 3:30 AM, Alberto G. Corona agocor...@gmail.com wrote: The point is that pure data structures can not be used as shared data in multithreaded environments. They must be encapsulated in mutable blocking references, such is MVars, and the whole update process blocks any

Re: [Haskell-cafe] HANSEI in Haskell?

2011-02-23 Thread Chung-chieh Shan
Hello! Thank you for your interest. Daryoush Mehrtash dmehrt...@gmail.com wrote in haskell-cafe: Is the Embedded domain-specific language HANSEI for probabilistic models and (nested) inference described in: http://okmij.org/ftp/kakuritu/index.html#implementation available in Haskell? The

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Steffen Schuldenzucker
Hi, On 02/23/2011 04:40 PM, Kurt Stutsman wrote: [...] Test is actually a kind of Serializable class. I don't want to restrict it to only working with Enums, which is what your OverlappingInstances seems to address. Is there a better way for doing what I am trying to do? Example: import

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 4:56 AM, Victor Nazarov asviraspossi...@gmail.com wrote: What about making Hashable subclass of Eq    class Eq a = Hashable a where I think it's is obvious from Hasable class properties that some kind of equality is needed and I think it will reduce type class

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Kurt Stutsman
Stephen Tetley wrote: On 23 February 2011 15:40, Kurt Stutsman kstuts...@gmail.com wrote: instance Enum e = Serializable e where get mask = {- convert mask to Int and then to a BitSet -} put bitset = {- convert BitSet to Int and then to String -} I looks like all you need is for

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread John Goerzen
On 02/23/2011 10:03 AM, Leon Smith wrote: My biggest (mostly) fixable complaint with HDBC is that it hasn't turned out to be a very complete or robust solution for accessing databases that like to use PostgreSQL-specific features. My biggest This is probably true, both that it isn't designed

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread John Goerzen
On 02/23/2011 05:48 AM, Chris Dornan wrote: The simple answer is that I need to be able to use HDBC in proprietary products and the LGPL makes this awkward – the most serious issue being that owners of the code base don’t want GNU licensed parts being linked into their code base. Packaging and

Re: [Haskell-cafe] Having trouble with instance context

2011-02-23 Thread Brandon Moore
From Kurt Stutsman kstuts...@gmail.com on Wed, February 23, 2011 9:40:09 AM Daniel Fischer wrote: No, it's not. The language report says an instance head must have the form (tyCon a1 ... an), where tyCon is a type constructor and a1 ... an are *distinct* type variables

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread Chris Dornan
Thanks John, I think this is a valuable discussion. The compromise you propose wouldn't address the main point - the fear and aversion of using (L)GPL IP in proprietary IP. For me the key phrase in your email was the final one - 'if my reading is correct'. Everywhere I would take

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Jan-Willem Maessen
On Wed, Feb 23, 2011 at 11:08 AM, Johan Tibell johan.tib...@gmail.com wrote: ... HashTable is not a concurrent data structure. You need e.g. a lock free mutable hash table. Good implementations of which are *not* thick on the ground. Even java.util.concurrent isn't fully lock-free. -Jan

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread John Goerzen
On 02/23/2011 11:57 AM, Chris Dornan wrote: Thanks John, I think this is a valuable discussion. The compromise you propose wouldn’t address the main point – the fear and aversion of using (L)GPL IP in proprietary IP. Is that fear well-grounded or not? If not, then people should be

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Max Bolingbroke
On 23 February 2011 16:03, Johan Tibell johan.tib...@gmail.com wrote: Thanks for the examples. Point 3 is interesting but most of the gain there could probably be had by telling the user to use (bigmap `union` smallmap). My guess is that the user has a good idea which argument is

Re: [Haskell-cafe] HDBC's future and request for help

2011-02-23 Thread Chris Dornan
John, As far as I know it is the libraries that interface to O/S libraries that have most value in the platform and, AFAIK, many HP libraries link to O/S libraries (e.g., GLUT). I had expected that at least the principle HDBC drivers would have to go into the Haskell Platform with HDBC.

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 12:46 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: By the way, do you plan to add a HashSet to complement HashMap? Yes, definitely. I want to flesh out the HashMap API some more and then add a HashSet implementation. The code is still moving around a lot (e.g.

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 12:57 PM, Gwern Branwen gwe...@gmail.com wrote: On Wed, Feb 23, 2011 at 12:45 AM, Max Bolingbroke batterseapo...@hotmail.com wrote: I'm a bit sceptical that it is (I was not convinced by the earlier strict-set-inclusion argument, since that's another Data.Map feature

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Gwern Branwen
On Wed, Feb 23, 2011 at 1:18 PM, Johan Tibell johan.tib...@gmail.com wrote: Could you manually look at some of them to see if you find something interesting. In particular `Set.size s == 0` (a common use of size in imperative languages) could be replaced by `Set.null s`. You could look at

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 1:27 PM, Gwern Branwen gwe...@gmail.com wrote: You could look at them yourself; I attached the files. I see 6 uses out of ~100 which involve an == 0 Looks like the mailing list gateway didn't let your attachements through. No need to attach them though, I can just grep

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Sterling Clover
A quick grep of some of my own source reveals that I've used M.size and S.size only to test for sizes equal to 1. So, for my purposes at least, an O(1) isSingleton operation would be just as useful as an O(1) size. Cheers, Sterl On Feb 23, 2011, at 4:32 PM, Johan Tibell wrote: On Wed, Feb

Re: [Haskell-cafe] HANSEI in Haskell?

2011-02-23 Thread Daryoush Mehrtash
I would very much appreciate if you can expand on this: Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd have to defeat that memoization by sprinkling () - throughout the types. Would it be possible to explain this with an example? Thanks Daryoush On Wed,

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Max Bolingbroke
On 23 February 2011 21:27, Gwern Branwen gwe...@gmail.com wrote: On Wed, Feb 23, 2011 at 1:18 PM, Johan Tibell johan.tib...@gmail.com wrote: Could you manually look at some of them to see if you find something interesting. In particular `Set.size s == 0` (a common use of size in imperative

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
On Wed, Feb 23, 2011 at 1:55 PM, Max Bolingbroke batterseapo...@hotmail.com wrote: Thanks for bringing some data to the table. There are definitely some common patterns in what you sent me: 1) For defining Binary instances, you need to write set size before you write the elements: ~7

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread Johan Tibell
Attached are all the uses of S.size and Set.size from a semi-recent snapshot of Hackage. Johan Combinatorrent/0.3.2/Combinatorrent-0.3.2/src/Process/Peer.hs:let sz = S.size q Combinatorrent/0.3.2/Combinatorrent-0.3.2/src/Process/PieceMgr.hs: ipHave = S.size . ipHaveBlocks

Re: [Haskell-cafe] Performance difference between ghc and ghci

2011-02-23 Thread Henning Thielemann
Roel van Dijk schrieb: In general code compiled with GHC will be a lot faster than code interpreted by GHCI. You can also call compiled code from within GHCI, in which case you would hardly see a performance difference. $ ghci -fobject-code compiles modules before loading into the interpreter

Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library

2011-02-23 Thread wren ng thornton
On 2/23/11 4:42 PM, Sterling Clover wrote: A quick grep of some of my own source reveals that I've used M.size and S.size only to test for sizes equal to 1. So, for my purposes at least, an O(1) isSingleton operation would be just as useful as an O(1) size. I agree, a fast isSingleton

Re: [Haskell-cafe] HANSEI in Haskell?

2011-02-23 Thread Leon Smith
On Wed, Feb 23, 2011 at 10:52 AM, Chung-chieh Shan ccs...@cs.rutgers.edu wrote: Mostly we preferred (as do the domain experts we target) to write probabilistic models in direct style rather than monadic style. Haskell's laziness doesn't help -- in fact, to avoid running out of memory, we'd

[Haskell-cafe] Haskell Weekly News: Issue 170

2011-02-23 Thread Daniel Santa Cruz
Welcome to issue 170 of the HWN, a newsletter covering developments in the [1]Haskell community. This release covers the week of February 13 - 19, 2011. Announcements Simon Michael [2]informed us of reviving of FunGEn as a community project. FunGEn (Functional Game Engine) is a