git.iko.soy/rowtype-yoga/purescript-docs-search
on master help sign in
Upgrade package-set, use newer bower-json.
14ff010klntsky
packages.dhall+1−16
@@ -2,7 +2,7 @@ let mkPackage =
2 https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.2-20190725/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
2 https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.2-20190725/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
3
3
4let upstream =
4let upstream =
5− https://github.com/purescript/package-sets/releases/download/psc-0.13.8/packages.dhall sha256:0e95ec11604dc8afc1b129c4d405dcc17290ce56d7d0665a0ff15617e32bbf03
5+ https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200724/packages.dhall sha256:bb941d30820a49345a0e88937094d2b9983d939c9fd3a46969b85ce44953d7d9
6
6
7let overrides = {=}
7let overrides = {=}
8
8
@@ -74,21 +74,6 @@ let additions =
74 [ "markdown-it", "html-parser-halogen" ]
74 [ "markdown-it", "html-parser-halogen" ]
75 "https://github.com/nonbili/purescript-markdown-it-halogen.git"
75 "https://github.com/nonbili/purescript-markdown-it-halogen.git"
76 "08c9625015bf04214be14e45230e8ce12f3fa2bf"
76 "08c9625015bf04214be14e45230e8ce12f3fa2bf"
77− , bower-json =
78− mkPackage
79− [ "prelude"
80− , "generics-rep"
81− , "maybe"
82− , "arrays"
83− , "either"
84− , "newtype"
85− , "tuples"
86− , "foldable-traversable"
87− , "argonaut-codecs"
88− , "foreign-object"
89− ]
90− "https://github.com/klntsky/purescript-bower-json.git"
91− "v1.0.0"
92 , toppokki =
77 , toppokki =
93 mkPackage
78 mkPackage
94 [ "prelude"
79 [ "prelude"
src/Docs/Search/DocsJson.purs+11−6
@@ -7,6 +7,7 @@ import Docs.Search.TypeDecoder (Constraint, FunDeps, Kind, Type, TypeArgument)
7
7
8import Data.Argonaut.Core (fromString, stringify, toString)
8import Data.Argonaut.Core (fromString, stringify, toString)
9import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:), (.:?))
9import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:), (.:?))
10+import Data.Argonaut.Decode.Error (JsonDecodeError(..))
10import Data.Argonaut.Encode (class EncodeJson, encodeJson)
11import Data.Argonaut.Encode (class EncodeJson, encodeJson)
11import Data.Either (Either(..))
12import Data.Either (Either(..))
12import Data.Generic.Rep (class Generic)
13import Data.Generic.Rep (class Generic)
@@ -151,7 +152,7 @@ instance encodeJsonDeclType :: EncodeJson DeclType where
151instance decodeJsonDeclType :: DecodeJson DeclType where
152instance decodeJsonDeclType :: DecodeJson DeclType where
152 decodeJson json =
153 decodeJson json =
153 case toString json of
154 case toString json of
154− Nothing -> Left $ "Couldn't decode DeclType: " <> stringify json
155+ Nothing -> errorWith $ "Couldn't decode DeclType: " <> stringify json
155 Just string ->
156 Just string ->
156 case string of
157 case string of
157 "value" -> Right DeclValue
158 "value" -> Right DeclValue
@@ -161,7 +162,7 @@ instance decodeJsonDeclType :: DecodeJson DeclType where
161 "typeClass" -> Right DeclTypeClass
162 "typeClass" -> Right DeclTypeClass
162 "alias" -> Right DeclAlias
163 "alias" -> Right DeclAlias
163 "kind" -> Right DeclExternKind
164 "kind" -> Right DeclExternKind
164− _ -> Left $ "Couldn't decode DeclType: " <> string
165+ _ -> errorWith $ "Couldn't decode DeclType: " <> string
165
166
166
167
167data ChildDeclType
168data ChildDeclType
@@ -184,13 +185,13 @@ instance encodeJsonChildDeclType :: EncodeJson ChildDeclType where
184instance decodeJsonChildDeclType :: DecodeJson ChildDeclType where
185instance decodeJsonChildDeclType :: DecodeJson ChildDeclType where
185 decodeJson json =
186 decodeJson json =
186 case toString json of
187 case toString json of
187− Nothing -> Left $ "Couldn't decode ChildDeclType: " <> stringify json
188+ Nothing -> errorWith $ "Couldn't decode ChildDeclType: " <> stringify json
188 Just tag ->
189 Just tag ->
189 case tag of
190 case tag of
190 "instance" -> Right ChildDeclInstance
191 "instance" -> Right ChildDeclInstance
191 "dataConstructor" -> Right ChildDeclDataConstructor
192 "dataConstructor" -> Right ChildDeclDataConstructor
192 "typeClassMember" -> Right ChildDeclTypeClassMember
193 "typeClassMember" -> Right ChildDeclTypeClassMember
193− _ -> Left $ "Couldn't decode ChildDeclType: " <> tag
194+ _ -> errorWith $ "Couldn't decode ChildDeclType: " <> tag
194
195
195
196
196data DataDeclType
197data DataDeclType
@@ -215,5 +216,9 @@ instance decodeJsonDataDeclType :: DecodeJson DataDeclType where
215 case tag of
216 case tag of
216 "newtype" -> Right NewtypeDataDecl
217 "newtype" -> Right NewtypeDataDecl
217 "data" -> Right DataDataDecl
218 "data" -> Right DataDataDecl
218− _ -> Left $ "Couldn't decode DataDeclType: " <> tag
219+ _ -> errorWith $ "Couldn't decode DataDeclType: " <> tag
219− Nothing -> Left $ "Couldn't decode DataDeclType: " <> stringify json
220+ Nothing -> errorWith $ "Couldn't decode DataDeclType: " <> stringify json
221+
222+
223+errorWith :: forall a. String -> Either JsonDecodeError a
224+errorWith = Left <<< TypeMismatch
src/Docs/Search/IndexBuilder.purs+5−2
@@ -14,8 +14,10 @@ import Docs.Search.Types (PackageName, PartId)
14import Docs.Search.Meta (Meta)
14import Docs.Search.Meta (Meta)
15
15
16import Prelude
16import Prelude
17+
17import Data.Argonaut.Core (stringify)
18import Data.Argonaut.Core (stringify)
18import Data.Argonaut.Decode (decodeJson)
19import Data.Argonaut.Decode (decodeJson)
20+import Data.Argonaut.Decode.Error (printJsonDecodeError)
19import Data.Argonaut.Encode (encodeJson)
21import Data.Argonaut.Encode (encodeJson)
20import Data.Argonaut.Parser (jsonParser)
22import Data.Argonaut.Parser (jsonParser)
21import Data.Array as Array
23import Data.Array as Array
@@ -27,6 +29,7 @@ import Data.Map (Map)
27import Data.Map as Map
29import Data.Map as Map
28import Data.Maybe (Maybe(..), fromMaybe)
30import Data.Maybe (Maybe(..), fromMaybe)
29import Data.Newtype (unwrap)
31import Data.Newtype (unwrap)
32+import Data.Profunctor.Choice (left)
30import Data.Search.Trie as Trie
33import Data.Search.Trie as Trie
31import Data.Set as Set
34import Data.Set as Set
32import Data.String.CodePoints (contains) as String
35import Data.String.CodePoints (contains) as String
@@ -151,7 +154,7 @@ decodeDocsJsons cfg@{ docsFiles } = do
151 if doesExist then do
154 if doesExist then do
152
155
153 contents <- readTextFile UTF8 jsonFile
156 contents <- readTextFile UTF8 jsonFile
154− let eiResult = jsonParser contents >>= decodeJson
157+ let eiResult = jsonParser contents >>= left printJsonDecodeError <<< decodeJson
155
158
156 case eiResult of
159 case eiResult of
157 Left error -> do
160 Left error -> do
@@ -192,7 +195,7 @@ decodeBowerJsons { bowerFiles } = do
192 join <$> withExisting jsonFileName
195 join <$> withExisting jsonFileName
193 \contents ->
196 \contents ->
194 either (logError jsonFileName) pure
197 either (logError jsonFileName) pure
195− (jsonParser contents >>= decodeJson)
198+ (jsonParser contents >>= left printJsonDecodeError <<< decodeJson)
196
199
197 where
200 where
198 compareNames
201 compareNames
src/Docs/Search/Loader.purs+2−1
@@ -7,6 +7,7 @@ import Prelude
7import Control.Monad.Error.Class (throwError)
7import Control.Monad.Error.Class (throwError)
8import Control.Promise (Promise, toAffE)
8import Control.Promise (Promise, toAffE)
9import Data.Argonaut.Core (Json)
9import Data.Argonaut.Core (Json)
10+import Data.Argonaut.Decode.Error (printJsonDecodeError)
10import Data.Argonaut.Decode.Class (class DecodeJson, decodeJson)
11import Data.Argonaut.Decode.Class (class DecodeJson, decodeJson)
11import Data.Either (either)
12import Data.Either (either)
12import Data.Newtype (unwrap)
13import Data.Newtype (unwrap)
@@ -28,7 +29,7 @@ load globalIdentifier url = do
28 where
29 where
29 throw err = throwError $ error $
30 throw err = throwError $ error $
30 "Couldn't load content from window." <>
31 "Couldn't load content from window." <>
31− unwrap globalIdentifier <> ": " <> err
32+ unwrap globalIdentifier <> ": " <> printJsonDecodeError err
32
33
33
34
34foreign import loadFromScript
35foreign import loadFromScript
src/Docs/Search/TypeDecoder.purs+17−18
@@ -8,13 +8,13 @@ import Control.Alt ((<|>))
8import Data.Argonaut.Core (Json, caseJsonObject, fromArray, fromObject, jsonEmptyObject, stringify, toArray)
8import Data.Argonaut.Core (Json, caseJsonObject, fromArray, fromObject, jsonEmptyObject, stringify, toArray)
9import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:))
9import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:))
10import Data.Argonaut.Encode (class EncodeJson, encodeJson)
10import Data.Argonaut.Encode (class EncodeJson, encodeJson)
11−import Data.Array ((!!))
11+import Data.Argonaut.Decode.Error (JsonDecodeError(..))
12import Data.Either (Either(..))
12import Data.Either (Either(..))
13import Data.Generic.Rep (class Generic)
13import Data.Generic.Rep (class Generic)
14import Data.Generic.Rep.Show (genericShow)
14import Data.Generic.Rep.Show (genericShow)
15import Data.List (List(..), (:))
15import Data.List (List(..), (:))
16import Data.List as List
16import Data.List as List
17−import Data.Maybe (Maybe(..), fromMaybe)
17+import Data.Maybe (Maybe(..))
18import Data.Newtype (class Newtype)
18import Data.Newtype (class Newtype)
19import Data.Tuple (Tuple(..))
19import Data.Tuple (Tuple(..))
20import Foreign.Object as Object
20import Foreign.Object as Object
@@ -42,11 +42,11 @@ instance encodeJsonQualifiedName :: EncodeJson QualifiedName where
42 encodeJson (QualifiedName { moduleNameParts, name }) =
42 encodeJson (QualifiedName { moduleNameParts, name }) =
43 encodeTuple moduleNameParts name
43 encodeTuple moduleNameParts name
44
44
45−mkJsonError :: String -> Json -> (forall i. i -> String)
45+mkJsonError :: String -> Json -> (forall i. i -> JsonDecodeError)
46mkJsonError name json _ =
46mkJsonError name json _ =
47− "Couldn't parse " <> name <> " from " <> stringify json
47+ TypeMismatch $ "Couldn't parse " <> name <> " from " <> stringify json
48
48
49−mkJsonError' :: String -> Json -> String
49+mkJsonError' :: String -> Json -> JsonDecodeError
50mkJsonError' name json = mkJsonError name json unit
50mkJsonError' name json = mkJsonError name json unit
51
51
52-- | The data type of kinds
52-- | The data type of kinds
@@ -294,17 +294,16 @@ decodeTuple
294 . DecodeJson fst
294 . DecodeJson fst
295 => DecodeJson sec
295 => DecodeJson sec
296 => (fst -> sec -> res)
296 => (fst -> sec -> res)
297− -> (forall a. a -> String)
297+ -> (forall a. a -> JsonDecodeError)
298 -> Json
298 -> Json
299− -> Either String res
299+ -> Either JsonDecodeError res
300decodeTuple cont err json =
300decodeTuple cont err json =
301− fromMaybe (Left $ err unit) $
302− toArray json >>= \jsons ->
301+ case toArray json of
303− jsons !! 0 >>= \json1 ->
302+ Just [ json1, json2 ] -> do
304− jsons !! 1 >>= \json2 -> pure $ do
305− fst <- decodeJson json1
303+ fst <- decodeJson json1
306− sec <- decodeJson json2
304+ sec <- decodeJson json2
307− pure $ cont fst sec
305+ pure $ cont fst sec
306+ _ -> Left $ err unit
308
307
309-- | Decode a heterogeneous triple.
308-- | Decode a heterogeneous triple.
310decodeTriple
309decodeTriple
@@ -313,9 +312,9 @@ decodeTriple
313 => DecodeJson sec
312 => DecodeJson sec
314 => DecodeJson trd
313 => DecodeJson trd
315 => (fst -> sec -> trd -> res)
314 => (fst -> sec -> trd -> res)
316− -> (forall a. a -> String)
315+ -> (forall a. a -> JsonDecodeError)
317 -> Json
316 -> Json
318− -> Either String res
317+ -> Either JsonDecodeError res
319decodeTriple cont err json =
318decodeTriple cont err json =
320 case toArray json of
319 case toArray json of
321 Just [ json1, json2, json3 ] -> do
320 Just [ json1, json2, json3 ] -> do
@@ -333,9 +332,9 @@ decodeQuadriple
333 => DecodeJson trd
332 => DecodeJson trd
334 => DecodeJson frt
333 => DecodeJson frt
335 => (fst -> sec -> trd -> frt -> res)
334 => (fst -> sec -> trd -> frt -> res)
336− -> (forall a. a -> String)
335+ -> (forall a. a -> JsonDecodeError)
337 -> Json
336 -> Json
338− -> Either String res
337+ -> Either JsonDecodeError res
339decodeQuadriple cont err json =
338decodeQuadriple cont err json =
340 case toArray json of
339 case toArray json of
341 Just [ json1, json2, json3, json4 ] -> do
340 Just [ json1, json2, json3, json4 ] -> do