Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Notable changes to this project are documented in this file. The format is based
Breaking changes:

New features:

- Add `isEmpty` (#222 by @sigma-andex)
Bugfixes:

Other improvements:
Expand Down
13 changes: 11 additions & 2 deletions src/Data/Array.purs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module Data.Array
, many

, null
, isEmpty
, length

, (:), cons
Expand Down Expand Up @@ -217,13 +218,21 @@ many v = some v <|> pure []
-- Array size ------------------------------------------------------------------
--------------------------------------------------------------------------------

-- | Test whether an array is empty.
-- | Test whether an array is empty. Alias for `isEmpty`.
-- | ```purescript
-- | null [] = true
-- | null [1, 2] = false
-- | ```
null :: forall a. Array a -> Boolean
null xs = length xs == 0
null = isEmpty

-- | Test whether an array is empty.
-- | ```purescript
-- | isEmpty [] = true
-- | isEmpty [1, 2] = false
-- | ```
isEmpty :: forall a. Array a -> Boolean
isEmpty xs = length xs == 0

-- | Get the number of elements in an array.
-- | ```purescript
Expand Down