microlens-th 0.2.2.0 → 0.3.0.0
raw patch · 3 files changed
+18/−14 lines, 3 filesdep ~microlensPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: microlens
API changes (from Hackage documentation)
- Lens.Micro.TH: type Getter s a = forall r. Getting r s a
- Lens.Micro.TH: type Fold s a = forall r. Applicative (Const r) => Getting r s a
Files
- CHANGELOG.md +4/−0
- microlens-th.cabal +2/−2
- src/Lens/Micro/TH.hs +12/−12
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 0.3.0.0++* `SimpleGetter` and `SimpleFold` are no longer reexported.+ # 0.2.2.0 * Moved `Getter` and `Fold` from this package to microlens (they're in `Lens.Micro.Extras`).
microlens-th.cabal view
@@ -1,5 +1,5 @@ name: microlens-th-version: 0.2.2.0+version: 0.3.0.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).@@ -31,7 +31,7 @@ -- other-modules: -- other-extensions: build-depends: base >=4.5 && <5- , microlens >=0.3.5 && <0.4+ , microlens >=0.4.0 && <0.5 , containers >=0.4.0 && <0.6 -- lens has >=2.4, but GHC 7.4 shipped with 2.7 , template-haskell >=2.7 && <2.12
src/Lens/Micro/TH.hs view
@@ -22,10 +22,8 @@ -- * Using this module in GHCi -- $ghci-note - -- * Exports of @Getter@ and @Fold@- -- $compat-note- Getter,- Fold,+ -- * 'SimpleGetter' and 'SimpleFold'+ -- $getter-fold-note -- * Making lenses makeLenses,@@ -64,7 +62,6 @@ import Data.List (nub, findIndices, stripPrefix, isPrefixOf) import Data.Maybe import Lens.Micro-import Lens.Micro.Extras (Getter, Fold) import Lens.Micro.Internal (phantom) import Language.Haskell.TH @@ -72,6 +69,7 @@ import Data.Traversable (traverse, sequenceA) #endif + {- $errors-note When you use Template Haskell, the order of declarations suddenly starts to matter. For instance, if you try to use 'makeLenses', 'makeFields', etc before the type is defined, you'll get a “not in scope” error:@@ -133,9 +131,11 @@ @ -} -{- $compat-note+{- $getter-fold-note -When updates aren't allowed, or when a field simply can't be updated (for instance, in the presence of @forall@), instead of 'Lens' and 'Traversal' we generate 'Getter' and 'Fold', which come from "Lens.Micro.Extras" and are reexported here. These aren't true @Getter@ and @Fold@ from lens – they're not sufficiently polymorphic. Beware. (Still, they're compatible, it's just that you can't do some things with them that you can do with original ones.)+When updates are forbidden (by using 'generateUpdateableOptics'), or when a field simply can't be updated (for instance, in the presence of @forall@), instead of 'Lens' and 'Traversal' we generate 'SimpleGetter' and 'SimpleFold'. These aren't true @Getter@ and @Fold@ from lens, so beware. (Still, they're compatible, it's just that you can't do some things with them that you can do with original ones – for instance, @backwards@ and @takingWhile@ don't work on 'SimpleFold'.)++If you want to export true folds, it's recommended that you depend on <http://hackage.haskell.org/package/microlens-contra microlens-contra>, use 'makeLensesFor' to generate 'SimpleFold's with prefixes, and then export versions of those folds with @<http://hackage.haskell.org/package/microlens-contra/docs/Lens-Micro-Contra.html#v:fromSimpleFold fromSimpleFold>@ applied. -} -- Lens functions which would've been in Lens.Micro if it wasn't “micro”@@ -421,7 +421,7 @@ fmap (\x -> r { _generateSigs = x}) (f (_generateSigs r)) {- |-Generate “updateable” optics. When turned off, 'Fold's will be generated instead of 'Traversal's and 'Getter's will be generated instead of 'Lens'es.+Generate “updateable” optics. When turned off, 'SimpleFold's will be generated instead of 'Traversal's and 'SimpleGetter's will be generated instead of 'Lens'es. This option is enabled by default. Disabling it can be useful for types with invariants (also known as “types with smart constructors”) – if you generate updateable optics, anyone would be able to use them to break your invariants. -}@@ -744,14 +744,14 @@ let defType | Just (_,cx,a') <- a ^? _ForallT =- let optic | lensCase = ''Getter- | otherwise = ''Fold+ let optic | lensCase = ''SimpleGetter+ | otherwise = ''SimpleFold in OpticSa cx optic s' a' -- Getter and Fold are always simple | not (_allowUpdates rules) =- let optic | lensCase = ''Getter- | otherwise = ''Fold+ let optic | lensCase = ''SimpleGetter+ | otherwise = ''SimpleFold in OpticSa [] optic s' a -- Generate simple Lens and Traversal where possible