Skip to content
Draft
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
1 change: 1 addition & 0 deletions some.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ library
exposed-modules:
Data.GADT.Compare
Data.GADT.DeepSeq
Data.GADT.Instances
Data.GADT.Show
Data.Some
Data.Some.Church
Expand Down
21 changes: 21 additions & 0 deletions src/Data/GADT/Instances.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Data.GADT.Instances where

import Data.IORef (IORef)
import Data.STRef (STRef)
import Unsafe.Coerce (unsafeCoerce)

import Data.GADT.Compare (GEq(..))

#if __GLASGOW_HASKELL__ >=708
import Data.Typeable ((:~:)( Refl ))
#endif

instance GEq IORef where
a `geq` b = if a == unsafeCoerce b then Just $ unsafeCoerce Refl else Nothing

instance GEq (STRef s) where
a `geq` b = if a == unsafeCoerce b then Just $ unsafeCoerce Refl else Nothing