Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler: clean conversion builtin names #9724

Merged
merged 1 commit into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 <https://en.wikipedia.org/wiki/Rounding#Round_half_to_even>)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -256,17 +256,17 @@ 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"
BESubBigNumeric -> "SUB_BIGNUMERIC"
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"
Expand Down Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/DecodeV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions compiler/daml-lf-proto/src/DA/Daml/LF/Proto3/EncodeV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions compiler/daml-lf-tools/src/DA/Daml/LF/Simplifier.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 $
Expand All @@ -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
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions compiler/damlc/daml-prim-src/GHC/Classes.daml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/daml-prim-src/GHC/Show.daml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions compiler/damlc/daml-stdlib-src/DA/Internal/LF.daml
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down Expand Up @@ -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 -> "<contract-id>"
Some t -> t
#else
Expand Down
Loading