packages feed

microlens-th 0.2.1.0 → 0.2.1.1

raw patch · 3 files changed

+86/−10 lines, 3 filesdep ~microlensPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: microlens

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,6 +1,11 @@+# 0.2.1.1++* Bumped microlens version again.+ # 0.2.1.0 -* Bumped `base` version.+* Bumped base version.+* Bumped microlens version.  # 0.2.0.0 
microlens-th.cabal view
@@ -1,11 +1,10 @@ name:                microlens-th-version:             0.2.1.0+version:             0.2.1.1 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).+  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).+  .+  This package is a part of the <http://hackage.haskell.org/package/microlens microlens> family; see the readme <https://github.com/aelve/microlens#readme on Github>. license:             BSD3 license-file:        LICENSE author:              Artyom@@ -32,7 +31,7 @@   -- other-modules:          -- other-extensions:       build-depends:       base >=4.5 && <5-                     , microlens >=0.1 && <0.3+                     , microlens >=0.1 && <0.4                      , containers >=0.4.0 && <0.6                      -- lens has >=2.4, but GHC 7.4 shipped with 2.7                      , template-haskell >=2.7 && <2.11
src/Lens/Micro/TH.hs view
@@ -13,22 +13,33 @@ #define MIN_VERSION_containers(x,y,z) 1 #endif + module Lens.Micro.TH (-  -- $compatnote+  -- * Dealing with “not in scope” errors+  -- $errors-note++  -- * Using this module in GHCi+  -- $ghci-note+  +  -- * Types for compatibility+  -- $compat-note   Getter,   Fold,+   -- * Making lenses   makeLenses,   makeLensesFor,   makeLensesWith,   makeFields,+   -- * Default lens rules   LensRules,   DefName(..),   lensRules,   lensRulesFor,   camelCaseFields,+   -- * Configuring lens rules   lensField,   simpleLenses,@@ -38,6 +49,7 @@ ) where + import           Control.Applicative import           Control.Monad import           Data.Char@@ -58,9 +70,69 @@ import           Data.Traversable (traverse, sequenceA) #endif +{- $errors-note -{- $compatnote+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: +@+'makeLenses' ''Foo++data Foo = Foo {_foo :: Int}+@++@+Not in scope: type constructor or class ‘Foo’ …+    In the Template Haskell quotation ''Foo+@++You can't refer to generated lenses before you call 'makeLenses', either:++@+data Foo = Foo {_foo :: Int}++bar :: Lens' Foo Int+bar = foo++'makeLenses' ''Foo+@++@+Not in scope: ‘foo’ …+    Perhaps you meant one of these:+      data constructor ‘Foo’ (line 1), ‘_foo’ (line 1)+@+-}++{- $ghci-note++You can use 'makeLenses' and friends to define lenses right from GHCi, but it's slightly tricky.++First, enable Template Haskell:++>>> :set -XTemplateHaskell++Then define a bogus type (you can use any name in place of @M@, and you can use the same name many times), and follow the definition by the actual Template Haskell command you want to use:++>>> data M; makeLenses ''Foo++This will generate lenses for @Foo@ and you'll be able to use them from GHCi.++If you want, you can define the type and lenses for it simultaneously with @:{@ an @:}@:++@+>>> :{+data Foobar = Foobar {+  _foo :: Int,+  _bar :: Bool }+  deriving (Eq, Show)++makeLenses ''Foobar+:}+@+-}++{- $compat-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'. 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.) -} @@ -125,7 +197,7 @@ \{\-\# LANGUAGE TemplateHaskell \#\-\} @ -Then, after declaring the datatype (let's say @Foo@), add @makeLenses ''Foo@ on a separate line:+Then, after declaring the datatype (let's say @Foo@), add @makeLenses ''Foo@ on a separate line (if you do it before the type is declared, you'll get a “not in scope” error – see the section at the top of this page):  @ data Foo = Foo {