Language.PureScript.Make.Cache

purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.Make.Cache

Synopsis

- data ContentHash
- hash :: ByteString -> ContentHash
- type CacheDb = Map ModuleName CacheInfo
- newtype CacheInfo = CacheInfo {
  - unCacheInfo :: Map FilePath (UTCTime, ContentHash)
  }
- checkChanged :: Monad m => CacheDb -> ModuleName -> FilePath -> Map FilePath (UTCTime, m ContentHash) -> m (CacheInfo, Bool)
- removeModules :: Set ModuleName -> CacheDb -> CacheDb
- normaliseForCache :: FilePath -> FilePath -> FilePath

# Documentation

data ContentHash #

Defines the hash algorithm we use for cache invalidation of input files.

#### Instances

Instances details

FromJSON ContentHash # |
Instance details Defined in Language.PureScript.Make.Cache Methods parseJSON :: Value -> Parser ContentHash # parseJSONList :: Value -> Parser [ContentHash] # omittedField :: Maybe ContentHash #
ToJSON ContentHash # |
Instance details Defined in Language.PureScript.Make.Cache Methods toJSON :: ContentHash -> Value # toEncoding :: ContentHash -> Encoding # toJSONList :: [ContentHash] -> Value # toEncodingList :: [ContentHash] -> Encoding # omitField :: ContentHash -> Bool #
Show ContentHash # |
Instance details Defined in Language.PureScript.Make.Cache Methods showsPrec :: Int -> ContentHash -> ShowS # show :: ContentHash -> String # showList :: [ContentHash] -> ShowS #
Eq ContentHash # |
Instance details Defined in Language.PureScript.Make.Cache Methods (==) :: ContentHash -> ContentHash -> Bool # (/=) :: ContentHash -> ContentHash -> Bool #
Ord ContentHash # |
Instance details Defined in Language.PureScript.Make.Cache Methods compare :: ContentHash -> ContentHash -> Ordering # (<) :: ContentHash -> ContentHash -> Bool # (<=) :: ContentHash -> ContentHash -> Bool # (>) :: ContentHash -> ContentHash -> Bool # (>=) :: ContentHash -> ContentHash -> Bool # max :: ContentHash -> ContentHash -> ContentHash # min :: ContentHash -> ContentHash -> ContentHash #

hash :: ByteString -> ContentHash #

type CacheDb = Map ModuleName CacheInfo #

newtype CacheInfo #

A CacheInfo contains all of the information we need to store about a particular module in the cache database.

Constructors

CacheInfo |
Fields unCacheInfo :: Map FilePath (UTCTime, ContentHash)

#### Instances

Instances details

FromJSON CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods parseJSON :: Value -> Parser CacheInfo # parseJSONList :: Value -> Parser [CacheInfo] # omittedField :: Maybe CacheInfo #
ToJSON CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods toJSON :: CacheInfo -> Value # toEncoding :: CacheInfo -> Encoding # toJSONList :: [CacheInfo] -> Value # toEncodingList :: [CacheInfo] -> Encoding # omitField :: CacheInfo -> Bool #
Monoid CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods mempty :: CacheInfo # mappend :: CacheInfo -> CacheInfo -> CacheInfo # mconcat :: [CacheInfo] -> CacheInfo #
Semigroup CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods (<>) :: CacheInfo -> CacheInfo -> CacheInfo # sconcat :: NonEmpty CacheInfo -> CacheInfo # stimes :: Integral b => b -> CacheInfo -> CacheInfo #
Show CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods showsPrec :: Int -> CacheInfo -> ShowS # show :: CacheInfo -> String # showList :: [CacheInfo] -> ShowS #
Eq CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods (==) :: CacheInfo -> CacheInfo -> Bool # (/=) :: CacheInfo -> CacheInfo -> Bool #
Ord CacheInfo # |
Instance details Defined in Language.PureScript.Make.Cache Methods compare :: CacheInfo -> CacheInfo -> Ordering # (<) :: CacheInfo -> CacheInfo -> Bool # (<=) :: CacheInfo -> CacheInfo -> Bool # (>) :: CacheInfo -> CacheInfo -> Bool # (>=) :: CacheInfo -> CacheInfo -> Bool # max :: CacheInfo -> CacheInfo -> CacheInfo # min :: CacheInfo -> CacheInfo -> CacheInfo #

checkChanged :: Monad m => CacheDb -> ModuleName -> FilePath -> Map FilePath (UTCTime, m ContentHash) -> m (CacheInfo, Bool) #

Given a module name, and a map containing the associated input files together with current metadata i.e. timestamps and hashes, check whether the input files have changed, based on comparing with the database stored in the monadic state.

The CacheInfo in the return value should be stored in the cache for future builds.

The Bool in the return value indicates whether it is safe to use existing build artifacts for this module, at least based on the timestamps and hashes of the module's input files.

If the timestamps are the same as those in the database, assume the file is unchanged, and return True without checking hashes.

If any of the timestamps differ from what is in the database, check the hashes of those files. In this case, update the database with any changed timestamps and hashes, and return True if and only if all of the hashes are unchanged.

removeModules :: Set ModuleName -> CacheDb -> CacheDb #

Remove any modules from the given set from the cache database; used when they failed to build.

normaliseForCache :: FilePath -> FilePath -> FilePath #

1. Any path that is beneath our current working directory will be stored as a normalised relative path
2. Any path that isn't will be stored as an absolute path