summaryrefslogtreecommitdiff
path: root/src/Network/AWS/Wolf/Types/Ctx.hs
blob: d951be8aa24a9fee7bf9f4104269f9fc503ad943 (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{-# LANGUAGE ConstraintKinds   #-}
{-# LANGUAGE FlexibleContexts  #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell   #-}

-- | Context objects for monad transformers.
--
module Network.AWS.Wolf.Types.Ctx where

import Control.Monad.Trans.AWS
import Network.AWS.SWF
import Network.AWS.Wolf.Prelude
import Network.AWS.Wolf.Types.Product

-- | ConfCtx
--
-- Configuration context.
--
data ConfCtx = ConfCtx
  { _ccStatsCtx :: StatsCtx
    -- ^ Parent context.
  , _ccConf     :: Conf
    -- ^ Configuration parameters.
  }

$(makeClassyConstraints ''ConfCtx [''HasStatsCtx])

instance HasStatsCtx ConfCtx where
  statsCtx = ccStatsCtx

instance HasCtx ConfCtx where
  ctx = statsCtx . ctx

type MonadConf c m =
  ( MonadStatsCtx c m
  , HasConfCtx c
  )

-- | AmazonCtx
--
-- Amazon context.
--
data AmazonCtx = AmazonCtx
  { _acCtx :: Ctx
    -- ^ Parent context.
  , _acEnv :: Env
    -- ^ Amazon environment.
  }

$(makeClassyConstraints ''AmazonCtx [''HasCtx, ''HasEnv])

instance HasCtx AmazonCtx where
  ctx = acCtx

instance HasEnv AmazonCtx where
  environment = acEnv

type MonadAmazon c m =
  ( MonadCtx c m
  , HasAmazonCtx c
  , AWSConstraint c m
  )

-- | AmazonStoreCtx
--
-- Amazon store context.
--
data AmazonStoreCtx = AmazonStoreCtx
  { _ascConfCtx :: ConfCtx
    -- ^ Parent context.
  , _ascPrefix  :: Text
    -- ^ Object prefix.
  }

$(makeClassyConstraints ''AmazonStoreCtx [''HasConfCtx])

instance HasConfCtx AmazonStoreCtx where
  confCtx = ascConfCtx

instance HasStatsCtx AmazonStoreCtx where
  statsCtx = confCtx . statsCtx

instance HasCtx AmazonStoreCtx where
  ctx = statsCtx . ctx

type MonadAmazonStore c m =
   ( MonadConf c m
   , HasAmazonStoreCtx c
   )

-- | AmazonWorkCtx
--
-- Amazon work context.
--
data AmazonWorkCtx = AmazonWorkCtx
  { _awcConfCtx :: ConfCtx
    -- ^ Parent context.
  , _awcQueue   :: Text
    -- ^ Workflow queue.
  }

$(makeClassyConstraints ''AmazonWorkCtx [''HasConfCtx])

instance HasConfCtx AmazonWorkCtx where
   confCtx = awcConfCtx

instance HasStatsCtx AmazonWorkCtx where
  statsCtx = confCtx . statsCtx

instance HasCtx AmazonWorkCtx where
  ctx = statsCtx . ctx

type MonadAmazonWork c m =
   ( MonadConf c m
   , HasAmazonWorkCtx c
   )

-- | AmazonDecisionCtx
--
-- Amazon decision context.
--
data AmazonDecisionCtx = AmazonDecisionCtx
  { _adcConfCtx :: ConfCtx
    -- ^ Parent context.
  , _adcPlan    :: Plan
    -- ^ Decision plan.
  , _adcEvents  :: [HistoryEvent]
    -- ^ History events.
  }

$(makeClassyConstraints ''AmazonDecisionCtx [''HasConfCtx])

instance HasConfCtx AmazonDecisionCtx where
   confCtx = adcConfCtx

instance HasStatsCtx AmazonDecisionCtx where
  statsCtx = confCtx . statsCtx

instance HasCtx AmazonDecisionCtx where
  ctx = statsCtx . ctx

type MonadAmazonDecision c m =
   ( MonadConf c m
   , HasAmazonDecisionCtx c
   )