Skip to content

Instantly share code, notes, and snippets.

@Abhiroop
Created December 11, 2023 09:45
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 Abhiroop/760488058fbfe9e57565e775f2d1a2f0 to your computer and use it in GitHub Desktop.
Save Abhiroop/760488058fbfe9e57565e775f2d1a2f0 to your computer and use it in GitHub Desktop.
-- A.hs
module A where
class Foo a where
foo :: a -> Bool
data X = X Int
-- B.hs
module B where
import A
instance Foo X where
foo (X _) = True
-- C.hs
{-# LANGUAGE TypeSynonymInstances #-}
module C where
import A
type Z = X
instance Foo Z where
foo _ = False
-- Main.hs
import A
import B
-- or import C
-- dont import both B and C
main :: IO ()
main = do
putStrLn $ show $ foo (X 5) -- True if B is imported; False if C is imported
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment