data-lens-ixset 0.1.3 → 0.1.4
raw patch · 2 files changed
+19/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Lens/IxSet.hs +18/−9
- data-lens-ixset.cabal +1/−1
Data/Lens/IxSet.hs view
@@ -20,14 +20,23 @@ people\' = 'ixLens' (FirstName \"Simon\") '^%=' 'fmap' (lastName '^=' LastName \"Peyton-Jones\") '$' people @ +>>> people'+fromList [Person {_firstName = FirstName "Edward A.", _lastName = LastName "Kmett"}+ ,Person {_firstName = FirstName "Simon", _lastName = LastName "Peyton-Jones"}]+>>> (firstName ^$) <$> people' ^. ixLens (LastName "Peyton-Jones")+Just (FirstName "Simon")+>>> ixLens (LastName "Peyton-Jones") ^$ people+Nothing+ Perhaps more commonly you're working with an 'IxSet' from inside a state-monad such as with acid-state. In that case usage is even easier:+monad such as @Update@ from the @acid-state@ package. In that case usage+is even easier: @ changeLastName = 'ixLens' (FirstName \"Simon\") '%=' 'fmap' (lastName '^=' LastName \"Peyton-Jones\") @ -Here's the missing boilerplate:+Here's the missing boilerplate, which also needs the packages @data-lens-fd@ and @data-lens-template@: @ \{\-\# LANGUAGE DeriveDataTypeable \#\-\}@@ -39,17 +48,17 @@ import Data.Lens.IxSet import Data.Lens.Template +newtype FirstName = FirstName 'String'+ deriving ('Show', 'Eq', 'Ord', 'Data', 'Typeable')++newtype LastName = LastName 'String'+ deriving ('Show', 'Eq', 'Ord', 'Data', 'Typeable')+ data Person = Person { _firstName :: FirstName , _lastName :: LastName } deriving ('Show', 'Eq', 'Ord', 'Data', 'Typeable') -mkLens ''Person--newtype FirstName = FirstName String- deriving ('Show', 'Eq', 'Ord', 'Data', 'Typeable')--newtype LastName = LastName String- deriving ('Show', 'Eq', 'Ord', 'Data', 'Typeable')+makeLens ''Person instance 'Indexable' Person where empty = 'ixSet' [ 'ixGen' ('Proxy' :: 'Proxy' FirstName)
data-lens-ixset.cabal view
@@ -1,5 +1,5 @@ Name : data-lens-ixset-Version : 0.1.3+Version : 0.1.4 Synopsis : A Lens for IxSet Description : Integrates Data.IxSet with Data.Lens. Homepage : https://github.com/dag/data-lens-ixset