Re: Data.Map API

Previous Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Data.Map API

Ben Franksen-2
On Thursday 10 November 2005 12:35, Christian Maeder wrote:

> Iavor Diatchki wrote:
> >> import Data.Map (Map); import qualified Data.Map as Map hiding
> >> (Map)
> >
> > PS: How do people import 'Data.Map'?  The above seems clunky...
>
> I only use:
>
> import qualified Data.Map as Map
>
> and write "Map.Map" in signatures, which is also a bit clunky.

Last time I used Data.Map I went for

import qualified Data.Map as Map
type Map = Map.Map

Ben
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Data.Map API

Tomasz Zielonka
On Sat, Nov 12, 2005 at 02:05:54AM +0100, Benjamin Franksen wrote:
> Last time I used Data.Map I went for
>
> import qualified Data.Map as Map
> type Map = Map.Map

There is a small problem - you can define type-class instances for
type synonyms in Haskell 98.

What's wrong with this approach, besides being overly verbose:

    import qualified Data.Map as Map
    import Data.Map (Map)

I've seen it used in others' code. The report allows to import
the same module many times:

"A single module may be imported by more than one import declaration."

Best regards
Tomasz
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Data.Map API

Ben Franksen-2
On Saturday 12 November 2005 10:13, Tomasz Zielonka wrote:
> On Sat, Nov 12, 2005 at 02:05:54AM +0100, Benjamin Franksen wrote:
> > Last time I used Data.Map I went for
> >
> > import qualified Data.Map as Map
> > type Map = Map.Map
>
> There is a small problem - you can define type-class instances for
> type synonyms in Haskell 98.

So what?

> What's wrong with this approach, besides being overly verbose:
>
>     import qualified Data.Map as Map
>     import Data.Map (Map)

Nothing, except being overly verbose ;-)

Ben
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Data.Map API

Tomasz Zielonka
On Sat, Nov 12, 2005 at 08:02:27PM +0100, Benjamin Franksen wrote:
> > There is a small problem - you can define type-class instances for
> > type synonyms in Haskell 98.
>
> So what?

Oops, it should be: "you *can't* define type-class instances ..."
But I guess you already figured it out.

Best regards
Tomasz
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
Reply | Threaded
Open this post in threaded view
|

Re: Data.Map API

Ben Franksen-2
On Saturday 12 November 2005 21:19, Tomasz Zielonka wrote:
> On Sat, Nov 12, 2005 at 08:02:27PM +0100, Benjamin Franksen wrote:
> > > There is a small problem - you can define type-class instances
> > > for type synonyms in Haskell 98.
> >
> > So what?
>
> Oops, it should be: "you *can't* define type-class instances ..."

Ah, yes it's a limitation.

> But I guess you already figured it out.

No. I thought you might refer to some obscure way how this could lead to
a name resolution conflict but couldn't think of one.

Cheers,
Ben
_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries