@@ -37,7 +37,7 @@ data Error
37 = Mismatch Mismatch
37 = Mismatch Mismatch
38 | BadMain Type.Canonical
38 | BadMain Type.Canonical
39 | BadFlags Type.Canonical (Maybe Text)
39 | BadFlags Type.Canonical (Maybe Text)
40− | InfiniteType Text Type.Canonical
40+ | InfiniteType (Either Hint Text) Type.Canonical
43data Mismatch = MismatchInfo
43data Mismatch = MismatchInfo
@@ -111,8 +111,8 @@ toReport localizer err =
111 Mismatch info ->
111 Mismatch info ->
112 mismatchToReport localizer info
112 mismatchToReport localizer info
114− InfiniteType name overallType ->
114+ InfiniteType context overallType ->
115− infiniteTypeToReport localizer name overallType
115+ infiniteTypeToReport localizer context overallType
117 BadMain tipe ->
117 BadMain tipe ->
118 Report.report
118 Report.report
@@ -960,25 +960,112 @@ padTypo arrow maxLen (missingField, knownField) =
960-- INFINITE TYPES
960-- INFINITE TYPES
963−infiniteTypeToReport
963+infiniteTypeToReport :: RenderType.Localizer -> Either Hint Text -> Type.Canonical -> Report.Report
964− :: RenderType.Localizer
968−infiniteTypeToReport localizer name overallType =
964+infiniteTypeToReport localizer context overallType =
966+ (maybeRegion, description) =
969+ ( Nothing, functionName name )
969− Report.report
973+ Report.report
970− "INFINITE TYPE"
974+ "INFINITE TYPE"
971− Nothing
975+ maybeRegion
972− ( "I am inferring a weird self-referential type for " <> functionName name
976+ ( "I am inferring a weird self-referential type for " <> description <> ":"
975− [ reflowParagraph $
979+ [ reflowParagraph $
976− "Here is my best effort at writing down the type. You will see ? and ∞ for\
980+ "Here is my best effort at writing down the type. You will see ∞ for\
977− \ parts of the type that repeat something already printed out infinitely."
981+ \ parts of the type that repeat something already printed out infinitely."
978− , indent 4 (RenderType.toDoc localizer overallType)
982+ , indent 4 (RenderType.toDoc localizer overallType)
979− , reflowParagraph $
983+ , reflowParagraph $
980− "Usually staring at the type is not so helpful in these cases, so definitely\
984+ "Usually staring at the type is not so helpful in these cases, so definitely\
981− \ read the debugging hints for ideas on how to figure this out: "
985+ \ read the debugging hints for ideas on how to figure this out: "
982− <> Help.hintLink "infinite-type"
986+ <> Help.hintLink "infinite-type"
991+infiniteHint :: Hint -> (Maybe Region.Region, Text)
994+ CaseBranch n region ->
995+ ( Just region, "the " <> ordinalize n <> " `case` branch" )
998+ ( Nothing, "this `case` expression" )
1001+ ( Nothing, "the `if` condition" )
1004+ ( Nothing, "the `if` branches" )
1006+ MultiIfBranch n region ->
1007+ ( Just region, "the " <> ordinalize n <> " `if` branch" )
1010+ ( Nothing, "this `if` expression" )
1013+ ( Nothing, "this list" )
1015+ ListElement n region ->
1016+ ( Just region, "the " <> ordinalize n <> " list entry" )
1018+ BinopLeft _ region ->
1019+ ( Just region, "the left argument" )
1021+ BinopRight _ region ->
1022+ ( Just region, "the right argument" )
1025+ ( Nothing, "this expression" )
1027+ Function maybeName ->
1028+ ( Nothing, maybeFuncName maybeName )
1030+ UnexpectedArg maybeName 1 1 region ->
1031+ ( Just region, "the argument to " <> maybeFuncName maybeName )
1033+ UnexpectedArg maybeName index _total region ->
1034+ ( Just region, "the " <> ordinalize index <> " argument to " <> maybeFuncName maybeName )
1036+ FunctionArity maybeName _ _ region ->
1037+ ( Just region, maybeFuncName maybeName )
1039+ ReturnType name _ _ region ->
1040+ ( Just region, functionName name )
1043+ ( Nothing, functionName name )
1049+ ( Nothing, "this pattern" )
1052+ ( Nothing, "this shader" )
1055+ ( Nothing, "this anonymous function" )
1058+ ( Nothing, "this field access" )
1061+ ( Nothing, "this record" )
1063+ -- effect manager problems
1065+ ( Nothing, functionName name )
1068+ ( Nothing, functionName name )
1071+ ( Nothing, "this code" )