-
-
Save qnikst/c9018b85b05d5f7e57fe2b61c83d32af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module A (A(..)) where | |
newtype A = A Int | |
deriving (Show, Eq) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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