-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6596 from phadej/indexstate-module
Move IndexState to own module
- Loading branch information
Showing
11 changed files
with
59 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
cabal-install/Distribution/Client/IndexUtils/IndexState.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Distribution.Client.IndexUtils.IndexUtils | ||
-- Copyright : (c) 2016 Herbert Valerio Riedel | ||
-- License : BSD3 | ||
-- | ||
-- Timestamp type used in package indexes | ||
module Distribution.Client.IndexUtils.IndexState ( | ||
IndexState(..), | ||
) where | ||
|
||
import Distribution.Client.Compat.Prelude | ||
import Distribution.Client.IndexUtils.Timestamp (Timestamp) | ||
|
||
import Distribution.FieldGrammar.Described | ||
import Distribution.Parsec (Parsec (..)) | ||
import Distribution.Pretty (Pretty (..)) | ||
|
||
import qualified Distribution.Compat.CharParsing as P | ||
import qualified Text.PrettyPrint as Disp | ||
|
||
-- | Specification of the state of a specific repo package index | ||
data IndexState = IndexStateHead -- ^ Use all available entries | ||
| IndexStateTime !Timestamp -- ^ Use all entries that existed at | ||
-- the specified time | ||
deriving (Eq,Generic,Show) | ||
|
||
instance Binary IndexState | ||
instance Structured IndexState | ||
instance NFData IndexState | ||
|
||
instance Pretty IndexState where | ||
pretty IndexStateHead = Disp.text "HEAD" | ||
pretty (IndexStateTime ts) = pretty ts | ||
|
||
instance Parsec IndexState where | ||
parsec = parseHead <|> parseTime where | ||
parseHead = IndexStateHead <$ P.string "HEAD" | ||
parseTime = IndexStateTime <$> parsec | ||
|
||
instance Described IndexState where | ||
describe _ = REUnion | ||
[ "HEAD" | ||
, RENamed "timestamp" (describe (Proxy :: Proxy Timestamp)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters