Skip to content

Commit

Permalink
Merge pull request #91 from justinwoo/ps-0.15.0-upgrade-pure-code-cha…
Browse files Browse the repository at this point in the history
…nges

purs 0.15.0
  • Loading branch information
justinwoo authored May 12, 2022
2 parents 2341aa4 + c0cb9a0 commit b85e112
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 53 deletions.
20 changes: 10 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"output"
],
"dependencies": {
"purescript-prelude": "^5.0.0",
"purescript-typelevel-prelude": "^6.0.0",
"purescript-record": "^3.0.0",
"purescript-variant": "^7.0.1",
"purescript-nullable": "^5.0.0",
"purescript-foreign-object": "^3.0.0",
"purescript-foreign": "^6.0.0",
"purescript-exceptions": "^5.0.0",
"purescript-arrays": "^6.0.0"
"purescript-prelude": "^6.0.0",
"purescript-typelevel-prelude": "^7.0.0",
"purescript-record": "^4.0.0",
"purescript-variant": "^8.0.0",
"purescript-nullable": "^6.0.0",
"purescript-foreign-object": "^4.0.0",
"purescript-foreign": "^7.0.0",
"purescript-exceptions": "^6.0.0",
"purescript-arrays": "^7.0.0"
},
"devDependencies": {
"purescript-assert": "^5.0.0"
"purescript-assert": "^6.0.0"
}
}
34 changes: 17 additions & 17 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ let
};
in

{ pkgs ? import nixpkgs {} }:
{ pkgs ? import nixpkgs { } }:

let
ezPscSrc = pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "e8a1ffafafcdf2e81adba419693eb35f3ee422f8";
sha256 = "0bk32wckk82f1j5i5gva63f3b3jl8swc941c33bqc3pfg5cgkyyf";
};
ezPsc = import ezPscSrc { inherit pkgs; };
in
let
ezPscSrc = pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "0ad5775c1e80cdd952527db2da969982e39ff592";
sha256 = "0x53ads5v8zqsk4r1mfpzf5913byifdpv5shnvxpgw634ifyj1kg";
};
ezPsc = import ezPscSrc { inherit pkgs; };
in

pkgs.mkShell {
buildInputs = [
ezPsc.purs-0_14_0
pkgs.nodePackages_10_x.bower
pkgs.nodePackages_10_x.pulp
];
}
pkgs.mkShell {
buildInputs = [
ezPsc.purs-0_15_0
ezPsc.pulp
pkgs.nodePackages_10_x.bower
];
}
6 changes: 3 additions & 3 deletions src/Simple/JSON.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports._parseJSON = JSON.parse;
export const _parseJSON = JSON.parse;

exports._undefined = undefined;
export const _undefined = undefined;

exports._unsafeStringify = JSON.stringify;
export const _unsafeStringify = JSON.stringify;
13 changes: 7 additions & 6 deletions src/Simple/JSON.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Simple.JSON
, read
, read'
, read_
, readAsForeign
, parseJSON
, undefined
, unsafeStringify
Expand Down Expand Up @@ -39,7 +40,7 @@ import Data.Identity (Identity(..))
import Data.List.NonEmpty (singleton)
import Data.Maybe (Maybe(..), maybe)
import Data.Nullable (Nullable, toMaybe, toNullable)
import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol)
import Data.Symbol (class IsSymbol, reflectSymbol)
import Data.Traversable (sequence, traverse)
import Data.TraversableWithIndex (traverseWithIndex)
import Data.Variant (Variant, inj, on)
Expand All @@ -56,7 +57,7 @@ import Prim.RowList (class RowToList, Cons, Nil, RowList)
import Record (get)
import Record.Builder (Builder)
import Record.Builder as Builder
import Type.Prelude (Proxy(..))
import Type.Proxy (Proxy(..))

-- | An alias for the Either result of decoding
type E a = Either MultipleErrors a
Expand Down Expand Up @@ -227,7 +228,7 @@ instance readFieldsCons ::
value <- withExcept' (readImpl =<< readProp name obj)
pure $ Builder.insert nameP value
rest = getFields tailP obj
nameP = SProxy :: SProxy name
nameP = Proxy :: Proxy name
tailP = Proxy :: Proxy tail
name = reflectSymbol nameP
withExcept' = withExcept <<< map $ ErrorAtProperty name
Expand Down Expand Up @@ -280,7 +281,7 @@ instance readVariantCons ::
(fail <<< ForeignError $ "Did not match variant tag " <> name)
<|> readVariantImpl (Proxy :: Proxy tail) o
where
namep = SProxy :: SProxy name
namep = Proxy :: Proxy name
name = reflectSymbol namep

