spago-0.21.0

Safe Haskell | None
Language | Haskell2010

Spago.GlobalCache

Synopsis

- newtype CommitHash = CommitHash Text
- newtype Tag = Tag Text
- data RepoMetadataV1 = RepoMetadataV1 {
  - commits :: [CommitHash]
  - latest :: Maybe Tag
  - owner :: Text
  - tags :: Map Tag CommitHash
  }
- type ReposMetadataV1 = Map PackageName RepoMetadataV1
- globallyCache :: HasLogFunc env => (PackageName, Repo, Text) -> FilePath -> ReposMetadataV1 -> (FilePath -> RIO env ()) -> RIO env () -> RIO env ()
- getMetadata :: (HasLogFunc env, HasGlobalCache env) => RIO env ReposMetadataV1
- getGlobalCacheDir :: (MonadUnliftIO m, HasLogFunc env, MonadReader env m) => m FilePath
- fetchTarball :: HasLogFunc env => FilePath -> Text -> RIO env ()

# Documentation

newtype CommitHash #

Constructors

CommitHash Text |

#### Instances

Instances details

FromJSON CommitHash # |
Instance details Defined in Spago.GlobalCache Methods parseJSON :: Value -> Parser CommitHash # parseJSONList :: Value -> Parser [CommitHash] # omittedField :: Maybe CommitHash #
ToJSON CommitHash # |
Instance details Defined in Spago.GlobalCache Methods toJSON :: CommitHash -> Value # toEncoding :: CommitHash -> Encoding # toJSONList :: [CommitHash] -> Value # toEncodingList :: [CommitHash] -> Encoding # omitField :: CommitHash -> Bool #
Data CommitHash # |

Instance details

Defined in Spago.GlobalCache

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CommitHash -> c CommitHash #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CommitHash #

toConstr :: CommitHash -> Constr #

dataTypeOf :: CommitHash -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CommitHash) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CommitHash) #

gmapT :: (forall b. Data b => b -> b) -> CommitHash -> CommitHash #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CommitHash -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CommitHash -> r #

gmapQ :: (forall d. Data d => d -> u) -> CommitHash -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CommitHash -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CommitHash -> m CommitHash #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CommitHash -> m CommitHash #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CommitHash -> m CommitHash #

Generic CommitHash # |

Instance details

Defined in Spago.GlobalCache

Associated Types

