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 b->a instance for Alignable #133

Merged
merged 2 commits into from
Oct 24, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Diagrams/Align.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ instance ( HasLinearMap v, InnerSpace v, OrderedField (Scalar v)
) => Alignable (QDiagram b v m) where
defaultBoundary = envelopeBoundary

-- | Although the alignBy method for the (b -> a) instance is
-- sensible, there is no good implementation for
-- defaultBoundary. Instead, we provide a total method, but one that
-- is not sensible. This should not present a serious problem as long
-- as your use of Alignable happens through alignBy.
instance (HasOrigin a, Alignable a) => Alignable (b -> a) where
alignBy v d f b = alignBy v d (f b)
defaultBoundary _ _ = origin

-- | @align v@ aligns an enveloped object along the edge in the
-- direction of @v@. That is, it moves the local origin in the
-- direction of @v@ until it is on the edge of the envelope. (Note
Expand Down