Set, Map libraries

S. Alexander Jacobson alex at alexjacobson.com
Thu Jun 2 17:03:26 EDT 2005


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.

-Alex-


On Thu, 2 Jun 2005, Robert van Herk wrote:

>
>> 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 List     (genericLength)
>>  ?
>> 
> As the documentation reads:
>
> This module is intended to be imported qualified, to avoid name clashes with 
> Prelude 
> <http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html> 
> functions. eg.
>
> import Data.Set as Set
>
>
>
> So, you should write:
>
> import qualified Data./x/ as /y/
>
> Now, no name clashes will occur. However, you will have to write /y/.null to 
> access null in /x/, for example:
>
> import qualified Data.Set as Set
>
> if (Set.null ...) then ... else ...
>
> Regards,
> Robert
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>

______________________________________________________________
S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com


More information about the Glasgow-haskell-users mailing list