Closed AshleyYakeley closed 1 year ago
Problem: there's a diamond:
Semigroup _ <: Monoid _ <: List _
Semigroup _ <: List1 _ <: List _
Rules are:
Semigroup a <: Monoid a
Monoid (List a) <: List a
Semigroup (List1 a) <: List1 a
List1 a <: List a
Given Semigroup (List Unit) <: List Unit
, we get
Semigroup (List Unit) <: Monoid a
and Monoid a <: List Unit
(OK)Semigroup (List Unit) <: List1 a
and List1 a <: List Unit
(first one fails)Solution might just be to try all in the diamond.
This is causing problems:
Consider f = \x => [()] ++ x
Inferred: f: a -> Semigroup (a | List1 Unit)
Cannot subsume to List Unit -> List Unit
.
Simplify List1 Unit|List Unit
Result: hangs
Can we join the conversions?
F A -> G C
F B -> G D
This depends on the polarities.
F (A | B) -> G (C | D)
can be constructedF (A & B) -> G (C & D)
can be constructedF (A & B) -> G (C | D)
can be constructed but is less useful than either oneF (A | B) -> G (C & D)
cannot be constructedAlso have this diamond:
Monoid _ <: Text <: Literal <: Entity
Monoid _ <: List _ <: Entity
Rules are:
Monoid Text <: Text
List Entity <: Entity
Monoid (List a) <: List a
This gives:
Monoid Text <: Entity
Monoid (List Entity) <: Entity
Consider:
p: a -> Monoid a
q: Entity -> Entity
r = fn x => q (p x)
What is the type of r
? Either
Text -> Entity
List Entity -> Entity
These cannot be joined.
UPDATE: in this case, Pinafore would reject r
for incoherent ground type conversions.
Can't be done.
This is possible actually.
Consider:
Monoid Text <: Entity
Monoid (List Entity) <: Entity
p: a -> Monoid a
q: Entity -> Entity
r1 = fn x => q (p x)
r2 = fn x => q (p (x: Text))
Pinafore rejects r1
but accepts r2
. Is this OK?
No, because we have Monoid Text <: Text
and Text <: Entity
, but not Monoid Text <: Entity
, violating the composition rule.
Monoid Text <: Entity
exists only as a (composed) subtype conversion entry, not as an actual subtype relation.
Nope.