Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsString instance for WidgetT site m () #1038

Merged
merged 4 commits into from
Jul 23, 2015

Conversation

andrewthad
Copy link
Contributor

@@ -250,6 +250,10 @@ instance (a ~ (), Monad m) => Monoid (WidgetT site m a) where
mempty = return ()
mappend x y = x >> y
instance (a ~ (), Monad m) => Semigroup (WidgetT site m a)
instance Monad m => IsString (WidgetT site m ()) where
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'll get better type inference with:

instance (Monad m, a ~ ()) => IsString (WidgetT site m a)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! That dumb trick I always forget.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only remembered because the previous instance uses it

On Tue, Jul 21, 2015, 8:36 AM Andrew Martin notifications@github.com
wrote:

In yesod-core/Yesod/Core/Types.hs
#1038 (comment):

@@ -250,6 +250,10 @@ instance (a ~ (), Monad m) => Monoid (WidgetT site m a) where
mempty = return ()
mappend x y = x >> y
instance (a ~ (), Monad m) => Semigroup (WidgetT site m a)
+instance Monad m => IsString (WidgetT site m ()) where

Ah! That dumb trick I always forget.


Reply to this email directly or view it on GitHub
https://github.com/yesodweb/yesod/pull/1038/files#r35116687.

@andrewthad
Copy link
Contributor Author

I'll wait two days to see if there is any opposition to this, and then I'll merge the branch.

@creichert
Copy link
Member

@andrewthad Do you mind if I push a doc string for the new instance?

@andrewthad
Copy link
Contributor Author

@creichert That would be wonderful.

@andrewthad
Copy link
Contributor Author

@creichert I think you might have typoed the docstring a little. It reads:

Any type with an 'IsString' instance can be trivially promoted to a widget.

I think it was supposed to be:

A 'String' can be trivially promoted to a widget.

Or something like that. Because there are lots of types (ByteString for example) that have IsString instances but can't be trivially promoted to a widget.

@creichert
Copy link
Member

Yea, my mistake, thanks. I pushed a fix.

On Tue, Jul 21 2015, Andrew Martin notifications@github.com wrote:

@creichert I think you might have typoed the docstring a little. It reads:

Any type with an 'IsString' instance can be trivially promoted to a widget.

I think it was supposed to be:

An 'String' can be trivially promoted to a widget.

Or something like that. Because there are lots of types (ByteString for example) that have IsString instances but can't be trivially promoted to a widget.


Reply to this email directly or view it on GitHub:
#1038 (comment)

andrewthad added a commit that referenced this pull request Jul 23, 2015
Add IsString instance for WidgetT site m ()
@andrewthad andrewthad merged commit 81c996f into master Jul 23, 2015
@andrewthad andrewthad deleted the widget_isstring_instance branch July 23, 2015 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants