Skip to content

Commit

Permalink
Merge pull request #134 from diagrams/located-lens
Browse files Browse the repository at this point in the history
add located lens for access into Located things
  • Loading branch information
fryguybob committed Nov 2, 2013
2 parents 1f7f0d8 + a5cfe99 commit c0debab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Diagrams/Located.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@

module Diagrams.Located
( Located
, at, viewLoc, unLoc, loc, mapLoc
, at, viewLoc, unLoc, loc, mapLoc, located
)
where

import Control.Lens (Lens)
import Data.AffineSpace
import Data.Functor ((<$>))
import Data.VectorSpace

import Diagrams.Core
Expand Down Expand Up @@ -83,6 +85,10 @@ viewLoc (Loc p a) = (p,a)
mapLoc :: (V a ~ V b) => (a -> b) -> Located a -> Located b
mapLoc f (Loc p a) = Loc p (f a)

-- | A lens giving access to the object within a 'Located' wrapper.
located :: (V a ~ V a') => Lens (Located a) (Located a') a a'
located f (Loc p a) = Loc p <$> f a

deriving instance (Eq (V a), Eq a ) => Eq (Located a)
deriving instance (Ord (V a), Ord a ) => Ord (Located a)
deriving instance (Show (V a), Show a) => Show (Located a)
Expand Down

0 comments on commit c0debab

Please sign in to comment.