commit ghc-microlens-th for openSUSE:Factory
![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package ghc-microlens-th for openSUSE:Factory checked in at 2016-11-10 13:25:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-microlens-th (Old) and /work/SRC/openSUSE:Factory/.ghc-microlens-th.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "ghc-microlens-th" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-microlens-th/ghc-microlens-th.changes 2016-11-02 12:36:38.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-microlens-th.new/ghc-microlens-th.changes 2016-11-10 13:25:26.000000000 +0100 @@ -1,0 +2,10 @@ +Sun Aug 21 17:10:55 UTC 2016 - psimons@suse.com + +- Update to version 0.4.1.0 revision 0 with cabal2obs. + +------------------------------------------------------------------- +Wed Aug 17 18:28:55 UTC 2016 - psimons@suse.com + +- Update to version 0.4.0.1 revision 0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- microlens-th-0.4.0.0.tar.gz New: ---- microlens-th-0.4.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-microlens-th.spec ++++++ --- /var/tmp/diff_new_pack.TAmjOM/_old 2016-11-10 13:25:27.000000000 +0100 +++ /var/tmp/diff_new_pack.TAmjOM/_new 2016-11-10 13:25:27.000000000 +0100 @@ -18,21 +18,19 @@ %global pkg_name microlens-th Name: ghc-%{pkg_name} -Version: 0.4.0.0 +Version: 0.4.1.0 Release: 0 Summary: Automatic generation of record lenses for microlens License: BSD-3-Clause -Group: System/Libraries +Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel -# Begin cabal-rpm deps: BuildRequires: ghc-containers-devel BuildRequires: ghc-microlens-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-template-haskell-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build -# End cabal-rpm deps %description This package lets you automatically generate lenses for data types; code was @@ -58,15 +56,12 @@ %prep %setup -q -n %{pkg_name}-%{version} - %build %ghc_lib_build - %install %ghc_lib_install - %post devel %ghc_pkg_recache ++++++ microlens-th-0.4.0.0.tar.gz -> microlens-th-0.4.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/microlens-th-0.4.0.0/CHANGELOG.md new/microlens-th-0.4.1.0/CHANGELOG.md --- old/microlens-th-0.4.0.0/CHANGELOG.md 2016-04-09 20:06:12.000000000 +0200 +++ new/microlens-th-0.4.1.0/CHANGELOG.md 2016-08-15 11:34:35.000000000 +0200 @@ -1,3 +1,11 @@ +# 0.4.1.0 + +* Added `abbreviatedFields`. + +# 0.4.0.1 + +* Ported a lens commit that (probably) makes lens generation deterministic. See [this issue](https://github.com/aelve/microlens/issues/83). + # 0.4.0.0 * Added `makeClassy` (and `createClass`). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/microlens-th-0.4.0.0/microlens-th.cabal new/microlens-th-0.4.1.0/microlens-th.cabal --- old/microlens-th-0.4.0.0/microlens-th.cabal 2016-04-09 20:06:12.000000000 +0200 +++ new/microlens-th-0.4.1.0/microlens-th.cabal 2016-08-15 11:34:41.000000000 +0200 @@ -1,5 +1,5 @@ name: microlens-th -version: 0.4.0.0 +version: 0.4.1.0 synopsis: Automatic generation of record lenses for microlens description: This package lets you automatically generate lenses for data types; code was extracted from the lens package, and therefore generated lenses are fully compatible with ones generated by lens (and can be used both from lens and microlens). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/microlens-th-0.4.0.0/src/Lens/Micro/TH.hs new/microlens-th-0.4.1.0/src/Lens/Micro/TH.hs --- old/microlens-th-0.4.0.0/src/Lens/Micro/TH.hs 2016-04-09 20:06:12.000000000 +0200 +++ new/microlens-th-0.4.1.0/src/Lens/Micro/TH.hs 2016-08-15 11:31:54.000000000 +0200 @@ -44,6 +44,7 @@ lensRulesFor, classyRules, camelCaseFields, + abbreviatedFields, -- * Configuring lens rules lensField, @@ -61,7 +62,6 @@ import Data.Char import Data.Data import Data.Either -import Data.Foldable (toList) import qualified Data.Map as Map import Data.Map (Map) import Data.Monoid @@ -376,7 +376,7 @@ If you only want to make lenses for some fields, you can prefix them with underscores – the rest would be untouched. If no fields are prefixed with underscores, lenses would be created for all fields. -The prefix must be the same as the name of the name of the data type (/not/ the constructor). +The prefix must be the same as the name of the name of the data type (/not/ the constructor). If you don't like this behavior, use @'makeLensesWith' 'abbreviatedFields'@ – it allows any prefix (and even different prefixes). If you want to use 'makeFields' on types declared in different modules, you can do it, but then you would have to export the @Has*@ classes from one of the modules – 'makeFields' creates a class if it's not in scope yet, so the class must be in scope or else there would be duplicate classes and you would get an “Ambiguous occurrence” error. @@ -638,6 +638,36 @@ computeMethod (x:xs) | isUpper x = Just (toLower x : xs) computeMethod _ = Nothing +{- | +Like standard rules used by 'makeFields', but doesn't put any restrictions on the prefix. I.e. if you have fields called + +* @_fooBarBaz@ +* @_someX@ +* @someY@ + +then the generated lenses would be called @barBaz@ and @x@. +-} +abbreviatedFields :: LensRules +abbreviatedFields = defaultFieldRules { _fieldToDef = abbreviatedNamer } + +abbreviatedNamer :: Name -> [Name] -> Name -> [DefName] +abbreviatedNamer _ fields field = maybeToList $ do + + fieldPart <- stripMaxLc (nameBase field) + method <- computeMethod fieldPart + let cls = "Has" ++ fieldPart + return (MethodName (mkName cls) (mkName method)) + + where + stripMaxLc f = do x <- stripPrefix optUnderscore f + case break isUpper x of + (p,s) | null p || null s -> Nothing + | otherwise -> Just s + optUnderscore = ['_' | any (isPrefixOf "_" . nameBase) fields ] + + computeMethod (x:xs) | isUpper x = Just (toLower x : xs) + computeMethod _ = Nothing + defaultFieldRules :: LensRules defaultFieldRules = LensRules { _simpleLenses = True @@ -1262,9 +1292,7 @@ ------------------------------------------------------------------------ {- | -Rules used to generate lenses. You can't create them from scratch, but you can customise already existing ones with lenses in the “Configuring lens rules” section. - -For an example, see 'makeLensesWith'. +Rules used to generate lenses. The fields are intentionally not exported; to create your own rules, see lenses in the “Configuring lens rules” section. You'd have to customise one of the existing rulesets; for an example of doing that, see 'makeLensesWith'. -} data LensRules = LensRules { _simpleLenses :: Bool @@ -1295,16 +1323,17 @@ -- Template Haskell wants type variables declared in a forall, so -- we find all free type variables in a given type and declare them. quantifyType :: Cxt -> Type -> Type -quantifyType c t = ForallT vs c t - where - vs = map PlainTV (toList (setOf typeVars t)) +quantifyType = quantifyType' Set.empty -- This function works like 'quantifyType' except that it takes -- a list of variables to exclude from quantification. quantifyType' :: Set Name -> Cxt -> Type -> Type quantifyType' exclude c t = ForallT vs c t where - vs = map PlainTV (toList (setOf typeVars t Set.\\ exclude)) + vs = map PlainTV + $ filter (`Set.notMember` exclude) + $ nub -- stable order + $ toListOf typeVars t ------------------------------------------------------------------------
participants (1)
-
root@hilbert.suse.de