Quantcast

A Down newtype in Data.Ord?

classic Classic list List threaded Threaded
29 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

A Down newtype in Data.Ord?

Daniel Peebles
I noticed that the Down newtype (whose Ord instance inverts its payload's ordering) currently only exists in GHC.Exts, and it seems like something fairly generally useful. What do people think of moving it to (or re-exporting it from) Data.Ord? Moving it would be nicer, but the fancy list comprehension desugaring might want it in GHC.Exts, so I'm not sure what the consequences would be.

Anyone have comments/ideas?

Thanks,
Dan

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

Re: A Down newtype in Data.Ord?

Michael Snoyman
On Fri, Nov 18, 2011 at 11:48 AM, Daniel Peebles <[hidden email]> wrote:
> I noticed that the Down newtype (whose Ord instance inverts its payload's
> ordering) currently only exists in GHC.Exts, and it seems like something
> fairly generally useful. What do people think of moving it to (or
> re-exporting it from) Data.Ord? Moving it would be nicer, but the fancy list
> comprehension desugaring might want it in GHC.Exts, so I'm not sure what the
> consequences would be.
> Anyone have comments/ideas?
> Thanks,
> Dan

I have no opinion on whether it's moved or re-exported, but +1 on
providing this type.

Michael

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

Re: A Down newtype in Data.Ord?

Sjoerd Visscher-2
In reply to this post by Daniel Peebles
I like the concept, but not the name. Inverse (or Inv) would be a better name imho.

Sjoerd

On Nov 18, 2011, at 8:48 PM, Daniel Peebles wrote:

> I noticed that the Down newtype (whose Ord instance inverts its payload's ordering) currently only exists in GHC.Exts, and it seems like something fairly generally useful. What do people think of moving it to (or re-exporting it from) Data.Ord? Moving it would be nicer, but the fancy list comprehension desugaring might want it in GHC.Exts, so I'm not sure what the consequences would be.
>
> Anyone have comments/ideas?
>
> Thanks,
> Dan
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries


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

Re: A Down newtype in Data.Ord?

Herbert Valerio Riedel
On Sat, 2011-11-19 at 12:07 +0100, Sjoerd Visscher wrote:
> I like the concept, but not the name. Inverse (or Inv) would be a better name imho.

btw, doesn't that "Down" transform the Ord relation into its "dual" (in
the category sense)? If so, wouldn't a categorical term like "Dual" or
"Opposite" (as in "Opposite Category") be more appropriate (given that
Haskell libraries already recycles many categorical terms?)

Just saying... :-)

-- hvr.


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

Re: A Down newtype in Data.Ord?

Edward Kmett
The problem Dual is taken by Data.Monoid. With Opposite it isn't clear what is being inverted as well. Perhaps Desc (or Descending)?

That would permit nice descriptions when used with the extended list comprehension sugar.

Sent from my iPad

On Nov 19, 2011, at 7:28 AM, Herbert Valerio Riedel <[hidden email]> wrote:

> On Sat, 2011-11-19 at 12:07 +0100, Sjoerd Visscher wrote:
>> I like the concept, but not the name. Inverse (or Inv) would be a better name imho.
>
> btw, doesn't that "Down" transform the Ord relation into its "dual" (in
> the category sense)? If so, wouldn't a categorical term like "Dual" or
> "Opposite" (as in "Opposite Category") be more appropriate (given that
> Haskell libraries already recycles many categorical terms?)
>
> Just saying... :-)
>
> -- hvr.
>
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries

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

Re: A Down newtype in Data.Ord?

Felipe Lessa
On Sat, Nov 19, 2011 at 4:48 PM, Edward Kmett <[hidden email]> wrote:
> The problem Dual is taken by Data.Monoid. With Opposite it isn't clear what is being inverted as well. Perhaps Desc (or Descending)?
>
> That would permit nice descriptions when used with the extended list comprehension sugar.

I like Desc, and it's better than Descending.

+1 (whatever the name is chosen)

Cheers,

