-
Notifications
You must be signed in to change notification settings - Fork 194
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
Ch6 - Clarify Action exercises #228
Ch6 - Clarify Action exercises #228
Conversation
@@ -113,17 +111,11 @@ newtype Self m | |||
instance actionSelf :: Monoid m => Action m (Self m) where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the Monoid
constraint required here? It seems like this superclass relationship is already specified by the Action
class and that it should be possible to write it like this instead:
instance actionSelf :: Action m (Self m) where
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answer:
it's required for the superclass relationship, it's not provided by the superclass relationship
mempty = Self mempty | ||
-- These may also be written manualy | ||
derive newtype instance showSelf :: Show m => Show (Self m) | ||
derive newtype instance eqSelf :: Eq m => Eq (Self m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fine to write without newtype wrapper:
derive instance eqSelf :: Eq m => Eq (Self m)
derive newtype instance showSelf :: Show m => Show (Self m) | ||
derive newtype instance eqSelf :: Eq m => Eq (Self m) | ||
derive newtype instance semigroupSelf :: Semigroup m => Semigroup (Self m) | ||
derive newtype instance monoidSelf :: Monoid m => Monoid (Self m) | ||
|
||
instance repeatActionMultSelf :: Action (Self Multiply) Int where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not be the best instance name (doesn't follow the earlier convention of just squishing everything together), although this doesn't really matter.
Fixes #200