Skip to content

Commit 987a805

Browse files
authored
Add roles declarations to allow safe coercions (#16)
1 parent 5208b6e commit 987a805

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Foreign/Object.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ import Unsafe.Coerce (unsafeCoerce)
6464
-- | `Object a` represents a homogeneous JS Object with values of type `a`.
6565
foreign import data Object :: Type -> Type
6666

67+
type role Object representational
68+
6769
foreign import _copyST :: forall a b r. a -> ST r b
6870

6971
-- | Convert an immutable Object into a mutable Object

src/Foreign/Object/ST.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import Data.Maybe (Maybe(..))
2424
-- | that of `Object a`, except that mutation is allowed.
2525
foreign import data STObject :: Region -> Type -> Type
2626

27+
type role STObject nominal representational
28+
2729
-- | Create a new, empty mutable object
2830
foreign import new :: forall a r. ST r (STObject r a)
2931

0 commit comments

Comments
 (0)