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 11e4dac commit a55e99d
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 a55e99d

Please sign in to comment.