blob: 4d4a9eb8fffbb5ec48864c894002b9e260578a54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
{-|
These are variants of the functions in "Data.Dependent.EnumMap.Strict" that do
not type-check keys: they do not check that you don't create two keys with the
same 'Int' and different types. As a result, these functions do not have a
'Data.Type.Equality.TestEquality' constraint, and are faster.
Be aware though, because one can easily create @unsafeCoerce@ with this API:
@
{-# LANGUAGE ScopedTypeVariables TypeFamilies #-}
import qualified Data.Dependent.EnumMap.Strict as DE
import qualified Data.Dependent.EnumMap.Strict.Unsafe as DEU
import Data.Functor.Identity
import Data.Maybe
import Data.Some
data Foo a = Foo Int
deriving (Show)
instance DE.Enum1 Foo where
type Enum1Info Foo = ()
fromEnum1 (Foo i) = (i, ())
toEnum1 i () = Some (Foo i)
unsafe :: forall a b. a -> b
unsafe x = runIdentity $ fromJust $
DEU.lookupUnsafe (Foo 1 :: Foo b) $
DE.singleton (Foo 1 :: Foo a) (Identity x)
@
-}
module Data.Dependent.EnumMap.Strict.Unsafe (
adjustUnsafe,
alterUnsafe,
lookupUnsafe,
findWithDefaultUnsafe,
unionUnsafe,
unionWithUnsafe,
) where
import Prelude ()
import Data.Dependent.EnumMap.Strict.Internal
|