type Rep CommitHash |
Instance details Defined in Spago.GlobalCache type Rep CommitHash = D1 ('MetaData "CommitHash" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'True) (C1 ('MetaCons "CommitHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Methods

from :: CommitHash -> Rep CommitHash x #

to :: Rep CommitHash x -> CommitHash #

Read CommitHash # |
Instance details Defined in Spago.GlobalCache Methods readsPrec :: Int -> ReadS CommitHash # readList :: ReadS [CommitHash] # readPrec :: ReadPrec CommitHash # readListPrec :: ReadPrec [CommitHash] #
Show CommitHash # |
Instance details Defined in Spago.GlobalCache Methods showsPrec :: Int -> CommitHash -> ShowS # show :: CommitHash -> String # showList :: [CommitHash] -> ShowS #
Eq CommitHash # |
Instance details Defined in Spago.GlobalCache Methods (==) :: CommitHash -> CommitHash -> Bool # (/=) :: CommitHash -> CommitHash -> Bool #
Ord CommitHash # |
Instance details Defined in Spago.GlobalCache Methods compare :: CommitHash -> CommitHash -> Ordering # (<) :: CommitHash -> CommitHash -> Bool # (<=) :: CommitHash -> CommitHash -> Bool # (>) :: CommitHash -> CommitHash -> Bool # (>=) :: CommitHash -> CommitHash -> Bool # max :: CommitHash -> CommitHash -> CommitHash # min :: CommitHash -> CommitHash -> CommitHash #
type Rep CommitHash # |
Instance details Defined in Spago.GlobalCache type Rep CommitHash = D1 ('MetaData "CommitHash" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'True) (C1 ('MetaCons "CommitHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

newtype Tag #

Constructors

Tag Text |

#### Instances

Instances details

FromJSON Tag # |
Instance details Defined in Spago.GlobalCache Methods parseJSON :: Value -> Parser Tag # parseJSONList :: Value -> Parser [Tag] # omittedField :: Maybe Tag #
FromJSONKey Tag # |
Instance details Defined in Spago.GlobalCache Methods fromJSONKey :: FromJSONKeyFunction Tag # fromJSONKeyList :: FromJSONKeyFunction [Tag] #
ToJSON Tag # |
Instance details Defined in Spago.GlobalCache Methods toJSON :: Tag -> Value # toEncoding :: Tag -> Encoding # toJSONList :: [Tag] -> Value # toEncodingList :: [Tag] -> Encoding # omitField :: Tag -> Bool #
ToJSONKey Tag # |
Instance details Defined in Spago.GlobalCache Methods toJSONKey :: ToJSONKeyFunction Tag # toJSONKeyList :: ToJSONKeyFunction [Tag] #
Data Tag # |

Instance details

Defined in Spago.GlobalCache

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Tag -> c Tag #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Tag #

toConstr :: Tag -> Constr #

dataTypeOf :: Tag -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Tag) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Tag) #

gmapT :: (forall b. Data b => b -> b) -> Tag -> Tag #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Tag -> r #

gmapQ :: (forall d. Data d => d -> u) -> Tag -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Tag -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Tag -> m Tag #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Tag -> m Tag #

Generic Tag # |

Instance details

Defined in Spago.GlobalCache

Associated Types

type Rep Tag |
Instance details Defined in Spago.GlobalCache type Rep Tag = D1 ('MetaData "Tag" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'True) (C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Methods

from :: Tag -> Rep Tag x #

to :: Rep Tag x -> Tag #

Read Tag # |
Instance details Defined in Spago.GlobalCache Methods readsPrec :: Int -> ReadS Tag # readList :: ReadS [Tag] # readPrec :: ReadPrec Tag # readListPrec :: ReadPrec [Tag] #
Show Tag # |
Instance details Defined in Spago.GlobalCache Methods showsPrec :: Int -> Tag -> ShowS # show :: Tag -> String # showList :: [Tag] -> ShowS #
Eq Tag # |
Instance details Defined in Spago.GlobalCache Methods (==) :: Tag -> Tag -> Bool # (/=) :: Tag -> Tag -> Bool #
Ord Tag # |
Instance details Defined in Spago.GlobalCache Methods compare :: Tag -> Tag -> Ordering # (<) :: Tag -> Tag -> Bool # (<=) :: Tag -> Tag -> Bool # (>) :: Tag -> Tag -> Bool # (>=) :: Tag -> Tag -> Bool # max :: Tag -> Tag -> Tag # min :: Tag -> Tag -> Tag #
type Rep Tag # |
Instance details Defined in Spago.GlobalCache type Rep Tag = D1 ('MetaData "Tag" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'True) (C1 ('MetaCons "Tag" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data RepoMetadataV1 #

Constructors

RepoMetadataV1 |

Fields

- commits :: [CommitHash]
- latest :: Maybe Tag
- owner :: Text
- tags :: Map Tag CommitHash

#### Instances

Instances details

FromJSON RepoMetadataV1 # |
Instance details Defined in Spago.GlobalCache Methods parseJSON :: Value -> Parser RepoMetadataV1 # parseJSONList :: Value -> Parser [RepoMetadataV1] # omittedField :: Maybe RepoMetadataV1 #
ToJSON RepoMetadataV1 # |
Instance details Defined in Spago.GlobalCache Methods toJSON :: RepoMetadataV1 -> Value # toEncoding :: RepoMetadataV1 -> Encoding # toJSONList :: [RepoMetadataV1] -> Value # toEncodingList :: [RepoMetadataV1] -> Encoding # omitField :: RepoMetadataV1 -> Bool #
Generic RepoMetadataV1 # |

Instance details

Defined in Spago.GlobalCache

Associated Types

type Rep RepoMetadataV1 |

Instance details

Defined in Spago.GlobalCache

type Rep RepoMetadataV1 = D1 ('MetaData "RepoMetadataV1" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'False) (C1 ('MetaCons "RepoMetadataV1" 'PrefixI 'True) ((S1 ('MetaSel ('Just "commits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CommitHash]) :*: S1 ('MetaSel ('Just "latest") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Tag))) :*: (S1 ('MetaSel ('Just "owner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "tags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Tag CommitHash)))))

Methods

from :: RepoMetadataV1 -> Rep RepoMetadataV1 x #

to :: Rep RepoMetadataV1 x -> RepoMetadataV1 #

Show RepoMetadataV1 # |
Instance details Defined in Spago.GlobalCache Methods showsPrec :: Int -> RepoMetadataV1 -> ShowS # show :: RepoMetadataV1 -> String # showList :: [RepoMetadataV1] -> ShowS #
type Rep RepoMetadataV1 # |

Instance details

Defined in Spago.GlobalCache

type Rep RepoMetadataV1 = D1 ('MetaData "RepoMetadataV1" "Spago.GlobalCache" "spago-0.21.0-7wZ2i2dSXT92RnTwenz8EK" 'False) (C1 ('MetaCons "RepoMetadataV1" 'PrefixI 'True) ((S1 ('MetaSel ('Just "commits") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [CommitHash]) :*: S1 ('MetaSel ('Just "latest") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Tag))) :*: (S1 ('MetaSel ('Just "owner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "tags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map Tag CommitHash)))))

type ReposMetadataV1 = Map PackageName RepoMetadataV1 #

globallyCache :: HasLogFunc env => (PackageName, Repo, Text) -> FilePath -> ReposMetadataV1 -> (FilePath -> RIO env ()) -> RIO env () -> RIO env () #

A package is "globally cacheable" if: * it's a GitHub repo * the ref we have is a commit or a tag -- i.e. "immutable enough", so e.g. not a branch

So here we check that one of the two is true, and if so we run the callback with the URL of the .tar.gz archive on GitHub, otherwise another callback for when it's not

getMetadata :: (HasLogFunc env, HasGlobalCache env) => RIO env ReposMetadataV1 #

Download the GitHub Index cache from the `package-sets-metadata` repo

getGlobalCacheDir :: (MonadUnliftIO m, HasLogFunc env, MonadReader env m) => m FilePath #

Directory in which spago will put its global cache `getXdgDirectory XdgCache` tries to find the folder pointed by `$XDG_CACHE_HOME`, otherwise it uses: - (on LinuxMacOS) the folder pointed by `$HOME.cache`, or - (on Windows) the folder pointed by `LocalAppData`

fetchTarball :: HasLogFunc env => FilePath -> Text -> RIO env () #

Fetch the tarball at `archiveUrl` and unpack it into `destination`