-
Notifications
You must be signed in to change notification settings - Fork 62
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
Lens style #236
Lens style #236
Conversation
I've added The changes shouldn't break any backends (except for povray which I'll fix). Overall I'm reasonably happy with it, I think it's ready to merge. What do people think? |
_recommend f (Recommend a) = Recommend <$> f a | ||
_recommend f (Commit a) = Commit <$> f a | ||
|
||
-- | Lens onto weather something is committed or not. |
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.
whether
, not weather
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.
If only we had a lens into weather...
On Fri, Feb 27, 2015 at 10:19 AM, Daniel Bergey notifications@github.com
wrote:
In src/Diagrams/Attributes.hs
#236 (comment):
+-- | Prism onto a 'Recommend'.
+_Recommend :: Prism' (Recommend a) a
+_Recommend = prism' Recommend $ \case (Recommend a) -> Just a; _ -> Nothing
+
+-- | Prism onto a 'Commit'.
+_Commit :: Prism' (Recommend a) a
+_Commit = prism' Commit $ \case (Commit a) -> Just a; _ -> Nothing
+
+-- | Lens onto the value inside either a 'Recommend' or 'Commit'. Unlike
+-- 'committed', this is a valid lens.
+_recommend :: Lens (Recommend a) (Recommend b) a b
+_recommend f (Recommend a) = Recommend <$> f a
+_recommend f (Commit a) = Commit <$> f a
+
+-- | Lens onto weather something is committed or not.whether, not weather
—
Reply to this email directly or view it on GitHub
https://github.com/diagrams/diagrams-lib/pull/236/files#r25512596.
Looks good to me. |
Looks good to me too. |
3D attributes haven't been changed yet. This requires changes to the povray backend.
Now _Attribute is an Iso and _attribute is a lens onto the attribute in a style.
They're just added noise, you never really use them because you need to know the types. We can always add them later.
There's no need to use the maybe value, transparent it equivilent to no fill. This reverts commit 731f181.
a1fa13c
to
73d0676
Compare
See diagrams/diagrams-core#80. Includes a bunch of lenses onto attributes of a
Style
.The only real issue is lenses that include a
Recommend
are always "committed" (this is how the previousstyleFillTexture
setter was). This is almost always what you want, otherwise styles set with a lens could be accidentally overwritten. These lenses have warnings and a validR
variant that includes theRecommend
.The 3D attributes lenses haven't been added these lenses because the povray backend needs changes, I'll do that later if this gets merged.
Other then that this should be ready to merge.