Void is not Monoid?

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

Void is not Monoid?

Javran Cheng
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

Javran Cheng

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Void is not Monoid?

Will Yager
On Sun, Jan 13, 2019 at 4:00 PM Javran Cheng <[hidden email]> wrote:
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

This diverges, does it not?

A monoid has an identity element, and void does not. 


Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

How would you write return with void as the writer?

You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

--Will

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Fwd: Void is not Monoid?

Javran Cheng
(forgot to reply all, sorry)

Hi Will,

Thanks for the reply!

> A monoid has an identity element, and void does not. 

now I feel dull never thought about that.

> How would you write return with void as the writer?
> You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

Unit does work fine, but I figure using Void is an interesting idea, as I can make sure that no one can use the "W" part of my RWST.

Javran


On Sun, Jan 13, 2019 at 12:23 AM William Yager <[hidden email]> wrote:
On Sun, Jan 13, 2019 at 4:00 PM Javran Cheng <[hidden email]> wrote:
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

This diverges, does it not?

A monoid has an identity element, and void does not. 


Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

How would you write return with void as the writer?

You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

--Will


--
Javran (Fang) Cheng


--
Javran (Fang) Cheng

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Void is not Monoid?

Isaac Elliott
If you had an `RWST r Void s m a`, then you would be able to produce an `m (a, s, Void)`, which is `absurd`.

On Sun, 13 Jan. 2019, 6:43 pm Javran Cheng, <[hidden email]> wrote:
(forgot to reply all, sorry)

Hi Will,

Thanks for the reply!

> A monoid has an identity element, and void does not. 

now I feel dull never thought about that.

> How would you write return with void as the writer?
> You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

Unit does work fine, but I figure using Void is an interesting idea, as I can make sure that no one can use the "W" part of my RWST.

Javran


On Sun, Jan 13, 2019 at 12:23 AM William Yager <[hidden email]> wrote:
On Sun, Jan 13, 2019 at 4:00 PM Javran Cheng <[hidden email]> wrote:
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

This diverges, does it not?

A monoid has an identity element, and void does not. 


Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

How would you write return with void as the writer?

You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

--Will


--
Javran (Fang) Cheng


--
Javran (Fang) Cheng
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Void is not Monoid?

Javran Cheng
That's a valid point. come to think of it, is there any use case where Void appears on a positive position?

On Sun, Jan 13, 2019 at 1:15 AM Isaac Elliott <[hidden email]> wrote:
If you had an `RWST r Void s m a`, then you would be able to produce an `m (a, s, Void)`, which is `absurd`.

On Sun, 13 Jan. 2019, 6:43 pm Javran Cheng, <[hidden email]> wrote:
(forgot to reply all, sorry)

Hi Will,

Thanks for the reply!

> A monoid has an identity element, and void does not. 

now I feel dull never thought about that.

> How would you write return with void as the writer?
> You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

Unit does work fine, but I figure using Void is an interesting idea, as I can make sure that no one can use the "W" part of my RWST.

Javran


On Sun, Jan 13, 2019 at 12:23 AM William Yager <[hidden email]> wrote:
On Sun, Jan 13, 2019 at 4:00 PM Javran Cheng <[hidden email]> wrote:
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

This diverges, does it not?

A monoid has an identity element, and void does not. 


Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

How would you write return with void as the writer?

You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

--Will


--
Javran (Fang) Cheng


--
Javran (Fang) Cheng
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


--
Javran (Fang) Cheng

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Void is not Monoid?

Michael Snoyman
Functions like `forever` can put Void in positive position as a proof that the value is never produced.

On Sun, Jan 13, 2019 at 11:53 AM Javran Cheng <[hidden email]> wrote:
That's a valid point. come to think of it, is there any use case where Void appears on a positive position?

On Sun, Jan 13, 2019 at 1:15 AM Isaac Elliott <[hidden email]> wrote:
If you had an `RWST r Void s m a`, then you would be able to produce an `m (a, s, Void)`, which is `absurd`.

On Sun, 13 Jan. 2019, 6:43 pm Javran Cheng, <[hidden email]> wrote:
(forgot to reply all, sorry)

Hi Will,

Thanks for the reply!

> A monoid has an identity element, and void does not. 

now I feel dull never thought about that.

> How would you write return with void as the writer?
> You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

Unit does work fine, but I figure using Void is an interesting idea, as I can make sure that no one can use the "W" part of my RWST.

Javran


On Sun, Jan 13, 2019 at 12:23 AM William Yager <[hidden email]> wrote:
On Sun, Jan 13, 2019 at 4:00 PM Javran Cheng <[hidden email]> wrote:
Hi Cafe,

I'm wondering why Data.Void does not have a Monoid instance, or, what would be the problem if we do "mempty = absurd mempty"?

This diverges, does it not?

A monoid has an identity element, and void does not. 


Long story: I was using a monad with some transformers, then I realize I can collapse State and Reader into RWST with Void being Writer output.
(well, I could have just used Unit but I wanna give Void a try...) I know beforehand that Void is Semigroup but is a bit surprise it doesn't have Monoid instance.

How would you write return with void as the writer?

You can accomplish what you want with the free monoid over Void - i.e. [Void], which is isomorphic to unit. So unit seems like the right choice.

--Will


--
Javran (Fang) Cheng


--
Javran (Fang) Cheng
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.


--
Javran (Fang) Cheng
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.

_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.