mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 08:48:21 +03:00
hunt down DAML (#13191)
Process: - `git ls-files | xargs sed -i 's/DAML/Daml/g'` - `git add -p` To review: - Check for false positives by carefully reviewing the diff in this PR. - Check for false negatives with `git grep DAML`. CHANGELOG_BEGIN - Removed all traces of DAML. This may affect error messages and debug outputs. CHANGELOG_END
This commit is contained in:
parent
85c4ea0b5c
commit
961ca80b77
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,7 +8,7 @@ dist
|
|||||||
target
|
target
|
||||||
*.tgz
|
*.tgz
|
||||||
|
|
||||||
# DAML
|
# Daml
|
||||||
.daml/
|
.daml/
|
||||||
|
|
||||||
# dev-env
|
# dev-env
|
||||||
|
@ -41,7 +41,7 @@ LSP_TYPES_VERSION = "1.4.0.0"
|
|||||||
LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67"
|
LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67"
|
||||||
|
|
||||||
def daml_haskell_deps():
|
def daml_haskell_deps():
|
||||||
"""Load all Haskell dependencies of the DAML repository."""
|
"""Load all Haskell dependencies of the Daml repository."""
|
||||||
|
|
||||||
#
|
#
|
||||||
# Vendored Packages
|
# Vendored Packages
|
||||||
@ -68,7 +68,7 @@ haskell_cabal_library(
|
|||||||
urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)],
|
urls = ["http://hackage.haskell.org/package/lsp-types-{version}/lsp-types-{version}.tar.gz".format(version = LSP_TYPES_VERSION)],
|
||||||
)
|
)
|
||||||
|
|
||||||
# ghc-lib based ghcide - injected into `@stackage` and used for DAML IDE.
|
# ghc-lib based ghcide - injected into `@stackage` and used for Daml IDE.
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "ghcide_ghc_lib",
|
name = "ghcide_ghc_lib",
|
||||||
build_file_content = """
|
build_file_content = """
|
||||||
|
@ -46,7 +46,7 @@ mkdir -p "$DIR/protobuf/com/daml"
|
|||||||
cp -RL "daml-lf/archive/src/main/protobuf/com/daml/daml_lf_dev" "$DIR/protobuf/com/daml/"
|
cp -RL "daml-lf/archive/src/main/protobuf/com/daml/daml_lf_dev" "$DIR/protobuf/com/daml/"
|
||||||
# generate code from protobuf using the matching tool, as a configure script
|
# generate code from protobuf using the matching tool, as a configure script
|
||||||
cat <<EOF >"$DIR/Setup.hs"
|
cat <<EOF >"$DIR/Setup.hs"
|
||||||
-- Copyright (c) 2021 The DAML Authors. All rights reserved.
|
-- Copyright (c) 2021 The Daml Authors. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
--
|
--
|
||||||
-- Parts of this code were adapted from
|
-- Parts of this code were adapted from
|
||||||
|
@ -37,7 +37,7 @@ steps:
|
|||||||
title="$2"
|
title="$2"
|
||||||
git branch -D $branch || true
|
git branch -D $branch || true
|
||||||
git checkout -b $branch
|
git checkout -b $branch
|
||||||
git -c user.name="Azure Pipelines DAML Build" \
|
git -c user.name="Azure Pipelines Daml Build" \
|
||||||
-c user.email="support@digitalasset.com" \
|
-c user.email="support@digitalasset.com" \
|
||||||
commit \
|
commit \
|
||||||
-m "$(printf "$title\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
|
-m "$(printf "$title\n\nCHANGELOG_BEGIN\nCHANGELOG_END\n")"
|
||||||
|
@ -108,5 +108,5 @@ http_get url = do
|
|||||||
|
|
||||||
add_github_contact_header :: HTTP.Request -> HTTP.Request
|
add_github_contact_header :: HTTP.Request -> HTTP.Request
|
||||||
add_github_contact_header req =
|
add_github_contact_header req =
|
||||||
req { HTTP.requestHeaders = ("User-Agent", "DAML cron (team-daml-app-runtime@digitalasset.com)") : HTTP.requestHeaders req }
|
req { HTTP.requestHeaders = ("User-Agent", "Daml cron (team-daml-app-runtime@digitalasset.com)") : HTTP.requestHeaders req }
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ head = "0.0.0"
|
|||||||
)
|
)
|
||||||
for sdk_version in sdk_versions
|
for sdk_version in sdk_versions
|
||||||
for platform_version in platform_versions
|
for platform_version in platform_versions
|
||||||
# Test that the DAML script runner can run DARs built with an older SDK
|
# Test that the Daml script runner can run DARs built with an older SDK
|
||||||
# version. I.e. where the runner version is at least the SDK version or
|
# version. I.e. where the runner version is at least the SDK version or
|
||||||
# more recent.
|
# more recent.
|
||||||
if versions.is_at_least(sdk_version, platform_version)
|
if versions.is_at_least(sdk_version, platform_version)
|
||||||
@ -118,7 +118,7 @@ first_post_7587_trigger_version = "1.7.0-snapshot.20201012.5405.0.af92198d"
|
|||||||
)
|
)
|
||||||
for sdk_version in sdk_versions
|
for sdk_version in sdk_versions
|
||||||
for platform_version in platform_versions
|
for platform_version in platform_versions
|
||||||
# Test that the DAML trigger runner can run DARs built with an older SDK
|
# Test that the Daml trigger runner can run DARs built with an older SDK
|
||||||
# version. I.e. where the runner version is at least the SDK version or
|
# version. I.e. where the runner version is at least the SDK version or
|
||||||
# more recent.
|
# more recent.
|
||||||
if versions.is_at_least(first_post_7587_trigger_version, sdk_version) and
|
if versions.is_at_least(first_post_7587_trigger_version, sdk_version) and
|
||||||
|
@ -18,7 +18,7 @@ load("@rules_haskell//haskell:cabal.bzl", "stack_snapshot")
|
|||||||
load("@dadew//:dadew.bzl", "dadew_tool_home")
|
load("@dadew//:dadew.bzl", "dadew_tool_home")
|
||||||
|
|
||||||
def daml_haskell_deps():
|
def daml_haskell_deps():
|
||||||
"""Load all Haskell dependencies of the DAML repository."""
|
"""Load all Haskell dependencies of the Daml repository."""
|
||||||
|
|
||||||
stack_snapshot(
|
stack_snapshot(
|
||||||
name = "stackage",
|
name = "stackage",
|
||||||
|
@ -183,7 +183,7 @@ main = withTempDir $ \npmCache -> do
|
|||||||
let ingredients = defaultIngredients ++ [includingOptions options]
|
let ingredients = defaultIngredients ++ [includingOptions options]
|
||||||
defaultMainWithIngredients ingredients $
|
defaultMainWithIngredients ingredients $
|
||||||
withTools $ \getTools -> do
|
withTools $ \getTools -> do
|
||||||
testGroup "Create DAML App tests"
|
testGroup "Create Daml App tests"
|
||||||
[ test getTools
|
[ test getTools
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
@ -51,7 +51,7 @@ test step modelDar = Test {..}
|
|||||||
testDivulgee = Party "divulgee"
|
testDivulgee = Party "divulgee"
|
||||||
|
|
||||||
-- The datatypes are defined such that the autoderived Aeson instances
|
-- The datatypes are defined such that the autoderived Aeson instances
|
||||||
-- match the DAML-LF JSON encoding.
|
-- match the Daml-LF JSON encoding.
|
||||||
--
|
--
|
||||||
data Asset = Asset
|
data Asset = Asset
|
||||||
{ owner :: Party
|
{ owner :: Party
|
||||||
|
@ -74,7 +74,7 @@ test step modelDar = Test {..}
|
|||||||
testReceiver = Party "receiver"
|
testReceiver = Party "receiver"
|
||||||
|
|
||||||
-- The datatypes are defined such that the autoderived Aeson instances
|
-- The datatypes are defined such that the autoderived Aeson instances
|
||||||
-- match the DAML-LF JSON encoding.
|
-- match the Daml-LF JSON encoding.
|
||||||
|
|
||||||
pattern CreatedAsset :: ContractId -> Asset -> Event
|
pattern CreatedAsset :: ContractId -> Asset -> Event
|
||||||
pattern CreatedAsset cid asset <- Created cid (TemplateId "KeyTransfer" "Asset") (A.fromJSON -> A.Success asset)
|
pattern CreatedAsset cid asset <- Created cid (TemplateId "KeyTransfer" "Asset") (A.fromJSON -> A.Success asset)
|
||||||
|
@ -87,7 +87,7 @@ test step modelDar = Test {..}
|
|||||||
testAccepter = Party "accepter"
|
testAccepter = Party "accepter"
|
||||||
|
|
||||||
-- The datatypes are defined such that the autoderived Aeson instances
|
-- The datatypes are defined such that the autoderived Aeson instances
|
||||||
-- match the DAML-LF JSON encoding.
|
-- match the Daml-LF JSON encoding.
|
||||||
|
|
||||||
data Deal = Deal
|
data Deal = Deal
|
||||||
{ proposer :: Party
|
{ proposer :: Party
|
||||||
|
@ -50,7 +50,7 @@ getSdkVersion :: SdkVersion -> String
|
|||||||
getSdkVersion (SdkVersion ver) = SemVer.toString ver
|
getSdkVersion (SdkVersion ver) = SemVer.toString ver
|
||||||
|
|
||||||
-- The datatypes are defined such that the autoderived Aeson instances
|
-- The datatypes are defined such that the autoderived Aeson instances
|
||||||
-- match the DAML-LF JSON encoding.
|
-- match the Daml-LF JSON encoding.
|
||||||
|
|
||||||
newtype ContractId = ContractId T.Text
|
newtype ContractId = ContractId T.Text
|
||||||
deriving newtype A.FromJSON
|
deriving newtype A.FromJSON
|
||||||
|
@ -13,7 +13,7 @@ import spray.json._
|
|||||||
object JsonProtocol extends DefaultJsonProtocol {
|
object JsonProtocol extends DefaultJsonProtocol {
|
||||||
|
|
||||||
private def cannotReadDamlLf(): RuntimeException =
|
private def cannotReadDamlLf(): RuntimeException =
|
||||||
new UnsupportedOperationException("Reading JSON-encoded DAML-LF value is not supported")
|
new UnsupportedOperationException("Reading JSON-encoded Daml-LF value is not supported")
|
||||||
|
|
||||||
implicit object RecordJsonFormat extends JsonFormat[Record] {
|
implicit object RecordJsonFormat extends JsonFormat[Record] {
|
||||||
override def read(json: JsValue): Record =
|
override def read(json: JsValue): Record =
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "daml",
|
"name": "daml",
|
||||||
"displayName": "DAML",
|
"displayName": "Daml",
|
||||||
"description": "DAML editing and analysis tools",
|
"description": "Daml editing and analysis tools",
|
||||||
"version": "__VERSION__",
|
"version": "__VERSION__",
|
||||||
"publisher": "DigitalAssetHoldingsLLC",
|
"publisher": "DigitalAssetHoldingsLLC",
|
||||||
"repository": "https://github.com/digital-asset/daml/tree/main/compiler/daml-extension",
|
"repository": "https://github.com/digital-asset/daml/tree/main/compiler/daml-extension",
|
||||||
@ -26,7 +26,7 @@
|
|||||||
".daml"
|
".daml"
|
||||||
],
|
],
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"DAML"
|
"Daml"
|
||||||
],
|
],
|
||||||
"configuration": "./daml12.configuration.json"
|
"configuration": "./daml12.configuration.json"
|
||||||
},
|
},
|
||||||
@ -36,7 +36,7 @@
|
|||||||
".daml-core"
|
".daml-core"
|
||||||
],
|
],
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"DAML CORE"
|
"Daml Core"
|
||||||
],
|
],
|
||||||
"configuration": "./daml12.configuration.json"
|
"configuration": "./daml12.configuration.json"
|
||||||
}
|
}
|
||||||
@ -56,11 +56,11 @@
|
|||||||
"commands": [
|
"commands": [
|
||||||
{
|
{
|
||||||
"command": "daml.showResource",
|
"command": "daml.showResource",
|
||||||
"title": "Open DAML virtual resource"
|
"title": "Open Daml virtual resource"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "daml.openDamlDocs",
|
"command": "daml.openDamlDocs",
|
||||||
"title": "[DAML Documentation]"
|
"title": "[Daml Documentation]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "daml.visualize",
|
"command": "daml.visualize",
|
||||||
@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "daml.resetTelemetryConsent",
|
"command": "daml.resetTelemetryConsent",
|
||||||
"title": "Ask me about DAML telemetry again on startup"
|
"title": "Ask me about Daml telemetry again on startup"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"keybindings": [
|
"keybindings": [
|
||||||
@ -81,12 +81,12 @@
|
|||||||
],
|
],
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "DAML Studio configuration",
|
"title": "Daml Studio configuration",
|
||||||
"properties": {
|
"properties": {
|
||||||
"daml.debug": {
|
"daml.debug": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Enable debug logging in the DAML Language Server."
|
"description": "Enable debug logging in the Daml Language Server."
|
||||||
},
|
},
|
||||||
"daml.experimental": {
|
"daml.experimental": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@ -105,7 +105,7 @@
|
|||||||
"From consent popup"
|
"From consent popup"
|
||||||
],
|
],
|
||||||
"default": "From consent popup",
|
"default": "From consent popup",
|
||||||
"description": "Controls whether you send DAML usage data to Digital Asset"
|
"description": "Controls whether you send Daml usage data to Digital Asset"
|
||||||
},
|
},
|
||||||
"daml.extraArguments": {
|
"daml.extraArguments": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"comment": "DA Modeling Language",
|
"comment": "DA Modeling Language",
|
||||||
"scopeName": "source.daml",
|
"scopeName": "source.daml",
|
||||||
"name": "DAML",
|
"name": "Daml",
|
||||||
"fileTypes": ["daml", "daml-core"],
|
"fileTypes": ["daml", "daml-core"],
|
||||||
"patterns": [
|
"patterns": [
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ cabal-version: 2.4
|
|||||||
name: daml-lf-ast
|
name: daml-lf-ast
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
version: 0.1.15.0
|
version: 0.1.15.0
|
||||||
synopsis: DAML-LF AST
|
synopsis: Daml-LF AST
|
||||||
license: Apache-2.0
|
license: Apache-2.0
|
||||||
author: Digital Asset
|
author: Digital Asset
|
||||||
maintainer: Digital Asset
|
maintainer: Digital Asset
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | AST of the DAML Ledger Fragment. Batteries included.
|
-- | AST of the Daml Ledger Fragment. Batteries included.
|
||||||
module DA.Daml.LF.Ast
|
module DA.Daml.LF.Ast
|
||||||
( module LF
|
( module LF
|
||||||
) where
|
) where
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{-# LANGUAGE DerivingStrategies #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
-- | Types and pretty-printer for the AST of the DAML Ledger Fragment.
|
-- | Types and pretty-printer for the AST of the Daml Ledger Fragment.
|
||||||
module DA.Daml.LF.Ast.Base(
|
module DA.Daml.LF.Ast.Base(
|
||||||
module DA.Daml.LF.Ast.Base
|
module DA.Daml.LF.Ast.Base
|
||||||
) where
|
) where
|
||||||
@ -878,7 +878,7 @@ data TemplateKey = TemplateKey
|
|||||||
-- ^ Note that the protobuf imposes strict restrictions on what this can be (see
|
-- ^ Note that the protobuf imposes strict restrictions on what this can be (see
|
||||||
-- proto file). However the compiler produces things that are _not_ in that fragment,
|
-- proto file). However the compiler produces things that are _not_ in that fragment,
|
||||||
-- and thus we gradually simplify them to try to turn them into something as part
|
-- and thus we gradually simplify them to try to turn them into something as part
|
||||||
-- of that fragment in DAML-LF directly.
|
-- of that fragment in Daml-LF directly.
|
||||||
, tplKeyMaintainers :: !Expr
|
, tplKeyMaintainers :: !Expr
|
||||||
}
|
}
|
||||||
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
||||||
@ -989,7 +989,7 @@ data TemplateChoice = TemplateChoice
|
|||||||
data FeatureFlags = FeatureFlags
|
data FeatureFlags = FeatureFlags
|
||||||
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
||||||
|
|
||||||
-- | Feature flags for DAML 1.2.
|
-- | Feature flags for Daml 1.2.
|
||||||
daml12FeatureFlags :: FeatureFlags
|
daml12FeatureFlags :: FeatureFlags
|
||||||
daml12FeatureFlags = FeatureFlags
|
daml12FeatureFlags = FeatureFlags
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | DAML-LF Numeric literals, with scale attached.
|
-- | Daml-LF Numeric literals, with scale attached.
|
||||||
module DA.Daml.LF.Ast.Numeric
|
module DA.Daml.LF.Ast.Numeric
|
||||||
( Numeric (..)
|
( Numeric (..)
|
||||||
, NumericError (..)
|
, NumericError (..)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
-- | This module provides all the boilerplate necessary to make the DAML-LF AST
|
-- | This module provides all the boilerplate necessary to make the Daml-LF AST
|
||||||
-- work with the recursion-schemes package.
|
-- work with the recursion-schemes package.
|
||||||
module DA.Daml.LF.Ast.Recursive(
|
module DA.Daml.LF.Ast.Recursive(
|
||||||
ExprF(..),
|
ExprF(..),
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{-# LANGUAGE DerivingStrategies #-}
|
{-# LANGUAGE DerivingStrategies #-}
|
||||||
{-# LANGUAGE PatternSynonyms #-}
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
|
|
||||||
-- | Representation of DAML-LF type-level naturals.
|
-- | Representation of Daml-LF type-level naturals.
|
||||||
module DA.Daml.LF.Ast.TypeLevelNat
|
module DA.Daml.LF.Ast.TypeLevelNat
|
||||||
( TypeLevelNat
|
( TypeLevelNat
|
||||||
, TypeLevelNatError (..)
|
, TypeLevelNatError (..)
|
||||||
|
@ -298,8 +298,8 @@ getPackageMetadata pkgName mbPkgVersion =
|
|||||||
|
|
||||||
-- | Given the name of a DALF and the decoded package return package metadata.
|
-- | Given the name of a DALF and the decoded package return package metadata.
|
||||||
--
|
--
|
||||||
-- For newer DAML-LF versions this is taken directly from the
|
-- For newer Daml-LF versions this is taken directly from the
|
||||||
-- package metadata in DAML-LF. For older versions, we instead infer
|
-- package metadata in Daml-LF. For older versions, we instead infer
|
||||||
-- metadata from the filename.
|
-- metadata from the filename.
|
||||||
packageMetadataFromFile :: FilePath -> Package -> PackageId -> (PackageName, Maybe PackageVersion)
|
packageMetadataFromFile :: FilePath -> Package -> PackageId -> (PackageName, Maybe PackageVersion)
|
||||||
packageMetadataFromFile file pkg pkgId
|
packageMetadataFromFile file pkg pkgId
|
||||||
|
@ -12,7 +12,7 @@ import qualified Data.Map.Strict as MS
|
|||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Text.Read as Read
|
import qualified Text.Read as Read
|
||||||
|
|
||||||
-- | DAML-LF version of an archive payload.
|
-- | Daml-LF version of an archive payload.
|
||||||
data Version
|
data Version
|
||||||
= V1{versionMinor :: MinorVersion}
|
= V1{versionMinor :: MinorVersion}
|
||||||
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
||||||
@ -20,39 +20,39 @@ data Version
|
|||||||
data MinorVersion = PointStable Int | PointDev
|
data MinorVersion = PointStable Int | PointDev
|
||||||
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
deriving (Eq, Data, Generic, NFData, Ord, Show)
|
||||||
|
|
||||||
-- | DAML-LF version 1.6
|
-- | Daml-LF version 1.6
|
||||||
version1_6 :: Version
|
version1_6 :: Version
|
||||||
version1_6 = V1 $ PointStable 6
|
version1_6 = V1 $ PointStable 6
|
||||||
|
|
||||||
-- | DAML-LF version 1.7
|
-- | Daml-LF version 1.7
|
||||||
version1_7 :: Version
|
version1_7 :: Version
|
||||||
version1_7 = V1 $ PointStable 7
|
version1_7 = V1 $ PointStable 7
|
||||||
|
|
||||||
-- | DAML-LF version 1.8
|
-- | Daml-LF version 1.8
|
||||||
version1_8 :: Version
|
version1_8 :: Version
|
||||||
version1_8 = V1 $ PointStable 8
|
version1_8 = V1 $ PointStable 8
|
||||||
|
|
||||||
-- | DAML-LF version 1.11
|
-- | Daml-LF version 1.11
|
||||||
version1_11 :: Version
|
version1_11 :: Version
|
||||||
version1_11 = V1 $ PointStable 11
|
version1_11 = V1 $ PointStable 11
|
||||||
|
|
||||||
-- | DAML-LF version 1.12
|
-- | Daml-LF version 1.12
|
||||||
version1_12 :: Version
|
version1_12 :: Version
|
||||||
version1_12 = V1 $ PointStable 12
|
version1_12 = V1 $ PointStable 12
|
||||||
|
|
||||||
-- | DAML-LF version 1.13
|
-- | Daml-LF version 1.13
|
||||||
version1_13 :: Version
|
version1_13 :: Version
|
||||||
version1_13 = V1 $ PointStable 13
|
version1_13 = V1 $ PointStable 13
|
||||||
|
|
||||||
-- | DAML-LF version 1.14
|
-- | Daml-LF version 1.14
|
||||||
version1_14 :: Version
|
version1_14 :: Version
|
||||||
version1_14 = V1 $ PointStable 14
|
version1_14 = V1 $ PointStable 14
|
||||||
|
|
||||||
-- | The DAML-LF version used by default.
|
-- | The Daml-LF version used by default.
|
||||||
versionDefault :: Version
|
versionDefault :: Version
|
||||||
versionDefault = version1_14
|
versionDefault = version1_14
|
||||||
|
|
||||||
-- | The DAML-LF development version.
|
-- | The Daml-LF development version.
|
||||||
versionDev :: Version
|
versionDev :: Version
|
||||||
versionDev = V1 PointDev
|
versionDev = V1 PointDev
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ alphaTests = testGroup "alpha equivalence"
|
|||||||
assertAlpha
|
assertAlpha
|
||||||
(ELet (Binding (ExprVarName "x", TInt64) (ENone TInt64)) (EVar (ExprVarName "x")))
|
(ELet (Binding (ExprVarName "x", TInt64) (ENone TInt64)) (EVar (ExprVarName "x")))
|
||||||
(ELet (Binding (ExprVarName "y", TInt64) (ENone TInt64)) (EVar (ExprVarName "y")))
|
(ELet (Binding (ExprVarName "y", TInt64) (ENone TInt64)) (EVar (ExprVarName "y")))
|
||||||
assertNotAlpha -- NOTE: "let" is not recursive in DAML-LF
|
assertNotAlpha -- NOTE: "let" is not recursive in Daml-LF
|
||||||
(ELet (Binding (ExprVarName "x", TInt64) (EVar (ExprVarName "x"))) (EVar (ExprVarName "x")))
|
(ELet (Binding (ExprVarName "x", TInt64) (EVar (ExprVarName "x"))) (EVar (ExprVarName "x")))
|
||||||
(ELet (Binding (ExprVarName "y", TInt64) (EVar (ExprVarName "y"))) (EVar (ExprVarName "y")))
|
(ELet (Binding (ExprVarName "y", TInt64) (EVar (ExprVarName "y"))) (EVar (ExprVarName "y")))
|
||||||
assertAlpha
|
assertAlpha
|
||||||
|
@ -2,7 +2,7 @@ cabal-version: 2.4
|
|||||||
name: daml-lf-proto
|
name: daml-lf-proto
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
version: 0.1.15.0
|
version: 0.1.15.0
|
||||||
synopsis: DAML-LF Protobuf Encoding
|
synopsis: Daml-LF Protobuf Encoding
|
||||||
license: Apache-2.0
|
license: Apache-2.0
|
||||||
author: Digital Asset
|
author: Digital Asset
|
||||||
maintainer: Digital Asset
|
maintainer: Digital Asset
|
||||||
|
@ -18,16 +18,16 @@ import qualified Data.Text.Internal as T (text)
|
|||||||
import qualified Data.Text.Read as T
|
import qualified Data.Text.Read as T
|
||||||
import Data.Word
|
import Data.Word
|
||||||
|
|
||||||
-- DAML-LF talks about *identifier* to build up different kind of
|
-- Daml-LF talks about *identifier* to build up different kind of
|
||||||
-- names.
|
-- names.
|
||||||
--
|
--
|
||||||
-- DAML-LF identifiers are non-empty string of ASCII letters, `$`,
|
-- Daml-LF identifiers are non-empty string of ASCII letters, `$`,
|
||||||
-- and `_` as first character, and ASCII letters, ASCII digits, `$`,
|
-- and `_` as first character, and ASCII letters, ASCII digits, `$`,
|
||||||
-- and `_` afterwords.
|
-- and `_` afterwords.
|
||||||
--
|
--
|
||||||
-- To mangle an DAML identifier into a DAML-LF identifier, we:
|
-- To mangle an Daml identifier into a Daml-LF identifier, we:
|
||||||
--
|
--
|
||||||
-- * Pass through characters DAML-LF allows apart from `$`. Note that
|
-- * Pass through characters Daml-LF allows apart from `$`. Note that
|
||||||
-- the first character is different -- we won't be able to accept
|
-- the first character is different -- we won't be able to accept
|
||||||
-- digits.
|
-- digits.
|
||||||
-- * We escape `$` to `$$`.
|
-- * We escape `$` to `$$`.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | Utilities for working with DAML-LF protobuf archives
|
-- | Utilities for working with Daml-LF protobuf archives
|
||||||
module DA.Daml.LF.Proto3.Archive
|
module DA.Daml.LF.Proto3.Archive
|
||||||
( module DA.Daml.LF.Proto3.Archive.Decode
|
( module DA.Daml.LF.Proto3.Archive.Decode
|
||||||
, module DA.Daml.LF.Proto3.Archive.Encode
|
, module DA.Daml.LF.Proto3.Archive.Encode
|
||||||
|
@ -19,7 +19,7 @@ import qualified Data.ByteString.Lazy as BSL
|
|||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import qualified Proto3.Suite as Proto
|
import qualified Proto3.Suite as Proto
|
||||||
|
|
||||||
-- | Encode a LFv1 package payload into a DAML-LF archive using the default
|
-- | Encode a LFv1 package payload into a Daml-LF archive using the default
|
||||||
-- hash function.
|
-- hash function.
|
||||||
encodeArchiveLazy :: LF.Package -> BSL.ByteString
|
encodeArchiveLazy :: LF.Package -> BSL.ByteString
|
||||||
encodeArchiveLazy = fst . encodeArchiveAndHash
|
encodeArchiveLazy = fst . encodeArchiveAndHash
|
||||||
|
@ -80,7 +80,7 @@ decodeMangledString t = (decoded, unmangledOrErr)
|
|||||||
where !decoded = decodeString t
|
where !decoded = decodeString t
|
||||||
unmangledOrErr = unmangleIdentifier decoded
|
unmangledOrErr = unmangleIdentifier decoded
|
||||||
|
|
||||||
-- | Decode a string that will be interned in DAML-LF 1.7 and onwards.
|
-- | Decode a string that will be interned in Daml-LF 1.7 and onwards.
|
||||||
-- At the protobuf level, we represent internable non-empty lists of strings
|
-- At the protobuf level, we represent internable non-empty lists of strings
|
||||||
-- by a repeatable string and a number. If there's at least one string,
|
-- by a repeatable string and a number. If there's at least one string,
|
||||||
-- then the number must not be set, i.e. zero. If there are no strings,
|
-- then the number must not be set, i.e. zero. If there are no strings,
|
||||||
@ -96,7 +96,7 @@ decodeInternableStrings strs id
|
|||||||
|
|
||||||
-- | Decode the name of a syntactic object, e.g., a variable or a data
|
-- | Decode the name of a syntactic object, e.g., a variable or a data
|
||||||
-- constructor. These strings are mangled to escape special characters. All
|
-- constructor. These strings are mangled to escape special characters. All
|
||||||
-- names will be interned in DAML-LF 1.7 and onwards.
|
-- names will be interned in Daml-LF 1.7 and onwards.
|
||||||
decodeName
|
decodeName
|
||||||
:: Util.EitherLike TL.Text Int32 e
|
:: Util.EitherLike TL.Text Int32 e
|
||||||
=> (T.Text -> a) -> Maybe e -> Decode a
|
=> (T.Text -> a) -> Maybe e -> Decode a
|
||||||
@ -119,7 +119,7 @@ decodeNameString wrapName unmangledOrErr =
|
|||||||
|
|
||||||
-- | Decode the multi-component name of a syntactic object, e.g., a type
|
-- | Decode the multi-component name of a syntactic object, e.g., a type
|
||||||
-- constructor. All compononents are mangled. Dotted names will be interned
|
-- constructor. All compononents are mangled. Dotted names will be interned
|
||||||
-- in DAML-LF 1.7 and onwards.
|
-- in Daml-LF 1.7 and onwards.
|
||||||
decodeDottedName :: Util.EitherLike LF1.DottedName Int32 e
|
decodeDottedName :: Util.EitherLike LF1.DottedName Int32 e
|
||||||
=> ([T.Text] -> a) -> Maybe e -> Decode a
|
=> ([T.Text] -> a) -> Maybe e -> Decode a
|
||||||
decodeDottedName wrapDottedName mbDottedNameOrId = mayDecode "dottedName" mbDottedNameOrId $ \dottedNameOrId -> do
|
decodeDottedName wrapDottedName mbDottedNameOrId = mayDecode "dottedName" mbDottedNameOrId $ \dottedNameOrId -> do
|
||||||
@ -138,7 +138,7 @@ decodeDottedNameId wrapDottedName dnId = do
|
|||||||
Right unmangled -> pure $ wrapDottedName (coerce unmangled)
|
Right unmangled -> pure $ wrapDottedName (coerce unmangled)
|
||||||
|
|
||||||
-- | Decode the name of a top-level value. The name is mangled and will be
|
-- | Decode the name of a top-level value. The name is mangled and will be
|
||||||
-- interned in DAML-LF 1.7 and onwards.
|
-- interned in Daml-LF 1.7 and onwards.
|
||||||
decodeValueName :: String -> V.Vector TL.Text -> Int32 -> Decode ExprValName
|
decodeValueName :: String -> V.Vector TL.Text -> Int32 -> Decode ExprValName
|
||||||
decodeValueName ident mangledV dnId = do
|
decodeValueName ident mangledV dnId = do
|
||||||
(mangled, unmangledOrErr) <- decodeInternableStrings mangledV dnId
|
(mangled, unmangledOrErr) <- decodeInternableStrings mangledV dnId
|
||||||
@ -150,7 +150,7 @@ decodeValueName ident mangledV dnId = do
|
|||||||
throwError $ ParseError $ "Unexpected multi-segment def name: " ++ show mangledV ++ "//" ++ show mangled
|
throwError $ ParseError $ "Unexpected multi-segment def name: " ++ show mangledV ++ "//" ++ show mangled
|
||||||
|
|
||||||
-- | Decode a reference to a top-level value. The name is mangled and will be
|
-- | Decode a reference to a top-level value. The name is mangled and will be
|
||||||
-- interned in DAML-LF 1.7 and onwards.
|
-- interned in Daml-LF 1.7 and onwards.
|
||||||
decodeValName :: LF1.ValName -> Decode (Qualified ExprValName)
|
decodeValName :: LF1.ValName -> Decode (Qualified ExprValName)
|
||||||
decodeValName LF1.ValName{..} = do
|
decodeValName LF1.ValName{..} = do
|
||||||
(pref, mname) <- mayDecode "valNameModule" valNameModule decodeModuleRef
|
(pref, mname) <- mayDecode "valNameModule" valNameModule decodeModuleRef
|
||||||
@ -158,7 +158,7 @@ decodeValName LF1.ValName{..} = do
|
|||||||
pure $ Qualified pref mname name
|
pure $ Qualified pref mname name
|
||||||
|
|
||||||
-- | Decode a reference to a package. Package names are not mangled. Package
|
-- | Decode a reference to a package. Package names are not mangled. Package
|
||||||
-- name are interned since DAML-LF 1.6.
|
-- name are interned since Daml-LF 1.6.
|
||||||
decodePackageRef :: LF1.PackageRef -> Decode PackageRef
|
decodePackageRef :: LF1.PackageRef -> Decode PackageRef
|
||||||
decodePackageRef (LF1.PackageRef pref) =
|
decodePackageRef (LF1.PackageRef pref) =
|
||||||
mayDecode "packageRefSum" pref $ \case
|
mayDecode "packageRefSum" pref $ \case
|
||||||
@ -175,7 +175,7 @@ decodeVersion mbPkgId minorText = do
|
|||||||
let unsupported :: Either Error a
|
let unsupported :: Either Error a
|
||||||
unsupported = throwError (UnsupportedMinorVersion minorText)
|
unsupported = throwError (UnsupportedMinorVersion minorText)
|
||||||
-- we translate "no version" to minor version 0, since we introduced
|
-- we translate "no version" to minor version 0, since we introduced
|
||||||
-- minor versions once DAML-LF v1 was already out, and we want to be
|
-- minor versions once Daml-LF v1 was already out, and we want to be
|
||||||
-- able to parse packages that were compiled before minor versions
|
-- able to parse packages that were compiled before minor versions
|
||||||
-- were a thing. DO NOT replicate this code bejond major version 1!
|
-- were a thing. DO NOT replicate this code bejond major version 1!
|
||||||
minor <- if
|
minor <- if
|
||||||
|
@ -109,11 +109,11 @@ allocDottedName ids = do
|
|||||||
encodeString :: T.Text -> TL.Text
|
encodeString :: T.Text -> TL.Text
|
||||||
encodeString = TL.fromStrict
|
encodeString = TL.fromStrict
|
||||||
|
|
||||||
-- | Encode a string that will be interned in DAML-LF 1.7 and onwards.
|
-- | Encode a string that will be interned in Daml-LF 1.7 and onwards.
|
||||||
encodeInternableString :: T.Text -> Encode (Either TL.Text Int32)
|
encodeInternableString :: T.Text -> Encode (Either TL.Text Int32)
|
||||||
encodeInternableString = coerce (encodeInternableStrings @Identity)
|
encodeInternableString = coerce (encodeInternableStrings @Identity)
|
||||||
|
|
||||||
-- | Encode a string that will be interned in DAML-LF 1.7 and onwards.
|
-- | Encode a string that will be interned in Daml-LF 1.7 and onwards.
|
||||||
encodeInternableStrings :: Traversable t => t T.Text -> Encode (Either (t TL.Text) (t Int32))
|
encodeInternableStrings :: Traversable t => t T.Text -> Encode (Either (t TL.Text) (t Int32))
|
||||||
encodeInternableStrings strs = do
|
encodeInternableStrings strs = do
|
||||||
EncodeEnv{..} <- get
|
EncodeEnv{..} <- get
|
||||||
@ -123,7 +123,7 @@ encodeInternableStrings strs = do
|
|||||||
|
|
||||||
-- | Encode the name of a syntactic object, e.g., a variable or a data
|
-- | Encode the name of a syntactic object, e.g., a variable or a data
|
||||||
-- constructor. These strings are mangled to escape special characters. All
|
-- constructor. These strings are mangled to escape special characters. All
|
||||||
-- names will be interned in DAML-LF 1.7 and onwards.
|
-- names will be interned in Daml-LF 1.7 and onwards.
|
||||||
encodeName
|
encodeName
|
||||||
:: Util.EitherLike TL.Text Int32 e
|
:: Util.EitherLike TL.Text Int32 e
|
||||||
=> (a -> T.Text) -> a -> Encode (Just e)
|
=> (a -> T.Text) -> a -> Encode (Just e)
|
||||||
@ -153,7 +153,7 @@ encodeNames = encodeInternableStrings . fmap mangleName
|
|||||||
|
|
||||||
-- | Encode the multi-component name of a syntactic object, e.g., a type
|
-- | Encode the multi-component name of a syntactic object, e.g., a type
|
||||||
-- constructor. All compononents are mangled. Dotted names will be interned
|
-- constructor. All compononents are mangled. Dotted names will be interned
|
||||||
-- in DAML-LF 1.7 and onwards.
|
-- in Daml-LF 1.7 and onwards.
|
||||||
encodeDottedName :: Util.EitherLike P.DottedName Int32 e
|
encodeDottedName :: Util.EitherLike P.DottedName Int32 e
|
||||||
=> (a -> [T.Text]) -> a -> Encode (Just e)
|
=> (a -> [T.Text]) -> a -> Encode (Just e)
|
||||||
encodeDottedName unwrapDottedName (unwrapDottedName -> unmangled) =
|
encodeDottedName unwrapDottedName (unwrapDottedName -> unmangled) =
|
||||||
@ -179,7 +179,7 @@ encodeDottedNameId unwrapDottedName (unwrapDottedName -> unmangled) = do
|
|||||||
Right id -> pure id
|
Right id -> pure id
|
||||||
|
|
||||||
-- | Encode the name of a top-level value. The name is mangled and will be
|
-- | Encode the name of a top-level value. The name is mangled and will be
|
||||||
-- interned in DAML-LF 1.7 and onwards.
|
-- interned in Daml-LF 1.7 and onwards.
|
||||||
--
|
--
|
||||||
-- For now, value names are always encoded using a single segment.
|
-- For now, value names are always encoded using a single segment.
|
||||||
-- This is to keep backwards compat with older .dalf files, but also
|
-- This is to keep backwards compat with older .dalf files, but also
|
||||||
@ -194,7 +194,7 @@ encodeValueName valName = do
|
|||||||
Right id -> pure (V.empty, id)
|
Right id -> pure (V.empty, id)
|
||||||
|
|
||||||
-- | Encode a reference to a package. Package names are not mangled. Package
|
-- | Encode a reference to a package. Package names are not mangled. Package
|
||||||
-- name are interned since DAML-LF 1.6.
|
-- name are interned since Daml-LF 1.6.
|
||||||
encodePackageRef :: PackageRef -> Encode (Just P.PackageRef)
|
encodePackageRef :: PackageRef -> Encode (Just P.PackageRef)
|
||||||
encodePackageRef = fmap (Just . P.PackageRef . Just) . \case
|
encodePackageRef = fmap (Just . P.PackageRef . Just) . \case
|
||||||
PRSelf -> pure $ P.PackageRefSumSelf P.Unit
|
PRSelf -> pure $ P.PackageRefSumSelf P.Unit
|
||||||
@ -767,7 +767,7 @@ encodeUpdate = fmap (P.Update . Just) . \case
|
|||||||
UExerciseByKey{..} -> do
|
UExerciseByKey{..} -> do
|
||||||
update_ExerciseByKeyTemplate <- encodeQualTypeConName exeTemplate
|
update_ExerciseByKeyTemplate <- encodeQualTypeConName exeTemplate
|
||||||
update_ExerciseByKeyChoiceInternedStr <-
|
update_ExerciseByKeyChoiceInternedStr <-
|
||||||
fromRight (error "INTERNAL: exercise_by_key is only available in DAML-LF versions supporting string interning")
|
fromRight (error "INTERNAL: exercise_by_key is only available in Daml-LF versions supporting string interning")
|
||||||
<$> encodeName' @(Either TL.Text Int32) unChoiceName exeChoice
|
<$> encodeName' @(Either TL.Text Int32) unChoiceName exeChoice
|
||||||
update_ExerciseByKeyKey <- encodeExpr exeKey
|
update_ExerciseByKeyKey <- encodeExpr exeKey
|
||||||
update_ExerciseByKeyArg <- encodeExpr exeArg
|
update_ExerciseByKeyArg <- encodeExpr exeArg
|
||||||
@ -1023,7 +1023,7 @@ encodePackageMetadata PackageMetadata{..} = do
|
|||||||
packageMetadataVersionInternedStr <- fromRight (error "Package name is always interned") <$> encodeInternableString (unPackageVersion packageVersion)
|
packageMetadataVersionInternedStr <- fromRight (error "Package name is always interned") <$> encodeInternableString (unPackageVersion packageVersion)
|
||||||
pure P.PackageMetadata{..}
|
pure P.PackageMetadata{..}
|
||||||
|
|
||||||
-- | NOTE(MH): Assumes the DAML-LF version of the 'Package' is 'V1'.
|
-- | NOTE(MH): Assumes the Daml-LF version of the 'Package' is 'V1'.
|
||||||
encodePackage :: Package -> P.Package
|
encodePackage :: Package -> P.Package
|
||||||
encodePackage (Package version mods metadata) =
|
encodePackage (Package version mods metadata) =
|
||||||
let env = initEncodeEnv version (WithInterning True)
|
let env = initEncodeEnv version (WithInterning True)
|
||||||
@ -1039,8 +1039,8 @@ encodePackage (Package version mods metadata) =
|
|||||||
P.Package{..}
|
P.Package{..}
|
||||||
|
|
||||||
-- | NOTE(MH): This functions is used for sanity checking. The actual checks
|
-- | NOTE(MH): This functions is used for sanity checking. The actual checks
|
||||||
-- are done in the conversion to DAML-LF.
|
-- are done in the conversion to Daml-LF.
|
||||||
_checkFeature :: Feature -> Version -> a -> a
|
_checkFeature :: Feature -> Version -> a -> a
|
||||||
_checkFeature feature version x
|
_checkFeature feature version x
|
||||||
| version `supports` feature = x
|
| version `supports` feature = x
|
||||||
| otherwise = error $ "DAML-LF " ++ renderPretty version ++ " cannot encode feature: " ++ T.unpack (featureName feature)
|
| otherwise = error $ "Daml-LF " ++ renderPretty version ++ " cannot encode feature: " ++ T.unpack (featureName feature)
|
||||||
|
@ -2,7 +2,7 @@ cabal-version: 2.4
|
|||||||
name: daml-lf-reader
|
name: daml-lf-reader
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
version: 0.1.15.0
|
version: 0.1.15.0
|
||||||
synopsis: DAML-LF Archive reader
|
synopsis: Daml-LF Archive reader
|
||||||
license: Apache-2.0
|
license: Apache-2.0
|
||||||
author: Digital Asset
|
author: Digital Asset
|
||||||
maintainer: Digital Asset
|
maintainer: Digital Asset
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
{-# LANGUAGE RankNTypes #-}
|
{-# LANGUAGE RankNTypes #-}
|
||||||
-- | This module contains the DAML-LF type checker.
|
-- | This module contains the Daml-LF type checker.
|
||||||
--
|
--
|
||||||
-- Some notes:
|
-- Some notes:
|
||||||
--
|
--
|
||||||
@ -507,7 +507,7 @@ typeOfAltsOptional elemType =
|
|||||||
CPDefault -> (,) AllRanks <$> typeOf rhs
|
CPDefault -> (,) AllRanks <$> typeOf rhs
|
||||||
_ -> throwWithContext (EPatternTypeMismatch patn (TOptional elemType))
|
_ -> throwWithContext (EPatternTypeMismatch patn (TOptional elemType))
|
||||||
|
|
||||||
-- NOTE(MH): The DAML-LF spec says that `CPDefault` matches _every_ value,
|
-- NOTE(MH): The Daml-LF spec says that `CPDefault` matches _every_ value,
|
||||||
-- regardless of its type.
|
-- regardless of its type.
|
||||||
typeOfAltsOnlyDefault :: MonadGamma m => Type -> [CaseAlternative] -> m (MatchedRanks, Type)
|
typeOfAltsOnlyDefault :: MonadGamma m => Type -> [CaseAlternative] -> m (MatchedRanks, Type)
|
||||||
typeOfAltsOnlyDefault scrutType =
|
typeOfAltsOnlyDefault scrutType =
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{-# LANGUAGE RankNTypes #-}
|
{-# LANGUAGE RankNTypes #-}
|
||||||
{-# LANGUAGE TemplateHaskell #-}
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
|
||||||
-- | This module provides the data type for the environment of the DAML-LF type
|
-- | This module provides the data type for the environment of the Daml-LF type
|
||||||
-- checker and functions to manipulate it.
|
-- checker and functions to manipulate it.
|
||||||
module DA.Daml.LF.TypeChecker.Env(
|
module DA.Daml.LF.TypeChecker.Env(
|
||||||
MonadGamma,
|
MonadGamma,
|
||||||
@ -31,7 +31,7 @@ import Data.HashMap.Strict (HashMap)
|
|||||||
import DA.Daml.LF.Ast
|
import DA.Daml.LF.Ast
|
||||||
import DA.Daml.LF.TypeChecker.Error
|
import DA.Daml.LF.TypeChecker.Error
|
||||||
|
|
||||||
-- | The environment for the DAML-LF type checker.
|
-- | The environment for the Daml-LF type checker.
|
||||||
data Gamma = Gamma
|
data Gamma = Gamma
|
||||||
{ _locCtx :: !Context
|
{ _locCtx :: !Context
|
||||||
-- ^ The current type checking context for error reporting.
|
-- ^ The current type checking context for error reporting.
|
||||||
@ -42,7 +42,7 @@ data Gamma = Gamma
|
|||||||
, _world :: !World
|
, _world :: !World
|
||||||
-- ^ The packages in scope.
|
-- ^ The packages in scope.
|
||||||
, _lfVersion :: Version
|
, _lfVersion :: Version
|
||||||
-- ^ The DAML-LF version of the package being type checked.
|
-- ^ The Daml-LF version of the package being type checked.
|
||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''Gamma
|
makeLenses ''Gamma
|
||||||
|
@ -362,7 +362,7 @@ instance Pretty Error where
|
|||||||
"expected list type, but found: " <> pretty typ
|
"expected list type, but found: " <> pretty typ
|
||||||
EUnsupportedFeature Feature{..} ->
|
EUnsupportedFeature Feature{..} ->
|
||||||
"unsupported feature:" <-> pretty featureName
|
"unsupported feature:" <-> pretty featureName
|
||||||
<-> "only supported in DAML-LF version" <-> pretty featureMinVersion <-> "and later"
|
<-> "only supported in Daml-LF version" <-> pretty featureMinVersion <-> "and later"
|
||||||
EForbiddenNameCollision name names ->
|
EForbiddenNameCollision name names ->
|
||||||
"name collision between " <-> pretty name <-> " and " <-> pretty (T.intercalate ", " names)
|
"name collision between " <-> pretty name <-> " and " <-> pretty (T.intercalate ", " names)
|
||||||
ESynAppWrongArity DefTypeSyn{synName,synParams} args ->
|
ESynAppWrongArity DefTypeSyn{synName,synParams} args ->
|
||||||
@ -438,7 +438,7 @@ toDiagnostic sev err = Diagnostic
|
|||||||
, _severity = Just sev
|
, _severity = Just sev
|
||||||
, _code = Nothing
|
, _code = Nothing
|
||||||
, _tags = Nothing
|
, _tags = Nothing
|
||||||
, _source = Just "DAML-LF typechecker"
|
, _source = Just "Daml-LF typechecker"
|
||||||
, _message = renderPretty err
|
, _message = renderPretty err
|
||||||
, _relatedInformation = Nothing
|
, _relatedInformation = Nothing
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ checkModule m = do
|
|||||||
-- | Is one module an ascendant of another? For instance
|
-- | Is one module an ascendant of another? For instance
|
||||||
-- module "A" is an ascendant of module "A.B" and "A.B.C".
|
-- module "A" is an ascendant of module "A.B" and "A.B.C".
|
||||||
--
|
--
|
||||||
-- Normally we wouldn't care about this in DAML, because
|
-- Normally we wouldn't care about this in Daml, because
|
||||||
-- the name of a module has no relation to its logical
|
-- the name of a module has no relation to its logical
|
||||||
-- dependency structure. But since we're compiling to LF,
|
-- dependency structure. But since we're compiling to LF,
|
||||||
-- module names (e.g. "A.B") may conflict with type names
|
-- module names (e.g. "A.B") may conflict with type names
|
||||||
@ -253,9 +253,9 @@ checkModule m = do
|
|||||||
-- may arise.
|
-- may arise.
|
||||||
--
|
--
|
||||||
-- The check here is case-insensitive because the name-collision
|
-- The check here is case-insensitive because the name-collision
|
||||||
-- condition in DAML-LF is case-insensitiv (in order to make
|
-- condition in Daml-LF is case-insensitiv (in order to make
|
||||||
-- codegen easier for languages that control case differently
|
-- codegen easier for languages that control case differently
|
||||||
-- from DAML).
|
-- from Daml).
|
||||||
isAscendant :: ModuleName -> ModuleName -> Bool
|
isAscendant :: ModuleName -> ModuleName -> Bool
|
||||||
isAscendant (ModuleName xs) (ModuleName ys) =
|
isAscendant (ModuleName xs) (ModuleName ys) =
|
||||||
(length xs < length ys) && and (zipWith sameish xs ys)
|
(length xs < length ys) && and (zipWith sameish xs ys)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | This module provides a function to check that a DAML-LF module does not
|
-- | This module provides a function to check that a Daml-LF module does not
|
||||||
-- contain recursive data type definitions.
|
-- contain recursive data type definitions.
|
||||||
module DA.Daml.LF.TypeChecker.Recursion
|
module DA.Daml.LF.TypeChecker.Recursion
|
||||||
( checkModule
|
( checkModule
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | This module provides functions to perform the DAML-LF constraint checks on
|
-- | This module provides functions to perform the Daml-LF constraint checks on
|
||||||
-- types in certain positions. In fact, we also need to do some form of
|
-- types in certain positions. In fact, we also need to do some form of
|
||||||
-- "constraint inference". To perform this inference in an incremental fashion,
|
-- "constraint inference". To perform this inference in an incremental fashion,
|
||||||
-- we also provide a way to augment a 'ModuleInterface' with constraint
|
-- we also provide a way to augment a 'ModuleInterface' with constraint
|
||||||
-- information about the exported data types in 'augmentInterface'.
|
-- information about the exported data types in 'augmentInterface'.
|
||||||
--
|
--
|
||||||
-- Checking whether a function or template definition complies with the DAML-LF
|
-- Checking whether a function or template definition complies with the Daml-LF
|
||||||
-- type constraints is straightforward. It is implemented in 'checkModule', which
|
-- type constraints is straightforward. It is implemented in 'checkModule', which
|
||||||
-- assumes that the constraint information on the data types in the module being
|
-- assumes that the constraint information on the data types in the module being
|
||||||
-- checked have already been inferred. In other words, the environment must
|
-- checked have already been inferred. In other words, the environment must
|
||||||
@ -106,7 +106,7 @@ serializabilityConditionsType world0 _version mbCurrentModule vars = go
|
|||||||
BTUpdate -> Left URUpdate
|
BTUpdate -> Left URUpdate
|
||||||
BTScenario -> Left URScenario
|
BTScenario -> Left URScenario
|
||||||
BTContractId -> Left URContractId -- 'ContractId' is used as a higher-kinded type constructor
|
BTContractId -> Left URContractId -- 'ContractId' is used as a higher-kinded type constructor
|
||||||
-- (or polymorphically in DAML-LF <= 1.4).
|
-- (or polymorphically in Daml-LF <= 1.4).
|
||||||
BTArrow -> Left URFunction
|
BTArrow -> Left URFunction
|
||||||
BTNumeric -> Left URNumeric -- 'Numeric' is used as a higher-kinded type constructor.
|
BTNumeric -> Left URNumeric -- 'Numeric' is used as a higher-kinded type constructor.
|
||||||
BTAny -> Left URAny
|
BTAny -> Left URAny
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Hoogle documentation for DAML, generated by damlc
|
-- Hoogle documentation for Daml, generated by damlc
|
||||||
-- See Hoogle, http://www.haskell.org/hoogle/
|
-- See Hoogle, http://www.haskell.org/hoogle/
|
||||||
|
|
||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates.
|
||||||
|
@ -73,11 +73,11 @@ createDarFile loggerH fp dar = do
|
|||||||
|
|
||||||
A (fat) dar file is a zip file containing
|
A (fat) dar file is a zip file containing
|
||||||
|
|
||||||
* a dalf of a DAML library <name>.dalf
|
* a dalf of a Daml library <name>.dalf
|
||||||
* a MANIFEST.MF file that describes the package
|
* a MANIFEST.MF file that describes the package
|
||||||
* all source files to that library
|
* all source files to that library
|
||||||
- a dependency tree of imports
|
- a dependency tree of imports
|
||||||
- starting from the given top-level DAML 'file'
|
- starting from the given top-level Daml 'file'
|
||||||
- all these files _must_ reside in the same “source root” directory
|
- all these files _must_ reside in the same “source root” directory
|
||||||
- the “source root” in the absolute path is replaced by 'name-hash'
|
- the “source root” in the absolute path is replaced by 'name-hash'
|
||||||
* all dalf dependencies
|
* all dalf dependencies
|
||||||
@ -243,7 +243,7 @@ mergePkgs pkgName mbPkgVer ver pkgs =
|
|||||||
LF.Package { LF.packageLfVersion = ver, LF.packageModules = NM.empty, LF.packageMetadata = Just $ LF.getPackageMetadata pkgName mbPkgVer }
|
LF.Package { LF.packageLfVersion = ver, LF.packageModules = NM.empty, LF.packageMetadata = Just $ LF.getPackageMetadata pkgName mbPkgVer }
|
||||||
pkgs
|
pkgs
|
||||||
|
|
||||||
-- | Find all DAML files below a given source root. If the source root is a file we interpret it as
|
-- | Find all Daml files below a given source root. If the source root is a file we interpret it as
|
||||||
-- main and return that file and all dependencies.
|
-- main and return that file and all dependencies.
|
||||||
getDamlFiles :: FilePath -> MaybeT Action [NormalizedFilePath]
|
getDamlFiles :: FilePath -> MaybeT Action [NormalizedFilePath]
|
||||||
getDamlFiles srcRoot = do
|
getDamlFiles srcRoot = do
|
||||||
@ -266,7 +266,7 @@ damlFilesInDir srcRoot = do
|
|||||||
srcRoot
|
srcRoot
|
||||||
pure $ map toNormalizedFilePath' $ filter (".daml" `isExtensionOf`) fs
|
pure $ map toNormalizedFilePath' $ filter (".daml" `isExtensionOf`) fs
|
||||||
|
|
||||||
-- | Find all DAML files below a given source root. If the source root is a file we interpret it as
|
-- | Find all Daml files below a given source root. If the source root is a file we interpret it as
|
||||||
-- main and return only that file. This is different from getDamlFiles which also returns
|
-- main and return only that file. This is different from getDamlFiles which also returns
|
||||||
-- all dependencies.
|
-- all dependencies.
|
||||||
getDamlRootFiles :: FilePath -> IO [NormalizedFilePath]
|
getDamlRootFiles :: FilePath -> IO [NormalizedFilePath]
|
||||||
|
@ -196,7 +196,7 @@ isDuplicate ty1 ty2 = LF.alphaType (getExpandedType ty1) (getExpandedType ty2)
|
|||||||
data ImportOrigin = FromCurrentSdk UnitId | FromPackage LF.PackageId
|
data ImportOrigin = FromCurrentSdk UnitId | FromPackage LF.PackageId
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
-- | A module reference coming from DAML-LF.
|
-- | A module reference coming from Daml-LF.
|
||||||
data ModRef = ModRef
|
data ModRef = ModRef
|
||||||
{ modRefModule :: LF.ModuleName
|
{ modRefModule :: LF.ModuleName
|
||||||
, modRefOrigin :: ImportOrigin
|
, modRefOrigin :: ImportOrigin
|
||||||
@ -707,7 +707,7 @@ generateSrcFromLf env = noLoc mod
|
|||||||
convConDetails hasExactlyOneConstructor = \case
|
convConDetails hasExactlyOneConstructor = \case
|
||||||
-- nullary variant constructor (see issue #7207)
|
-- nullary variant constructor (see issue #7207)
|
||||||
--
|
--
|
||||||
-- We translate a variant constructor `C ()` to `C` in DAML. But
|
-- We translate a variant constructor `C ()` to `C` in Daml. But
|
||||||
-- if it's the only constructor, we leave it as `C ()` to distinguish
|
-- if it's the only constructor, we leave it as `C ()` to distinguish
|
||||||
-- it from an enum type.
|
-- it from an enum type.
|
||||||
LF.TUnit | not hasExactlyOneConstructor ->
|
LF.TUnit | not hasExactlyOneConstructor ->
|
||||||
@ -1425,7 +1425,7 @@ getSuperclassReferences body =
|
|||||||
isDFunName :: LF.ExprValName -> Bool
|
isDFunName :: LF.ExprValName -> Bool
|
||||||
isDFunName (LF.ExprValName t) = any (`T.isPrefixOf` t) ["$f", "$d"]
|
isDFunName (LF.ExprValName t) = any (`T.isPrefixOf` t) ["$f", "$d"]
|
||||||
|
|
||||||
-- | Convert dictionary function signature into a DAML type.
|
-- | Convert dictionary function signature into a Daml type.
|
||||||
convDFunSig :: Env -> MS.Map LF.TypeSynName LF.PackageId -> DFunSig -> Gen (HsType GhcPs)
|
convDFunSig :: Env -> MS.Map LF.TypeSynName LF.PackageId -> DFunSig -> Gen (HsType GhcPs)
|
||||||
convDFunSig env reexported DFunSig{..} = do
|
convDFunSig env reexported DFunSig{..} = do
|
||||||
binders <- mapM (convTyVarBinder env) dfsBinders
|
binders <- mapM (convTyVarBinder env) dfsBinders
|
||||||
|
@ -135,7 +135,7 @@ shadowPat vars p
|
|||||||
go p@NPat{} = p
|
go p@NPat{} = p
|
||||||
go NPlusKPat{} = error "N+k patterns are not suppported"
|
go NPlusKPat{} = error "N+k patterns are not suppported"
|
||||||
go (SigPat ext pat sig) = SigPat ext (go pat) sig
|
go (SigPat ext pat sig) = SigPat ext (go pat) sig
|
||||||
go SplicePat {} = error "DAML does not support Template Haskell"
|
go SplicePat {} = error "Daml does not support Template Haskell"
|
||||||
go (CoPat ext wrap pat ty) = CoPat ext wrap (go pat) ty
|
go (CoPat ext wrap pat ty) = CoPat ext wrap (go pat) ty
|
||||||
go (XPat locP) = XPat (fmap go locP)
|
go (XPat locP) = XPat (fmap go locP)
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ runDamlDoc options@DamldocOptions{..} = do
|
|||||||
docData <- inputDocData options
|
docData <- inputDocData options
|
||||||
renderDocData options (applyTransform do_transformOptions docData)
|
renderDocData options (applyTransform do_transformOptions docData)
|
||||||
|
|
||||||
-- | Load doc data, either via the DAML typechecker or via JSON files.
|
-- | Load doc data, either via the Daml typechecker or via JSON files.
|
||||||
inputDocData :: DamldocOptions -> IO [ModuleDoc]
|
inputDocData :: DamldocOptions -> IO [ModuleDoc]
|
||||||
inputDocData DamldocOptions{..} = do
|
inputDocData DamldocOptions{..} = do
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | This module extracts docs from DAML modules. It does so by reading
|
-- | This module extracts docs from Daml modules. It does so by reading
|
||||||
-- haddock-style comments from the parsed syntax tree and correlating them
|
-- haddock-style comments from the parsed syntax tree and correlating them
|
||||||
-- with definitions in the typechecked module in order to obtain accurate
|
-- with definitions in the typechecked module in order to obtain accurate
|
||||||
-- type information.
|
-- type information.
|
||||||
|
@ -56,9 +56,9 @@ data DocCtx = DocCtx
|
|||||||
, dc_ids :: MS.Map Fieldname Id
|
, dc_ids :: MS.Map Fieldname Id
|
||||||
-- ^ values defined in this module
|
-- ^ values defined in this module
|
||||||
, dc_templates :: Set.Set Typename
|
, dc_templates :: Set.Set Typename
|
||||||
-- ^ DAML templates defined in this module
|
-- ^ Daml templates defined in this module
|
||||||
, dc_choices :: MS.Map Typename (Set.Set Typename)
|
, dc_choices :: MS.Map Typename (Set.Set Typename)
|
||||||
-- ^ choices per DAML template defined in this module
|
-- ^ choices per Daml template defined in this module
|
||||||
, dc_extractOptions :: ExtractOptions
|
, dc_extractOptions :: ExtractOptions
|
||||||
-- ^ command line options that affect the doc extractor
|
-- ^ command line options that affect the doc extractor
|
||||||
, dc_exports :: ExportSet
|
, dc_exports :: ExportSet
|
||||||
|
@ -13,7 +13,7 @@ data RenderFormat = Rst | Markdown | Html
|
|||||||
deriving (Eq, Show, Read, Enum, Bounded)
|
deriving (Eq, Show, Read, Enum, Bounded)
|
||||||
|
|
||||||
-- | Control whether to render docs as a single file, or as
|
-- | Control whether to render docs as a single file, or as
|
||||||
-- an interlinked folder of many files, one per DAML module.
|
-- an interlinked folder of many files, one per Daml module.
|
||||||
data RenderMode
|
data RenderMode
|
||||||
= RenderToFile FilePath -- ^ render to single file
|
= RenderToFile FilePath -- ^ render to single file
|
||||||
| RenderToFolder FilePath -- ^ render to folder, one file per module
|
| RenderToFolder FilePath -- ^ render to folder, one file per module
|
||||||
|
@ -302,7 +302,7 @@
|
|||||||
- warn: {lhs: bimap f1 g (first f2 x), rhs: bimap (f1 . f2) g x}
|
- warn: {lhs: bimap f1 g (first f2 x), rhs: bimap (f1 . f2) g x}
|
||||||
- warn: {lhs: bimap f g1 (second g2 x), rhs: bimap f (g1 . g2) x}
|
- warn: {lhs: bimap f g1 (second g2 x), rhs: bimap f (g1 . g2) x}
|
||||||
# We disable those rules since nobody should have to understand bifunctors
|
# We disable those rules since nobody should have to understand bifunctors
|
||||||
# to use DAML.
|
# to use Daml.
|
||||||
# - hint: {lhs: "\\(x,y) -> (f x, g y)", rhs: DA.Bifunctor.bimap f g}
|
# - hint: {lhs: "\\(x,y) -> (f x, g y)", rhs: DA.Bifunctor.bimap f g}
|
||||||
# - hint: {lhs: "\\(x,y) -> (f x,y)", rhs: DA.Bifunctor.first f}
|
# - hint: {lhs: "\\(x,y) -> (f x,y)", rhs: DA.Bifunctor.first f}
|
||||||
# - hint: {lhs: "\\(x,y) -> (x,f y)", rhs: DA.Bifunctor.second f}
|
# - hint: {lhs: "\\(x,y) -> (x,f y)", rhs: DA.Bifunctor.second f}
|
||||||
@ -659,7 +659,7 @@
|
|||||||
- hint: {lhs: "not (x && y)", rhs: "not x || not y", name: Apply De Morgan law}
|
- hint: {lhs: "not (x && y)", rhs: "not x || not y", name: Apply De Morgan law}
|
||||||
|
|
||||||
# --
|
# --
|
||||||
# DAML specific
|
# Daml specific
|
||||||
|
|
||||||
# Not popular or useful
|
# Not popular or useful
|
||||||
- ignore: {name: Use camelCase}
|
- ignore: {name: Use camelCase}
|
||||||
@ -667,16 +667,16 @@
|
|||||||
# -Wunused-matches. Also, it's generally considered by Neil to be
|
# -Wunused-matches. Also, it's generally considered by Neil to be
|
||||||
# dodgy.
|
# dodgy.
|
||||||
- ignore: {name: Reduce duplication}
|
- ignore: {name: Reduce duplication}
|
||||||
# Not relevant to DAML
|
# Not relevant to Daml
|
||||||
- ignore: {name: Use newtype instead of data}
|
- ignore: {name: Use newtype instead of data}
|
||||||
# Don't warn on redundant parens or $
|
# Don't warn on redundant parens or $
|
||||||
- ignore: {name: Redundant bracket}
|
- ignore: {name: Redundant bracket}
|
||||||
- ignore: {name: Redundant $}
|
- ignore: {name: Redundant $}
|
||||||
# Don't warn on redundant do (DAML choice syntax *mandates* 'do'!)
|
# Don't warn on redundant do (Daml choice syntax *mandates* 'do'!)
|
||||||
- ignore: {name: Redundant do}
|
- ignore: {name: Redundant do}
|
||||||
# ApplicativeDo syntax mandates 'pure's which seem redundant
|
# ApplicativeDo syntax mandates 'pure's which seem redundant
|
||||||
- ignore: {name: Redundant pure}
|
- ignore: {name: Redundant pure}
|
||||||
# Not helpful for beginner DAML programmers
|
# Not helpful for beginner Daml programmers
|
||||||
- ignore: {name: Eta reduce}
|
- ignore: {name: Eta reduce}
|
||||||
- ignore: {name: Avoid lambda}
|
- ignore: {name: Avoid lambda}
|
||||||
# Disabled to avoid introducing even more syntax.
|
# Disabled to avoid introducing even more syntax.
|
||||||
|
@ -372,7 +372,7 @@ ondiskDesugar hsc tm =
|
|||||||
-- This rule is for on-disk incremental builds. We cannot use the fine-grained rules that we have for
|
-- This rule is for on-disk incremental builds. We cannot use the fine-grained rules that we have for
|
||||||
-- in-memory builds since we need to be able to serialize intermediate results. GHC doesn’t provide a way to serialize
|
-- in-memory builds since we need to be able to serialize intermediate results. GHC doesn’t provide a way to serialize
|
||||||
-- TypeCheckedModules or CoreModules. In addition to that, making this too fine-grained would probably also incur a performance penalty.
|
-- TypeCheckedModules or CoreModules. In addition to that, making this too fine-grained would probably also incur a performance penalty.
|
||||||
-- Therefore we have a single rule that performs the steps parsed module -> typechecked module -> core module -> DAML-LF module.
|
-- Therefore we have a single rule that performs the steps parsed module -> typechecked module -> core module -> Daml-LF module.
|
||||||
-- This rule writes both the .dalf and the .hi files.
|
-- This rule writes both the .dalf and the .hi files.
|
||||||
-- We use the ABI hash of the .hi files to detect if we need to recompile dependent files. Note that this is more aggressive
|
-- We use the ABI hash of the .hi files to detect if we need to recompile dependent files. Note that this is more aggressive
|
||||||
-- than just looking at the file hash. E.g., consider module A depending on module B. If B changes but its ABI hash stays the same
|
-- than just looking at the file hash. E.g., consider module A depending on module B. If B changes but its ABI hash stays the same
|
||||||
@ -711,7 +711,7 @@ writeDalfFile dalfFile mod = do
|
|||||||
liftIO $ createDirectoryIfMissing True (takeDirectory $ fromNormalizedFilePath dalfFile)
|
liftIO $ createDirectoryIfMissing True (takeDirectory $ fromNormalizedFilePath dalfFile)
|
||||||
liftIO $ BSL.writeFile (fromNormalizedFilePath dalfFile) $ Proto.toLazyByteString $ encodeScenarioModule lfVersion mod
|
liftIO $ BSL.writeFile (fromNormalizedFilePath dalfFile) $ Proto.toLazyByteString $ encodeScenarioModule lfVersion mod
|
||||||
|
|
||||||
-- Generates a DAML-LF archive without adding serializability information
|
-- Generates a Daml-LF archive without adding serializability information
|
||||||
-- or type checking it. This must only be used for debugging/testing.
|
-- or type checking it. This must only be used for debugging/testing.
|
||||||
generateRawPackageRule :: Options -> Rules ()
|
generateRawPackageRule :: Options -> Rules ()
|
||||||
generateRawPackageRule options =
|
generateRawPackageRule options =
|
||||||
@ -1048,7 +1048,7 @@ vrNoteSetNotification vr note = do
|
|||||||
-- A rule that builds the files-of-interest and notifies via the
|
-- A rule that builds the files-of-interest and notifies via the
|
||||||
-- callback of any errors. NOTE: results may contain errors for any
|
-- callback of any errors. NOTE: results may contain errors for any
|
||||||
-- dependent module.
|
-- dependent module.
|
||||||
-- TODO (MK): We should have a non-DAML version of this rule
|
-- TODO (MK): We should have a non-Daml version of this rule
|
||||||
ofInterestRule :: Options -> Rules ()
|
ofInterestRule :: Options -> Rules ()
|
||||||
ofInterestRule opts = do
|
ofInterestRule opts = do
|
||||||
-- go through a rule (not just an action), so it shows up in the profile
|
-- go through a rule (not just an action), so it shows up in the profile
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
|
||||||
-- | Gather code lenses like scenario execution for a DAML file.
|
-- | Gather code lenses like scenario execution for a Daml file.
|
||||||
module DA.Daml.LanguageServer.CodeLens
|
module DA.Daml.LanguageServer.CodeLens
|
||||||
( plugin
|
( plugin
|
||||||
) where
|
) where
|
||||||
@ -24,7 +24,7 @@ import Development.IDE.Types.Location
|
|||||||
import Language.LSP.Types
|
import Language.LSP.Types
|
||||||
import qualified Language.LSP.Server as LSP
|
import qualified Language.LSP.Server as LSP
|
||||||
|
|
||||||
-- | Gather code lenses like scenario execution for a DAML file.
|
-- | Gather code lenses like scenario execution for a Daml file.
|
||||||
handle
|
handle
|
||||||
:: IdeState
|
:: IdeState
|
||||||
-> CodeLensParams
|
-> CodeLensParams
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
-- | Useful references:
|
-- | Useful references:
|
||||||
--
|
--
|
||||||
-- * DAML-LF AST: https://github.com/digital-asset/daml/blob/main/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
|
-- * Daml-LF AST: https://github.com/digital-asset/daml/blob/main/compiler/daml-lf-ast/src/DA/Daml/LF/Ast/Base.hs
|
||||||
-- * GHC Syntax: https://hackage.haskell.org/package/ghc-8.4.1/docs/CoreSyn.html#t:Expr
|
-- * GHC Syntax: https://hackage.haskell.org/package/ghc-8.4.1/docs/CoreSyn.html#t:Expr
|
||||||
--
|
--
|
||||||
-- The conversion works element by element, in a fairly direct way, apart from the exceptions
|
-- The conversion works element by element, in a fairly direct way, apart from the exceptions
|
||||||
@ -22,7 +22,7 @@
|
|||||||
-- DICTIONARY SANITIZATION
|
-- DICTIONARY SANITIZATION
|
||||||
--
|
--
|
||||||
-- GHC's desugaring for default methods relies on the fact that Haskell is
|
-- GHC's desugaring for default methods relies on the fact that Haskell is
|
||||||
-- lazy. In contrast, DAML-LF is strict. This mismatch causes a few problems.
|
-- lazy. In contrast, Daml-LF is strict. This mismatch causes a few problems.
|
||||||
-- For instance, GHC desugars:
|
-- For instance, GHC desugars:
|
||||||
--
|
--
|
||||||
-- > class Foo a where
|
-- > class Foo a where
|
||||||
@ -50,7 +50,7 @@
|
|||||||
--
|
--
|
||||||
-- To fix this problem, we make the fields of dictionary types (like @Foo@)
|
-- To fix this problem, we make the fields of dictionary types (like @Foo@)
|
||||||
-- lazy by introducing an artificial argument of type @Unit@ to them. In order
|
-- lazy by introducing an artificial argument of type @Unit@ to them. In order
|
||||||
-- to do so, we do three transformations on the generated DAML-LF:
|
-- to do so, we do three transformations on the generated Daml-LF:
|
||||||
--
|
--
|
||||||
-- (1) Translate dictionary type definitions with an extra @Unit@ argument
|
-- (1) Translate dictionary type definitions with an extra @Unit@ argument
|
||||||
-- for each field.
|
-- for each field.
|
||||||
@ -64,7 +64,7 @@
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- GHC produces a @newtype@ rather than a @data@ type for dictionary types of
|
-- GHC produces a @newtype@ rather than a @data@ type for dictionary types of
|
||||||
-- type classes with a single method and no super classes. Since DAML-LF does
|
-- type classes with a single method and no super classes. Since Daml-LF does
|
||||||
-- not support @newtype@, we could either treat them as some sort of type
|
-- not support @newtype@, we could either treat them as some sort of type
|
||||||
-- synonym or translate them to a record type with a single field. We have
|
-- synonym or translate them to a record type with a single field. We have
|
||||||
-- chosen to do the latter for the sake of uniformity among all dictionary
|
-- chosen to do the latter for the sake of uniformity among all dictionary
|
||||||
@ -133,7 +133,7 @@ conversionError msg = do
|
|||||||
throwError $ (convModuleFilePath,ShowDiag,) Diagnostic
|
throwError $ (convModuleFilePath,ShowDiag,) Diagnostic
|
||||||
{ _range = maybe noRange sourceLocToRange convRange
|
{ _range = maybe noRange sourceLocToRange convRange
|
||||||
, _severity = Just DsError
|
, _severity = Just DsError
|
||||||
, _source = Just "Core to DAML-LF"
|
, _source = Just "Core to Daml-LF"
|
||||||
, _message = T.pack msg
|
, _message = T.pack msg
|
||||||
, _code = Nothing
|
, _code = Nothing
|
||||||
, _relatedInformation = Nothing
|
, _relatedInformation = Nothing
|
||||||
@ -144,7 +144,7 @@ unsupported :: (HasCallStack, Outputable a) => String -> a -> ConvertM e
|
|||||||
unsupported typ x = conversionError errMsg
|
unsupported typ x = conversionError errMsg
|
||||||
where
|
where
|
||||||
errMsg =
|
errMsg =
|
||||||
"Failure to process DAML program, this feature is not currently supported.\n" ++
|
"Failure to process Daml program, this feature is not currently supported.\n" ++
|
||||||
typ ++ "\n" ++
|
typ ++ "\n" ++
|
||||||
prettyPrint x
|
prettyPrint x
|
||||||
|
|
||||||
@ -1060,7 +1060,7 @@ convertBind env (name, x)
|
|||||||
-- (This rewriting can be regarded as a very limited form of lambda
|
-- (This rewriting can be regarded as a very limited form of lambda
|
||||||
-- lifting where the lifted version of `f` happens to be `name`.)
|
-- lifting where the lifted version of `f` happens to be `name`.)
|
||||||
-- This workaround should be removed once we either have a proper lambda
|
-- This workaround should be removed once we either have a proper lambda
|
||||||
-- lifter or DAML-LF supports local recursion.
|
-- lifter or Daml-LF supports local recursion.
|
||||||
--
|
--
|
||||||
-- NOTE(SF): Due to issue #7953, this has been modified to allow for
|
-- NOTE(SF): Due to issue #7953, this has been modified to allow for
|
||||||
-- additional (nonrecursive) let bindings between the top-level
|
-- additional (nonrecursive) let bindings between the top-level
|
||||||
@ -1132,10 +1132,10 @@ convertBind env (name, x)
|
|||||||
name' <- convValWithType env name
|
name' <- convValWithType env name
|
||||||
pure [defValue name name' x']
|
pure [defValue name name' x']
|
||||||
|
|
||||||
-- NOTE(MH): These are the names of the builtin DAML-LF types whose Surface
|
-- NOTE(MH): These are the names of the builtin Daml-LF types whose Surface
|
||||||
-- DAML counterpart is not defined in 'GHC.Types'. They are all defined in
|
-- Daml counterpart is not defined in 'GHC.Types'. They are all defined in
|
||||||
-- 'DA.Internal.LF' in terms of 'GHC.Types.Opaque'. We need to remove them
|
-- 'DA.Internal.LF' in terms of 'GHC.Types.Opaque'. We need to remove them
|
||||||
-- during conversion to DAML-LF together with their constructors since we
|
-- during conversion to Daml-LF together with their constructors since we
|
||||||
-- deliberately remove 'GHC.Types.Opaque' as well.
|
-- deliberately remove 'GHC.Types.Opaque' as well.
|
||||||
internalTypes :: UniqSet FastString
|
internalTypes :: UniqSet FastString
|
||||||
internalTypes = mkUniqSet
|
internalTypes = mkUniqSet
|
||||||
@ -1369,7 +1369,7 @@ convertExpr env0 e = do
|
|||||||
callstack' <- convertExpr env callstack
|
callstack' <- convertExpr env callstack
|
||||||
pure $ mkEApps submitMustFail' [TyArg m', TyArg cmds', TmArg dict', TyArg typ', TmArg callstack', TmArg pty', TmArg upd']
|
pure $ mkEApps submitMustFail' [TyArg m', TyArg cmds', TmArg dict', TyArg typ', TmArg callstack', TmArg pty', TmArg upd']
|
||||||
|
|
||||||
-- custom conversion because they correspond to builtins in DAML-LF, so can make the output more readable
|
-- custom conversion because they correspond to builtins in Daml-LF, so can make the output more readable
|
||||||
go env (VarIn DA_Internal_Prelude "pure") (LType monad : LExpr dict : LType t : LExpr x : args)
|
go env (VarIn DA_Internal_Prelude "pure") (LType monad : LExpr dict : LType t : LExpr x : args)
|
||||||
-- This is generating the special UPure/SPure nodes when the monad is Update/Scenario.
|
-- This is generating the special UPure/SPure nodes when the monad is Update/Scenario.
|
||||||
= fmap (, args) $ join $ mkPure env monad dict <$> convertType env t <*> convertExpr env x
|
= fmap (, args) $ join $ mkPure env monad dict <$> convertType env t <*> convertExpr env x
|
||||||
@ -2006,7 +2006,7 @@ qDA_Types env a = do
|
|||||||
pkgRef <- packageNameToPkgRef env primUnitId
|
pkgRef <- packageNameToPkgRef env primUnitId
|
||||||
pure $ rewriteStableQualified env $ Qualified pkgRef (mkModName ["DA", "Types"]) a
|
pure $ rewriteStableQualified env $ Qualified pkgRef (mkModName ["DA", "Types"]) a
|
||||||
|
|
||||||
-- | Types of a kind not supported in DAML-LF, e.g., the DataKinds stuff from GHC.Generics
|
-- | Types of a kind not supported in Daml-LF, e.g., the DataKinds stuff from GHC.Generics
|
||||||
-- are translated to a special uninhabited Erased type. This allows us to easily catch these
|
-- are translated to a special uninhabited Erased type. This allows us to easily catch these
|
||||||
-- cases in data-dependencies.
|
-- cases in data-dependencies.
|
||||||
erasedTy :: Env -> ConvertM LF.Type
|
erasedTy :: Env -> ConvertM LF.Type
|
||||||
@ -2014,7 +2014,7 @@ erasedTy env = do
|
|||||||
pkgRef <- packageNameToPkgRef env primUnitId
|
pkgRef <- packageNameToPkgRef env primUnitId
|
||||||
pure $ TCon $ rewriteStableQualified env (Qualified pkgRef (mkModName ["DA", "Internal", "Erased"]) (mkTypeCon ["Erased"]))
|
pure $ TCon $ rewriteStableQualified env (Qualified pkgRef (mkModName ["DA", "Internal", "Erased"]) (mkTypeCon ["Erased"]))
|
||||||
|
|
||||||
-- | Type-level strings are represented in DAML-LF via the PromotedText type. This is
|
-- | Type-level strings are represented in Daml-LF via the PromotedText type. This is
|
||||||
-- For example, the type-level string @"foo"@ will be represented by the type
|
-- For example, the type-level string @"foo"@ will be represented by the type
|
||||||
-- @PromotedText {"_foo": Unit}@. This allows us to preserve all the information we need
|
-- @PromotedText {"_foo": Unit}@. This allows us to preserve all the information we need
|
||||||
-- to reconstruct `HasField` instances in data-dependencies without resorting to
|
-- to reconstruct `HasField` instances in data-dependencies without resorting to
|
||||||
@ -2193,7 +2193,7 @@ convertKind x = unhandled "Kind" x
|
|||||||
|
|
||||||
convNameLoc :: NamedThing a => a -> Maybe LF.SourceLoc
|
convNameLoc :: NamedThing a => a -> Maybe LF.SourceLoc
|
||||||
convNameLoc n = case nameSrcSpan (getName n) of
|
convNameLoc n = case nameSrcSpan (getName n) of
|
||||||
-- NOTE(MH): Locations are 1-based in GHC and 0-based in DAML-LF.
|
-- NOTE(MH): Locations are 1-based in GHC and 0-based in Daml-LF.
|
||||||
-- Hence all the @- 1@s below.
|
-- Hence all the @- 1@s below.
|
||||||
RealSrcSpan srcSpan -> Just (convRealSrcSpan srcSpan)
|
RealSrcSpan srcSpan -> Just (convRealSrcSpan srcSpan)
|
||||||
UnhelpfulSpan{} -> Nothing
|
UnhelpfulSpan{} -> Nothing
|
||||||
|
@ -375,9 +375,9 @@ decodeBool = \case
|
|||||||
-- Type Synonyms --
|
-- Type Synonyms --
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
-- | This encoding is needed since DAML-LF only supports @*@-kinded type synonyms.
|
-- | This encoding is needed since Daml-LF only supports @*@-kinded type synonyms.
|
||||||
-- @*@-kinded synonyms are unchanged.
|
-- @*@-kinded synonyms are unchanged.
|
||||||
-- @Nat@-kinded synonyms are wrapped in @DA.Internal.NatSyn.NatSyn@, so the DAML-LF
|
-- @Nat@-kinded synonyms are wrapped in @DA.Internal.NatSyn.NatSyn@, so the Daml-LF
|
||||||
-- synonym has kind @*@.
|
-- synonym has kind @*@.
|
||||||
-- For @(->)@-kinded synonyms, the required number of artificial parameters is
|
-- For @(->)@-kinded synonyms, the required number of artificial parameters is
|
||||||
-- added to the LHS and applied to the RHS of the type synonym.
|
-- added to the LHS and applied to the RHS of the type synonym.
|
||||||
@ -438,7 +438,7 @@ decodeTypeSynonym defTypeSyn = do
|
|||||||
| c == natSynTCon = n
|
| c == natSynTCon = n
|
||||||
unNatSyn t = t
|
unNatSyn t = t
|
||||||
|
|
||||||
-- | For saturating type synonym definitions in DAML-LF
|
-- | For saturating type synonym definitions in Daml-LF
|
||||||
artificialTypeVarName :: Integer -> LF.TypeVarName
|
artificialTypeVarName :: Integer -> LF.TypeVarName
|
||||||
artificialTypeVarName i = LF.TypeVarName $ "$$artificial" <> T.pack (show i)
|
artificialTypeVarName i = LF.TypeVarName $ "$$artificial" <> T.pack (show i)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{-# OPTIONS_GHC -Wno-overlapping-patterns #-} -- Because the pattern match checker is garbage
|
{-# OPTIONS_GHC -Wno-overlapping-patterns #-} -- Because the pattern match checker is garbage
|
||||||
|
|
||||||
|
|
||||||
-- | The DAML-LF primitives, matched with their type, and using 'primitive' on the libraries side.
|
-- | The Daml-LF primitives, matched with their type, and using 'primitive' on the libraries side.
|
||||||
module DA.Daml.LFConversion.Primitives(convertPrim) where
|
module DA.Daml.LFConversion.Primitives(convertPrim) where
|
||||||
|
|
||||||
import DA.Daml.LF.Ast
|
import DA.Daml.LF.Ast
|
||||||
@ -413,7 +413,7 @@ convertPrim (V1 PointDev) (L.stripPrefix "$" -> Just builtin) typ =
|
|||||||
-- Unknown primitive.
|
-- Unknown primitive.
|
||||||
convertPrim _ x ty = error $ "Unknown primitive " ++ show x ++ " at type " ++ renderPretty ty
|
convertPrim _ x ty = error $ "Unknown primitive " ++ show x ++ " at type " ++ renderPretty ty
|
||||||
|
|
||||||
-- | Some builtins are only supported in specific versions of DAML-LF.
|
-- | Some builtins are only supported in specific versions of Daml-LF.
|
||||||
whenRuntimeSupports :: Version -> Feature -> Type -> Expr -> Expr
|
whenRuntimeSupports :: Version -> Feature -> Type -> Expr -> Expr
|
||||||
whenRuntimeSupports version feature t e
|
whenRuntimeSupports version feature t e
|
||||||
| version `supports` feature = e
|
| version `supports` feature = e
|
||||||
@ -423,4 +423,4 @@ runtimeUnsupported :: Feature -> Type -> Expr
|
|||||||
runtimeUnsupported (Feature name version _) t =
|
runtimeUnsupported (Feature name version _) t =
|
||||||
ETmApp
|
ETmApp
|
||||||
(ETyApp (EBuiltin BEError) t)
|
(ETyApp (EBuiltin BEError) t)
|
||||||
(EBuiltin (BEText (name <> " only supported when compiling to DAML-LF " <> T.pack (renderVersion version) <> " or later")))
|
(EBuiltin (BEText (name <> " only supported when compiling to Daml-LF " <> T.pack (renderVersion version) <> " or later")))
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
-- | DAML-LF utility functions, may move to the LF utility if they are generally useful
|
-- | Daml-LF utility functions, may move to the LF utility if they are generally useful
|
||||||
module DA.Daml.UtilLF (
|
module DA.Daml.UtilLF (
|
||||||
module DA.Daml.UtilLF
|
module DA.Daml.UtilLF
|
||||||
) where
|
) where
|
||||||
|
@ -50,7 +50,7 @@ import System.FilePath
|
|||||||
instance Show PackageFlag where
|
instance Show PackageFlag where
|
||||||
show = prettyPrint
|
show = prettyPrint
|
||||||
|
|
||||||
-- | Compiler run configuration for DAML-GHC.
|
-- | Compiler run configuration for Daml-GHC.
|
||||||
data Options = Options
|
data Options = Options
|
||||||
{ optImportPath :: [FilePath]
|
{ optImportPath :: [FilePath]
|
||||||
-- ^ import path for both user modules and standard library
|
-- ^ import path for both user modules and standard library
|
||||||
|
@ -110,7 +110,7 @@ damlKeywords =
|
|||||||
, "let", "in", "where"
|
, "let", "in", "where"
|
||||||
, "module"
|
, "module"
|
||||||
|
|
||||||
-- DAML-specific keywords, sync with daml12.tmLanguage.xml when new
|
-- Daml-specific keywords, sync with daml12.tmLanguage.xml when new
|
||||||
-- keywords are added.
|
-- keywords are added.
|
||||||
, "agreement", "controller", "can", "ensure", "signatory", "nonconsuming", "observer"
|
, "agreement", "controller", "can", "ensure", "signatory", "nonconsuming", "observer"
|
||||||
, "preconsuming", "postconsuming", "with", "choice", "template", "key", "maintainer"
|
, "preconsuming", "postconsuming", "with", "choice", "template", "key", "maintainer"
|
||||||
@ -237,7 +237,7 @@ runGhcFast act = do
|
|||||||
setSession env
|
setSession env
|
||||||
GHC.withCleanupSession act
|
GHC.withCleanupSession act
|
||||||
|
|
||||||
-- | Language options enabled in the DAML-1.2 compilation
|
-- | Language options enabled in the Daml-1.2 compilation
|
||||||
xExtensionsSet :: [Extension]
|
xExtensionsSet :: [Extension]
|
||||||
xExtensionsSet =
|
xExtensionsSet =
|
||||||
[ -- Haskell 2010 extensions which are enabled by default (we would need to
|
[ -- Haskell 2010 extensions which are enabled by default (we would need to
|
||||||
@ -305,22 +305,22 @@ dataDependableExtensions = ES.fromList $ xExtensionsSet ++
|
|||||||
-- on the IsList typeclass which in turn uses a type family.
|
-- on the IsList typeclass which in turn uses a type family.
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Language settings _disabled_ ($-XNo...$) in the DAML-1.2 compilation
|
-- | Language settings _disabled_ ($-XNo...$) in the Daml-1.2 compilation
|
||||||
xExtensionsUnset :: [Extension]
|
xExtensionsUnset :: [Extension]
|
||||||
xExtensionsUnset =
|
xExtensionsUnset =
|
||||||
[ -- This is part of Haskell 2010 and would hence be enabled by default,
|
[ -- This is part of Haskell 2010 and would hence be enabled by default,
|
||||||
-- which makes zero sense for DAML.
|
-- which makes zero sense for Daml.
|
||||||
ForeignFunctionInterface
|
ForeignFunctionInterface
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Flags set for DAML-1.2 compilation
|
-- | Flags set for Daml-1.2 compilation
|
||||||
xFlagsSet :: Options -> [GeneralFlag]
|
xFlagsSet :: Options -> [GeneralFlag]
|
||||||
xFlagsSet options =
|
xFlagsSet options =
|
||||||
[Opt_Ticky
|
[Opt_Ticky
|
||||||
] ++
|
] ++
|
||||||
[ Opt_DoCoreLinting | optCoreLinting options ]
|
[ Opt_DoCoreLinting | optCoreLinting options ]
|
||||||
|
|
||||||
-- | Warning options set for DAML compilation. Note that these can be modified
|
-- | Warning options set for Daml compilation. Note that these can be modified
|
||||||
-- (per file) by the user via file headers '{-# OPTIONS -fwarn-... #-} and
|
-- (per file) by the user via file headers '{-# OPTIONS -fwarn-... #-} and
|
||||||
-- '{-# OPTIONS -no-warn-... #-}'.
|
-- '{-# OPTIONS -no-warn-... #-}'.
|
||||||
wOptsSet :: [ WarningFlag ]
|
wOptsSet :: [ WarningFlag ]
|
||||||
@ -343,14 +343,14 @@ wOptsSet =
|
|||||||
-- , Opt_WarnUnusedLocalBinds
|
-- , Opt_WarnUnusedLocalBinds
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Warning options set for DAML compilation, which become errors.
|
-- | Warning options set for Daml compilation, which become errors.
|
||||||
wOptsSetFatal :: [ WarningFlag ]
|
wOptsSetFatal :: [ WarningFlag ]
|
||||||
wOptsSetFatal =
|
wOptsSetFatal =
|
||||||
[ Opt_WarnMissingFields
|
[ Opt_WarnMissingFields
|
||||||
, Opt_WarnMissingMethods
|
, Opt_WarnMissingMethods
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | Warning options unset for DAML compilation. Note that these can be modified
|
-- | Warning options unset for Daml compilation. Note that these can be modified
|
||||||
-- (per file) by the user via file headers '{-# OPTIONS -fwarn-... #-} and
|
-- (per file) by the user via file headers '{-# OPTIONS -fwarn-... #-} and
|
||||||
-- '{-# OPTIONS -no-warn-... #-}'.
|
-- '{-# OPTIONS -no-warn-... #-}'.
|
||||||
wOptsUnset :: [ WarningFlag ]
|
wOptsUnset :: [ WarningFlag ]
|
||||||
@ -452,13 +452,13 @@ locateCppPath = do
|
|||||||
exists <- doesFileExist path
|
exists <- doesFileExist path
|
||||||
pure (guard exists >> Just path)
|
pure (guard exists >> Just path)
|
||||||
|
|
||||||
-- | Configures the @DynFlags@ for this session to DAML-1.2
|
-- | Configures the @DynFlags@ for this session to Daml-1.2
|
||||||
-- compilation:
|
-- compilation:
|
||||||
-- * Installs a custom log action;
|
-- * Installs a custom log action;
|
||||||
-- * Sets up the package databases;
|
-- * Sets up the package databases;
|
||||||
-- * Sets the import paths to the given list of 'FilePath'.
|
-- * Sets the import paths to the given list of 'FilePath'.
|
||||||
-- * if present, parses and applies custom options for GHC
|
-- * if present, parses and applies custom options for GHC
|
||||||
-- (may fail if the custom options are inconsistent with std DAML ones)
|
-- (may fail if the custom options are inconsistent with std Daml ones)
|
||||||
setupDamlGHC :: GhcMonad m => Maybe NormalizedFilePath -> Options -> m ()
|
setupDamlGHC :: GhcMonad m => Maybe NormalizedFilePath -> Options -> m ()
|
||||||
setupDamlGHC mbProjectRoot options@Options{..} = do
|
setupDamlGHC mbProjectRoot options@Options{..} = do
|
||||||
tmpDir <- liftIO getTemporaryDirectory
|
tmpDir <- liftIO getTemporaryDirectory
|
||||||
|
@ -138,8 +138,8 @@ noPreprocessor _dflags x =
|
|||||||
, preprocSource = x
|
, preprocSource = x
|
||||||
}
|
}
|
||||||
|
|
||||||
-- With RebindableSyntax any missing DAML import results in pretty much nothing
|
-- With RebindableSyntax any missing Daml import results in pretty much nothing
|
||||||
-- working (literals, if-then-else) so we inject an implicit import DAML for
|
-- working (literals, if-then-else) so we inject an implicit import Daml for
|
||||||
-- peoples convenience
|
-- peoples convenience
|
||||||
importDamlPreprocessor :: GHC.ParsedSource -> GHC.ParsedSource
|
importDamlPreprocessor :: GHC.ParsedSource -> GHC.ParsedSource
|
||||||
importDamlPreprocessor = fmap onModule
|
importDamlPreprocessor = fmap onModule
|
||||||
@ -397,13 +397,13 @@ checkKinds (GHC.L _ m) = do
|
|||||||
|
|
||||||
symbolKindMsg :: String
|
symbolKindMsg :: String
|
||||||
symbolKindMsg = unlines
|
symbolKindMsg = unlines
|
||||||
[ "Reference to Symbol kind will not be preserved during DAML compilation."
|
[ "Reference to Symbol kind will not be preserved during Daml compilation."
|
||||||
, "This will cause problems when importing this module via data-dependencies."
|
, "This will cause problems when importing this module via data-dependencies."
|
||||||
]
|
]
|
||||||
|
|
||||||
ghcTypesSymbolMsg :: String
|
ghcTypesSymbolMsg :: String
|
||||||
ghcTypesSymbolMsg = unlines
|
ghcTypesSymbolMsg = unlines
|
||||||
[ "Reference to GHC.Types.Symbol will not be preserved during DAML compilation."
|
[ "Reference to GHC.Types.Symbol will not be preserved during Daml compilation."
|
||||||
, "This will cause problems when importing this module via data-dependencies."
|
, "This will cause problems when importing this module via data-dependencies."
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ onExp (L o (SectionR _ mid@(isDot -> True) rhs))
|
|||||||
[] -> error "IMPOSSIBLE: getSelectors never returns an empty list"
|
[] -> error "IMPOSSIBLE: getSelectors never returns an empty list"
|
||||||
-- NOTE(MH): We don't want a lambda for a single projection since we
|
-- NOTE(MH): We don't want a lambda for a single projection since we
|
||||||
-- don't need it when the record type is unknown. When the record type
|
-- don't need it when the record type is unknown. When the record type
|
||||||
-- is known, the conversion to DAML-LF needs to add the lambda anyway.
|
-- is known, the conversion to Daml-LF needs to add the lambda anyway.
|
||||||
[sel] -> mkVar var_getField `mkAppType` sel
|
[sel] -> mkVar var_getField `mkAppType` sel
|
||||||
_:_:_ -> mkLam var_record $ foldl' (\x sel -> mkVar var_getField `mkAppType` sel `mkApp` x) (mkVar var_record) sels
|
_:_:_ -> mkLam var_record $ foldl' (\x sel -> mkVar var_getField `mkAppType` sel `mkApp` x) (mkVar var_record) sels
|
||||||
where
|
where
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{-# LANGUAGE TypeFamilies #-}
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
-- | This module extends the general Haskell rule types in
|
-- | This module extends the general Haskell rule types in
|
||||||
-- `Development.IDE.Core.RuleTypes` with DAML specific rule types
|
-- `Development.IDE.Core.RuleTypes` with Daml specific rule types
|
||||||
-- such as those for producing Daml-LF.
|
-- such as those for producing Daml-LF.
|
||||||
module Development.IDE.Core.RuleTypes.Daml(
|
module Development.IDE.Core.RuleTypes.Daml(
|
||||||
module Development.IDE.Core.RuleTypes,
|
module Development.IDE.Core.RuleTypes,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | Note: This is only supported in DAML-LF 1.11 or later.
|
-- | Note: This is only supported in Daml-LF 1.11 or later.
|
||||||
--
|
--
|
||||||
-- This module provides variants of other standard library
|
-- This module provides variants of other standard library
|
||||||
-- functions that are based on the builtin Daml-LF ordering rather
|
-- functions that are based on the builtin Daml-LF ordering rather
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
-- | Note: This is only supported in DAML-LF 1.11 or later.
|
-- | Note: This is only supported in Daml-LF 1.11 or later.
|
||||||
--
|
--
|
||||||
-- This module exports the generic map type `Map k v` and associated
|
-- This module exports the generic map type `Map k v` and associated
|
||||||
-- functions. This module should be imported qualified, for example:
|
-- functions. This module should be imported qualified, for example:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP #-}
|
||||||
{-# OPTIONS_GHC -Wno-orphans #-}
|
{-# OPTIONS_GHC -Wno-orphans #-}
|
||||||
|
|
||||||
-- | Note: This is only supported in DAML-LF 1.11 or later.
|
-- | Note: This is only supported in Daml-LF 1.11 or later.
|
||||||
--
|
--
|
||||||
-- This module exports the generic set type `Set k` and associated
|
-- This module exports the generic set type `Set k` and associated
|
||||||
-- functions. This module should be imported qualified, for example:
|
-- functions. This module should be imported qualified, for example:
|
||||||
|
@ -325,7 +325,7 @@ sha256 = primitive @"BESha256Text"
|
|||||||
|
|
||||||
-- | Reverse some `Text`.
|
-- | Reverse some `Text`.
|
||||||
-- ```
|
-- ```
|
||||||
-- reverse "DAML" == "LMAD"
|
-- reverse "Daml" == "lmaD"
|
||||||
-- ```
|
-- ```
|
||||||
reverse : Text -> Text
|
reverse : Text -> Text
|
||||||
reverse = implode . P.reverse . explode
|
reverse = implode . P.reverse . explode
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
-- Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
{-# LANGUAGE PatternSynonyms #-}
|
{-# LANGUAGE PatternSynonyms #-}
|
||||||
-- | Main entry-point of the DAML compiler
|
-- | Main entry-point of the Daml compiler
|
||||||
module DA.Daml.Visual
|
module DA.Daml.Visual
|
||||||
( execVisual
|
( execVisual
|
||||||
, tplNameUnqual
|
, tplNameUnqual
|
||||||
@ -360,7 +360,7 @@ dotFileGen world = constructDotGraph $ graphFromWorld world
|
|||||||
webPageTemplate :: T.Text
|
webPageTemplate :: T.Text
|
||||||
webPageTemplate =
|
webPageTemplate =
|
||||||
T.unlines [ "<html>"
|
T.unlines [ "<html>"
|
||||||
, "<head><title>DAML Visualization</title><meta charset=\"utf-8\"></head>"
|
, "<head><title>Daml Visualization</title><meta charset=\"utf-8\"></head>"
|
||||||
, "<body>"
|
, "<body>"
|
||||||
, "<div id='viz'></div>"
|
, "<div id='viz'></div>"
|
||||||
, "<script>"
|
, "<script>"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>DAML Visualization</title>
|
<title>Daml Visualization</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<script src="/d3plus.v1.9.8/js/d3.js"></script>
|
<script src="/d3plus.v1.9.8/js/d3.js"></script>
|
||||||
<script src="/d3plus.v1.9.8/js/d3plus.js"></script>
|
<script src="/d3plus.v1.9.8/js/d3plus.js"></script>
|
||||||
|
@ -143,7 +143,7 @@ cmdLicense =
|
|||||||
cmdCompile :: Int -> Mod CommandFields Command
|
cmdCompile :: Int -> Mod CommandFields Command
|
||||||
cmdCompile numProcessors =
|
cmdCompile numProcessors =
|
||||||
command "compile" $ info (helper <*> cmd) $
|
command "compile" $ info (helper <*> cmd) $
|
||||||
progDesc "Compile the Daml program into a Core/DAML-LF archive."
|
progDesc "Compile the Daml program into a Core/Daml-LF archive."
|
||||||
<> fullDesc
|
<> fullDesc
|
||||||
where
|
where
|
||||||
cmd = execCompile
|
cmd = execCompile
|
||||||
|
@ -22,7 +22,7 @@ import qualified Data.Set as Set
|
|||||||
cmd :: Int -> (CmdArgs -> a) -> Mod CommandFields a
|
cmd :: Int -> (CmdArgs -> a) -> Mod CommandFields a
|
||||||
cmd numProcessors f = command "docs" $
|
cmd numProcessors f = command "docs" $
|
||||||
info (helper <*> (f <$> documentation numProcessors)) $
|
info (helper <*> (f <$> documentation numProcessors)) $
|
||||||
progDesc "Early Access (Labs). Generate documentation for the given DAML program."
|
progDesc "Early Access (Labs). Generate documentation for the given Daml program."
|
||||||
<> fullDesc
|
<> fullDesc
|
||||||
|
|
||||||
documentation :: Int -> Parser CmdArgs
|
documentation :: Int -> Parser CmdArgs
|
||||||
|
@ -67,8 +67,8 @@ import SdkVersion
|
|||||||
--
|
--
|
||||||
-- data-deps (data-dependencies in daml.yaml):
|
-- data-deps (data-dependencies in daml.yaml):
|
||||||
-- This is intended for packages that have already been uploaded to the
|
-- This is intended for packages that have already been uploaded to the
|
||||||
-- ledger. Based on the DAML-LF we generate dummy interface files
|
-- ledger. Based on the Daml-LF we generate dummy interface files
|
||||||
-- and then remap references to those dummy packages to the original DAML-LF
|
-- and then remap references to those dummy packages to the original Daml-LF
|
||||||
-- package id.
|
-- package id.
|
||||||
createProjectPackageDb :: NormalizedFilePath -> Options -> MS.Map UnitId GHC.ModuleName -> IO ()
|
createProjectPackageDb :: NormalizedFilePath -> Options -> MS.Map UnitId GHC.ModuleName -> IO ()
|
||||||
createProjectPackageDb projectRoot (disableScenarioService -> opts) modulePrefixes
|
createProjectPackageDb projectRoot (disableScenarioService -> opts) modulePrefixes
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
-- SPDX-License-Identifier: Apache-2.0
|
-- SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
|
||||||
-- | Main entry-point of the DAML compiler
|
-- | Main entry-point of the Daml compiler
|
||||||
module DA.Cli.Damlc.Test (
|
module DA.Cli.Damlc.Test (
|
||||||
execTest
|
execTest
|
||||||
, UseColor(..)
|
, UseColor(..)
|
||||||
@ -49,7 +49,7 @@ newtype UseColor = UseColor {getUseColor :: Bool}
|
|||||||
newtype ShowCoverage = ShowCoverage {getShowCoverage :: Bool}
|
newtype ShowCoverage = ShowCoverage {getShowCoverage :: Bool}
|
||||||
newtype RunAllTests = RunAllTests {getRunAllTests :: Bool}
|
newtype RunAllTests = RunAllTests {getRunAllTests :: Bool}
|
||||||
|
|
||||||
-- | Test a DAML file.
|
-- | Test a Daml file.
|
||||||
execTest :: [NormalizedFilePath] -> RunAllTests -> ShowCoverage -> UseColor -> Maybe FilePath -> Options -> IO ()
|
execTest :: [NormalizedFilePath] -> RunAllTests -> ShowCoverage -> UseColor -> Maybe FilePath -> Options -> IO ()
|
||||||
execTest inFiles runAllTests coverage color mbJUnitOutput opts = do
|
execTest inFiles runAllTests coverage color mbJUnitOutput opts = do
|
||||||
loggerH <- getLogger opts "test"
|
loggerH <- getLogger opts "test"
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
# A DAML package database contains a subdirectory for each DAML-LF
|
# A Daml package database contains a subdirectory for each Daml-LF
|
||||||
# version. Each subdirectory contains a regular GHC package database
|
# version. Each subdirectory contains a regular GHC package database
|
||||||
# and the DALF files. Note
|
# and the DALF files. Note
|
||||||
# that the GHC package database also needs to be able to depend on the
|
# that the GHC package database also needs to be able to depend on the
|
||||||
# DAML-LF version since we want to make things in DAML conditional on
|
# Daml-LF version since we want to make things in Daml conditional on
|
||||||
# the target version.
|
# the target version.
|
||||||
|
|
||||||
# We have the following rules:
|
# We have the following rules:
|
||||||
#
|
#
|
||||||
# daml-package:
|
# daml-package:
|
||||||
# Inputs:
|
# Inputs:
|
||||||
# - A DAML source directory
|
# - A Daml source directory
|
||||||
# - The root DAML file
|
# - The root Daml file
|
||||||
# - The target LF version
|
# - The target LF version
|
||||||
# - A package database in the format described above.
|
# - A package database in the format described above.
|
||||||
# Outputs:
|
# Outputs:
|
||||||
@ -45,7 +45,7 @@ depends: {depends}
|
|||||||
|
|
||||||
DamlPackage = provider(fields = ["daml_lf_version", "pkg_name", "pkg_name_version", "pkg_conf", "iface_dir", "dalf", "modules"])
|
DamlPackage = provider(fields = ["daml_lf_version", "pkg_name", "pkg_name_version", "pkg_conf", "iface_dir", "dalf", "modules"])
|
||||||
|
|
||||||
# Compile a DAML file and create the GHC package database
|
# Compile a Daml file and create the GHC package database
|
||||||
# for it.
|
# for it.
|
||||||
def _daml_package_rule_impl(ctx):
|
def _daml_package_rule_impl(ctx):
|
||||||
name = ctx.attr.name
|
name = ctx.attr.name
|
||||||
|
@ -87,7 +87,7 @@ da_haskell_test(
|
|||||||
"//daml-script/daml:daml-script.dar",
|
"//daml-script/daml:daml-script.dar",
|
||||||
|
|
||||||
# TODO https://github.com/digital-asset/daml/issues/12051
|
# TODO https://github.com/digital-asset/daml/issues/12051
|
||||||
# Remove once DAML-LF 1.15 is the default compiler output
|
# Remove once Daml-LF 1.15 is the default compiler output
|
||||||
"//daml-script/daml:daml-script-1.dev.dar",
|
"//daml-script/daml:daml-script-1.dev.dar",
|
||||||
],
|
],
|
||||||
hackage_deps = [
|
hackage_deps = [
|
||||||
|
@ -290,7 +290,7 @@ testParseDecimal = scenario do
|
|||||||
|
|
||||||
|
|
||||||
testReverse = scenario do
|
testReverse = scenario do
|
||||||
T.reverse "DAML" === "LMAD"
|
T.reverse "Daml" === "lmaD"
|
||||||
|
|
||||||
testNuls = scenario do
|
testNuls = scenario do
|
||||||
"\0" === "\0"
|
"\0" === "\0"
|
||||||
|
Loading…
Reference in New Issue
Block a user