3
3
{-# LANGUAGE TypeFamilies #-}
4
4
5
5
{-# LANGUAGE NoMonoLocalBinds #-}
6
+ {-# LANGUAGE BangPatterns #-}
6
7
7
8
module Wingman.EmptyCase where
8
9
@@ -33,9 +34,12 @@ import Wingman.CodeGen (destructionFor)
33
34
import Wingman.GHC
34
35
import Wingman.Judgements
35
36
import Wingman.LanguageServer
36
- import Wingman.Types
37
- import GHC (LocatedA , SrcSpanAnnA , SrcSpanAnn' (.. ))
37
+ import Wingman.Types hiding ( traceShowId )
38
+ import GHC (LocatedA , SrcSpanAnnA , SrcSpanAnn' (.. ), EpAnn ( .. ) )
38
39
import GHC.Hs (LocatedL )
40
+ import Debug.Trace
41
+ import GHC.Plugins (generatedSrcSpan )
42
+ import Language.Haskell.GHC.ExactPrint
39
43
40
44
41
45
data EmptyCaseT = EmptyCaseT
@@ -70,10 +74,12 @@ emptyCaseInteraction = Interaction $
70
74
destructionFor
71
75
(foldMap (hySingleton . occName . fst ) bindings)
72
76
ty
77
+ traceShowM matches
73
78
edits <- liftMaybe $ hush $
74
79
mkWorkspaceEdits le_dflags ccs fc_uri (unTrack pm) $
75
80
graftMatchGroup (RealSrcSpan (unTrack ss) Nothing ) $
76
81
noLocA matches
82
+ traceShowM edits
77
83
pure
78
84
( range
79
85
, Metadata
@@ -85,6 +91,8 @@ emptyCaseInteraction = Interaction $
85
91
)
86
92
(\ _ _ _ we -> pure $ pure $ RawEdit we)
87
93
94
+ instance Show (GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs )))) where
95
+ show = unsafeRender
88
96
89
97
scrutinzedType :: EmptyCaseSort Type -> Maybe Type
90
98
scrutinzedType (EmptyCase ty) = pure ty
@@ -107,6 +115,12 @@ hush (Left _) = Nothing
107
115
hush (Right a) = Just a
108
116
109
117
118
+ instance Show (EpAnn AnnListItem ) where
119
+ show = unsafeRender
120
+
121
+ instance Show (EpAnn EpAnnHsCase ) where
122
+ show = unsafeRender . fmap showAst
123
+
110
124
------------------------------------------------------------------------------
111
125
-- | Graft a 'RunTacticResults' into the correct place in an AST. Correctly
112
126
-- deals with top-level holes, in which we might need to fiddle with the
@@ -118,7 +132,7 @@ graftMatchGroup
118
132
graftMatchGroup ss l =
119
133
hoistGraft (runExcept . runExceptString) $ graftExprWithM ss $ \ case
120
134
L span (HsCase ext scrut mg) -> do
121
- pure $ Just $ L span $ HsCase ext scrut $ mg { mg_alts = l }
135
+ pure $ Just $ traceShowId $ L span $ HsCase ext scrut $ mg { mg_alts = l }
122
136
L span (HsLamCase ext mg) -> do
123
137
pure $ Just $ L span $ HsLamCase ext $ mg { mg_alts = l }
124
138
(_ :: LHsExpr GhcPs ) -> pure Nothing
0 commit comments