Skip to content

Instantly share code, notes, and snippets.

@qnikst
Created November 21, 2020 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qnikst/c9018b85b05d5f7e57fe2b61c83d32af to your computer and use it in GitHub Desktop.
Save qnikst/c9018b85b05d5f7e57fe2b61c83d32af to your computer and use it in GitHub Desktop.
module A (A(..)) where
newtype A = A Int
deriving (Show, Eq)
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DerivingVia #-}
module B(test) where
import A
import qualified Data.Map as Map
import GHC.Exts
deriving via (Down A) instance Ord A
test :: Map.Map A Int
test = Map.fromList [(A 1,1)]
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module C(test) where
import A
import qualified Data.Map as Map
deriving newtype instance Ord A
test :: Map.Map A Int
test = Map.fromList [(A 1,1)]
import A
import qualified C
import qualified B
import qualified Data.Map as Map
test0 = C.test <> B.test
test1 = Map.insert (A 1) 1 C.test
test2 = Map.insert (A 1) 1 B.test
M.hs:9:9: error:
• Overlapping instances for Ord A
arising from a use of ‘Map.insert’
Matching instances:
instance Ord A -- Defined at C.hs:9:1
instance Ord A -- Defined at B.hs:10:1
• In the expression: Map.insert (A 1) 1 B.test
In an equation for ‘test2’: test2 = Map.insert (A 1) 1 B.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment