Skip to content

Commit

Permalink
Update Structured.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaz authored Aug 6, 2021
1 parent 3dcfe27 commit 5a4290c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cabal/src/Distribution/Utils/Structured.hs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ structuredDecodeOrFailIO bs =
handler (ErrorCall str) = return $ Left str
#endif

-- | Lazily decode a triple, parsing the first two fields strictly and returning a lazy value containing either the last one or an error.
-- This is helpful for cabal cache files where the first two components contain header data that lets one test if the cache is still valid,
-- and the last (potentially large) component is the cached value itself. This way we can test for cache validity without needing to pay the cost
-- of the decode of stale cache data.
structuredDecodeTriple
:: forall a b c. (Structured (a,b,c), Binary.Binary a, Binary.Binary b, Binary.Binary c)
=> LBS.ByteString -> Either String (a, b, Either String c)
Expand Down

0 comments on commit 5a4290c

Please sign in to comment.