-- -- | A class for writing a value into JSON
Expand Down Expand Up @@ -341,7 +342,7 @@ instance consWriteForeignFields ::
) => WriteForeignFields (Cons name ty tail) row from to where
writeImplFields _ rec = result
where
namep = SProxy :: SProxy name
namep = Proxy :: Proxy name
value = writeImpl $ get namep rec
tailp = Proxy :: Proxy tail
rest = writeImplFields tailp rec
Expand Down Expand Up @@ -379,7 +380,7 @@ instance consWriteForeignVariant ::
(writeVariantImpl (Proxy :: Proxy tail))
variant
where
namep = SProxy :: SProxy name
namep = Proxy :: Proxy name
writeVariant value = unsafeToForeign
{ type: reflectSymbol namep
, value: writeImpl value
Expand Down
10 changes: 3 additions & 7 deletions test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

bower install

# NOTE: The following bug has been fixed, but the fix hasn't been upstreamed
# to the version of nixpkgs pinned in this repo:
#
# https://github.com/purescript-contrib/pulp/issues/392
#
# Once pulp has been updated, drop '--no-check-main'
pulp test --no-check-main
pulp build --include test

node ./test/index.mjs
5 changes: 3 additions & 2 deletions test/EnumSumGeneric.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import Foreign (Foreign)
import Foreign as Foreign
import Simple.JSON as JSON
import Test.Assert (assert)
import Type.Prelude (class IsSymbol, SProxy(..), reflectSymbol)
import Type.Prelude (class IsSymbol, reflectSymbol)
import Type.Proxy (Proxy(..))

enumReadForeign :: forall a rep
. Generic a rep
Expand Down Expand Up @@ -44,7 +45,7 @@ instance constructorEnumReadForeign ::
else throwError <<< pure <<< Foreign.ForeignError $
"Enum string " <> s <> " did not match expected string " <> name
where
name = reflectSymbol (SProxy :: SProxy name)
name = reflectSymbol (Proxy :: Proxy name)

data Fruit
= Abogado
Expand Down
6 changes: 3 additions & 3 deletions test/Inferred.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foreign as Foreign
import Record as Record
import Simple.JSON as JSON
import Test.Assert (assert)
import Type.Prelude (SProxy(..))
import Type.Proxy (Proxy(..))

type RecordWithEither =
{ apple :: Int
Expand Down Expand Up @@ -43,8 +43,8 @@ readRecordMisnamedField s = do
inter <- JSON.readJSON s
pure $ Record.rename grapeP cherryP inter
where
grapeP = SProxy :: SProxy "grape"
cherryP = SProxy :: SProxy "cherry"
grapeP = Proxy :: Proxy "grape"
cherryP = Proxy :: Proxy "cherry"

main :: Effect Unit
main = do
Expand Down
11 changes: 6 additions & 5 deletions test/Util.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Prelude
import Prim.Row as Row
import Prim.RowList (class RowToList, Cons, Nil, RowList)
import Record (get)
import Type.Prelude (class IsSymbol, RLProxy(..), SProxy(..))
import Type.Prelude (class IsSymbol)
import Type.Proxy (Proxy(..))

-- | Check two records of the same type for equality.
equal
Expand All @@ -15,10 +16,10 @@ equal
=> Record r
-> Record r
-> Boolean
equal a b = equalFields (RLProxy :: RLProxy rs) a b
equal a b = equalFields (Proxy :: Proxy rs) a b

class EqualFields (rs :: RowList Type) (row :: Row Type) | rs -> row where
equalFields :: RLProxy rs -> Record row -> Record row -> Boolean
equalFields :: Proxy rs -> Record row -> Record row -> Boolean

instance equalFieldsCons
::
Expand All @@ -29,8 +30,8 @@ instance equalFieldsCons
) => EqualFields (Cons name ty tail) row where
equalFields _ a b = get' a == get' b && rest
where
get' = get (SProxy :: SProxy name)
rest = equalFields (RLProxy :: RLProxy tail) a b
get' = get (Proxy :: Proxy name)
rest = equalFields (Proxy :: Proxy tail) a b

instance equalFieldsNil :: EqualFields Nil row where
equalFields _ _ _ = true
3 changes: 3 additions & 0 deletions test/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { main } from "../output/Test.Main/index.js";

main();

0 comments on commit b85e112

Please sign in to comment.