-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
10 changed files
with
172 additions
and
95 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
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
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
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
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,35 @@ | ||
module JSON.Array | ||
( fromFoldable | ||
, empty | ||
, singleton | ||
, index | ||
, toUnfoldable | ||
, module Exports | ||
) where | ||
|
||
import Data.Array as Array | ||
import Data.Foldable (class Foldable) | ||
import Data.Maybe (Maybe) | ||
import Data.Unfoldable (class Unfoldable) | ||
import JSON.Internal (JArray, JSON, toArray, fromArray) | ||
import JSON.Internal (JArray, toArray, fromArray) as Exports | ||
|
||
-- | Creates a `JArray` from a `Foldable` source of `JSON`. | ||
fromFoldable :: forall f. Foldable f => f JSON -> JArray | ||
fromFoldable js = fromArray (Array.fromFoldable js) | ||
|
||
-- | An empty `JArray`. | ||
empty :: JArray | ||
empty = fromArray [] | ||
|
||
-- | Creates a `JArray` with a single entry. | ||
singleton :: JSON -> JArray | ||
singleton j = fromArray [ j ] | ||
|
||
-- | Attempts to read a value from the specified index of a `JArray`. | ||
index :: JArray -> Int -> Maybe JSON | ||
index js = Array.index (toArray js) | ||
|
||
-- | Unfolds a `JArray` into `JSON` items | ||
toUnfoldable :: forall f. Unfoldable f => JArray -> f JSON | ||
toUnfoldable js = Array.toUnfoldable (toArray js) |
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
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
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
Oops, something went wrong.