From 9ce8e17dfa6ceb41dd867de3220a476c08d4d412 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Fri, 4 Dec 2020 17:06:51 -0800 Subject: [PATCH] Update to v0.14.0-rc3 (#90) * Update packages.dhall to prepare-0.14 bootstrap * Update CI to use v0.14.0-rc3 PS release * Use Proxy; add Type kind to Row and RowList --- .github/workflows/ci.yml | 2 ++ packages.dhall | 2 +- src/Data/Argonaut/Decode/Class.purs | 16 ++++++++-------- src/Data/Argonaut/Encode/Class.purs | 14 +++++++------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b0550f..d91f17d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,8 @@ jobs: - name: Set up a PureScript toolchain uses: purescript-contrib/setup-purescript@main + with: + purescript: "0.14.0-rc3" - name: Cache PureScript dependencies uses: actions/cache@v2 diff --git a/packages.dhall b/packages.dhall index 6413e8d..9c3ee6f 100644 --- a/packages.dhall +++ b/packages.dhall @@ -1,4 +1,4 @@ let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200831/packages.dhall sha256:cdb3529cac2cd8dd780f07c80fd907d5faceae7decfcaa11a12037df68812c83 + https://raw.githubusercontent.com/purescript/package-sets/prepare-0.14/src/packages.dhall in upstream diff --git a/src/Data/Argonaut/Decode/Class.purs b/src/Data/Argonaut/Decode/Class.purs index 3b1f62f..d9cd695 100644 --- a/src/Data/Argonaut/Decode/Class.purs +++ b/src/Data/Argonaut/Decode/Class.purs @@ -15,14 +15,14 @@ import Data.Maybe (Maybe(..)) import Data.NonEmpty (NonEmpty) import Data.Set as S import Data.String (CodePoint) -import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol) +import Data.Symbol (class IsSymbol, reflectSymbol) import Data.Tuple (Tuple) import Foreign.Object as FO import Prelude (class Ord, Unit, Void, bind, ($), (<<<)) import Prim.Row as Row import Prim.RowList as RL import Record as Record -import Type.Data.RowList (RLProxy(..)) +import Type.Proxy (Proxy(..)) class DecodeJson a where decodeJson :: Json -> Either JsonDecodeError a @@ -97,11 +97,11 @@ instance decodeRecord => DecodeJson (Record row) where decodeJson json = case toObject json of - Just object -> gDecodeJson object (RLProxy :: RLProxy list) + Just object -> gDecodeJson object (Proxy :: Proxy list) Nothing -> Left $ TypeMismatch "Object" -class GDecodeJson (row :: # Type) (list :: RL.RowList) | list -> row where - gDecodeJson :: FO.Object Json -> RLProxy list -> Either JsonDecodeError (Record row) +class GDecodeJson (row :: Row Type) (list :: RL.RowList Type) | list -> row where + gDecodeJson :: forall proxy. FO.Object Json -> proxy list -> Either JsonDecodeError (Record row) instance gDecodeJsonNil :: GDecodeJson () RL.Nil where gDecodeJson _ _ = Right {} @@ -115,14 +115,14 @@ instance gDecodeJsonCons ) => GDecodeJson row (RL.Cons field value tail) where gDecodeJson object _ = do - let - _field = SProxy :: SProxy field + let + _field = Proxy :: Proxy field fieldName = reflectSymbol _field case FO.lookup fieldName object of Just jsonVal -> do val <- lmap (AtKey fieldName) <<< decodeJson $ jsonVal - rest <- gDecodeJson object (RLProxy :: RLProxy tail) + rest <- gDecodeJson object (Proxy :: Proxy tail) Right $ Record.insert _field val rest Nothing -> diff --git a/src/Data/Argonaut/Encode/Class.purs b/src/Data/Argonaut/Encode/Class.purs index 3d39fce..d9d457e 100644 --- a/src/Data/Argonaut/Encode/Class.purs +++ b/src/Data/Argonaut/Encode/Class.purs @@ -13,14 +13,14 @@ import Data.Maybe (Maybe) import Data.NonEmpty (NonEmpty) import Data.Set as S import Data.String (CodePoint) -import Data.Symbol (class IsSymbol, SProxy(..), reflectSymbol) +import Data.Symbol (class IsSymbol, reflectSymbol) import Data.Tuple (Tuple) import Foreign.Object as FO import Prelude (class Ord, Unit, Void, identity, ($)) import Prim.Row as Row import Prim.RowList as RL import Record as Record -import Type.Data.RowList (RLProxy(..)) +import Type.Proxy (Proxy(..)) class EncodeJson a where encodeJson :: a -> Json @@ -96,10 +96,10 @@ instance encodeRecord , RL.RowToList row list ) => EncodeJson (Record row) where - encodeJson rec = fromObject $ gEncodeJson rec (RLProxy :: RLProxy list) + encodeJson rec = fromObject $ gEncodeJson rec (Proxy :: Proxy list) -class GEncodeJson (row :: # Type) (list :: RL.RowList) where - gEncodeJson :: Record row -> RLProxy list -> FO.Object Json +class GEncodeJson (row :: Row Type) (list :: RL.RowList Type) where + gEncodeJson :: forall proxy. Record row -> proxy list -> FO.Object Json instance gEncodeJsonNil :: GEncodeJson row RL.Nil where gEncodeJson _ _ = FO.empty @@ -112,8 +112,8 @@ instance gEncodeJsonCons ) => GEncodeJson row (RL.Cons field value tail) where gEncodeJson row _ = do - let _field = SProxy :: SProxy field + let _field = Proxy :: Proxy field FO.insert (reflectSymbol _field) (encodeJson $ Record.get _field row) - (gEncodeJson row (RLProxy :: RLProxy tail)) + (gEncodeJson row (Proxy :: Proxy tail))