From 9d3d29d0efe0f28321d886ea1656cee8ab36833d Mon Sep 17 00:00:00 2001 From: Ana Pantilie Date: Thu, 31 Oct 2024 10:38:57 +0200 Subject: [PATCH] Temp --- plutus-tx-plugin/test/List/Spec.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plutus-tx-plugin/test/List/Spec.hs diff --git a/plutus-tx-plugin/test/List/Spec.hs b/plutus-tx-plugin/test/List/Spec.hs new file mode 100644 index 00000000000..291d9384828 --- /dev/null +++ b/plutus-tx-plugin/test/List/Spec.hs @@ -0,0 +1,22 @@ +module List.Spec where + +import PlutusTx.Data.List qualified as Data.List +import PlutusTx.Prelude qualified as PlutusTx + +newtype ListS a = ListS [a] + deriving stock (Show, Eq) + +semanticsToList :: ListS a -> PlutusTx.[a] +semanticsToList (ListS l) = l + +listToSemantics :: PlutusTx.[a] -> ListS a +listToSemantics = ListS + +semanticsToDataList :: (ToData a) => ListS a -> Data.List.List a +semanticsToDataList = ListS . BI.unsafeDataAsList . B.mkList . fmap toBuiltinData + +dataListToSemantics :: (UnsafeFromData a) => Data.List.List a -> ListS a +dataListToSemantics = ListS . go + where + go = B.caseList' [] (\h t -> unsafeFromBuiltinData h : go t) +