Permalink
Browse files

More consistent behavior for `typeVars` and `substType` with regards …

…to binders. (#67)
  • Loading branch information...
1 parent d7fc01f commit d0c562019a18ab0e016a4304eb7aad5f680066dd @ekmett committed Oct 15, 2012
Showing with 9 additions and 2 deletions.
  1. +5 −0 CHANGELOG.markdown
  2. +1 −1 lens.cabal
  3. +3 −1 src/Language/Haskell/TH/Lens.hs
View
@@ -1,3 +1,8 @@
+3.0.3
+-----
+* Refined the behavior of `substType` in `Control.Lens.TH` to match the behavior of `typeVarsEx` when moving under binders.
+
+
3.0.2
-----
* Added `generateSignatures` option to `Control.Lens.TH` to allow the end user to disable the generation of type signatures for the
View
@@ -1,6 +1,6 @@
name: lens
category: Data, Lenses
-version: 3.0.2
+version: 3.0.3
license: BSD3
cabal-version: >= 1.8
license-file: LICENSE
@@ -28,6 +28,7 @@ module Language.Haskell.TH.Lens
import Control.Applicative
import Control.Lens.Getter
import Control.Lens.Setter
+import Control.Lens.Fold
import Control.Lens.Type
import Control.Lens.Traversal
import Control.Lens.IndexedLens
@@ -104,7 +105,8 @@ class SubstType t where
instance SubstType Type where
substType m t@(VarT n) = fromMaybe t (m^.at n)
- substType m (ForallT bs ctx ty) = ForallT bs (substType m ctx) (substType m ty)
+ substType m (ForallT bs ctx ty) = ForallT bs (substType m' ctx) (substType m' ty)
+ where m' = foldrOf typeVars Map.delete m bs
substType m (SigT t k) = SigT (substType m t) k
substType m (AppT l r) = AppT (substType m l) (substType m r)
substType _ t = t

0 comments on commit d0c5620

Please sign in to comment.