-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a27142e
commit 9d3d29d
Showing
1 changed file
with
22 additions
and
0 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
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) | ||
|