mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 09:17:43 +03:00
Remove DefValueInfo data type (#252)
This was used by the old DAML-LF based record constructor/projection inliner. We'bve recently replaced by an inlining mechanism which is part of the conversion from GHC Core to DAML-LF.
This commit is contained in:
parent
be177b39d9
commit
7c3cd8840b
@ -613,55 +613,8 @@ data DefValue = DefValue
|
||||
-- ^ Is the value maked as a test to be run as a scenario?
|
||||
, dvalBody :: !Expr
|
||||
-- ^ Expression whose value to bind to the name.
|
||||
, dvalInfo :: !(Maybe DefValueInfo)
|
||||
-- ^ Includes additional info that we use in the simplifier. Note that
|
||||
-- this information is generated by 'DA.Daml.LF.Ast.DefValueInfo' and
|
||||
-- _not_ contained in the proto.
|
||||
}
|
||||
|
||||
{-
|
||||
TODO currently we do not recognize proxies to variant constructors,
|
||||
since they're not required for contract keys, but if we were these data structures
|
||||
should work.
|
||||
|
||||
data VariantConstructorProxyType =
|
||||
VCPTNormal
|
||||
-- ^ normal constructor proxy: just pass an argument through
|
||||
| VCPTRecord
|
||||
{ vcptType :: !(Qualified TypeConName)
|
||||
, vcptTyVars :: ![TypeVarName]
|
||||
}
|
||||
-- ^ constructors deriving from types like
|
||||
--
|
||||
-- @
|
||||
-- data Foo = Bar with bar: Int; baz: Bool | ...
|
||||
-- @
|
||||
--
|
||||
-- which will induce constructor proxies that take @bar@ and
|
||||
-- @baz@ as parameters and construct the record directly.
|
||||
-}
|
||||
|
||||
-- | Some additional metadata we generate for each value definition,
|
||||
-- mostly used by the simplifier.
|
||||
data DefValueInfo =
|
||||
DVIRecordConstructorProxy
|
||||
{ dviRecConTyCon :: !(Qualified TypeConName)
|
||||
}
|
||||
{-
|
||||
TODO currently we do not recognize proxies to variant constructors,
|
||||
since they're not required for contract keys, but if we were these data structures
|
||||
should work.
|
||||
| DVIVariantConstructorProxy
|
||||
{ dviVarConTyCon :: !(Qualified TypeConName)
|
||||
, dviVarConVariant :: !VariantConName
|
||||
, dviVarConType :: !VariantConstructorProxyType
|
||||
}
|
||||
-}
|
||||
| DVIRecordProjectionProxy
|
||||
{ dviRecProjType :: !(Qualified TypeConName)
|
||||
, dviRecProjField :: !FieldName
|
||||
}
|
||||
|
||||
data TemplateKey = TemplateKey
|
||||
{ tplKeyType :: !Type
|
||||
, tplKeyBody :: !Expr
|
||||
@ -787,14 +740,12 @@ concatSequenceA $
|
||||
, makePrisms ''Scenario
|
||||
, makePrisms ''DataCons
|
||||
, makePrisms ''Package
|
||||
-- , makePrisms ''VariantConstructorProxyType
|
||||
, makeUnderscoreLenses ''DefDataType
|
||||
, makeUnderscoreLenses ''DefValue
|
||||
, makeUnderscoreLenses ''TemplateChoice
|
||||
, makeUnderscoreLenses ''Template
|
||||
, makeUnderscoreLenses ''Module
|
||||
, makeUnderscoreLenses ''Package
|
||||
, makeUnderscoreLenses ''DefValueInfo
|
||||
, makeUnderscoreLenses ''TemplateKey
|
||||
] ++
|
||||
map (makeInstancesExcept [''FromJSON])
|
||||
@ -824,8 +775,6 @@ concatSequenceA $
|
||||
, ''TemplateChoice
|
||||
, ''FeatureFlags
|
||||
, ''TemplateKey
|
||||
-- , ''VariantConstructorProxyType
|
||||
, ''DefValueInfo
|
||||
] ++
|
||||
map (makeInstancesExcept [''Ord, ''FromJSON])
|
||||
[ ''Template
|
||||
@ -884,7 +833,5 @@ instance NFData Type
|
||||
instance NFData TypeConApp
|
||||
instance NFData RetrieveByKey
|
||||
instance NFData Update
|
||||
-- instance NFData VariantConstructorProxyType
|
||||
instance NFData DefValueInfo
|
||||
|
||||
instance NFData a => NFData (Qualified a)
|
||||
|
@ -136,9 +136,6 @@ instance MonoTraversable ModuleRef Template
|
||||
instance MonoTraversable ModuleRef FeatureFlags
|
||||
instance MonoTraversable ModuleRef Module
|
||||
|
||||
instance MonoTraversable ModuleRef DefValueInfo
|
||||
-- instance MonoTraversable ModuleRef VariantConstructorProxyType
|
||||
|
||||
exprPartyLiteral
|
||||
:: forall f. Applicative f
|
||||
=> (PartyLiteral -> f PartyLiteral) -> (Expr -> f Expr)
|
||||
|
@ -419,25 +419,14 @@ instance Pretty DefDataType where
|
||||
"|" <-> prettyName name <-> pPrintPrec prettyNormal precHighest typ
|
||||
|
||||
instance Pretty DefValue where
|
||||
pPrint (DefValue mbLoc binder (HasNoPartyLiterals noParties) (IsTest isTest) body mbInfo) =
|
||||
pPrint (DefValue mbLoc binder (HasNoPartyLiterals noParties) (IsTest isTest) body) =
|
||||
withSourceLoc mbLoc $
|
||||
vcat $ concat
|
||||
[ case mbInfo of
|
||||
Nothing -> []
|
||||
Just info -> [text "--" <-> pretty info]
|
||||
, [ hang (keyword_ kind <-> annot <-> prettyNameAndType binder <-> "=") 2 (pretty body) ]
|
||||
]
|
||||
vcat
|
||||
[ hang (keyword_ kind <-> annot <-> prettyNameAndType binder <-> "=") 2 (pretty body) ]
|
||||
where
|
||||
kind = if isTest then "test" else "def"
|
||||
annot = if noParties then mempty else "@partyliterals"
|
||||
|
||||
instance Pretty DefValueInfo where
|
||||
pPrint = \case
|
||||
DVIRecordConstructorProxy tyCon ->
|
||||
text "proxy for record" <-> pretty tyCon
|
||||
DVIRecordProjectionProxy tyCon fld ->
|
||||
text "proxy for field" <-> text (unTagged fld) <-> text "of record" <-> pretty tyCon
|
||||
|
||||
prettyTemplateChoice ::
|
||||
ModuleName -> TypeConName -> TemplateChoice -> Doc ann
|
||||
prettyTemplateChoice modName tpl (TemplateChoice mbLoc name isConsuming actor selfBinder argBinder retType update) =
|
||||
|
@ -90,7 +90,6 @@ decodeDefValue (LF1.DefValue mbBinder mbBody noParties isTest mbLoc) =
|
||||
<*> pure (HasNoPartyLiterals noParties)
|
||||
<*> pure (IsTest isTest)
|
||||
<*> mayDecode "defValueExpr" mbBody decodeExpr
|
||||
<*> pure Nothing
|
||||
|
||||
decodeDefTemplate :: LF1.DefTemplate -> Decode Template
|
||||
decodeDefTemplate LF1.DefTemplate{..} =
|
||||
|
@ -81,7 +81,6 @@ decodeDefValue (LF1.DefValue mbBinder mbBody noParties isTest mbLoc) =
|
||||
<*> pure (HasNoPartyLiterals noParties)
|
||||
<*> pure (IsTest isTest)
|
||||
<*> mayDecode "defValueExpr" mbBody decodeExpr
|
||||
<*> pure Nothing
|
||||
|
||||
decodeDefTemplate :: LF1.DefTemplate -> Decode Template
|
||||
decodeDefTemplate LF1.DefTemplate{..} =
|
||||
|
@ -488,7 +488,7 @@ checkDefDataType (DefDataType _loc _name _serializable params dataCons) =
|
||||
traverse_ (`checkType` KStar) types
|
||||
|
||||
checkDefValue :: MonadGamma m => DefValue -> m ()
|
||||
checkDefValue (DefValue _loc (_, typ) _noParties (IsTest isTest) expr _info) = do
|
||||
checkDefValue (DefValue _loc (_, typ) _noParties (IsTest isTest) expr) = do
|
||||
checkType typ KStar
|
||||
checkExpr expr typ
|
||||
when isTest $
|
||||
|
@ -1115,7 +1115,7 @@ defDataType name params constrs =
|
||||
|
||||
defValue :: NamedThing a => a -> (ExprValName, LF.Type) -> LF.Expr -> Definition
|
||||
defValue loc binder@(name, lftype) body =
|
||||
DValue $ DefValue (convNameLoc loc) binder (HasNoPartyLiterals True) (IsTest isTest) body Nothing
|
||||
DValue $ DefValue (convNameLoc loc) binder (HasNoPartyLiterals True) (IsTest isTest) body
|
||||
where
|
||||
isTest = case view _TForalls lftype of
|
||||
(_, LF.TScenario _) -> True
|
||||
|
@ -107,7 +107,6 @@ ghcPrim = Module
|
||||
, varVariant = conName
|
||||
, varArg = EBuiltin (BEEnumCon ECUnit)
|
||||
}
|
||||
, dvalInfo = Nothing
|
||||
}
|
||||
|
||||
ghcTypes :: Module
|
||||
@ -140,7 +139,6 @@ ghcTypes = Module
|
||||
, varVariant = mkVariantCon con
|
||||
, varArg = EBuiltin (BEEnumCon ECUnit)
|
||||
}
|
||||
, dvalInfo = Nothing
|
||||
}
|
||||
dataProxy = DefDataType
|
||||
{ dataLocation= Nothing
|
||||
@ -160,6 +158,5 @@ ghcTypes = Module
|
||||
, dvalBody = ETyLam
|
||||
(Tagged "a", KStar)
|
||||
(ERecCon (TypeConApp (qual (dataTypeCon dataProxy)) [TVar (Tagged "a")]) [])
|
||||
, dvalInfo = Nothing
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user