diff options
| author | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-25 14:30:40 +0100 |
|---|---|---|
| committer | Simon Peyton Jones <simonpj@microsoft.com> | 2018-10-25 14:30:40 +0100 |
| commit | d85606d6dcc439a5d3e32da920cf605c13ce0781 (patch) | |
| tree | 117a55502afc2bd74814344b0a16689eda4fb3ce /compiler | |
| parent | a9a09b53c3f50df576564e8616b6dd4be029dcf6 (diff) | |
| download | haskell-d85606d6dcc439a5d3e32da920cf605c13ce0781.tar.gz | |
Fix comment in TcType
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/typecheck/TcType.hs | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/compiler/typecheck/TcType.hs b/compiler/typecheck/TcType.hs index 32026365b1..5bbaa0fe81 100644 --- a/compiler/typecheck/TcType.hs +++ b/compiler/typecheck/TcType.hs @@ -891,28 +891,13 @@ Note [Silly type synonym] Consider type T a = Int What are the free tyvars of (T x)? Empty, of course! -Here's the example that Ralf Laemmel showed me: - foo :: (forall a. C u a -> C u a) -> u - mappend :: Monoid u => u -> u -> u - - bar :: Monoid u => u - bar = foo (\t -> t `mappend` t) -We have to generalise at the arg to f, and we don't -want to capture the constraint (Monad (C u a)) because -it appears to mention a. Pretty silly, but it was useful to him. exactTyCoVarsOfType is used by the type checker to figure out exactly -which type variables are mentioned in a type. It's also used in the -smart-app checking code --- see TcExpr.tcIdApp - -On the other hand, consider a *top-level* definition - f = (\x -> x) :: T a -> T a -If we don't abstract over 'a' it'll get fixed to GHC.Prim.Any, and then -if we have an application like (f "x") we get a confusing error message -involving Any. So the conclusion is this: when generalising - - at top level use tyCoVarsOfType - - in nested bindings use exactTyCoVarsOfType -See Trac #1813 for example. +which type variables are mentioned in a type. It only matters +occasionally -- see the calls to exactTyCoVarsOfType. + +Historical note: years and years ago this function was used during +generalisation -- see Trac #1813. But that code has long since died. -} exactTyCoVarsOfType :: Type -> TyCoVarSet |
