diff options
Diffstat (limited to 'src/CHAD/AST/Sparse')
| -rw-r--r-- | src/CHAD/AST/Sparse/Types.hs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/CHAD/AST/Sparse/Types.hs b/src/CHAD/AST/Sparse/Types.hs index 8f41ba4..f97a261 100644 --- a/src/CHAD/AST/Sparse/Types.hs +++ b/src/CHAD/AST/Sparse/Types.hs @@ -20,6 +20,7 @@ data Sparse t t' where SpMaybe :: Sparse t t' -> Sparse (TMaybe t) (TMaybe t') SpArr :: Sparse t t' -> Sparse (TArr n t) (TArr n t') SpScal :: Sparse (TScal t) (TScal t) + SpUser :: Sparse (TUser t) (TUser t) deriving instance Show (Sparse t t') class ApplySparse f where @@ -33,6 +34,7 @@ instance ApplySparse STy where applySparse (SpMaybe s) (STMaybe t) = STMaybe (applySparse s t) applySparse (SpArr s) (STArr n t) = STArr n (applySparse s t) applySparse SpScal t = t + applySparse SpUser t = t instance ApplySparse SMTy where applySparse (SpSparse s) t = SMTMaybe (applySparse s t) @@ -42,6 +44,7 @@ instance ApplySparse SMTy where applySparse (SpMaybe s) (SMTMaybe t) = SMTMaybe (applySparse s t) applySparse (SpArr s) (SMTArr n t) = SMTArr n (applySparse s t) applySparse SpScal t = t + applySparse SpUser t = t class IsSubType s where @@ -68,6 +71,7 @@ instance IsSubType Sparse where subtTrans (SpMaybe s1) (SpMaybe s2) = SpMaybe (subtTrans s1 s2) subtTrans (SpArr s1) (SpArr s2) = SpArr (subtTrans s1 s2) subtTrans SpScal SpScal = SpScal + subtTrans SpUser SpUser = SpUser subtFull = spDense @@ -78,6 +82,7 @@ spDense (SMTLEither t1 t2) = SpLEither (spDense t1) (spDense t2) spDense (SMTMaybe t) = SpMaybe (spDense t) spDense (SMTArr _ t) = SpArr (spDense t) spDense (SMTScal _) = SpScal +spDense (SMTUser _) = SpUser isDense :: SMTy t -> Sparse t t' -> Maybe (t :~: t') isDense SMTNil SpAbsent = Just Refl @@ -96,6 +101,7 @@ isDense (SMTArr _ t) (SpArr s) | Just Refl <- isDense t s = Just Refl | otherwise = Nothing isDense (SMTScal _) SpScal = Just Refl +isDense (SMTUser _) SpUser = Just Refl isAbsent :: Sparse t t' -> Bool isAbsent (SpSparse s) = isAbsent s @@ -105,3 +111,4 @@ isAbsent (SpLEither s1 s2) = isAbsent s1 && isAbsent s2 isAbsent (SpMaybe s) = isAbsent s isAbsent (SpArr s) = isAbsent s isAbsent SpScal = False +isAbsent SpUser = False |
