Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/Foreign.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
"use strict";

exports.unsafeToForeign = function (value) {
return value;
};

exports.unsafeFromForeign = function (value) {
return value;
};

exports.typeOf = function (value) {
return typeof value;
};
Expand Down
8 changes: 5 additions & 3 deletions src/Foreign.purs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ module Foreign
import Prelude

import Control.Monad.Except (Except, throwError, mapExcept)

import Data.Either (Either(..), either)
import Data.Int as Int
import Data.List.NonEmpty (NonEmptyList)
import Data.List.NonEmpty as NEL
import Data.Maybe (Maybe(..), maybe)
import Data.String.CodeUnits (toChar)
import Unsafe.Coerce (unsafeCoerce)

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

-- | Unsafely coerce a `Foreign` value.
foreign import unsafeFromForeign :: forall a. Foreign -> a
unsafeFromForeign :: forall a. Foreign -> a
unsafeFromForeign = unsafeCoerce

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