on master help sign in
Remove the ShakeValue on A (#587)
a9bf409Neil Mitchell
src/Development/IDE/Core/Shake.hs+6−8
@@ -511,12 +511,10 @@ instance Show k => Show (Q k) where
511
511
512-- | Invariant: the 'v' must be in normal form (fully evaluated).
512-- | Invariant: the 'v' must be in normal form (fully evaluated).
513-- Otherwise we keep repeatedly 'rnf'ing values taken from the Shake database
513-- Otherwise we keep repeatedly 'rnf'ing values taken from the Shake database
514−-- Note (MK) I am not sure why we need the ShakeValue here, maybe we
515−-- can just remove it?
516−data A v = A (Value v) ShakeValue
514+newtype A v = A (Value v)
517 deriving Show
515 deriving Show
518
516
519−instance NFData (A v) where rnf (A v x) = v `seq` rnf x
517+instance NFData (A v) where rnf (A v) = v `seq` ()
520
518
521-- In the Shake database we only store one type of key/result pairs,
519-- In the Shake database we only store one type of key/result pairs,
522-- namely Q (question) / A (answer).
520-- namely Q (question) / A (answer).
@@ -526,13 +524,13 @@ type instance RuleResult (Q k) = A (RuleResult k)
526-- | Return up2date results. Stale results will be ignored.
524-- | Return up2date results. Stale results will be ignored.
527uses :: IdeRule k v
525uses :: IdeRule k v
528 => k -> [NormalizedFilePath] -> Action [Maybe v]
526 => k -> [NormalizedFilePath] -> Action [Maybe v]
529−uses key files = map (\(A value _) -> currentValue value) <$> apply (map (Q . (key,)) files)
527+uses key files = map (\(A value) -> currentValue value) <$> apply (map (Q . (key,)) files)
530
528
531-- | Return the last computed result which might be stale.
529-- | Return the last computed result which might be stale.
532usesWithStale :: IdeRule k v
530usesWithStale :: IdeRule k v
533 => k -> [NormalizedFilePath] -> Action [Maybe (v, PositionMapping)]
531 => k -> [NormalizedFilePath] -> Action [Maybe (v, PositionMapping)]
534usesWithStale key files = do
532usesWithStale key files = do
535− values <- map (\(A value _) -> value) <$> apply (map (Q . (key,)) files)
533+ values <- map (\(A value) -> value) <$> apply (map (Q . (key,)) files)
536 zipWithM lastValue files values
534 zipWithM lastValue files values
537
535
538
536
@@ -558,7 +556,7 @@ defineEarlyCutoff op = addBuiltinRule noLint noIdentity $ \(Q (key, file)) (old
558 case v of
556 case v of
559 -- No changes in the dependencies and we have
557 -- No changes in the dependencies and we have
560 -- an existing result.
558 -- an existing result.
561− Just v -> return $ Just $ RunResult ChangedNothing old $ A v (decodeShakeValue old)
559+ Just v -> return $ Just $ RunResult ChangedNothing old $ A v
562 _ -> return Nothing
560 _ -> return Nothing
563 _ -> return Nothing
561 _ -> return Nothing
564 case val of
562 case val of
@@ -589,7 +587,7 @@ defineEarlyCutoff op = addBuiltinRule noLint noIdentity $ \(Q (key, file)) (old
589 return $ RunResult
587 return $ RunResult
590 (if eq then ChangedRecomputeSame else ChangedRecomputeDiff)
588 (if eq then ChangedRecomputeSame else ChangedRecomputeDiff)
591 (encodeShakeValue bs) $
589 (encodeShakeValue bs) $
592− A res bs
590+ A res
593
591
594
592
595-- | Rule type, input file
593-- | Rule type, input file