Skip to content
Snippets Groups Projects
  1. Feb 06, 2024
    • Andrei Borzenkov's avatar
      Lazy skolemisation for @a-binders (#17594) · f5d3e03c
      Andrei Borzenkov authored and Marge Bot's avatar Marge Bot committed
      This patch is a preparation for @a-binders implementation.  The main changes are:
      
      * Skolemisation is now prepared to deal with @binders.
        See Note [Skolemisation overview] in GHC.Tc.Utils.Unify.
        Most of the action is in
          - Utils.Unify.matchExpectedFunTys
          - Gen.Pat.tcMatchPats
          - Gen.Expr.tcPolyExprCheck
          - Gen.Binds.tcPolyCheck
      
      Some accompanying refactoring:
      
      * I found that funTyConAppTy_maybe was doing a lot of allocation, and
        rejigged userTypeError_maybe to avoid calling it.
      f5d3e03c
  2. Dec 06, 2023
    • Vladislav Zavialov's avatar
      T2T in Patterns (#23739) · 0f0c53a5
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements the T2T (term-to-type) transformation in patterns.
      Patterns that are checked against a visible forall can now be written
      without the `type` keyword:
      
      	  \(type t) (x :: t) -> ...   -- old
      	  \t (x :: t) -> ...          -- new
      
      The `t` binder is parsed and renamed as a term pattern (Pat), but
      then undergoes a conversion to a type pattern (HsTyPat).
      See the new function pat_to_type_pat in compiler/GHC/Tc/Gen/Pat.hs
      0f0c53a5
  3. Nov 30, 2023
  4. Nov 26, 2023
    • Vladislav Zavialov's avatar
      Term variable capture (#23740) · d1bf25c7
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch changes type variable lookup rules (lookupTypeOccRn) and
      implicit quantification rules (filterInScope) so that variables bound
      in the term namespace can be captured at the type level
      
        {-# LANGUAGE RequiredTypeArguments #-}
        f1 x = g1 @x                -- `x` used in a type application
        f2 x = g2 (undefined :: x)  -- `x` used in a type annotation
        f3 x = g3 (type x)          -- `x` used in an embedded type
        f4 x = ...
          where g4 :: x -> x        -- `x` used in a type signature
                g4 = ...
      
      This change alone does not allow us to accept examples shown above,
      but at least it gets them past the renamer.
      d1bf25c7
  5. Nov 03, 2023
    • Vladislav Zavialov's avatar
      T2T in Expressions (#23738) · 0dfb1fa7
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements the T2T (term-to-type) transformation in
      expressions. Given a function with a required type argument
      	vfun :: forall a -> ...
      
      the user can now call it as
      	vfun (Maybe Int)
      
      instead of
      	vfun (type (Maybe Int))
      
      The Maybe Int argument is parsed and renamed as a term (HsExpr), but then
      undergoes a conversion to a type (HsType).
      See the new function expr_to_type in compiler/GHC/Tc/Gen/App.hs
      and Note [RequiredTypeArguments and the T2T mapping]
      
      Left as future work: checking for puns.
      0dfb1fa7
  6. Jul 23, 2023
    • Vladislav Zavialov's avatar
      Visible forall in types of terms: Part 1 (#22326) · 33b6850a
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements part 1 of GHC Proposal #281,
      introducing explicit `type` patterns and `type` arguments.
      
      Summary of the changes:
      
      1. New extension flag:
           RequiredTypeArguments
      
      2. New user-facing syntax:
           `type p` patterns    (represented by EmbTyPat)
           `type e` expressions (represented by HsEmbTy)
      
      3. Functions with required type arguments (visible forall)
         can now be defined and applied:
            idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
            idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
            x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)
      
      4. template-haskell support:
            TH.TypeE corresponds to HsEmbTy
            TH.TypeP corresponds to EmbTyPat
      
      5. Test cases and a new User's Guide section
      
      Changes *not* included here are the t2t (term-to-type) transformation
      and term variable capture; those belong to part 2.
      33b6850a
Loading