diff --git a/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs b/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs index f0118f89614d..94d9b6d0936f 100644 --- a/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs +++ b/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs @@ -264,7 +264,7 @@ data BuiltinExpr | BEGreater !BuiltinType -- :: t -> t -> Bool, where t is the builtin type | BEToText !BuiltinType -- :: t -> Text, where t is one of the builtin types -- {Int64, Decimal, Text, Timestamp, Date, Party} - | BEToTextContractId -- :: forall t. ContractId t -> Option Text + | BEContractIdToText -- :: forall t. ContractId t -> Option Text -- Decimal arithmetic | BEAddDecimal -- :: Decimal -> Decimal -> Decimal, crashes on overflow @@ -279,7 +279,7 @@ data BuiltinExpr | BELessEqNumeric -- :: ∀(s:nat). Numeric s -> Numeric s -> Bool | BEGreaterEqNumeric -- :: ∀(s:nat). Numeric s -> Numeric s -> Bool | BEGreaterNumeric -- :: ∀(s:nat). Numeric s -> Numeric s -> Bool - | BEToTextNumeric -- :: ∀(s:nat). Numeric s -> Text + | BENumericToText -- :: ∀(s:nat). Numeric s -> Text | BEAddNumeric -- :: ∀(s:nat). Numeric s -> Numeric s -> Numeric s, crashes on overflow | BESubNumeric -- :: ∀(s:nat). Numeric s -> Numeric s -> Numeric s, crashes on overflow | BEMulNumeric -- :: ∀(s1:nat). ∀(s2:nat). ∀(s3:nat). Numeric s1 -> Numeric s2 -> Numeric s3, crashes on overflow and underflow, automatically rounds to even (see ) @@ -335,12 +335,12 @@ data BuiltinExpr | BEAppendText -- :: Text -> Text -> Text | BEImplodeText -- :: List Text -> Text | BESha256Text -- :: Text -> Text - | BEPartyFromText -- :: Text -> Optional Party - | BEInt64FromText -- :: Text -> Optional Int64 - | BEDecimalFromText -- :: Text -> Optional Decimal - | BENumericFromText -- :: ∀(s:nat). Text -> Optional (Numeric s) + | BETextToParty -- :: Text -> Optional Party + | BETextToInt64 -- :: Text -> Optional Int64 + | BETextToDecimal -- :: Text -> Optional Decimal + | BETextToNumeric -- :: ∀(s:nat). Text -> Optional (Numeric s) | BETextToCodePoints -- :: Text -> List Int64 - | BETextFromCodePoints -- :: List Int64 -> Text + | BECodePointsToText -- :: List Int64 -> Text | BEPartyToQuotedText -- :: Party -> Text -- BigNumeric operations @@ -351,8 +351,8 @@ data BuiltinExpr | BEMulBigNumeric -- :: BigNumeric -> BigNumeric -> BigNumeric | BEDivBigNumeric -- :: Int64 -> RoundingMode -> BigNumeric -> BigNumeric -> BigNumeric | BEShiftRightBigNumeric -- :: Int64 -> BigNumeric -> BigNumeric - | BEToNumericBigNumeric -- :: ∀(s:nat). BigNumeric -> Numeric s - | BEFromNumericBigNumeric -- :: ∀(s:nat). Numeric s -> BigNumeric + | BEBigNumericToNumeric -- :: ∀(s:nat). BigNumeric -> Numeric s + | BENumericToBigNumeric -- :: ∀(s:nat). Numeric s -> BigNumeric | BETrace -- :: forall a. Text -> a -> a | BEEqualContractId -- :: forall a. ContractId a -> ContractId a -> Bool diff --git a/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs b/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs index 6882f0ca267b..1409fafbd816 100644 --- a/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs +++ b/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs @@ -236,7 +236,7 @@ instance Pretty BuiltinExpr where BEGreater t -> pPrintAppKeyword lvl prec "GREATER" [TyArg (TBuiltin t)] BEGreaterEq t -> pPrintAppKeyword lvl prec "GREATER_EQ" [TyArg (TBuiltin t)] BEToText t -> pPrintAppKeyword lvl prec "TO_TEXT" [TyArg (TBuiltin t)] - BEToTextContractId -> "CONTRACT_ID_TO_TEXT" + BEContractIdToText -> "CONTRACT_ID_TO_TEXT" BEAddDecimal -> "ADD_DECIMAL" BESubDecimal -> "SUB_DECIMAL" BEMulDecimal -> "MUL_DECIMAL" @@ -256,8 +256,8 @@ instance Pretty BuiltinExpr where BELessNumeric -> "LESS_NUMERIC" BEGreaterEqNumeric -> "GEQ_NUMERIC" BEGreaterNumeric -> "GREATER_NUMERIC" - BENumericFromText -> "TEXT_TO_NUMERIC" - BEToTextNumeric -> "NUMERIC_TO_TEXT" + BETextToNumeric -> "TEXT_TO_NUMERIC" + BENumericToText -> "NUMERIC_TO_TEXT" BEScaleBigNumeric -> "SCALE_BIGNUMERIC" BEPrecisionBigNumeric -> "PRECISION_BIGNUMERIC" BEAddBigNumeric -> "ADD_BIGNUMERIC" @@ -265,8 +265,8 @@ instance Pretty BuiltinExpr where BEMulBigNumeric -> "MUl_BIGNUMERIC" BEDivBigNumeric -> "DIV_BIGNUMERIC" BEShiftRightBigNumeric -> "SHIFT_RIGHT_BIGNUMERIC" - BEToNumericBigNumeric -> "BIGNUMERIC_TO_NUMERIC" - BEFromNumericBigNumeric -> "NUMERIC_TO_BIGNUMERIC" + BEBigNumericToNumeric -> "BIGNUMERIC_TO_NUMERIC" + BENumericToBigNumeric -> "NUMERIC_TO_BIGNUMERIC" BEAddInt64 -> "ADD_INT64" BESubInt64 -> "SUB_INT64" BEMulInt64 -> "MUL_INT64" @@ -303,12 +303,12 @@ instance Pretty BuiltinExpr where BESha256Text -> "SHA256_TEXT" BETrace -> "TRACE" BEEqualContractId -> "EQUAL_CONTRACT_ID" - BEPartyFromText -> "TEXT_TO_PARTY" - BEInt64FromText -> "TEXT_TO_INT64" - BEDecimalFromText -> "TEXT_TO_DECIMAL" + BETextToParty -> "TEXT_TO_PARTY" + BETextToInt64 -> "TEXT_TO_INT64" + BETextToDecimal -> "TEXT_TO_DECIMAL" BEPartyToQuotedText -> "PARTY_TO_QUOTED_TEXT" BETextToCodePoints -> "TEXT_TO_CODE_POINTS" - BETextFromCodePoints -> "CODE_POINTS_TO_TEXT" + BECodePointsToText -> "CODE_POINTS_TO_TEXT" BECoerceContractId -> "COERCE_CONTRACT_ID" BETextToUpper -> "TEXT_TO_UPPER" BETextToLower -> "TEXT_TO_LOWER" diff --git a/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs b/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs index c73fe612a709..36b48c570f37 100644 --- a/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs +++ b/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs @@ -402,18 +402,18 @@ decodeBuiltinFunction = pure . \case LF1.BuiltinFunctionINT64_TO_TEXT -> BEToText BTInt64 LF1.BuiltinFunctionDECIMAL_TO_TEXT -> BEToText BTDecimal - LF1.BuiltinFunctionNUMERIC_TO_TEXT -> BEToTextNumeric + LF1.BuiltinFunctionNUMERIC_TO_TEXT -> BENumericToText LF1.BuiltinFunctionTEXT_TO_TEXT -> BEToText BTText LF1.BuiltinFunctionTIMESTAMP_TO_TEXT -> BEToText BTTimestamp LF1.BuiltinFunctionPARTY_TO_TEXT -> BEToText BTParty LF1.BuiltinFunctionDATE_TO_TEXT -> BEToText BTDate - LF1.BuiltinFunctionCONTRACT_ID_TO_TEXT -> BEToTextContractId + LF1.BuiltinFunctionCONTRACT_ID_TO_TEXT -> BEContractIdToText LF1.BuiltinFunctionBIGNUMERIC_TO_TEXT -> BEToText BTBigNumeric - LF1.BuiltinFunctionCODE_POINTS_TO_TEXT -> BETextFromCodePoints - LF1.BuiltinFunctionTEXT_TO_PARTY -> BEPartyFromText - LF1.BuiltinFunctionTEXT_TO_INT64 -> BEInt64FromText - LF1.BuiltinFunctionTEXT_TO_DECIMAL -> BEDecimalFromText - LF1.BuiltinFunctionTEXT_TO_NUMERIC -> BENumericFromText + LF1.BuiltinFunctionCODE_POINTS_TO_TEXT -> BECodePointsToText + LF1.BuiltinFunctionTEXT_TO_PARTY -> BETextToParty + LF1.BuiltinFunctionTEXT_TO_INT64 -> BETextToInt64 + LF1.BuiltinFunctionTEXT_TO_DECIMAL -> BETextToDecimal + LF1.BuiltinFunctionTEXT_TO_NUMERIC -> BETextToNumeric LF1.BuiltinFunctionTEXT_POINTS_TO_CODE -> BETextToCodePoints LF1.BuiltinFunctionPARTY_TO_QUOTED_TEXT -> BEPartyToQuotedText @@ -496,8 +496,8 @@ decodeBuiltinFunction = pure . \case LF1.BuiltinFunctionMUL_BIGNUMERIC -> BEMulBigNumeric LF1.BuiltinFunctionDIV_BIGNUMERIC -> BEDivBigNumeric LF1.BuiltinFunctionSHIFT_RIGHT_BIGNUMERIC -> BEShiftRightBigNumeric - LF1.BuiltinFunctionBIGNUMERIC_TO_NUMERIC -> BEToNumericBigNumeric - LF1.BuiltinFunctionNUMERIC_TO_BIGNUMERIC -> BEFromNumericBigNumeric + LF1.BuiltinFunctionBIGNUMERIC_TO_NUMERIC -> BEBigNumericToNumeric + LF1.BuiltinFunctionNUMERIC_TO_BIGNUMERIC -> BENumericToBigNumeric decodeLocation :: LF1.Location -> Decode SourceLoc decodeLocation (LF1.Location mbModRef mbRange) = do diff --git a/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs b/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs index 89e188bb800e..48587987412d 100644 --- a/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs +++ b/compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs @@ -481,13 +481,13 @@ encodeBuiltinExpr = \case BTParty -> builtin P.BuiltinFunctionPARTY_TO_TEXT BTBigNumeric -> builtin P.BuiltinFunctionBIGNUMERIC_TO_TEXT other -> error $ "BEToText unexpected type " <> show other - BEToTextContractId -> builtin P.BuiltinFunctionCONTRACT_ID_TO_TEXT - BEToTextNumeric -> builtin P.BuiltinFunctionNUMERIC_TO_TEXT - BETextFromCodePoints -> builtin P.BuiltinFunctionCODE_POINTS_TO_TEXT - BEPartyFromText -> builtin P.BuiltinFunctionTEXT_TO_PARTY - BEInt64FromText -> builtin P.BuiltinFunctionTEXT_TO_INT64 - BEDecimalFromText-> builtin P.BuiltinFunctionTEXT_TO_DECIMAL - BENumericFromText-> builtin P.BuiltinFunctionTEXT_TO_NUMERIC + BEContractIdToText -> builtin P.BuiltinFunctionCONTRACT_ID_TO_TEXT + BENumericToText -> builtin P.BuiltinFunctionNUMERIC_TO_TEXT + BECodePointsToText -> builtin P.BuiltinFunctionCODE_POINTS_TO_TEXT + BETextToParty -> builtin P.BuiltinFunctionTEXT_TO_PARTY + BETextToInt64 -> builtin P.BuiltinFunctionTEXT_TO_INT64 + BETextToDecimal-> builtin P.BuiltinFunctionTEXT_TO_DECIMAL + BETextToNumeric-> builtin P.BuiltinFunctionTEXT_TO_NUMERIC BETextToCodePoints -> builtin P.BuiltinFunctionTEXT_POINTS_TO_CODE BEPartyToQuotedText -> builtin P.BuiltinFunctionPARTY_TO_QUOTED_TEXT @@ -512,8 +512,8 @@ encodeBuiltinExpr = \case BEMulBigNumeric -> builtin P.BuiltinFunctionMUL_BIGNUMERIC BEDivBigNumeric -> builtin P.BuiltinFunctionDIV_BIGNUMERIC BEShiftRightBigNumeric -> builtin P.BuiltinFunctionSHIFT_RIGHT_BIGNUMERIC - BEToNumericBigNumeric -> builtin P.BuiltinFunctionBIGNUMERIC_TO_NUMERIC - BEFromNumericBigNumeric -> builtin P.BuiltinFunctionNUMERIC_TO_BIGNUMERIC + BEBigNumericToNumeric -> builtin P.BuiltinFunctionBIGNUMERIC_TO_NUMERIC + BENumericToBigNumeric -> builtin P.BuiltinFunctionNUMERIC_TO_BIGNUMERIC BEAddInt64 -> builtin P.BuiltinFunctionADD_INT64 BESubInt64 -> builtin P.BuiltinFunctionSUB_INT64 diff --git a/compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs b/compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs index 6f61526e3400..b02efdc20c35 100644 --- a/compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs +++ b/compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs @@ -98,8 +98,8 @@ safetyStep = \case BEGreaterEq _ -> Safe 2 BEGreater _ -> Safe 2 BEToText _ -> Safe 1 - BEToTextContractId -> Safe 1 - BETextFromCodePoints -> Safe 1 + BEContractIdToText -> Safe 1 + BECodePointsToText -> Safe 1 BEAddDecimal -> Safe 1 BESubDecimal -> Safe 1 BEMulDecimal -> Safe 1 @@ -116,8 +116,8 @@ safetyStep = \case BEDivNumeric -> Safe 1 BEInt64ToNumeric -> Safe 0 BENumericToInt64 -> Safe 0 - BENumericFromText -> Safe 1 - BEToTextNumeric -> Safe 1 + BETextToNumeric -> Safe 1 + BENumericToText -> Safe 1 BERoundNumeric -> Safe 1 BECastNumeric -> Safe 0 BEShiftNumeric -> Safe 1 @@ -128,8 +128,8 @@ safetyStep = \case BEMulBigNumeric -> Safe 1 -- fails on overflow BEDivBigNumeric -> Safe 3 -- takes 4 arguments, fails on division by 0 and on rounding ("rounding unnecessary" mode) BEShiftRightBigNumeric -> Safe 1 -- fails on overflow (shift too large) - BEToNumericBigNumeric -> Safe 0 -- fails on overflow (numeric doesn't fit) - BEFromNumericBigNumeric -> Safe 1 -- doesn't fail + BEBigNumericToNumeric -> Safe 0 -- fails on overflow (numeric doesn't fit) + BENumericToBigNumeric -> Safe 1 -- doesn't fail BEAddInt64 -> Safe 1 BESubInt64 -> Safe 1 BEMulInt64 -> Safe 1 @@ -165,9 +165,9 @@ safetyStep = \case BETrace -> Unsafe -- we make it unsafe so that it never gets erased BEEqualContractId -> Safe 2 BEPartyToQuotedText -> Safe 1 - BEPartyFromText -> Safe 1 - BEInt64FromText -> Safe 1 - BEDecimalFromText -> Safe 1 + BETextToParty -> Safe 1 + BETextToInt64 -> Safe 1 + BETextToDecimal -> Safe 1 BETextToCodePoints -> Safe 1 BECoerceContractId -> Safe 1 BETextToUpper -> Safe 1 diff --git a/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs b/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs index 416121a925ab..b17831888dbc 100644 --- a/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs +++ b/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs @@ -229,12 +229,12 @@ typeOfBuiltin = \case BEGreater btype -> pure $ tComparison btype BEGreaterEq btype -> pure $ tComparison btype BEToText btype -> pure $ TBuiltin btype :-> TText - BEToTextContractId -> pure $ TForall (alpha, KStar) $ TContractId tAlpha :-> TOptional TText - BETextFromCodePoints -> pure $ TList TInt64 :-> TText + BEContractIdToText -> pure $ TForall (alpha, KStar) $ TContractId tAlpha :-> TOptional TText + BECodePointsToText -> pure $ TList TInt64 :-> TText BEPartyToQuotedText -> pure $ TParty :-> TText - BEPartyFromText -> pure $ TText :-> TOptional TParty - BEInt64FromText -> pure $ TText :-> TOptional TInt64 - BEDecimalFromText -> pure $ TText :-> TOptional TDecimal + BETextToParty -> pure $ TText :-> TOptional TParty + BETextToInt64 -> pure $ TText :-> TOptional TInt64 + BETextToDecimal -> pure $ TText :-> TOptional TDecimal BETextToCodePoints -> pure $ TText :-> TList TInt64 BEAddDecimal -> pure $ tBinop TDecimal BESubDecimal -> pure $ tBinop TDecimal @@ -255,8 +255,8 @@ typeOfBuiltin = \case BEShiftNumeric -> pure $ TForall (alpha, KNat) $ TForall (beta, KNat) $ TNumeric tAlpha :-> TNumeric tBeta BEInt64ToNumeric -> pure $ TForall (alpha, KNat) $ TInt64 :-> TNumeric tAlpha BENumericToInt64 -> pure $ TForall (alpha, KNat) $ TNumeric tAlpha :-> TInt64 - BEToTextNumeric -> pure $ TForall (alpha, KNat) $ TNumeric tAlpha :-> TText - BENumericFromText -> pure $ TForall (alpha, KNat) $ TText :-> TOptional (TNumeric tAlpha) + BENumericToText -> pure $ TForall (alpha, KNat) $ TNumeric tAlpha :-> TText + BETextToNumeric -> pure $ TForall (alpha, KNat) $ TText :-> TOptional (TNumeric tAlpha) BEScaleBigNumeric -> pure $ TBigNumeric :-> TInt64 BEPrecisionBigNumeric -> pure $ TBigNumeric :-> TInt64 @@ -265,8 +265,8 @@ typeOfBuiltin = \case BEMulBigNumeric -> pure $ TBigNumeric :-> TBigNumeric :-> TBigNumeric BEDivBigNumeric -> pure $ TInt64 :-> TRoundingMode :-> TBigNumeric :-> TBigNumeric :-> TBigNumeric BEShiftRightBigNumeric -> pure $ TInt64 :-> TBigNumeric :-> TBigNumeric - BEToNumericBigNumeric -> pure $ TForall (alpha, KNat) $ TBigNumeric :-> TNumeric tAlpha - BEFromNumericBigNumeric -> pure $ TForall (alpha, KNat) $ TNumeric tAlpha :-> TBigNumeric + BEBigNumericToNumeric -> pure $ TForall (alpha, KNat) $ TBigNumeric :-> TNumeric tAlpha + BENumericToBigNumeric -> pure $ TForall (alpha, KNat) $ TNumeric tAlpha :-> TBigNumeric BEAddInt64 -> pure $ tBinop TInt64 BESubInt64 -> pure $ tBinop TInt64 diff --git a/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion.hs b/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion.hs index ed45579d77d3..4ae5ab0077ea 100644 --- a/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion.hs +++ b/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion.hs @@ -338,7 +338,7 @@ convertRationalBigNumeric num denom = case numericFromRational rational of Left _ -> invalid Right n -> let scale = numericScale n - in pure (EBuiltin BEFromNumericBigNumeric + in pure (EBuiltin BENumericToBigNumeric `ETyApp` TNat (typeLevelNat scale) `ETmApp` EBuiltin (BENumeric n)) diff --git a/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion/Primitives.hs b/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion/Primitives.hs index 28c8ea8cf948..0b730ae0286c 100644 --- a/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion/Primitives.hs +++ b/compiler/damlc/daml-lf-conversion/src/DA/Daml/LFConversion/Primitives.hs @@ -138,16 +138,16 @@ convertPrim _ "BESha256Text" (TText :-> TText) = EBuiltin BESha256Text convertPrim _ "BEPartyToQuotedText" (TParty :-> TText) = EBuiltin BEPartyToQuotedText -convertPrim _ "BEPartyFromText" (TText :-> TOptional TParty) = - EBuiltin BEPartyFromText -convertPrim _ "BEInt64FromText" (TText :-> TOptional TInt64) = - EBuiltin BEInt64FromText -convertPrim _ "BEDecimalFromText" (TText :-> TOptional TDecimal) = - EBuiltin BEDecimalFromText +convertPrim _ "BETextToParty" (TText :-> TOptional TParty) = + EBuiltin BETextToParty +convertPrim _ "BETextToInt64" (TText :-> TOptional TInt64) = + EBuiltin BETextToInt64 +convertPrim _ "BETextToDecimal" (TText :-> TOptional TDecimal) = + EBuiltin BETextToDecimal convertPrim _ "BETextToCodePoints" (TText :-> TList TInt64) = EBuiltin BETextToCodePoints -convertPrim _ "BETextFromCodePoints" (TList TInt64 :-> TText) = - EBuiltin BETextFromCodePoints +convertPrim _ "BECodePointsToText" (TList TInt64 :-> TText) = + EBuiltin BECodePointsToText -- Map operations @@ -212,9 +212,9 @@ convertPrim _ "BEInt64ToDecimal" (TInt64 :-> TNumeric10) = convertPrim _ "BEDecimalToInt64" (TNumeric10 :-> TInt64) = ETyApp (EBuiltin BENumericToInt64) TNat10 convertPrim _ "BEToText" (TNumeric10 :-> TText) = - ETyApp (EBuiltin BEToTextNumeric) TNat10 -convertPrim _ "BEDecimalFromText" (TText :-> TOptional TNumeric10) = - ETyApp (EBuiltin BENumericFromText) TNat10 + ETyApp (EBuiltin BENumericToText) TNat10 +convertPrim _ "BETextToDecimal" (TText :-> TOptional TNumeric10) = + ETyApp (EBuiltin BETextToNumeric) TNat10 -- Numeric primitives. These are polymorphic in the scale. convertPrim _ "BEAddNumeric" (TNumeric n1 :-> TNumeric n2 :-> TNumeric n3) | n1 == n2, n1 == n3 = @@ -255,10 +255,10 @@ convertPrim _ "BEInt64ToNumeric" (TInt64 :-> TNumeric n) = ETyApp (EBuiltin BEInt64ToNumeric) n convertPrim _ "BENumericToInt64" (TNumeric n :-> TInt64) = ETyApp (EBuiltin BENumericToInt64) n -convertPrim _ "BEToTextNumeric" (TNumeric n :-> TText) = - ETyApp (EBuiltin BEToTextNumeric) n -convertPrim _ "BENumericFromText" (TText :-> TOptional (TNumeric n)) = - ETyApp (EBuiltin BENumericFromText) n +convertPrim _ "BENumericToText" (TNumeric n :-> TText) = + ETyApp (EBuiltin BENumericToText) n +convertPrim _ "BETextToNumeric" (TText :-> TOptional (TNumeric n)) = + ETyApp (EBuiltin BETextToNumeric) n convertPrim version "BEScaleBigNumeric" ty@(TBigNumeric :-> TInt64) = whenRuntimeSupports version featureBigNumeric ty $ @@ -281,12 +281,12 @@ convertPrim version "BEDivBigNumeric" ty@(TInt64 :-> TRoundingMode :-> TBigNumer convertPrim version "BEShiftRightBigNumeric" ty@(TInt64 :-> TBigNumeric :-> TBigNumeric) = whenRuntimeSupports version featureBigNumeric ty $ EBuiltin BEShiftRightBigNumeric -convertPrim version "BEFromNumericBigNumeric" ty@(TNumeric n :-> TBigNumeric) = +convertPrim version "BENumericToBigNumeric" ty@(TNumeric n :-> TBigNumeric) = whenRuntimeSupports version featureBigNumeric ty $ - EBuiltin BEFromNumericBigNumeric `ETyApp` n -convertPrim version "BEToNumericBigNumeric" ty@(TBigNumeric :-> TNumeric n) = + EBuiltin BENumericToBigNumeric `ETyApp` n +convertPrim version "BEBigNumericToNumeric" ty@(TBigNumeric :-> TNumeric n) = whenRuntimeSupports version featureBigNumeric ty $ - EBuiltin BEToNumericBigNumeric `ETyApp` n + EBuiltin BEBigNumericToNumeric `ETyApp` n -- Experimental text primitives. convertPrim _ "BETextToUpper" (TText :-> TText) = EBuiltin BETextToUpper @@ -300,8 +300,8 @@ convertPrim _ "BETextIntercalate" (TText :-> TList TText :-> TText) = EBuiltin B -- Conversion from ContractId to Text -convertPrim _ "BEToTextContractId" (TContractId t :-> TOptional TText) = - ETyApp (EBuiltin BEToTextContractId) t +convertPrim _ "BEContractIdToText" (TContractId t :-> TOptional TText) = + ETyApp (EBuiltin BEContractIdToText) t -- Template Desugaring. diff --git a/compiler/damlc/daml-prim-src/GHC/Classes.daml b/compiler/damlc/daml-prim-src/GHC/Classes.daml index 3c5d4bf321e9..5eb98af02071 100644 --- a/compiler/damlc/daml-prim-src/GHC/Classes.daml +++ b/compiler/damlc/daml-prim-src/GHC/Classes.daml @@ -477,10 +477,10 @@ class IsNumeric t where instance NumericScale n => IsNumeric (Numeric n) where fromNumeric = primitive @"BECastNumeric" - fromBigNumeric = primitive @"BEToNumericBigNumeric" + fromBigNumeric = primitive @"BEBigNumericToNumeric" instance IsNumeric BigNumeric where - fromNumeric = primitive @"BEFromNumericBigNumeric" + fromNumeric = primitive @"BENumericToBigNumeric" fromBigNumeric x = x #endif diff --git a/compiler/damlc/daml-prim-src/GHC/Show.daml b/compiler/damlc/daml-prim-src/GHC/Show.daml index bf3dd4f6a3ce..015b3645851a 100644 --- a/compiler/damlc/daml-prim-src/GHC/Show.daml +++ b/compiler/damlc/daml-prim-src/GHC/Show.daml @@ -116,7 +116,7 @@ instance Show Int where #ifdef DAML_NUMERIC instance Show (Numeric n) where - show = primitive @"BEToTextNumeric" + show = primitive @"BENumericToText" #else instance Show Decimal where show = primitive @"BEToText" diff --git a/compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml b/compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml index e1de0586dd48..06d47d8c9a52 100644 --- a/compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml +++ b/compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml @@ -98,7 +98,7 @@ partyToText = primitive @"BEToText" -- -- This function will crash at runtime if you compile Daml to Daml-LF < 1.2. partyFromText : Text -> Optional Party -partyFromText = primitive @"BEPartyFromText" +partyFromText = primitive @"BETextToParty" -- | Get the party with the given name. Party names must be non-empty and only -- contain alphanumeric charaters, space, `-` (dash) or `_` (underscore). @@ -147,7 +147,7 @@ instance Ord (ContractId a) where #endif instance Show (ContractId a) where #ifdef DAML_CONTRACT_ID_TO_TEXT - show cid = case primitive @"BEToTextContractId" cid of + show cid = case primitive @"BEContractIdToText" cid of None -> "" Some t -> t #else diff --git a/compiler/damlc/daml-stdlib-src/DA/Text.daml b/compiler/damlc/daml-stdlib-src/DA/Text.daml index fcf03aeb2c33..417b03362f1e 100644 --- a/compiler/damlc/daml-stdlib-src/DA/Text.daml +++ b/compiler/damlc/daml-stdlib-src/DA/Text.daml @@ -285,7 +285,7 @@ isAlphaNum = isPred (\t -> t >= "0" && t <= "9" || t >= "a" && t <= "z" || t >= -- | Attempt to parse an `Int` value from a given `Text`. parseInt : Text -> Optional Int -parseInt = primitive @"BEInt64FromText" +parseInt = primitive @"BETextToInt64" #ifdef DAML_NUMERIC -- | Attempt to parse a `Numeric` value from a given `Text`. @@ -300,7 +300,7 @@ parseInt = primitive @"BEInt64FromText" -- parseNumeric "+12.0" == Some 12 -- ``` parseNumeric : Text -> Optional (Numeric n) -parseNumeric = primitive @"BENumericFromText" +parseNumeric = primitive @"BETextToNumeric" #endif -- | Attempt to parse a `Decimal` value from a given `Text`. @@ -318,7 +318,7 @@ parseDecimal : Text -> Optional Decimal #ifdef DAML_NUMERIC parseDecimal = parseNumeric #else -parseDecimal = primitive @"BEDecimalFromText" +parseDecimal = primitive @"BETextToDecimal" #endif -- | Computes the SHA256 hash of the UTF8 bytes of the `Text`, and returns it in its hex-encoded @@ -343,7 +343,7 @@ toCodePoints = primitive @"BETextToCodePoints" -- | Convert a sequence of unicode code points into a `Text`. Raises an -- exception if any of the code points is invalid. fromCodePoints : [Int] -> Text -fromCodePoints = primitive @"BETextFromCodePoints" +fromCodePoints = primitive @"BECodePointsToText" #ifdef DAML_UNSTABLE