Skip to content

Commit

Permalink
#503, refactor getShakeExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
ndmitchell committed Dec 28, 2016
1 parent 7f5fa81 commit 1c9f68d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/Development/Shake/Internal/Derived.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ getShakeExtra = getShakeExtraForall

getShakeExtraForall :: forall a . Typeable a => Action (Maybe a)
getShakeExtraForall = do
mx <- Map.lookup rep . shakeExtra <$> getShakeOptions
case mx of
Just dyn
| Just x <- fromDynamic dyn -> return $ Just x
| otherwise ->
let err = "getShakeExtra: Key "++show rep++" had value of unexpected type "++show (dynTypeRep dyn)
in fail err
Nothing -> return Nothing
where
rep = typeRep (Proxy :: Proxy a)
let want = typeRep (Proxy :: Proxy a)
extra <- shakeExtra <$> getShakeOptions
case Map.lookup want extra of
Just dyn
| Just x <- fromDynamic dyn -> return $ Just x
| otherwise -> fail $
"getShakeExtra: Key " ++ show want ++ " had value of unexpected type " ++ show (dynTypeRep dyn)
Nothing -> return Nothing


-- | @copyFile' old new@ copies the existing file from @old@ to @new@.
Expand Down

0 comments on commit 1c9f68d

Please sign in to comment.