--
Felipe.

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

Re: A Down newtype in Data.Ord?

Sjoerd Visscher-2
In reply to this post by Edward Kmett
Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.

Sjoerd

On Nov 19, 2011, at 7:48 PM, Edward Kmett wrote:

> The problem Dual is taken by Data.Monoid. With Opposite it isn't clear what is being inverted as well. Perhaps Desc (or Descending)?
>
> That would permit nice descriptions when used with the extended list comprehension sugar.
>
> Sent from my iPad
>
> On Nov 19, 2011, at 7:28 AM, Herbert Valerio Riedel <[hidden email]> wrote:
>
>> On Sat, 2011-11-19 at 12:07 +0100, Sjoerd Visscher wrote:
>>> I like the concept, but not the name. Inverse (or Inv) would be a better name imho.
>>
>> btw, doesn't that "Down" transform the Ord relation into its "dual" (in
>> the category sense)? If so, wouldn't a categorical term like "Dual" or
>> "Opposite" (as in "Opposite Category") be more appropriate (given that
>> Haskell libraries already recycles many categorical terms?)
>>
>> Just saying... :-)
>>
>> -- hvr.
>>
>>
>> _______________________________________________
>> Libraries mailing list
>> [hidden email]
>> http://www.haskell.org/mailman/listinfo/libraries
>


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

Re: A Down newtype in Data.Ord?

Felipe Lessa
On Sat, Nov 19, 2011 at 6:19 PM, Sjoerd Visscher <[hidden email]> wrote:
> Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.

Desc reminds me of tables where you click the header and change
between ascending and descending.  Invert, Dual, Down and Opposite
don't remind me of anything regarding orders at all.  What are you
inverting?  Dual of what?  Of couse, that's only my humble opinion.
=)

Cheers,

--
Felipe.

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

Re: A Down newtype in Data.Ord?

Ben Millwood
On Sat, Nov 19, 2011 at 8:32 PM, Felipe Almeida Lessa
<[hidden email]> wrote:
> On Sat, Nov 19, 2011 at 6:19 PM, Sjoerd Visscher <[hidden email]> wrote:
>> Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.
>
> Desc reminds me of tables where you click the header and change
> between ascending and descending.  Invert, Dual, Down and Opposite
> don't remind me of anything regarding orders at all.  What are you
> inverting?  Dual of what?  Of couse, that's only my humble opinion.
> =)
>

Just to confuse and frustrate things further, I'm going to suggest
Reverse. I think that's the normal word I'd use to describe a flipped
ordering.

I don't see any harm in reusing the existing Dual newtype from Monoid, though.

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

Re: A Down newtype in Data.Ord?

Edward Kmett
Dual already has an Ord instance.

Sent from my iPhone

On Nov 19, 2011, at 4:46 PM, Ben Millwood <[hidden email]> wrote:

> On Sat, Nov 19, 2011 at 8:32 PM, Felipe Almeida Lessa
> <[hidden email]> wrote:
>> On Sat, Nov 19, 2011 at 6:19 PM, Sjoerd Visscher <[hidden email]> wrote:
>>> Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.
>>
>> Desc reminds me of tables where you click the header and change
>> between ascending and descending.  Invert, Dual, Down and Opposite
>> don't remind me of anything regarding orders at all.  What are you
>> inverting?  Dual of what?  Of couse, that's only my humble opinion.
>> =)
>>
>
> Just to confuse and frustrate things further, I'm going to suggest
> Reverse. I think that's the normal word I'd use to describe a flipped
> ordering.
>
> I don't see any harm in reusing the existing Dual newtype from Monoid, though.
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries

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

Re: A Down newtype in Data.Ord?

Stephen Tetley-2
In reply to this post by Felipe Lessa
On 19 November 2011 20:12, Felipe Almeida Lessa <[hidden email]> wrote:
> I like Desc, and it's better than Descending.
>
> +1 (whatever the name is chosen)
>

<bikeshedding>

I often use the name Desc in code as a shortening of Description...

