From 4ad8ce0b5c741862e2f94fd362077068b9b669d3 Mon Sep 17 00:00:00 2001 From: sheaf <sam.derbyshire@gmail.com> Date: Fri, 25 Feb 2022 12:11:01 +0100 Subject: GHCi: don't normalise partially instantiated types This patch skips performing type normalisation when we haven't fully instantiated the type. That is, in tcRnExpr (used only for :type in GHCi), skip normalisation if the result type responds True to isSigmaTy. Fixes #20974 --- docs/users_guide/ghci.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index cb98b15f6a..c26dedb5c3 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -2981,13 +2981,19 @@ commonly used commands. Infers and prints the type of ⟨expression⟩. For polymorphic types it instantiates the 'inferred' forall quantifiers (but not the - 'specified' ones; see :ref:`inferred-vs-specified`), solves constraints, and re-generalises. + 'specified' ones; see :ref:`inferred-vs-specified`), solves constraints, + re-generalises, and then reduces type families as much as possible. .. code-block:: none *X> :type length length :: Foldable t => t a -> Int + Type family reduction is skipped if the function is not fully instantiated, + as this has been observed to give more intuitive results. + You may want to use :ghci-cmd:`:info` if you are not applying any arguments, + as that will return the original type of the function without instantiating. + .. ghci-cmd:: :type +d; ⟨expression⟩ Infers and prints the type of ⟨expression⟩, instantiating *all* the forall -- cgit v1.2.1