generic-accessors 0.4.0 → 0.4.1
raw patch · 3 files changed
+16/−6 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Accessors: flatten' :: AccessorTree a -> [([String], Getter a, Setter a)]
Files
- CHANGELOG.md +4/−0
- generic-accessors.cabal +1/−1
- src/Accessors.hs +11/−5
CHANGELOG.md view
@@ -15,3 +15,7 @@ --- * Revive convenience show functions * Ints and Bools are no longer shown as floats++0.4.1+---+* add version of flatten which returns name as [String]
generic-accessors.cabal view
@@ -1,5 +1,5 @@ name: generic-accessors-version: 0.4.0+version: 0.4.1 synopsis: stringly-named getters for generic data license: BSD3 license-file: LICENSE
src/Accessors.hs view
@@ -13,6 +13,7 @@ , Getter(..) , accessors , flatten+ , flatten' , showTree , showFlat ) where@@ -66,13 +67,18 @@ showMsgs = intercalate "." flatten :: AccessorTree a -> [(String, Getter a, Setter a)]-flatten = flatten' []+flatten = map f . flatten'+ where+ f (x,y,z) = (showMsgs x, y, z) -flatten' :: [String] -> AccessorTree a -> [(String, Getter a, Setter a)]-flatten' msgs (ATGetter (get, set)) = [(showMsgs (reverse msgs), get, set)]-flatten' msgs (Data (_,_) trees) = concatMap f trees+flatten' :: AccessorTree a -> [([String], Getter a, Setter a)]+flatten' = flattenChain [] where- f (name,tree) = flatten' (name:msgs) tree+ flattenChain :: [String] -> AccessorTree a -> [([String], Getter a, Setter a)]+ flattenChain msgs (ATGetter (get, set)) = [(reverse msgs, get, set)]+ flattenChain msgs (Data (_,_) trees) = concatMap f trees+ where+ f (name,tree) = flattenChain (name:msgs) tree -- | Things which you can make a tree of labeled getters for. -- You should derive this using GHC.Generics.