-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
D.TwoD.Arrow: Lenses for setting head, tail, and shaft style directly.
This is the sort of convenient thing that we can do now that we use lens for everything: we can provide headColor, tailColor, and shaftColor directly as "virtual fields" so the user doesn't have to think about style modification functions in the common case where they just want to set the color (and we also protect them from the easy mistake of setting the line color on the head, or fill color on the shaft). This is something of a proof-of-concept. Ideally we could even refactor these as e.g. headColor = headStyle . styleFillColor where styleFillColor :: (Color c, Color c') => Setter (Style v) (Style v) c c'.
- Loading branch information
Brent Yorgey
committed
Nov 14, 2013
1 parent
a9339c6
commit 4937215
Showing
2 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4937215
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 is cool, and looks very convenient. Does Diagrams now have better support for arrows than Inkscape? :)
I look forward toI would have expected something more general than astyleFillColor
in the future, too.Setter
,though. If not aLens
, at least aPrism
. Is that not possible? Or shall I take a stab at it and find out?ETA: Should have read the next commit.
4937215
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.
OK, ignore me.
Prism
s are apparently more likeIso
s and less likeLens
es than I (mis)remembered.4937215
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.
Yeah, a
Setter
lets you set or modify but not get. We could make aLens' Style (Maybe c)
which might also be useful (this would let you delete an existing, say, fill color by setting it toNothing
).Prism
s are preciselyIso
s which are allowed to be partial in one direction, i.e. they express when one type is a "subset" of another type.