Skip to content

Commit

Permalink
Upgrade argonaut dependency (#49)
Browse files Browse the repository at this point in the history
* Upgrade argonaut dependency

* Migrate to Spago, update CI, and lint readme

* Forgot the argonaut dependency

* Update packages.dhall
  • Loading branch information
thomashoneyman committed Jun 30, 2020
1 parent 0f5c433 commit 6c05d54
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ node_js: 10
env:
- PATH=$HOME/purescript:$PATH
install:
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/v0.13.0/linux64.tar.gz
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/v0.13.8/linux64.tar.gz
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
- chmod a+x $HOME/purescript
- npm install -g psc-package-bin-simple pulp bower
- npm install -g spago bower
script:
- psc-package install && pulp --psc-package build
- spago build
- bower install && npm install && npm run compile:bower
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
[![Build Status](https://travis-ci.org/kRITZCREEK/purescript-psc-ide.svg?branch=master)](https://travis-ci.org/kRITZCREEK/purescript-psc-ide)

purescript-psc-ide
===
# purescript-psc-ide [![Build Status](https://travis-ci.org/kRITZCREEK/purescript-psc-ide.svg?branch=master)](https://travis-ci.org/kRITZCREEK/purescript-psc-ide)

A PureScript client for `purs ide server` (previously `psc-ide`). Information about the IDE server and protocol
can be found in the [compiler repository](https://github.com/purescript/purescript/tree/master/psc-ide).

Dependencies
====
## Dependencies

The npm dependency `which` is required for certain functionality.

```
```sh
npm install -S which
```
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"purescript-console": "^4.1.0",
"purescript-argonaut": "^6.0.0",
"purescript-argonaut": "^7.0.0",
"purescript-arrays": "^5.0.0",
"purescript-maybe": "^4.0.0",
"purescript-aff": "^5.0.2",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"compile:bower": "purs compile \"src/**/*.purs\" \"bower_components/purescript-*/src/**/*.purs\""
},
"devDependencies": {
"purescript": "^0.13.0"
"purescript": "^0.13.8"
}
}
12 changes: 12 additions & 0 deletions packages.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200615/packages.dhall sha256:5d0cfad9408c84db0a3fdcea2d708f9ed8f64297e164dc57a7cf6328706df93a

let overrides =
{ argonaut = upstream.argonaut // { version = "v7.0.0" }
, argonaut-codecs = upstream.argonaut-codecs // { version = "v7.0.0", dependencies = upstream.argonaut-codecs.dependencies # [ "generics-rep" ] }
, argonaut-traversals = upstream.argonaut-traversals // { version = "v8.0.0" }
}

let additions = {=}

in upstream // overrides // additions
16 changes: 0 additions & 16 deletions psc-package.json

This file was deleted.

16 changes: 16 additions & 0 deletions spago.dhall
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{ name = "psc-ide"
, dependencies =
[ "aff"
, "argonaut"
, "arrays"
, "console"
, "effect"
, "maybe"
, "node-child-process"
, "node-fs"
, "parallel"
, "random"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs" ]
}
18 changes: 9 additions & 9 deletions src/PscIde/Command.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module PscIde.Command where
import Prelude

import Control.Alt ((<|>))
import Data.Argonaut (getField)
import Data.Argonaut (JsonDecodeError(..), getField, parseJson, printJsonDecodeError)
import Data.Argonaut.Core (jsonEmptyObject, jsonSingletonObject, jsonNull, fromString, Json, toString)
import Data.Argonaut.Decode (class DecodeJson, decodeJson, (.:))
import Data.Argonaut.Encode (class EncodeJson, encodeJson, (~>), (:=))
import Data.Argonaut.Parser (jsonParser)
import Data.Array (singleton)
import Data.Bifunctor (lmap)
import Data.Either (Either(..), either, hush)
import Data.Maybe (Maybe(..), maybe)
import Data.String (joinWith)
Expand Down Expand Up @@ -283,8 +283,8 @@ data ImportType = Implicit | Explicit (Array String) | Hiding (Array String)
data ImportResult = SuccessFile Message | SuccessText (Array String) | MultipleResults (Array TypeInfo)

unwrapResponse :: forall a b. DecodeJson a => DecodeJson b => String -> Either String (Either a b)
unwrapResponse s = do
json <- jsonParser s
unwrapResponse s = lmap printJsonDecodeError do
json <- parseJson s
o <- decodeJson json
resultType <- o .: "resultType"
case resultType of
Expand All @@ -296,7 +296,7 @@ unwrapResponse s = do
pure (Left result)

instance decodeMessage :: DecodeJson Message where
decodeJson json = maybe (Left "Message not string") (Right <<< Message) $ toString json
decodeJson json = maybe (Left (TypeMismatch "String")) (Right <<< Message) $ toString json

instance decodeModuleList :: DecodeJson ModuleList where
decodeJson json = ModuleList <$> decodeJson json
Expand All @@ -314,7 +314,7 @@ instance decodeTypeInfo :: DecodeJson TypeInfo where
exportedFrom <- Right $ either (const []) identity $ getField o "exportedFrom"
pure (TypeInfo { identifier, type', module', definedAt, expandedType, documentation, exportedFrom })
where
getFieldMaybe :: forall a. (DecodeJson a) => Object Json -> String -> Either String (Maybe a)
getFieldMaybe :: forall a. (DecodeJson a) => Object Json -> String -> Either JsonDecodeError (Maybe a)
getFieldMaybe o f = Right $ either (const Nothing) Just $ getField o f

instance decodeTypePosition :: DecodeJson TypePosition where
Expand All @@ -326,7 +326,7 @@ instance decodeTypePosition :: DecodeJson TypePosition where
case start, end of
[sl, sc], [el, ec] ->
Right (TypePosition { name, start: { line: sl, column: sc }, end: { line: el, column: ec } })
_, _ -> Left "Start/end should be arrays"
_, _ -> Left (TypeMismatch "Array")

instance decodePursuitCompletion :: DecodeJson PursuitCompletion where
decodeJson json = do
Expand Down Expand Up @@ -374,14 +374,14 @@ instance decodeImport :: DecodeJson Import where
"hiding" -> do
identifiers <- o .: "identifiers"
pure $ Import {moduleName: moduleName, importType: Hiding identifiers, qualifier: q}
_ -> Left "unknown importType"
v -> Left (TypeMismatch "ImportType")

instance decodeImportResult :: DecodeJson ImportResult where
decodeJson json = do
(SuccessText <$> decodeJson json)
<|> (SuccessFile <$> decodeJson json)
<|> (MultipleResults <$> decodeJson json)
<|> (Left "Couldn't parse as ImportResult")
<|> (Left (TypeMismatch "ImportResult"))

instance decodeRebuildError :: DecodeJson RebuildError where
decodeJson json = do
Expand Down

0 comments on commit 6c05d54

Please sign in to comment.