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

Commit

Permalink
Merge pull request #20 from garyb/ps-0.11
Browse files Browse the repository at this point in the history
Updates for PureScript 0.11
  • Loading branch information
garyb authored Apr 21, 2017
2 parents 10be5a8 + f46004f commit d252fc3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 34 deletions.
20 changes: 10 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"package.json"
],
"dependencies": {
"purescript-argonaut": "^2.0.0",
"purescript-bifunctors": "^2.0.0",
"purescript-datetime": "^2.1.1",
"purescript-maps": "^2.0.0",
"purescript-matryoshka": "^0.2.0",
"purescript-newtype": "^1.2.0",
"purescript-parsing": "^3.0.0",
"purescript-precise": "^1.0.0",
"purescript-profunctor-lenses": "^2.4.0",
"purescript-strongcheck": "^2.0.0"
"purescript-argonaut": "^3.0.0",
"purescript-bifunctors": "^3.0.0",
"purescript-datetime": "^3.0.0",
"purescript-maps": "^3.0.0",
"purescript-matryoshka": "^0.3.0",
"purescript-newtype": "^2.0.0",
"purescript-parsing": "^4.1.0",
"purescript-precise": "^2.0.0",
"purescript-profunctor-lenses": "^3.2.0",
"purescript-strongcheck": "^3.1.0"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"test": "pulp test"
},
"devDependencies": {
"pulp": "^10.0.1",
"purescript": "^0.10.7",
"purescript-psa": "^0.4.0",
"pulp": "^11.0.0",
"purescript": "^0.11.4",
"purescript-psa": "^0.5.1",
"rimraf": "^2.6.1"
}
}
21 changes: 10 additions & 11 deletions src/Data/Json/Extended.purs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import Prelude hiding (map)
import Control.Lazy as Lazy

import Data.Argonaut as JS
import Data.Array as A
import Data.Bitraversable (bitraverse)
import Data.Either as E
import Data.Functor as F
Expand Down Expand Up @@ -92,52 +91,52 @@ array ∷ ∀ t. Corecursive t Sig.EJsonF ⇒ Array t → t
array = embed <<< Sig.Array

map t. Corecursive t Sig.EJsonF Map.Map t t t
map = embed <<< Sig.Map <<< Sig.EJsonMap <<< A.fromFoldable <<< Map.toList
map = embed <<< Sig.Map <<< Sig.EJsonMap <<< Map.toUnfoldable

map' t. Corecursive t Sig.EJsonF SM.StrMap t t
map' = embed <<< Sig.Map <<< Sig.EJsonMap <<< F.map go <<< A.fromFoldable <<< SM.toList
map' = embed <<< Sig.Map <<< Sig.EJsonMap <<< F.map go <<< SM.toUnfoldable
where
go (T.Tuple a b) = T.Tuple (string a) b

getType t. Recursive t Sig.EJsonF t EJsonType
getType = Sig.getType <<< project

_Null t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t Unit
_Null t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t Unit
_Null = prism' (const null) $ project >>> case _ of
Sig.NullM.Just unit
_ → M.Nothing

_String t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t String
_String t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t String
_String = prism' string $ project >>> case _ of
Sig.String s → M.Just s
_ → M.Nothing

_Boolean t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t Boolean
_Boolean t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t Boolean
_Boolean = prism' boolean $ project >>> case _ of
Sig.Boolean b → M.Just b
_ → M.Nothing

_Integer t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t Int
_Integer t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t Int
_Integer = prism' integer $ project >>> case _ of
Sig.Integer i → M.Just i
_ → M.Nothing

_Decimal t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t HN.HugeNum
_Decimal t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t HN.HugeNum
_Decimal = prism' decimal $ project >>> case _ of
Sig.Decimal d → M.Just d
_ → M.Nothing

_Array t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t (Array t)
_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
_ → M.Nothing

_Map t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF, Ord t) Prism' t (Map.Map t t)
_Map t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Ord t Prism' t (Map.Map t t)
_Map = prism' map $ project >>> case _ of
Sig.Map (Sig.EJsonMap kvs) → M.Just $ Map.fromFoldable kvs
_ → M.Nothing

_Map' t. (Corecursive t Sig.EJsonF, Recursive t Sig.EJsonF) Prism' t (SM.StrMap t)
_Map' t. Corecursive t Sig.EJsonF Recursive t Sig.EJsonF Prism' t (SM.StrMap t)
_Map' = prism' map' $ project >>> case _ of
Sig.Map (Sig.EJsonMap kvs) → SM.fromFoldable <$> for kvs (bitraverse (preview _String) pure)
_ → M.Nothing
2 changes: 1 addition & 1 deletion src/Data/Json/Extended/Cursor.purs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ setKey ∷ EJ.EJson → EJ.EJson → EJ.EJson → EJ.EJson
setKey k x v = case project v of
EJ.Map (EJ.EJsonMap fields) →
embed <<< EJ.Map <<< EJ.EJsonMap $ map
(\(kv@(Tuple k' v)) → if k == k' then Tuple k x else kv) fields
(\(kv@(Tuple k' _)) → if k == k' then Tuple k x else kv) fields
_ → v

-- | Attempts to lookup an index in an EJson Array, returning the associated
Expand Down
7 changes: 3 additions & 4 deletions src/Data/Json/Extended/Signature/Json.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Control.Alt ((<|>))
import Data.Argonaut.Core as JS
import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.?))
import Data.Argonaut.Encode (encodeJson)
import Data.Array as A
import Data.Bifunctor (lmap)
import Data.Either as E
import Data.HugeNum as HN
Expand Down Expand Up @@ -69,13 +68,13 @@ decodeJsonEJsonF =
pure
<<< Map
<<< EJsonMap
<<< A.fromFoldable
<<< map (lmap encodeJson)
<<< SM.toList
<<< SM.toUnfoldable

unwrapBranch
t
. (TR.Traversable t, DecodeJson (t JS.Json))
. TR.Traversable t
DecodeJson (t JS.Json)
String
(t JS.Json E.Either String (EJsonF JS.Json))
JS.JObject
Expand Down
11 changes: 7 additions & 4 deletions src/Data/Json/Extended/Signature/Parse.purs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ commaSep p = do
PS.skipSpaces
o ← PC.sepBy p do
PS.skipSpaces
PS.string ","
_ ← PS.string ","
PS.skipSpaces
PS.skipSpaces
pure o
Expand Down Expand Up @@ -114,7 +114,8 @@ parseNat =

parseNegative
m a
. (Monad m, Ring a)
. Monad m
Ring a
P.ParserT String m a
P.ParserT String m a
parseNegative p =
Expand All @@ -125,7 +126,8 @@ parseNegative p =

parsePositive
m a
. (Monad m, Ring a)
. Monad m
Ring a
P.ParserT String m a
P.ParserT String m a
parsePositive p =
Expand All @@ -134,7 +136,8 @@ parsePositive p =

parseSigned
m a
. (Monad m, Ring a)
. Monad m
Ring a
P.ParserT String m a
P.ParserT String m a
parseSigned p =
Expand Down
2 changes: 1 addition & 1 deletion test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Test.StrongCheck.Arbitrary as SCA
import Text.Parsing.Parser as P

type TestEffects =
( errEXCEPTION
( exceptionEXCEPTION
, randomRANDOM
, consoleCONSOLE
)
Expand Down

0 comments on commit d252fc3

Please sign in to comment.