Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Add lens for "number"s
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed Jun 28, 2017
1 parent 2d92a14 commit ae6e154
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Data/Json/Extended.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Data.Json.Extended
, boolean
, integer
, decimal
, number
, string
, map
, map'
Expand All @@ -24,6 +25,7 @@ module Data.Json.Extended
, _Boolean
, _Integer
, _Decimal
, _Number
, _Array
, _Map
, _Map'
Expand Down Expand Up @@ -89,6 +91,9 @@ integer = embed <<< Sig.Integer
decimal t. Corecursive t Sig.EJsonF HN.HugeNum t
decimal = embed <<< Sig.Decimal

number t. Corecursive t Sig.EJsonF E.Either HI.HugeInt HN.HugeNum t
number = embed <<< E.either Sig.Integer Sig.Decimal

string t. Corecursive t Sig.EJsonF String t
string = embed <<< Sig.String

Expand Down Expand Up @@ -131,6 +136,12 @@ _Decimal = prism' decimal $ project >>> case _ of
Sig.Decimal d → M.Just d
_ → M.Nothing

_Number t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t (E.Either HI.HugeInt HN.HugeNum)
_Number = prism' number $ project >>> case _ of
Sig.Integer i → M.Just (E.Left i)
Sig.Decimal d → M.Just (E.Right d)
_ → M.Nothing

_Array t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t (Array t)
_Array = prism' array $ project >>> case _ of
Sig.Array xs → M.Just xs
Expand Down

0 comments on commit ae6e154

Please sign in to comment.