Skip to content

Commit

Permalink
Merge pull request #133 from cscheid/Alignable-b-to-a-instance
Browse files Browse the repository at this point in the history
add b->a instance for Alignable
  • Loading branch information
byorgey committed Oct 24, 2013
2 parents f715bc2 + cf655bb commit f0788fc
Showing 1 changed file with 9 additions and 0 deletions.
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

0 comments on commit f0788fc

Please sign in to comment.