@@ -417,7 +417,6 @@ data PList
418 = TRecord TRecord Row Col
418 = TRecord TRecord Row Col
419 | TTuple TTuple Row Col
419 | TTuple TTuple Row Col
421 | TArrow Row Col
420 | TArrow Row Col
423 | TStart Row Col
422 | TStart Row Col
@@ -973,11 +972,11 @@ toDeclarationsReport source decl =
973 DeclSpace space row col ->
972 DeclSpace space row col ->
974 toSpaceReport source space row col
973 toSpaceReport source space row col
976− Port port row col ->
975+ Port port_ row col ->
977− error "TODO Port" port row col
976+ error "TODO Port" port_ row col
979 DeclType declType row col ->
978 DeclType declType row col ->
980− error "TODO DeclType" declType row col
979+ toDeclTypeReport source declType row col
982 DeclDef name declDef row col ->
981 DeclDef name declDef row col ->
983 toDeclDefReport source name declDef row col
982 toDeclDefReport source name declDef row col
@@ -989,6 +988,215 @@ toDeclarationsReport source decl =
989 error "TODO DeclFreshLineAfterDocComment" row col
988 error "TODO DeclFreshLineAfterDocComment" row col
995+toDeclTypeReport :: Code.Source -> DeclType -> Row -> Col -> Report.Report
996+toDeclTypeReport source declType startRow startCol =
998+ DT_Space space row col ->
999+ toSpaceReport source space row col
1003+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1004+ region = toRegion row col
1006+ Report.Report "EXPECTING TYPE NAME" region [] $
1007+ Code.toSnippet source surroundings (Just region)
1010+ "I think I am parsing a type declaration, but I got stuck here:"
1014+ ["I","was","expecting","a","name","like",D.dullyellow "Status","or",D.dullyellow "Style"
1015+ ,"next.","Just","make","sure","it","is","a","name","that","starts","with","a","capital","letter!"
1021+ DT_Alias typeAlias row col ->
1022+ toTypeAliasReport source typeAlias row col
1024+ DT_Union customType row col ->
1025+ toCustomTypeReport source customType row col
1027+ DT_IndentName row col ->
1029+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1030+ region = toRegion row col
1032+ Report.Report "EXPECTING TYPE NAME" region [] $
1033+ Code.toSnippet source surroundings (Just region)
1036+ "I think I am parsing a type declaration, but I got stuck here:"
1040+ ["I","was","expecting","a","name","like",D.dullyellow "Status","or",D.dullyellow "Style"
1041+ ,"next.","Just","make","sure","it","is","a","name","that","starts","with","a","capital","letter!"
1048+toTypeAliasReport :: Code.Source -> TypeAlias -> Row -> Col -> Report.Report
1049+toTypeAliasReport source typeAlias startRow startCol =
1051+ AliasSpace space row col ->
1052+ toSpaceReport source space row col
1054+ AliasName row col ->
1056+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1057+ region = toRegion row col
1059+ Report.Report "EXPECTING TYPE ALIAS NAME" region [] $
1060+ Code.toSnippet source surroundings (Just region)
1063+ "I think I am parsing a type alias, but I got stuck here:"
1067+ ["I","was","expecting","a","name","like",D.dullyellow "Person","or",D.dullyellow "Point"
1068+ ,"next.","Just","make","sure","it","is","a","name","that","starts","with","a","capital","letter!"
1074+ AliasEquals row col ->
1075+ error "TODO AliasEquals" row col
1077+ AliasBody tipe row col ->
1078+ toTypeReport source tipe row col
1080+ AliasIndentEquals row col ->
1081+ error "TODO AliasIndentEquals" row col
1083+ AliasIndentBody row col ->
1085+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1086+ region = toRegion row col
1088+ Report.Report "UNFINISHED TYPE ALIAS" region [] $
1089+ Code.toSnippet source surroundings (Just region)
1092+ "I am partway through parsing a type alias, but I got stuck here:"
1096+ ["I","was","expecting","to","see","a","type","next.","Something","as","simple"
1097+ ,"as",D.dullyellow "Int","or",D.dullyellow "Float","would","work!"
1104+typeAliasNote :: D.Doc
1108+ "Here is an example of a valid `type alias` for reference:"
1110+ [ D.indent 0 $ D.fillSep [D.cyan "type",D.cyan "alias",D.green "Person","="]
1111+ , D.indent 2 $ D.vcat $
1114+ ,", height : Float"
1119+ "This would let us use `Person` as a shorthand for that record type. Using this\
1120+ \ shorthand makes type annotations much easier to read, and makes changing code\
1121+ \ easier if you decide later that there is more to a person than age and height!"
1125+toCustomTypeReport :: Code.Source -> CustomType -> Row -> Col -> Report.Report
1126+toCustomTypeReport source customType startRow startCol =
1128+ CT_Space space row col ->
1129+ toSpaceReport source space row col
1133+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1134+ region = toRegion row col
1136+ Report.Report "EXPECTING TYPE NAME" region [] $
1137+ Code.toSnippet source surroundings (Just region)
1140+ "I think I am parsing a type declaration, but I got stuck here:"
1144+ ["I","was","expecting","a","name","like",D.dullyellow "Status","or",D.dullyellow "Style"
1145+ ,"next.","Just","make","sure","it","is","a","name","that","starts","with","a","capital","letter!"
1151+ CT_Equals row col ->
1152+ error "TODO CT_Equals" row col
1155+ error "TODO CT_Bar" row col
1157+ CT_Variant row col ->
1158+ error "TODO CT_Variant" row col
1160+ CT_VariantArg tipe row col ->
1161+ toTypeReport source tipe row col
1163+ CT_IndentEquals row col ->
1164+ error "TODO CT_IndentEquals" row col
1166+ CT_IndentBar row col ->
1167+ error "TODO CT_IndentBar" row col
1169+ CT_IndentAfterBar row col ->
1170+ error "TODO CT_IndentAfterBar" row col
1172+ CT_IndentAfterEquals row col ->
1173+ error "TODO CT_IndentAfterEquals" row col
1176+customTypeNote :: D.Doc
1180+ "Here is an example of a valid `type` declaration for reference:"
1182+ [ D.indent 0 $ D.fillSep [D.cyan "type",D.green "Status"]
1183+ , D.indent 2 $ D.fillSep ["=","Failure"]
1184+ , D.indent 2 $ D.fillSep ["|","Waiting"]
1185+ , D.indent 2 $ D.fillSep ["|","Success","String"]
1188+ "This defines a new `Status` type with three variants. This could be useful if\
1189+ \ we are waiting for an HTTP request. Maybe we start with `Waiting` and then\
1190+ \ switch to `Failure` or `Success \"message from server\"` depending on how\
1191+ \ things go. Notice that the Success variant has some associated data, allowing\
1192+ \ us to store a String if the request goes well!"
992toDeclDefReport :: Code.Source -> Name.Name -> DeclDef -> Row -> Col -> Report.Report
1200toDeclDefReport :: Code.Source -> Name.Name -> DeclDef -> Row -> Col -> Report.Report
993toDeclDefReport source name declDef startRow startCol =
1201toDeclDefReport source name declDef startRow startCol =
994 case declDef of
1202 case declDef of
@@ -1063,7 +1271,7 @@ toDeclDefReport source name declDef startRow startCol =
1065 DeclDefType tipe row col ->
1273 DeclDefType tipe row col ->
1066− error "TODO DeclDefType" toTypeReport tipe row col
1274+ toTypeReport source tipe row col
1068 DeclDefArg pattern row col ->
1276 DeclDefArg pattern row col ->
1069 toPatternReport source PArg pattern row col
1277 toPatternReport source PArg pattern row col
@@ -3400,6 +3608,8 @@ toPListReport source context list startRow startCol =
3611+-- TODO add context? say something special if you are in type annotation vs custom type vs type alias?
3403toTypeReport :: Code.Source -> Type -> Row -> Col -> Report.Report
3613toTypeReport :: Code.Source -> Type -> Row -> Col -> Report.Report
3404toTypeReport source tipe startRow startCol =
3614toTypeReport source tipe startRow startCol =
3405 case tipe of
3615 case tipe of
@@ -3409,14 +3619,11 @@ toTypeReport source tipe startRow startCol =
3409 TTuple tuple row col ->
3619 TTuple tuple row col ->
3410 toTTupleReport source tuple row col
3620 toTTupleReport source tuple row col
3412− TVariant row col ->
3413− error "TODO TVariant" row col startRow startCol
3415 TArrow row col ->
3622 TArrow row col ->
3416 error "TODO TArrow" row col
3623 error "TODO TArrow" row col
3418 TStart row col ->
3625 TStart row col ->
3419− error "TODO TStart" row col
3626+ error "TODO TStart" row col startRow startCol
3421 TSpace space row col ->
3628 TSpace space row col ->
3422 toSpaceReport source space row col
3629 toSpaceReport source space row col