Skip to content

Commit 242cb95

Browse files
committed
Merge pull request #5 from purescript-contrib/profunctor-lenses
Switch from optic to profunctor-lenses
2 parents 57a67e0 + e6c0306 commit 242cb95

File tree

6 files changed

+23
-28
lines changed

6 files changed

+23
-28
lines changed

.travis.yml

-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ node_js:
55
env:
66
- PATH=$HOME/purescript:$PATH
77
install:
8-
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
9-
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10-
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11-
- chmod a+x $HOME/purescript
128
- npm install bower gulp -g
139
- npm install
1410
- bower install --production

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
"license": "MIT",
2323
"dependencies": {
2424
"purescript-argonaut-codecs": "^0.3.0",
25-
"purescript-optic": "^0.8.0"
25+
"purescript-profunctor-lenses": "^0.3.3"
2626
},
2727
"devDependencies": {
28-
"purescript-strongcheck": "^0.12.1"
28+
"purescript-strongcheck": "^0.14.3"
2929
}
3030
}

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"license": "MIT",
55
"devDependencies": {
66
"gulp": "^3.9.0",
7-
"gulp-purescript": "^0.5.0",
8-
"gulp-run": "^1.6.8"
7+
"gulp-purescript": "^0.7.0",
8+
"gulp-run": "^1.6.8",
9+
"purescript": "^0.7.5-rc.3"
910
}
1011
}

src/Data/Argonaut/JCursor.purs

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ module Data.Argonaut.JCursor where
33
import Prelude
44

55
import Data.Argonaut.Core
6-
import Data.Argonaut.Encode
76
import Data.Argonaut.Decode
8-
import Data.Maybe (Maybe(..), fromMaybe, maybe)
9-
import Data.List (List(), zipWith, range, head, singleton, toList)
7+
import Data.Argonaut.Encode
108
import Data.Either (Either(..))
9+
import Data.Foldable (foldl)
10+
import Data.List (List(), zipWith, range, head, singleton, toList)
11+
import Data.Maybe (Maybe(..), fromMaybe, maybe)
1112
import Data.Monoid (Monoid, mempty)
1213
import Data.Tuple (Tuple(..), fst, snd)
13-
import Data.Foldable (foldl)
1414

15-
import qualified Data.Int as I
1615
import qualified Data.Array as A
17-
import qualified Data.StrMap as M
16+
import qualified Data.Int as I
1817
import qualified Data.Maybe.Unsafe as MU
18+
import qualified Data.StrMap as M
1919

2020
data JCursor
2121
= JCursorTop
@@ -58,7 +58,7 @@ insideOut (JIndex i c) = downIndex i (insideOut c)
5858
downField :: String -> JCursor -> JCursor
5959
downField i = downField' where
6060
downField' JCursorTop = JField i JCursorTop
61-
downField' (JField i' c) = JField i' (downField' c)
61+
downField' (JField i' c) = JField i' (downField' c)
6262
downField' (JIndex i' c) = JIndex i' (downField' c)
6363

6464
downIndex :: Int -> JCursor -> JCursor
@@ -83,7 +83,7 @@ cursorSet :: JCursor -> Json -> Json -> Maybe Json
8383
cursorSet JCursorTop v = pure <<< const v
8484
cursorSet (JField i c) v = foldJsonObject defaultObj mergeObjs
8585
where
86-
defaultObj :: Maybe Json
86+
defaultObj :: Maybe Json
8787
defaultObj = fromObject <<< M.singleton i <$> cursorSet c v (inferEmpty c)
8888

8989
mergeObjs :: JObject -> Maybe Json
@@ -94,7 +94,7 @@ cursorSet (JIndex i c) v = foldJsonArray defaultArr mergeArrs
9494
where
9595
defaultArr :: Maybe Json
9696
defaultArr = fromArray <<< MU.fromJust <<<
97-
flip (A.updateAt i) (A.replicate (i + 1) jsonNull) <$>
97+
flip (A.updateAt i) (A.replicate (i + 1) jsonNull) <$>
9898
cursorSet c v (inferEmpty c)
9999

100100
mergeArrs :: JArray -> Maybe Json
@@ -108,14 +108,14 @@ cursorSet (JIndex i c) v = foldJsonArray defaultArr mergeArrs
108108
else if i >= len
109109
then setArr (xs <> (A.replicate (i - len + 1) jsonNull)) i v
110110
else Just <<< fromArray <<< MU.fromJust $ A.updateAt i v xs
111-
111+
112112

113113
toPrims :: Json -> List (Tuple JCursor JsonPrim)
114114
toPrims = foldJson nullFn boolFn numFn strFn arrFn objFn
115115
where
116116
mkTop :: JsonPrim -> List (Tuple JCursor JsonPrim)
117117
mkTop p = singleton $ Tuple JCursorTop p
118-
118+
119119
nullFn :: JNull -> List (Tuple JCursor JsonPrim)
120120
nullFn _ = mkTop primNull
121121

@@ -139,7 +139,7 @@ toPrims = foldJson nullFn boolFn numFn strFn arrFn objFn
139139
arrFn' (Tuple i j) = toList ((\t -> Tuple (JIndex i (fst t)) (snd t))
140140
<$> toPrims j)
141141

142-
142+
143143
objFn :: JObject -> List (Tuple JCursor JsonPrim)
144144
objFn obj =
145145
let f :: Tuple String Json -> List (Tuple JCursor JsonPrim)
@@ -197,7 +197,7 @@ instance encodeJsonJCursor :: EncodeJson JCursor where
197197
loop (JIndex i c) = [encodeJson i] <> loop c
198198

199199
fail :: forall a b. (Show a) => a -> Either String b
200-
fail x = Left $ "Expected String or Number but found: " ++ show x
200+
fail x = Left $ "Expected String or Number but found: " ++ show x
201201

202202
instance decodeJsonJCursor :: DecodeJson JCursor where
203203
decodeJson j = decodeJson j >>= loop
@@ -220,4 +220,4 @@ instance decodeJsonJCursor :: DecodeJson JCursor where
220220

221221

222222

223-
223+

src/Data/Argonaut/Prisms.purs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module Data.Argonaut.Prisms where
22

3-
import Optic.Types (PrismP())
4-
import Optic.Prism (prism')
5-
import Data.Argonaut.Core
3+
import Data.Argonaut.Core
4+
import Data.Lens (PrismP(), prism')
65

76
_Null :: PrismP Json JNull
87
_Null = prism' fromNull toNull

src/Data/Argonaut/Traversals.purs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module Data.Argonaut.Traversals where
22

3+
import Data.Argonaut.Core
4+
import Data.Lens (TraversalP(), filtered)
35
import Prelude ((<<<), id)
4-
import Optic.Fold (filtered)
5-
import Optic.Extended (TraversalP())
6-
import Data.Argonaut.Core
76

87
_JsonNull :: TraversalP Json Json
98
_JsonNull = id <<< filtered isNull

0 commit comments

Comments
 (0)