Skip to content

Instantly share code, notes, and snippets.

@soc
Created December 15, 2014 18:15
Show Gist options
  • Select an option

  • Save soc/2e69912dab2040b43797 to your computer and use it in GitHub Desktop.

Select an option

Save soc/2e69912dab2040b43797 to your computer and use it in GitHub Desktop.
-- A.hs
module A where
data U = X | Y deriving (Eq, Show)
-- B.hs
module B where
import Data.Set
import A
instance Ord U where
compare X X = EQ
compare X Y = LT
compare Y X = GT
compare Y Y = EQ
ins :: U -> Set U -> Set U
ins = insert
-- C.hs
module C where
import Data.Set
import A
instance Ord U where
compare X X = EQ
compare X Y = GT
compare Y X = LT
compare Y Y = EQ
ins' :: U -> Set U -> Set U
ins' = insert
-- D.hs
module Main where
import Data.Set
import A
import B
import C
test :: Set U
test = ins' X $ ins X $ ins Y $ empty
main :: IO ()
main = print test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment