lens 3.0.1 → 3.0.2
raw patch · 3 files changed
+33/−10 lines, 3 files
Files
- CHANGELOG.markdown +5/−0
- lens.cabal +2/−2
- src/Control/Lens/TH.hs +26/−8
CHANGELOG.markdown view
@@ -1,3 +1,8 @@+3.0.2+-----+* Added `generateSignatures` option to `Control.Lens.TH` to allow the end user to disable the generation of type signatures for the+ template-haskell generated lenses. This lets the user supply hand-written haddocks and more restricted signatures.+ 3.0.1 ----- * Added `Control.Lens.Type.simple`.
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses-version: 3.0.1+version: 3.0.2 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -62,7 +62,7 @@ You can define lenses such as . > -- bar :: Simple Lens (Foo a) Int- > bar :: Functor f => (Int -> f Int) -> Foo a -> f Foo a+ > bar :: Functor f => (Int -> f Int) -> Foo a -> f (Foo a) > bar f (Foo a b c) = fmap (\a' -> Foo a' b c) (f a) . > -- baz :: Lens (Foo a) (Foo b) a b
src/Control/Lens/TH.hs view
@@ -36,7 +36,17 @@ , lensClass , lensFlags , LensFlag(..)- , simpleLenses, partialLenses, buildTraversals, handleSingletons, singletonIso, singletonRequired, createClass, createInstance, classRequired, singletonAndField+ , simpleLenses+ , partialLenses+ , buildTraversals+ , handleSingletons+ , singletonIso+ , singletonRequired+ , createClass+ , createInstance+ , classRequired+ , singletonAndField+ , generateSignatures ) where import Control.Applicative@@ -75,6 +85,7 @@ | CreateClass | CreateInstance | ClassRequired+ | GenerateSignatures deriving (Eq,Ord,Show,Read) -- | Only Generate valid 'Simple' 'Lens' lenses.@@ -123,6 +134,13 @@ classRequired :: Simple Lens LensRules Bool classRequired = lensFlags.contains ClassRequired +-- | Indicate whether or not to supply the signatures for the generated lenses.+--+-- Disabling this can be useful if you want to provide a more restricted type signature+-- or if you want to supply hand-written haddocks.+generateSignatures :: Simple Lens LensRules Bool+generateSignatures = lensFlags.contains GenerateSignatures+ -- | This configuration describes the options we'll be using to make isomorphisms or lenses. data LensRules = LensRules { _lensIso :: String -> Maybe String@@ -157,7 +175,7 @@ -- | Default lens rules defaultRules :: LensRules defaultRules = LensRules top field (const Nothing) $- Set.fromList [SingletonIso, SingletonAndField, CreateClass, CreateInstance, BuildTraversals]+ Set.fromList [SingletonIso, SingletonAndField, CreateClass, CreateInstance, BuildTraversals, GenerateSignatures] where top (c:cs) = Just (toLower c:cs) top _ = Nothing@@ -379,10 +397,10 @@ if cfg^.simpleLenses then [aty,aty,cty,cty] else [aty,bty,cty,dty] body <- makeBody isoName dataConName makeIsoFrom makeIsoTo #ifndef INLINING- return [decl, body]+ return $ if cfg^.generateSignatures then [decl, body] else [body] #else inlining <- inlinePragma isoName- return [decl, body, inlining]+ return $ if cfg^.generateSignatures then [decl, body, inlining] else [body, inlining] #endif accessorDecls <- case mkName <$> (maybeFieldName >>= view lensField cfg . nameBase) of jfn@(Just lensName)@@ -392,10 +410,10 @@ else [cty,dty,aty,bty] body <- makeBody lensName dataConName makeIsoTo makeIsoFrom #ifndef INLINING- return [decl, body]+ return $ if cfg^.generateSignatures then [decl, body] else [body] #else inlining <- inlinePragma lensName- return [decl, body, inlining]+ return $ if cfg^.generateSignatures then [decl, body, inlining] else [body, inlining] #endif _ -> return [] return $ isoDecls ++ accessorDecls@@ -514,10 +532,10 @@ body <- makeFieldLensBody isTraversal lensName conList maybeMethodName #ifndef INLINING- return [decl, body]+ return $ if cfg^.generateSignatures then [decl, body] else [body] #else inlining <- inlinePragma lensName- return [decl, body, inlining]+ return $ if cfg^.generateSignatures then [decl, body, inlining] else [body, inlining] #endif let defs = Prelude.concat bodies case maybeLensClass of