You implicitly assume that a type has only finitely many sub/supertypes, which for arbitrary types is clearly not the case. The simplest example is Any but you can also get this behavior when defining recursive types. More generally, given types TL, TU there is no way of returning all types T with TL <: T <: TU. You can describe this set using TypeVar, but you cannot just write it down.
Tommy On Wednesday, February 10, 2016 at 12:50:43 AM UTC+1, Jeffrey Sarnoff wrote: > > I see that your definition pours the subtypes from a pitcher of the poured > subtypes. The note about parametric types is well pointed. -- Jeffrey > > Clearly, the answer is therein. Cloudily, I'm looking. > > > On Tuesday, February 9, 2016 at 3:43:48 PM UTC-5, Milan Bouchet-Valat > wrote: >> >> Le mardi 09 février 2016 à 12:24 -0800, Jeffrey Sarnoff a écrit : >> > Any advice on quick 'n EZ coding of something like these? >> > >> > allsupertypes(Irrational) == ( Real, Number, Any ) >> > >> > allsubtypes(Integer) == ( BigInt, Bool, Signed, >> Int128,Int16,Int32,Int64,Int8, Unsigned, >> UInt128,UInt16,UInt32,UInt64,UInt8 ) >> > abstractsubtypes(Integer) == ( Signed, Unsigned ) >> > concretesubtypes(Integer) == ( >> BigInt,Bool,UInt128,UInt16,UInt32,UInt64,UInt8,UInt16,UInt32,UInt64,UInt8) >> Here's a way to get all concretes ubtypes: >> subtypestree(x) = length(subtypes(x)) > 1 ? map(subtypestree, >> subtypes(x)) : x >> [subtypestree(AbstractArray)...;] >> >> You should be able to adapt this to return all abstract types instead >> by using isleaftype() (which would better be called isconcretetype()?). >> But note there's the special case of parametric types, which aren't >> leaf types. >> >> >> Regards >> >
