Skip to content

Commit

Permalink
PS 0.15.0 upgrade (pure code changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
CGenie committed May 11, 2022
1 parent 2341aa4 commit cd6e8f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
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 function _parseJSON() { return JSON.parse.apply(this, arguments) };

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

exports._unsafeStringify = JSON.stringify;
export function _unsafeStringify() { return JSON.stringify.apply(this, arguments) };
12 changes: 6 additions & 6 deletions src/Simple/JSON.purs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 +56,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 +227,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 +280,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 +341,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 +379,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
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

0 comments on commit cd6e8f2

Please sign in to comment.