Skip to content

Commit

Permalink
[Builtins] Added 'Data' as a built-in type (IntersectMBO#3385)
Browse files Browse the repository at this point in the history
  • Loading branch information
effectfully authored Jul 1, 2021
1 parent b554ea6 commit b2ea280
Show file tree
Hide file tree
Showing 261 changed files with 1,419 additions and 1,960 deletions.
2 changes: 1 addition & 1 deletion doc/plutus/tutorials/basic-minting-policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Minting policies, like validators, receive some information from the validating

The minting policy is a function which receives these two inputs as *arguments*.
The validating node is responsible for passing them in and running the minting policy.
As with validator scripts, the arguments are passed encoded as :hsobj:`PlutusTx.Data.Data`.
As with validator scripts, the arguments are passed encoded as :hsobj:`PlutusCore.Data.Data`.

Using the minting context
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/plutus/tutorials/basic-validators.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The ``Data`` type
But how are the validator's arguments passed?
At least the redeemer and datum can be of different types depending on the script.

The answer is that we pass them as a generic structured data type :hsobj:`PlutusTx.Data.Data`.
The answer is that we pass them as a generic structured data type :hsobj:`PlutusCore.Data.Data`.
``Data`` is designed to make it easy to encode structured data into it, and to be itself encoded as CBOR.

Consequently, the validator scripts we will write in this tutorial take three arguments of type ``Data``.
Expand Down
19 changes: 13 additions & 6 deletions nix/pkgs/haskell/materialized-darwin/.plan.nix/plutus-core.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions nix/pkgs/haskell/materialized-linux/.plan.nix/plutus-core.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions nix/pkgs/haskell/materialized-unix/.plan.nix/plutus-core.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nix/pkgs/haskell/materialized-unix/.plan.nix/plutus-tx.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion playground-common/src/PSGenerator/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ psAssocMap =
dataBridge :: BridgePart
dataBridge = do
typeName ^== "Data"
typeModule ^== "PlutusTx.Data"
typeModule ^== "PlutusCore.Data"
pure psString

assocMapBridge :: BridgePart
Expand Down
28 changes: 14 additions & 14 deletions plutus-core/generators/PlutusCore/Generators/Interesting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module PlutusCore.Generators.Interesting
, genNaiveFib
, genNatRoundtrip
, natSum
, genListSum
, genScottListSum
, genIfIntegers
, fromInterestingTermGens
) where
Expand All @@ -30,19 +30,19 @@ import PlutusCore.Name
import PlutusCore.Quote

import PlutusCore.StdLib.Data.Bool
import PlutusCore.StdLib.Data.Function as Function
import PlutusCore.StdLib.Data.List as List
import PlutusCore.StdLib.Data.Function as Function
import PlutusCore.StdLib.Data.Nat
import PlutusCore.StdLib.Data.ScottList as ScottList
import PlutusCore.StdLib.Data.Unit
import PlutusCore.StdLib.Meta
import PlutusCore.StdLib.Type

import PlutusCore.Generators

import Data.List (genericIndex)
import Hedgehog hiding (Size, Var)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import Data.List (genericIndex)
import Hedgehog hiding (Size, Var)
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range

-- | The type of terms-and-their-values generators.
type TermGen a = Gen (TermOf (Term TyName Name DefaultUni DefaultFun ()) a)
Expand Down Expand Up @@ -77,8 +77,8 @@ factorial = runQuote $ do
let int = mkTyBuiltin @_ @Integer ()
return
. LamAbs () i int
. apply () List.product
$ mkIterApp () List.enumFromTo
. apply () ScottList.product
$ mkIterApp () ScottList.enumFromTo
[ mkConstant @Integer () 1
, Var () i
]
Expand Down Expand Up @@ -172,13 +172,13 @@ natSum = runQuote $ do

-- | Generate a list of 'Integer's, turn it into a Scott-encoded PLC @List@ (see 'List'),
-- sum elements of the list (see 'Sum') and return it along with the sum of the original list.
genListSum :: TermGen Integer
genListSum = do
genScottListSum :: TermGen Integer
genScottListSum = do
let typedInt = AsKnownType
intS = toTypeAst typedInt
ps <- Gen.list (Range.linear 0 10) $ genTypedBuiltinDef typedInt
let list = metaListToList intS $ Prelude.map _termOfTerm ps
term = apply () List.sum list
let list = metaListToScottList intS $ Prelude.map _termOfTerm ps
term = apply () ScottList.sum list
let haskSum = Prelude.sum $ Prelude.map _termOfValue ps
return $ TermOf term haskSum

Expand Down Expand Up @@ -259,7 +259,7 @@ fromInterestingTermGens f =
, f "factorial" genFactorial
, f "fibonacci" genNaiveFib
, f "NatRoundTrip" genNatRoundtrip
, f "ListSum" genListSum
, f "ScottListSum" genScottListSum
, f "IfIntegers" genIfIntegers
, f "ApplyAdd1" genApplyAdd1
, f "ApplyAdd2" genApplyAdd2
Expand Down
19 changes: 13 additions & 6 deletions plutus-core/plutus-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,27 @@ library
PlutusCore.Constant
PlutusCore.Constant.Dynamic.Emit
PlutusCore.Core
PlutusCore.Data
PlutusCore.DataFilePaths
PlutusCore.DeBruijn
PlutusCore.Default
PlutusCore.Error
PlutusCore.Evaluation.Machine.Ck
PlutusCore.Evaluation.Machine.BuiltinCostModel
PlutusCore.Evaluation.Machine.Ck
PlutusCore.Evaluation.Machine.CostModelInterface
PlutusCore.Evaluation.Machine.ExBudget
PlutusCore.Evaluation.Machine.Exception
PlutusCore.Evaluation.Machine.ExMemory
PlutusCore.Evaluation.Machine.Exception
PlutusCore.Evaluation.Machine.MachineParameters
PlutusCore.Evaluation.Result
PlutusCore.Examples.Builtins
PlutusCore.Examples.Data.Data
PlutusCore.Examples.Data.InterList
PlutusCore.Examples.Data.List
PlutusCore.Examples.Data.Pair
PlutusCore.Examples.Data.Shad
PlutusCore.Examples.Data.TreeForest
PlutusCore.Examples.Data.Vec
PlutusCore.Examples.Everything
PlutusCore.Flat
PlutusCore.FsTree
Expand All @@ -84,10 +92,13 @@ library
PlutusCore.Rename.Monad
PlutusCore.StdLib.Data.Bool
PlutusCore.StdLib.Data.ChurchNat
PlutusCore.StdLib.Data.Data
PlutusCore.StdLib.Data.Function
PlutusCore.StdLib.Data.Integer
PlutusCore.StdLib.Data.List
PlutusCore.StdLib.Data.Nat
PlutusCore.StdLib.Data.Pair
PlutusCore.StdLib.Data.ScottList
PlutusCore.StdLib.Data.ScottUnit
PlutusCore.StdLib.Data.Sum
PlutusCore.StdLib.Data.Unit
Expand Down Expand Up @@ -172,10 +183,6 @@ library
PlutusCore.Default.Universe
PlutusCore.Eq
PlutusCore.Evaluation.Machine.ExBudgetingDefaults
PlutusCore.Examples.Data.InterList
PlutusCore.Examples.Data.Shad
PlutusCore.Examples.Data.TreeForest
PlutusCore.Examples.Data.Vec
PlutusCore.Generators.Internal.Denotation
PlutusCore.Generators.Internal.Dependent
PlutusCore.Generators.Internal.Entity
Expand Down
Loading

0 comments on commit b2ea280

Please sign in to comment.