forked from commercialhaskell/stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInternal.hs
More file actions
88 lines (72 loc) · 2.61 KB
/
Internal.hs
File metadata and controls
88 lines (72 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{-# LANGUAGE Rank2Types #-}
-- | Internal types to the library.
module Stack.Types.Internal
( Env (..)
, HasTerminal (..)
, HasReExec (..)
, Sticky (..)
, HasSticky (..)
, LogOptions (..)
, HasLogOptions (..)
, view
) where
import Control.Concurrent.MVar
import Control.Monad.Logger (LogLevel)
import Data.Text (Text)
import Lens.Micro
import Stack.Types.Config
-- | Monadic environment.
data Env config =
Env {envConfig :: !config
,envReExec :: !Bool
,envLogOptions :: !LogOptions
,envTerminal :: !Bool
,envSticky :: !Sticky
}
envConfL :: Lens (Env a) (Env b) a b
envConfL = lens envConfig (\x y -> x { envConfig = y })
instance HasPlatform config => HasPlatform (Env config) where
platformL = envConfL.platformL
platformVariantL = envConfL.platformVariantL
instance HasGHCVariant config => HasGHCVariant (Env config) where
ghcVariantL = envConfL.ghcVariantL
instance HasConfig config => HasConfig (Env config) where
configL = envConfL.configL
instance HasBuildConfigNoLocal config => HasBuildConfigNoLocal (Env config) where
buildConfigNoLocalL = envConfL.buildConfigNoLocalL
instance HasMaybeBuildConfig config => HasMaybeBuildConfig (Env config) where
maybeBuildConfigLocalL = envConfL.maybeBuildConfigLocalL
instance HasBuildConfig config => HasBuildConfig (Env config) where
buildConfigLocalL = envConfL.buildConfigLocalL
instance HasEnvConfigNoLocal config => HasEnvConfigNoLocal (Env config) where
envConfigNoLocalL = envConfL.envConfigNoLocalL
instance HasMaybeEnvConfig config => HasMaybeEnvConfig (Env config) where
maybeEnvConfigLocalL = envConfL.maybeEnvConfigLocalL
instance HasEnvConfig config => HasEnvConfig (Env config) where
envConfigL = envConfL.envConfigL
class HasTerminal env where
terminalL :: Lens' env Bool
instance HasTerminal (Env config) where
terminalL = lens envTerminal (\x y -> x { envTerminal = y })
class HasReExec env where
reExecL :: Lens' env Bool
instance HasReExec (Env config) where
reExecL = lens envReExec (\x y -> x { envReExec = y })
newtype Sticky = Sticky
{ unSticky :: Maybe (MVar (Maybe Text))
}
class HasSticky env where
stickyL :: Lens' env Sticky
instance HasSticky (Env config) where
stickyL = lens envSticky (\x y -> x { envSticky = y })
data LogOptions = LogOptions
{ logUseColor :: Bool
, logUseUnicode :: Bool
, logUseTime :: Bool
, logMinLevel :: LogLevel
, logVerboseFormat :: Bool
}
class HasLogOptions env where
logOptionsL :: Lens' env LogOptions
instance HasLogOptions (Env config) where
logOptionsL = lens envLogOptions (\x y -> x { envLogOptions = y })