on master help sign in
Detect when there are super similarities

So if something is a number it will not complain about a “clash” with an Int or Float simply because unification did not get to it yet.

commitc005208eca3389c03d204dc5afce42eabe1c0805 authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 25 Apr 2018, 04:00 (9 years ago) parent9eb52f1
1 file changed+21
compiler/src/Type/Error.hs+21
compiler/src/Type/Error.hs+21
@@ -245,6 +245,9 @@ toDiff localizer ctx tipe1 tipe2 =
245245 (FlexVar _, _ ) -> similar localizer ctx tipe1 tipe2
246246 (_ , FlexVar _) -> similar localizer ctx tipe1 tipe2
247247
248+ (FlexSuper s _, t ) | isSuper s t -> similar localizer ctx tipe1 tipe2
249+ (t , FlexSuper s _) | isSuper s t -> similar localizer ctx tipe1 tipe2
250+
248251 (Lambda a b cs, Lambda x y zs) ->
249252 if length cs == length zs then
250253 RT.lambda ctx
@@ -409,6 +412,24 @@ isList home name =
409412
410413
411414
415+-- IS SUPER?
416+
417+
418+isSuper :: Super -> Type -> Bool
419+isSuper super tipe =
420+ case iteratedDealias tipe of
421+ Type h n args ->
422+ case super of
423+ Number -> isInt h n || isFloat h n
424+ Comparable -> isInt h n || isFloat h n || isString h n || isChar h n || isList h n && isSuper super (head args)
425+ Appendable -> isString h n || isList h n
426+ CompAppend -> isString h n || isList h n && isSuper Comparable (head args)
427+
428+ _ ->
429+ False
430+
431+
432+
412433-- DIFF ALIASED RECORD
413434
414435