Skip to content

Commit

Permalink
Temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ana-pantilie committed Oct 31, 2024
1 parent a27142e commit 9d3d29d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plutus-tx-plugin/test/List/Spec.hs
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9d3d29d

Please sign in to comment.