From 47b511ee7c22fecf53b6d608bea39ec289da1b36 Mon Sep 17 00:00:00 2001 From: Stefan Fehrenbach Date: Sat, 20 Mar 2021 10:49:35 +0100 Subject: [PATCH] Add type role for safe coercion Coercing in the value type parameter is possible: (coerce (empty :: HashMap Int (Additive Int))) :: HashMap Int Int But coercing in the key parameter is forbidden, because the two types might have different Hashable implementations. --- src/Data/HashMap.purs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Data/HashMap.purs b/src/Data/HashMap.purs index 44d0c66..67de62a 100644 --- a/src/Data/HashMap.purs +++ b/src/Data/HashMap.purs @@ -68,6 +68,8 @@ import Partial.Unsafe (unsafePartial) -- | Note that this is an *unordered* collection. foreign import data HashMap :: Type -> Type -> Type +type role HashMap nominal representational + foreign import eqPurs :: forall k v. Fn2 (k -> k -> Boolean) (v -> v -> Boolean) (HashMap k v -> HashMap k v -> Boolean) instance eqHashMap :: (Eq k, Eq v) => Eq (HashMap k v) where