@@ -1,7 +1,7 @@
11-- {-# OPTIONS_GHC -package=ghc-7.10.1 #-}
22{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, StandaloneDeriving, TypeOperators, FlexibleInstances, ScopedTypeVariables, ImplicitParams, MultiParamTypeClasses #-}
33
4−module TySet(plugin, Set, Union, dropPrefix) where
4+module TySet(plugin, Set, Union, dropPrefix, ppr) where
55
66import TypeRep
77import Type
@@ -82,17 +82,32 @@ instance Debug String IO where
8282pluginInit :: [CommandLineOption] -> TcPluginM ()
8383pluginInit _ = return ()
8484
85+printerS = let ?ifDebug = True in tcPluginIO . debug . showSDocUnsafe . ppCts
86+printer = let ?ifDebug = True in tcPluginIO . debug
87+
8588pluginSolve :: () -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginResult
8689pluginSolve () given derived wanted =
8790 let ?ifDebug = True in
8891
89− do
92+ do tcPluginIO $ debug "*****************************"
9093 tcPluginIO $ debug "Running TySet equality plugin"
91− debug $ ppCts wanted
94+ --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
92102 -- debug $ ppr $ head $ wanted
93103
94104 --solved <- findEmptySetEquality wanted
95105 (solved, generated) <- findSetEquality wanted
106+ printer "Done - solved"
107+ printerS (map snd solved)
108+ printer "DOne - generated"
109+ printerS generated
110+
96111 return $ TcPluginOk solved generated
97112
98113pluginStop :: () -> TcPluginM ()
@@ -288,7 +303,7 @@ testSetTermEquality = quickCheck (\((n, m) :: (TermTree Int, TermTree Int)) -> n
288303mkVar :: String -> Var
289304mkVar = undefined
290305
291−instance Arbitrary (TermTree Int, TermTree Int) where
306+instance {-# OVERLAPS #-} Arbitrary (TermTree Int, TermTree Int) where
292307 arbitrary = sized $ \vars ->
293308 sized $ \datums ->
294309 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'
334349 2 -> oneof [unionPerm (gen (tail vs) ds) (return $ Var (head vs)),
335350 unionPerm (gen vs ds) (return $ Var (head vs))]
336351 _ -> error "unpossible"
337−
338−
339−
340−
341352
342353
343354