</bikeshedding>

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

Re: A Down newtype in Data.Ord?

Herbert Valerio Riedel
In reply to this post by Edward Kmett
On Sat, 2011-11-19 at 17:03 -0500, Edward Kmett wrote:
> Dual already has an Ord instance.

...btw, why does a monoid need an Ord instance anyway? :-)


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

Re: A Down newtype in Data.Ord?

Edward Kmett
Because sometimes you put them in containers directly. I've done this, it isn't a theoretical situation.

Sent from my iPhone

On Nov 19, 2011, at 5:24 PM, Herbert Valerio Riedel <[hidden email]> wrote:

> On Sat, 2011-11-19 at 17:03 -0500, Edward Kmett wrote:
>> Dual already has an Ord instance.
>
> ...btw, why does a monoid need an Ord instance anyway? :-)
>

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

Re: A Down newtype in Data.Ord?

wren ng thornton
In reply to this post by Sjoerd Visscher-2
On 11/19/11 6:07 AM, Sjoerd Visscher wrote:
> I like the concept, but not the name. Inverse (or Inv) would be a better name imho.

+1, on both counts.

--
Live well,
~wren

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

Re: A Down newtype in Data.Ord?

wren ng thornton
In reply to this post by Sjoerd Visscher-2
On 11/19/11 3:19 PM, Sjoerd Visscher wrote:
> Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.

FWIW I call the newtype Reverse in my local libraries. Another option
would be Converse. (Both of which are a bit less ambiguous than Inverse.)

--
Live well,
~wren

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

Re: A Down newtype in Data.Ord?

Sjoerd Visscher-2
Reverse is better indeed, but +1 on any name that ends with -verse.

Sjoerd

On Nov 20, 2011, at 11:56 PM, wren ng thornton wrote:

> On 11/19/11 3:19 PM, Sjoerd Visscher wrote:
>> Desc has the same problem as Down: it doesn't make clear that it makes an already descending ordering ascending.
>
> FWIW I call the newtype Reverse in my local libraries. Another option would be Converse. (Both of which are a bit less ambiguous than Inverse.)
>
> --
> Live well,
> ~wren
>
> _______________________________________________
> Libraries mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/libraries
>


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

Re: A Down newtype in Data.Ord?

wren ng thornton
On 11/20/11 6:11 PM, Sjoerd Visscher wrote:
> Reverse is better indeed, but +1 on any name that ends with -verse.

So that's three votes for Reverse. Are there any complaints against this
color for the bikeshed?

--
Live well,
~wren

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

Re: A Down newtype in Data.Ord?

Michael Snoyman
On Sun, Nov 20, 2011 at 3:21 PM, wren ng thornton <[hidden email]> wrote:
> On 11/20/11 6:11 PM, Sjoerd Visscher wrote:
>>
>> Reverse is better indeed, but +1 on any name that ends with -verse.
>
> So that's three votes for Reverse. Are there any complaints against this
> color for the bikeshed?

Reverse sounds good to me too, especially since it matches up with the
reverse function so well.

Michael

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

Re: A Down newtype in Data.Ord?

Brent Yorgey-2
In reply to this post by Sjoerd Visscher-2
On Mon, Nov 21, 2011 at 12:11:27AM +0100, Sjoerd Visscher wrote:
> Reverse is better indeed, but +1 on any name that ends with -verse.

In that case I propose Universe, Adverse, or Perverse. ;)

-Brent

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

Re: A Down newtype in Data.Ord?

Ivan Lazar Miljenovic
On 21 November 2011 12:57, Brent Yorgey <[hidden email]> wrote:
> On Mon, Nov 21, 2011 at 12:11:27AM +0100, Sjoerd Visscher wrote:
>> Reverse is better indeed, but +1 on any name that ends with -verse.
>
> In that case I propose Universe, Adverse, or Perverse. ;)

Wouldn't Perverse have some kind of random (via unsafePerformIO of
course!) comparison functionality? ;-)

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Libraries mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/libraries
12
Loading...