diff --git a/common/Types.hs b/common/Types.hs index 00e3aaa..65296c4 100644 --- a/common/Types.hs +++ b/common/Types.hs @@ -19,7 +19,7 @@ with this program. If not, see . -- | Type inference and checking. module Types ( - specTypeOfName, typeOfSpec, typeOfSpec', abbrevModeOfName, underlyingType, stripArrayType, abbrevModeOfVariable, abbrevModeOfSpec + specTypeOfName, typeOfSpec, typeOfSpec', abbrevModeOfName, underlyingType, underlyingTypeOf, stripArrayType, abbrevModeOfVariable, abbrevModeOfSpec , isRealType, isIntegerType, isNumericType, isCaseableType, isScalarType, isDataType, isCommunicableType, isSequenceType, isMobileType , resolveUserType, isSafeConversion, isPreciseConversion, isImplicitConversionRain , isOperator, functionOperator, occamDefaultOperator, occamBuiltInOperatorFunctions @@ -64,6 +64,9 @@ class ASTTypeable a where instance ASTTypeable A.Type where astTypeOf = return +underlyingTypeOf :: (ASTTypeable a, CSMR m, Die m) => Meta -> a -> m A.Type +underlyingTypeOf m = underlyingType m <.< astTypeOf + -- | Gets the 'A.AbbrevMode' for a given 'A.Name' from the recorded types in the 'CompState'. Dies with an error if the name is unknown. abbrevModeOfName :: (CSMR m, Die m) => A.Name -> m A.AbbrevMode abbrevModeOfName n diff --git a/frontends/OccamTypes.hs b/frontends/OccamTypes.hs index 0f36d1e..5b78d58 100644 --- a/frontends/OccamTypes.hs +++ b/frontends/OccamTypes.hs @@ -721,7 +721,7 @@ inferTypes = occamOnlyPass "Infer types" n -> show n ++ "-ary" es' <- noTypeContext $ mapM recurse es - tes <- sequence [astTypeOf e `catchError` (const $ return A.Infer) | e <- es'] + tes <- sequence [underlyingTypeOf m e `catchError` (const $ return A.Infer) | e <- es'] cs <- getCompState