@@ -31,7 +31,7 @@ import Control.Concurrent (threadDelay)
31
31
import Control.Concurrent.Async (mapConcurrently )
32
32
import Control.Lens (Getting , to , universeOf , universeOn , universeOnOf )
33
33
import Control.Lens.Combinators (Fold )
34
- import Control.Monad (forM , forM_ , unless , void , when , zipWithM_ , (>=>) )
34
+ import Control.Monad (forM , forM_ , unless , void , when , zipWithM_ , (>=>) , join )
35
35
import qualified GHC.Core.Utils as CoreUtils
36
36
import qualified Data.Bifunctor
37
37
import Data.Bits (complement )
@@ -40,7 +40,7 @@ import Data.Data.Lens (template, tinplate, uniplate)
40
40
import Data.Dynamic (Dynamic , fromDynamic )
41
41
import Data.Function (on )
42
42
import Data.IORef (IORef , modifyIORef , newIORef , readIORef )
43
- import Data.List (groupBy , intercalate , nub , partition , stripPrefix )
43
+ import Data.List (groupBy , intercalate , nub , partition , stripPrefix , uncons )
44
44
import Data.Map (Map )
45
45
import qualified Data.Map as Map
46
46
import Data.Maybe (catMaybes , isJust , isNothing , mapMaybe )
@@ -212,7 +212,6 @@ addPreludeIfNotPresent decls =
212
212
where
213
213
isPrelude (IIModule mname) = mname == pRELUDE_NAME
214
214
isPrelude (IIDecl ImportDecl {.. }) = unLoc ideclName == pRELUDE_NAME
215
- isPrelude _ = False
216
215
prelImport = IIDecl $ simpleImportDecl pRELUDE_NAME
217
216
218
217
justParseExpr :: CompileConfig -> RExpr -> Ghc (LHsExpr GhcPs )
@@ -585,7 +584,6 @@ moduleToProb baseCC@CompConf {tempDirBase = baseTempDir, ..} mod_path mb_target
585
584
fh@ FunRhs {mc_fun = L l''' _} ->
586
585
fh {mc_fun = L l''' $ unLoc nfid}
587
586
o -> o
588
- nalt alt = alt
589
587
nalts = map nalt alts
590
588
nvpat :: IdP GhcPs -> LPat GhcPs
591
589
nvpat t_name =
@@ -594,7 +592,6 @@ moduleToProb baseCC@CompConf {tempDirBase = baseTempDir, ..} mod_path mb_target
594
592
(noLocA $ VarPat noExtField $ noLocA t_name)
595
593
noHsTok)
596
594
nvpats = map nvpat $ filter (`Set.member` vars) targets
597
- nmatches _ _ mg = mg
598
595
599
596
wrapProp :: LHsBind GhcPs -> [(LHsBind GhcPs , [Sig GhcPs ])]
600
597
wrapProp prop@ (L l fb@ FunBind {.. })
@@ -615,15 +612,11 @@ moduleToProb baseCC@CompConf {tempDirBase = baseTempDir, ..} mod_path mb_target
615
612
run_i_only mg@ MG {mg_alts = (L l' alts)} = mg {mg_alts = L l' $ map nalt alts}
616
613
where
617
614
nalt (L l'' m@ Match {.. }) = L l'' m {m_grhss = n_grhss m_grhss}
618
- nalt m = m
619
615
n_grhss grhss@ GRHSs {.. } = grhss {grhssGRHSs = map nGRHSS grhssGRHSs}
620
- n_grhss g = g
621
616
nGRHSS (L l3 (GRHS x guards bod)) = L l3 (GRHS x guards nbod)
622
617
where
623
618
nbod = noLocA $ HsApp noAnn nthapp (noLocA $ HsPar noAnn noHsTok bod noHsTok)
624
619
nthapp = noLocA $ HsPar noAnn noHsTok (noLocA $ HsApp noAnn (tf " testTreeNthTest" ) (il $ fromIntegral i)) noHsTok
625
- nGRHSS xg = xg
626
- run_i_only mg = mg
627
620
wrapProp prop@ (L l fb@ FunBind {.. }) =
628
621
[(L l fb {fun_id = nfid, fun_matches = nmatches prop_vars nfid fun_matches}, sig)]
629
622
where
@@ -658,7 +651,6 @@ moduleToProb baseCC@CompConf {tempDirBase = baseTempDir, ..} mod_path mb_target
658
651
tyApps (ty : tys) =
659
652
noLocA $ HsFunTy noAnn arr (noLocA ty) (tyApps tys)
660
653
where arr = HsUnrestrictedArrow noHsUniTok
661
- toWrapSig e = e
662
654
wrapped_props :: [EProp ]
663
655
prop_sigs :: [LSig GhcPs ]
664
656
(wrapped_props, prop_sigs) =
@@ -805,7 +797,7 @@ traceTarget ::
805
797
EProp ->
806
798
[RExpr ] ->
807
799
IO (Maybe TraceRes )
808
- traceTarget cc tp e fp ce = head <$> traceTargets cc tp e [(fp, ce)]
800
+ traceTarget cc tp e fp ce = (join . fmap fst . uncons) <$> traceTargets cc tp e [(fp, ce)]
809
801
810
802
toNonZeroInvokes :: Trace -> Map. Map (EExpr , SrcAnn AnnListItem ) Integer
811
803
toNonZeroInvokes (ex, res) = Map. fromList $ mapMaybe only_max $ flatten res
@@ -1195,7 +1187,7 @@ getExprFitCands expr_or_mod = do
1195
1187
let flat = flattenExpr tcd_context
1196
1188
-- We remove the ones already present and drop the first one
1197
1189
-- (since it will be the program itself)
1198
- flat' = filter nonTriv $ tail flat
1190
+ flat' = filter nonTriv $ drop 1 flat
1199
1191
in toEsAnNames wc flat'
1200
1192
_ -> []
1201
1193
liftIO $ logStr TRACE " Getting the session..."
0 commit comments