Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create data-backed types: List, Pair, Map
Signed-off-by: Ana Pantilie <ana.pantilie95@gmail.com>
- Loading branch information
1 parent
8f66cd7
commit 55bcd18
Showing
4 changed files
with
44 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
module PlutusTx.DataMap where | ||
|
||
import PlutusTx.AsData qualified as AsData | ||
import PlutusTx.DataList | ||
import PlutusTx.DataPair | ||
import PlutusTx.IsData qualified as P | ||
|
||
AsData.asData | ||
[d| | ||
data Map k v = Map (List (Pair k v)) | ||
deriving newtype (P.ToData, P.FromData, P.UnsafeFromData) | ||
|] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE PatternSynonyms #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE ViewPatterns #-} | ||
|
||
module PlutusTx.DataPair where | ||
|
||
import PlutusTx.AsData qualified as AsData | ||
import PlutusTx.IsData qualified as P | ||
import PlutusTx.Prelude qualified as Prelude | ||
|
||
AsData.asData | ||
[d| | ||
data Pair a b = Pair a b | ||
deriving newtype (P.ToData, P.FromData, P.UnsafeFromData) | ||
|] |