@@ -1,7 +1,7 @@
1-- {-# OPTIONS_GHC -package=ghc-7.10.1 #-}
1-- {-# OPTIONS_GHC -package=ghc-7.10.1 #-}
2{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, StandaloneDeriving, TypeOperators, FlexibleInstances, ScopedTypeVariables, ImplicitParams, MultiParamTypeClasses #-}
2{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, StandaloneDeriving, TypeOperators, FlexibleInstances, ScopedTypeVariables, ImplicitParams, MultiParamTypeClasses #-}
4−module TySet(plugin, Set, Union, dropPrefix) where
4+module TySet(plugin, Set, Union, dropPrefix, ppr) where
6import TypeRep
6import TypeRep
@@ -82,17 +82,32 @@ instance Debug String IO where
82pluginInit :: [CommandLineOption] -> TcPluginM ()
82pluginInit :: [CommandLineOption] -> TcPluginM ()
83pluginInit _ = return ()
83pluginInit _ = return ()
85+printerS = let ?ifDebug = True in tcPluginIO . debug . showSDocUnsafe . ppCts
86+printer = let ?ifDebug = True in tcPluginIO . debug
85pluginSolve :: () -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginResult
88pluginSolve :: () -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginResult
86pluginSolve () given derived wanted =
89pluginSolve () given derived wanted =
87 let ?ifDebug = True in
90 let ?ifDebug = True in
89− do
92+ do tcPluginIO $ debug "*****************************"
90 tcPluginIO $ debug "Running TySet equality plugin"
93 tcPluginIO $ debug "Running TySet equality plugin"
94+ --debug $ ppCts wanted
91− debug $ ppCts wanted
95+ tcPluginIO $ debug $ showSDocUnsafe $ ppCts wanted
96+ tcPluginIO $ debug "Givens"
97+ --debug $ ppCts given
98+ tcPluginIO $ debug $ showSDocUnsafe $ ppCts given
99+ tcPluginIO $ debug "Derived"
100+ -- debug $ ppCts derived
101+ tcPluginIO $ debug $ showSDocUnsafe $ ppCts derived
92 -- debug $ ppr $ head $ wanted
102 -- debug $ ppr $ head $ wanted
94 --solved <- findEmptySetEquality wanted
104 --solved <- findEmptySetEquality wanted
95 (solved, generated) <- findSetEquality wanted
105 (solved, generated) <- findSetEquality wanted
106+ printer "Done - solved"
107+ printerS (map snd solved)
108+ printer "DOne - generated"
96 return $ TcPluginOk solved generated
111 return $ TcPluginOk solved generated
98pluginStop :: () -> TcPluginM ()
113pluginStop :: () -> TcPluginM ()
@@ -288,7 +303,7 @@ testSetTermEquality = quickCheck (\((n, m) :: (TermTree Int, TermTree Int)) -> n
288mkVar :: String -> Var
303mkVar :: String -> Var
289mkVar = undefined
304mkVar = undefined
291−instance Arbitrary (TermTree Int, TermTree Int) where
306+instance {-# OVERLAPS #-} Arbitrary (TermTree Int, TermTree Int) where
292 arbitrary = sized $ \vars ->
307 arbitrary = sized $ \vars ->
293 sized $ \datums ->
308 sized $ \datums ->
294 do v0 <- (vector vars)::(Gen [String])
309 do v0 <- (vector vars)::(Gen [String])
@@ -334,10 +349,6 @@ gen vs ds = do -- Choose between 0 and 1 if 'vs' is empty, or 0-2 if 'vs'
334 2 -> oneof [unionPerm (gen (tail vs) ds) (return $ Var (head vs)),
349 2 -> oneof [unionPerm (gen (tail vs) ds) (return $ Var (head vs)),
335 unionPerm (gen vs ds) (return $ Var (head vs))]
350 unionPerm (gen vs ds) (return $ Var (head vs))]
336 _ -> error "unpossible"
351 _ -> error "unpossible"