Skip to content

Commit

Permalink
Add PlutusTx.Data.List.null (#6838)
Browse files Browse the repository at this point in the history
  • Loading branch information
zliu41 authored Feb 12, 2025
1 parent 5022eae commit 012055f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions plutus-tx/changelog.d/20250211_170605_unsafeFixIO_null.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


### Added

- Added `PlutusTx.Data.List.null`.
7 changes: 6 additions & 1 deletion plutus-tx/src/PlutusTx/Data/List.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module PlutusTx.Data.List (
-- constructor exported for testing
List(List),
null,
append,
find,
findIndices,
Expand All @@ -25,7 +26,7 @@ import PlutusTx.Builtins.Internal qualified as BI
import PlutusTx.IsData.Class (FromData (..), ToData (..), UnsafeFromData (..))
import PlutusTx.Lift (makeLift)
import PlutusTx.Prelude hiding (any, filter, find, findIndices, foldMap, length, map, mapMaybe,
mconcat, pred)
mconcat, null, pred)
import Prettyprinter (Pretty (..))

import Data.Semigroup qualified as Haskell
Expand Down Expand Up @@ -60,6 +61,10 @@ instance (UnsafeFromData a, Pretty a) => Pretty (List a) where
{-# INLINEABLE pretty #-}
pretty = pretty . toSOP

null :: List a -> Bool
null (List l) = B.null l
{-# INLINEABLE null #-}

cons :: (ToData a) => a -> List a -> List a
cons h (List t) = List (BI.mkCons (toBuiltinData h) t)
{-# INLINEABLE cons #-}
Expand Down

0 comments on commit 012055f

Please sign in to comment.