We detect type cycle that are not necessarily recursive types. For example:
r = "a" r / "b" .
is invalid because both branch have a different type: (^) and char. This is because we are too conservative on unit cycle. Actually we should not generate a rec type if the cycle does not actually build value with polymorphic types (such as Option<T> or (T1,T2)), if we build a single atom along the path of cycle, this is valid. A more interesting example is for example:
We detect type cycle that are not necessarily recursive types. For example:
is invalid because both branch have a different type:
(^)
andchar
. This is because we are too conservative on unit cycle. Actually we should not generate arec
type if the cycle does not actually build value with polymorphic types (such asOption<T>
or(T1,T2)
), if we build a single atom along the path of cycle, this is valid. A more interesting example is for example:The factor
(e)
is of the type ofe
, this is a valid example of unit cycle.