Re: Set, Map libraries

2005-06-02 Thread John Meacham
On Thu, Jun 02, 2005 at 05:03:26PM -0400, S. Alexander Jacobson wrote: > Any reason the libaries don't define: > > class HasNull a where null::a->Bool > class HasEmpty a where empty::a > > I find that I sometimes switch between using lists, sets, or tables as > my collection type and the for

Re: Set, Map libraries

2005-06-02 Thread S. Alexander Jacobson
Any reason the libaries don't define: class HasNull a where null::a->Bool class HasEmpty a where empty::a I find that I sometimes switch between using lists, sets, or tables as my collection type and the forced import qualifification for generic collection operations seems annoying. -Ale

Re: Map library

2005-06-02 Thread Mario Blazevic
Christian Maeder wrote: Mario Blazevic wrote: mapFilter :: (a -> Maybe b) -> Map k a -> Map k b mapFilter f = map Maybe.fromJust . filter Maybe.isJust . map f How about using Map.foldWithKey (and adding "Ord k =>" to the type signature)? mapFilter f = Map.foldWithKey ( \ k -> maybe

Re: Map library

2005-06-02 Thread Christian Maeder
Mario Blazevic wrote: > mapFilter :: (a -> Maybe b) -> Map k a -> Map k b > mapFilter f = map Maybe.fromJust . filter Maybe.isJust . map f How about using Map.foldWithKey (and adding "Ord k =>" to the type signature)? mapFilter f = Map.foldWithKey ( \ k -> maybe id (Map.insert k) . f) Map

Re: Map library

2005-06-02 Thread Mario Blazevic
This being the topic, I'll list the issues I ran into with the new Data.Map library: 1. The function Map.union is left-biased whereas the old FiniteMap.unionFM was right-biased. The change seems rather arbitrary. There are also other changes of this kind, the following two notable among them:

Re: Map, Set libraries

2005-06-02 Thread Christian Maeder
Serge D. Mechveliani wrote: > As Jens Fisseler notes, I have made a confusion about > > Set.elems, Set.toList, Set.setToList. There is even Set.toAscList (although one may argue that should be Set.toDistinctAscList) I think the right choice is Set.toList (replacing setToList) Is Set.elems just

doc on Map.insert

2005-06-02 Thread Serge D. Mechveliani
The ghc-6.4 documentation says about Data.Map " insert :: Ord k => k -> a -> Map k a -> Map k a O(log n). Insert a new key and value in the map. " If this is to replace old addToFM, then it is better to remove the word "new". Right? - Serge Mechveliani [EMAIL PROTECTED] ___

Re[4]: [Haskell-cafe] ghc 6.4 import problem

2005-06-02 Thread Bulat Ziganshin
Hello Simon, Thursday, June 02, 2005, 12:26:48 PM, you wrote: SM> You mean allowing SM> import M hiding (x) SM> even if x is not exported by M? Or making it a warning? yes. i think that warning will be enough - it will compile silently with new library versions and give warning, but still c

Re: Map, Set libraries

2005-06-02 Thread Serge D. Mechveliani
As Jens Fisseler notes, I have made a confusion about Set.elems, Set.toList, Set.setToList. Docs on setToList occurs all right (`Obsolete' item). And for some reason, Data.Set.html shows the pair > > " > > elems :: Set a -> [a] > > O(n). The elements of a set. > > > > toList :: Set a

Re: Map, Set libraries

2005-06-02 Thread Jens Fisseler
> I meant the description in the ghc-6.4 documentation. > Data.Set.html says > " > elems :: Set a -> [a] > O(n). The elements of a set. > > setToList :: Set a -> [a] > O(n). Convert the set to a list elements. > " > What is the difference? > If they are really equivalent, then, it is nat

Map, Set libraries

2005-06-02 Thread Serge D. Mechveliani
Thanks to people for the explanations. To my question >> 1. elems :: Set a -> [a] >> setToList :: Set a -> [a] >> >> These two look like synonyms, but have different comments. >> Am I missing something? Jens Fisseler <[EMAIL PROTECTED]> writes on 2 Jun 2005 > Both functions compu

Re: Set, Map libraries

2005-06-02 Thread Jean-Philippe Bernardy
The definition of the Set datatype being data Set a= Tip | Bin {-# UNPACK #-} !Size a !(Set a) !(Set a) type Size = Int It seems your're out of luck when it comes to very large sets. Also, since the structure is strict, it makes little sense to support 4-million-element

RE: Re[2]: [Haskell-cafe] ghc 6.4 import problem

2005-06-02 Thread Simon Marlow
On 01 June 2005 07:24, Bulat Ziganshin wrote: > Hello Fergus, > > Tuesday, May 31, 2005, 10:24:41 PM, you wrote: > >>> import Data.Set hiding (map) >>> import qualified Data.Set as Set >>> >>> will do fine. > >> That code only compiles with ghc 6.4, and won't compile with ghc 6.2: >> you'll ge

RE: Simplifier output explanation needed

2005-06-02 Thread Simon Marlow
On 01 June 2005 13:54, Jens Fisseler wrote: > I'm currently trying to optimize some code, in particular trying to > make some functions as strict as possible. To do this, I quite often > look for strictness annotations either in the interface files or the > the simplifier output. Doing this, somet

RE: .depend in base package

2005-06-02 Thread Simon Marlow
On 02 June 2005 08:22, Krasimir Angelov wrote: > I just tried to update and build my CVS tree, but the compilation > failed for base package. In the 'make boot' the .depend file is > created but it contains only the C part. The compiler is invoked as > normal and there isn't any error. The compila

Re: make html

2005-06-02 Thread Serge D. Mechveliani
On Thu, Jun 02, 2005 at 09:23:43AM +0100, Simon Marlow wrote: > On 01 June 2005 12:51, Serge D. Mechveliani wrote: > > > The problem was that I could not find these .gz archives by > > following the www references. I wonder what I was missing. > > Now, as I read your letter, I go to .../docs/l

RE: make html

2005-06-02 Thread Simon Marlow
On 01 June 2005 12:51, Serge D. Mechveliani wrote: > The problem was that I could not find these .gz archives by > following the www references. I wonder what I was missing. > Now, as I read your letter, I go to .../docs/latest/ and observe > them. The printable documentation is linked fro

Re: Set, Map libraries

2005-06-02 Thread Jens Fisseler
> 1. elems :: Set a -> [a] > setToList :: Set a -> [a] > > These two look like synonyms, but have different comments. > Am I missing something? Both functions compute the same list, and IMHO the comments state the same. > 2. size :: Set a -> Int-- O(1) ... > > And for large

Re: Set, Map libraries

2005-06-02 Thread Robert van Herk
6. My module applies Data.Set.null (s :: Set a), and null (xs :: [a]). Why ghc reports of the clash with GHC.List.null ? Is GHC.List same as old List library module? Should I write import GHC.List (genericLength, null) instead of import Li

.depend in base package

2005-06-02 Thread Krasimir Angelov
Hello, Guys I just tried to update and build my CVS tree, but the compilation failed for base package. In the 'make boot' the .depend file is created but it contains only the C part. The compiler is invoked as normal and there isn't any error. The compilation is failing latter when it tries to bui

Set, Map libraries

2005-06-02 Thread Serge D. Mechveliani
Dear GHC team, I am looking into the .html docs on the libraries of Map and Set. Here follow the questions and notices. 1. elems :: Set a -> [a] setToList :: Set a -> [a] These two look like synonyms, but have different comments. Am I missing something? 2. size :: Set a -> Int