Skip to content

Commit 46d601b

Browse files
committed
replace FFI functions with unsafeCoerce
1 parent 3b8f3ae commit 46d601b

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/Foreign.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
"use strict";
22

3-
exports.unsafeToForeign = function (value) {
4-
return value;
5-
};
6-
7-
exports.unsafeFromForeign = function (value) {
8-
return value;
9-
};
10-
113
exports.typeOf = function (value) {
124
return typeof value;
135
};

src/Foreign.purs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ module Foreign
3030
import Prelude
3131

3232
import Control.Monad.Except (Except, throwError, mapExcept)
33-
3433
import Data.Either (Either(..), either)
3534
import Data.Int as Int
3635
import Data.List.NonEmpty (NonEmptyList)
3736
import Data.List.NonEmpty as NEL
3837
import Data.Maybe (Maybe(..), maybe)
3938
import Data.String.CodeUnits (toChar)
39+
import Unsafe.Coerce (unsafeCoerce)
4040

4141
-- | A type for _foreign data_.
4242
-- |
@@ -88,10 +88,12 @@ type F = Except MultipleErrors
8888
-- | JavaScript types, rather than PureScript types. Exporting PureScript values
8989
-- | via the FFI can be dangerous as they can be mutated by code outside the
9090
-- | PureScript program, resulting in difficult to diagnose problems elsewhere.
91-
foreign import unsafeToForeign :: forall a. a -> Foreign
91+
unsafeToForeign :: forall a. a -> Foreign
92+
unsafeToForeign = unsafeCoerce
9293

9394
-- | Unsafely coerce a `Foreign` value.
94-
foreign import unsafeFromForeign :: forall a. Foreign -> a
95+
unsafeFromForeign :: forall a. Foreign -> a
96+
unsafeFromForeign = unsafeCoerce
9597

9698
-- | Read the Javascript _type_ of a value
9799
foreign import typeOf :: Foreign -> String

0 commit comments

Comments
 (0)