module DDC.Type.Transform.Instantiate
( instantiateT
, instantiateTs)
where
import DDC.Type.Exp
import DDC.Type.Transform.SubstituteT
import DDC.Base.Pretty (Pretty)
instantiateT :: (Ord n, Pretty n) => Type n -> Type n -> Maybe (Type n)
instantiateT (TForall b tBody) t2 = Just $ substituteT b t2 tBody
instantiateT _ _ = Nothing
instantiateTs :: (Ord n, Pretty n) => Type n -> [Type n] -> Maybe (Type n)
instantiateTs t [] = Just t
instantiateTs t (tArg:tsArgs)
= case instantiateT t tArg of
Nothing -> Nothing
Just t' -> instantiateTs t' tsArgs