diff --git a/.gitignore b/.gitignore index 760bddf..da6c2f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .psci* bower_components/ +node_modules/ output/ .psc-package .psc-ide-port diff --git a/README.md b/README.md index 9744ff6..f318957 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ First, define some data type and derive `Generic`: ```purescript > import Prelude > import Data.Generic.Rep (class Generic) -> import Data.Generic.Rep.Show (genericShow) +> import Data.Show.Generic (genericShow) > newtype MyRecord = MyRecord { a :: Int } > derive instance genericMyRecord :: Generic MyRecord _ diff --git a/bower.json b/bower.json index fe2c285..3507559 100644 --- a/bower.json +++ b/bower.json @@ -15,18 +15,16 @@ "url": "git://github.com/paf31/purescript-foreign-generic.git" }, "dependencies": { - "purescript-effect": "^2.0.0", - "purescript-foreign": "^5.0.0", - "purescript-foreign-object": "^2.0.0", - "purescript-generics-rep": "^6.0.0", - "purescript-ordered-collections": "^1.0.0", - "purescript-proxy": "^3.0.0", - "purescript-exceptions": "^4.0.0", - "purescript-record": "^2.0.0", - "purescript-identity": "^4.1.0" + "purescript-effect": "^3.0.0", + "purescript-foreign": "^6.0.0", + "purescript-foreign-object": "^3.0.0", + "purescript-ordered-collections": "^2.0.0", + "purescript-exceptions": "^5.0.0", + "purescript-record": "^3.0.0", + "purescript-identity": "^5.0.0" }, "devDependencies": { - "purescript-assert": "^4.0.0", - "purescript-psci-support": "^4.0.0" + "purescript-assert": "^5.0.0", + "purescript-psci-support": "^5.0.0" } } diff --git a/package.json b/package.json index aa08719..38e6586 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "test": "pulp test" }, "devDependencies": { - "pulp": "^12.0.0", - "purescript": "^0.12.0", + "pulp": "^15.0.0", + "purescript": "^0.14.0", "purescript-psa": "^0.5.0", "rimraf": "^2.5.0" } diff --git a/src/Foreign/Generic.purs b/src/Foreign/Generic.purs index 3125a7d..48f97c1 100644 --- a/src/Foreign/Generic.purs +++ b/src/Foreign/Generic.purs @@ -15,8 +15,8 @@ import Foreign (F, Foreign) import Foreign (F, Foreign, ForeignError(..)) as Reexports import Foreign.Generic.Class (class Decode, class Encode, class GenericDecode, class GenericEncode, Options, decode, decodeOpts, encode, encodeOpts) import Foreign.Generic.Class (class Decode, class Encode, class GenericDecode, class GenericEncode, Options, SumEncoding(..), defaultOptions, decode, encode) as Reexports +import Foreign.Internal.Stringify (unsafeStringify) import Foreign.JSON (decodeJSONWith, parseJSON) -import Global.Unsafe (unsafeStringify) -- | Read a value which has a `Generic` type. genericDecode diff --git a/src/Foreign/Internal/Stringify.js b/src/Foreign/Internal/Stringify.js new file mode 100644 index 0000000..97f76db --- /dev/null +++ b/src/Foreign/Internal/Stringify.js @@ -0,0 +1,3 @@ +exports.unsafeStringify = function (x) { + return JSON.stringify(x); +}; diff --git a/src/Foreign/Internal/Stringify.purs b/src/Foreign/Internal/Stringify.purs new file mode 100644 index 0000000..386b276 --- /dev/null +++ b/src/Foreign/Internal/Stringify.purs @@ -0,0 +1,5 @@ +module Foreign.Internal.Stringify (unsafeStringify) where + +-- | Uses the global JSON object to turn anything into a string. Careful! Trying +-- | to serialize functions returns undefined +foreign import unsafeStringify :: forall a. a -> String diff --git a/test/Main.purs b/test/Main.purs index 1c80643..0dc683e 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -15,9 +15,9 @@ import Foreign (isNull, unsafeToForeign) import Foreign.Generic (class Decode, class Encode, class GenericDecode, class GenericEncode, Options, decode, encode, defaultOptions, decodeJSON, encodeJSON, genericDecodeJSON, genericEncodeJSON) import Foreign.Generic.EnumEncoding (class GenericDecodeEnum, class GenericEncodeEnum, GenericEnumOptions, genericDecodeEnum, genericEncodeEnum) import Foreign.Index (readProp) +import Foreign.Internal.Stringify (unsafeStringify) import Foreign.JSON (parseJSON) import Foreign.Object as Object -import Global.Unsafe (unsafeStringify) import Test.Assert (assert, assert') import Test.Types (Fruit(..), IntList(..), RecordTest(..), Tree(..), TupleArray(..), UndefinedTest(..)) diff --git a/test/Types.purs b/test/Types.purs index 3c51ea5..ad2d060 100644 --- a/test/Types.purs +++ b/test/Types.purs @@ -7,8 +7,8 @@ import Foreign (ForeignError(..), fail, readArray, unsafeToForeign) import Foreign.Generic (class Encode, class Decode, Options, SumEncoding(..), encode, decode, defaultOptions, genericDecode, genericEncode) import Foreign.Generic.EnumEncoding (defaultGenericEnumOptions, genericDecodeEnum, genericEncodeEnum) import Data.Generic.Rep (class Generic) -import Data.Generic.Rep.Eq (genericEq) -import Data.Generic.Rep.Show (genericShow) +import Data.Eq.Generic (genericEq) +import Data.Show.Generic (genericShow) import Data.Maybe (Maybe) import Data.Tuple (Tuple(..))