Created
December 11, 2023 09:45
-
-
Save Abhiroop/760488058fbfe9e57565e775f2d1a2f0 to your computer and use it in GitHub Desktop.
This file contains 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
-- 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