Commit defd59f5 authored by Oleg Grenrus's avatar Oleg Grenrus

Move IndexState to own module

parent f8ad7bb4
......@@ -42,6 +42,7 @@ import Distribution.Simple.Utils
import Distribution.Verbosity
( Verbosity, normal, lessVerbose )
import Distribution.Client.IndexUtils.Timestamp
import Distribution.Client.IndexUtils.IndexState
import Distribution.Client.IndexUtils
( updateRepoIndexCache, Index(..), writeIndexTimestamp
, currentIndexTimestamp, indexBaseName )
......
......@@ -48,6 +48,7 @@ import qualified Codec.Archive.Tar as Tar
import qualified Codec.Archive.Tar.Entry as Tar
import qualified Codec.Archive.Tar.Index as Tar
import qualified Distribution.Client.Tar as Tar
import Distribution.Client.IndexUtils.IndexState
import Distribution.Client.IndexUtils.Timestamp
import Distribution.Client.Types
import Distribution.Verbosity
......
{-# 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))
]
......@@ -18,8 +18,6 @@ module Distribution.Client.IndexUtils.Timestamp
, timestampToUTCTime
, utcTimeToTimestamp
, maximumTimestamp
, IndexState(..)
) where
import Distribution.Client.Compat.Prelude
......@@ -278,31 +276,3 @@ instance Parsec Timestamp where
-- missing/unknown/invalid
nullTimestamp :: Timestamp
nullTimestamp = TS minBound
----------------------------------------------------------------------------
-- defined here for now to avoid import cycles
-- | 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))
]
......@@ -34,7 +34,7 @@ import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Client.SourceRepo (SourceRepoList)
import Distribution.Client.IndexUtils.Timestamp
import Distribution.Client.IndexUtils.IndexState
( IndexState )
import Distribution.Client.CmdInstall.ClientInstallFlags
......
......@@ -77,7 +77,7 @@ import Distribution.Client.BuildReports.Types
( ReportLevel(..) )
import Distribution.Client.Dependency.Types
( PreSolver(..) )
import Distribution.Client.IndexUtils.Timestamp
import Distribution.Client.IndexUtils.IndexState
( IndexState(..) )
import qualified Distribution.Client.Init.Types as IT
( InitFlags(..), PackageType(..) )
......
......@@ -201,6 +201,7 @@ executable cabal
Distribution.Client.HashValue
Distribution.Client.HttpUtils
Distribution.Client.IndexUtils
Distribution.Client.IndexUtils.IndexState
Distribution.Client.IndexUtils.Timestamp
Distribution.Client.Init
Distribution.Client.Init.Heuristics
......
......@@ -140,6 +140,7 @@ Version: 3.3.0.0
Distribution.Client.HashValue
Distribution.Client.HttpUtils
Distribution.Client.IndexUtils
Distribution.Client.IndexUtils.IndexState
Distribution.Client.IndexUtils.Timestamp
Distribution.Client.Init
Distribution.Client.Init.Heuristics
......
......@@ -23,7 +23,8 @@ import Distribution.Utils.NubList
import Distribution.Client.BuildReports.Types (ReportLevel (..))
import Distribution.Client.CmdInstall.ClientInstallFlags (InstallMethod)
import Distribution.Client.IndexUtils.Timestamp (IndexState (..), Timestamp, epochTimeToTimestamp)
import Distribution.Client.IndexUtils.IndexState (IndexState (..))
import Distribution.Client.IndexUtils.Timestamp (Timestamp, epochTimeToTimestamp)
import Distribution.Client.InstallSymlink (OverwritePolicy)
import Distribution.Client.Types (RepoName (..), WriteGhcEnvironmentFilesPolicy)
......
......@@ -17,8 +17,9 @@ import Distribution.Pretty (prettyShow)
import qualified Distribution.Utils.CharSet as CS
import Distribution.Client.IndexUtils.Timestamp (IndexState, Timestamp)
import Distribution.Client.Types (RepoName)
import Distribution.Client.IndexUtils.IndexState (IndexState)
import Distribution.Client.IndexUtils.Timestamp (Timestamp)
import Distribution.Client.Types (RepoName)
import qualified RERE as RE
import qualified RERE.CharSet as RE
......
......@@ -30,6 +30,7 @@ import Distribution.Solver.Types.Settings
import Distribution.Client.BuildReports.Types
import Distribution.Client.CmdInstall.ClientInstallFlags
import Distribution.Client.Dependency.Types
import Distribution.Client.IndexUtils.IndexState
import Distribution.Client.IndexUtils.Timestamp
import Distribution.Client.InstallSymlink
import Distribution.Client.ProjectConfig.Types
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment