{-# OPTIONS_GHC -Wno-orphans #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
module GHCup.Types.Optics where
import GHCup.Types
import Control.Monad.Reader
import Data.ByteString ( ByteString )
import Optics
import URI.ByteString
makePrisms ''Tool
makePrisms ''Architecture
makePrisms ''LinuxDistro
makePrisms ''Platform
makePrisms ''Tag
makeLenses ''PlatformResult
makeLenses ''DownloadInfo
makeLenses ''Tag
makeLenses ''VersionInfo
makeLenses ''GHCTargetVersion
makeLenses ''GHCupInfo
uriSchemeL' :: Lens' (URIRef Absolute) Scheme
uriSchemeL' :: Lens' URI Scheme
uriSchemeL' = LensVL URI URI Scheme Scheme -> Lens' URI Scheme
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL URI URI Scheme Scheme
uriSchemeL
schemeBSL' :: Lens' Scheme ByteString
schemeBSL' :: Lens' Scheme ByteString
schemeBSL' = LensVL Scheme Scheme ByteString ByteString
-> Lens' Scheme ByteString
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL Scheme Scheme ByteString ByteString
schemeBSL
authorityL' :: Lens' (URIRef a) (Maybe Authority)
authorityL' :: Lens' (URIRef a) (Maybe Authority)
authorityL' = LensVL (URIRef a) (URIRef a) (Maybe Authority) (Maybe Authority)
-> Lens' (URIRef a) (Maybe Authority)
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL forall a. Lens' (URIRef a) (Maybe Authority)
LensVL (URIRef a) (URIRef a) (Maybe Authority) (Maybe Authority)
authorityL
authorityHostL' :: Lens' Authority Host
authorityHostL' :: Lens' Authority Host
authorityHostL' = LensVL Authority Authority Host Host -> Lens' Authority Host
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL Authority Authority Host Host
authorityHostL
authorityPortL' :: Lens' Authority (Maybe Port)
authorityPortL' :: Lens' Authority (Maybe Port)
authorityPortL' = LensVL Authority Authority (Maybe Port) (Maybe Port)
-> Lens' Authority (Maybe Port)
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL Authority Authority (Maybe Port) (Maybe Port)
authorityPortL
portNumberL' :: Lens' Port Int
portNumberL' :: Lens' Port Int
portNumberL' = LensVL Port Port Int Int -> Lens' Port Int
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL Port Port Int Int
portNumberL
hostBSL' :: Lens' Host ByteString
hostBSL' :: Lens' Host ByteString
hostBSL' = LensVL Host Host ByteString ByteString -> Lens' Host ByteString
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL LensVL Host Host ByteString ByteString
hostBSL
pathL' :: Lens' (URIRef a) ByteString
pathL' :: Lens' (URIRef a) ByteString
pathL' = LensVL (URIRef a) (URIRef a) ByteString ByteString
-> Lens' (URIRef a) ByteString
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL forall a. Lens' (URIRef a) ByteString
LensVL (URIRef a) (URIRef a) ByteString ByteString
pathL
queryL' :: Lens' (URIRef a) Query
queryL' :: Lens' (URIRef a) Query
queryL' = LensVL (URIRef a) (URIRef a) Query Query -> Lens' (URIRef a) Query
forall s t a b. LensVL s t a b -> Lens s t a b
lensVL forall a. Lens' (URIRef a) Query
LensVL (URIRef a) (URIRef a) Query Query
queryL
gets :: forall f a env m . (MonadReader env m, LabelOptic' f A_Lens env a)
=> m a
gets :: m a
gets = (env -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks (env -> Optic' A_Lens NoIx env a -> a
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. forall k s t a b. LabelOptic f k s t a b => Optic k NoIx s t a b
forall (name :: Symbol) k s t a b.
LabelOptic name k s t a b =>
Optic k NoIx s t a b
labelOptic @f)
getAppState :: MonadReader AppState m => m AppState
getAppState :: m AppState
getAppState = m AppState
forall r (m :: * -> *). MonadReader r m => m r
ask
getLeanAppState :: ( MonadReader env m
, LabelOptic' "settings" A_Lens env Settings
, LabelOptic' "dirs" A_Lens env Dirs
, LabelOptic' "keyBindings" A_Lens env KeyBindings
, LabelOptic' "loggerConfig" A_Lens env LoggerConfig
)
=> m LeanAppState
getLeanAppState :: m LeanAppState
getLeanAppState = do
Settings
s <- forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "settings" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"settings"
Dirs
d <- forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "dirs" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"dirs"
KeyBindings
k <- forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "keyBindings" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"keyBindings"
LoggerConfig
l <- forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "loggerConfig" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"loggerConfig"
LeanAppState -> m LeanAppState
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Settings -> Dirs -> KeyBindings -> LoggerConfig -> LeanAppState
LeanAppState Settings
s Dirs
d KeyBindings
k LoggerConfig
l)
getSettings :: ( MonadReader env m
, LabelOptic' "settings" A_Lens env Settings
)
=> m Settings
getSettings :: m Settings
getSettings = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "settings" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"settings"
getDirs :: ( MonadReader env m
, LabelOptic' "dirs" A_Lens env Dirs
)
=> m Dirs
getDirs :: m Dirs
getDirs = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "dirs" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"dirs"
getLogCleanup :: ( MonadReader env m
, LabelOptic' "logCleanup" A_Lens env (IO ())
)
=> m (IO ())
getLogCleanup :: m (IO ())
getLogCleanup = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "logCleanup" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"logCleanup"
getKeyBindings :: ( MonadReader env m
, LabelOptic' "keyBindings" A_Lens env KeyBindings
)
=> m KeyBindings
getKeyBindings :: m KeyBindings
getKeyBindings = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "keyBindings" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"keyBindings"
getGHCupInfo :: ( MonadReader env m
, LabelOptic' "ghcupInfo" A_Lens env GHCupInfo
)
=> m GHCupInfo
getGHCupInfo :: m GHCupInfo
getGHCupInfo = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "ghcupInfo" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"ghcupInfo"
getPlatformReq :: ( MonadReader env m
, LabelOptic' "pfreq" A_Lens env PlatformRequest
)
=> m PlatformRequest
getPlatformReq :: m PlatformRequest
getPlatformReq = forall a env (m :: * -> *).
(MonadReader env m, LabelOptic' "pfreq" A_Lens env a) =>
m a
forall (f :: Symbol) a env (m :: * -> *).
(MonadReader env m, LabelOptic' f A_Lens env a) =>
m a
gets @"pfreq"
type HasSettings env = (LabelOptic' "settings" A_Lens env Settings)
type HasDirs env = (LabelOptic' "dirs" A_Lens env Dirs)
type HasKeyBindings env = (LabelOptic' "keyBindings" A_Lens env KeyBindings)
type HasGHCupInfo env = (LabelOptic' "ghcupInfo" A_Lens env GHCupInfo)
type HasPlatformReq env = (LabelOptic' "pfreq" A_Lens env PlatformRequest)
type HasLog env = (LabelOptic' "loggerConfig" A_Lens env LoggerConfig)
getCache :: (MonadReader env m, HasSettings env) => m Bool
getCache :: m Bool
getCache = m Settings
forall env (m :: * -> *).
(MonadReader env m, LabelOptic' "settings" A_Lens env Settings) =>
m Settings
getSettings m Settings -> (Settings -> Bool) -> m Bool
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> Settings -> Bool
cache
getDownloader :: (MonadReader env m, HasSettings env) => m Downloader
getDownloader :: m Downloader
getDownloader = m Settings
forall env (m :: * -> *).
(MonadReader env m, LabelOptic' "settings" A_Lens env Settings) =>
m Settings
getSettings m Settings -> (Settings -> Downloader) -> m Downloader
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> Settings -> Downloader
downloader
instance LabelOptic "dirs" A_Lens Dirs Dirs Dirs Dirs where
labelOptic :: Optic A_Lens NoIx Dirs Dirs Dirs Dirs
labelOptic = (Dirs -> Dirs)
-> (Dirs -> Dirs -> Dirs) -> Optic A_Lens NoIx Dirs Dirs Dirs Dirs
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens Dirs -> Dirs
forall a. a -> a
id (\Dirs
_ Dirs
d -> Dirs
d)