Closed AshleyYakeley closed 5 months ago
Alternative: define subtype relations at time of concrete creation.
dynamictype P;
dynamictype Q = !"Q" <: P;
This wouldn't work:
let
dynamictype P;
q: DynamicEntity = let dynamictype Q = !"Q" <: P in point.DynamicEntity @Q !"q";
in check @P q
"same code is accepted in different scopes, but with different results" is already a thing in Haskell, sort of:
{-# LANGUAGE
CPP,
TypeApplications,
FlexibleInstances,
AllowAmbiguousTypes
#-}
#define FLAG 1
module Main where
import Prelude
class C x where
val :: Int
instance C (Maybe a) where
val = 1
#if FLAG
instance {-# OVERLAPPING #-} C (Maybe ()) where
val = 2
#endif
main :: IO ()
main = putStrLn $ show (val @(Maybe ()))
Should subtype relationships be inferred when not declared?
For example:
dynamictype P;
dynamictype Q;
dynamictype X = !"X";
subtype X <: Q;
Does this give P <: Q
even though this is not declared?
Prefer "no"
Done.
Concrete dynamic type:
"dynamictype" <type-const> "=" <anchor>
Abstract dynamic type:
"dynamictype" <type-const>
Then use subtype relations to define abstract dynamic types.
subtype Q <: P
whereQ
is a concrete dynamic type andP
is an abstract dynamic type.Downside: same code is accepted in different scopes, but with different results: