generated from freckle/haskell-library-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.lhs
105 lines (79 loc) · 2.51 KB
/
README.lhs
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
# amazonka-mtl
[![Hackage](https://img.shields.io/hackage/v/amazonka-mtl.svg?style=flat)](https://hackage.haskell.org/package/amazonka-mtl)
[![Stackage Nightly](http://stackage.org/package/amazonka-mtl/badge/nightly)](http://stackage.org/nightly/package/amazonka-mtl)
[![Stackage LTS](http://stackage.org/package/amazonka-mtl/badge/lts)](http://stackage.org/lts/package/amazonka-mtl)
[![CI](https://github.com/freckle/amazonka-mtl/actions/workflows/ci.yml/badge.svg)](https://github.com/freckle/amazonka-mtl/actions/workflows/ci.yml)
MTL-style type-class and deriving-via newtypes for Amazonka.
## Example
This package allows incorporation of AWS actions into any MTL-style function,
<!--
```haskell
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
module Main (main) where
import Prelude
import Amazonka.S3 (BucketName)
import Control.Monad.Reader (MonadReader)
import Text.Markdown.Unlit ()
```
-->
```haskell
import Amazonka.Data.Text (ToText(..))
import Amazonka.S3.ListObjects
import Amazonka.S3.Types.Object
import Blammo.Logging
import Conduit
import Control.Lens hiding ((.=))
import Control.Monad.AWS as AWS
```
<!--
```haskell
data Settings = Settings
{ settingsBucketName :: BucketName
}
class HasSettings env where
settingsL :: Lens' env Settings
instance HasSettings Settings where
settingsL = id
```
-->
```haskell
someAction
:: ( MonadIO m
, MonadLogger m
, MonadAWS m
, MonadReader env m
, HasSettings env
)
=> m ()
someAction = do
Settings {..} <- view settingsL
keys <-
runConduit
$ paginate (newListObjects settingsBucketName)
.| concatMapC (^. listObjectsResponse_contents)
.| concatC
.| mapC (^. object_key . to toText)
.| iterMC (\k -> logDebug $ k :# [])
.| sinkList
logInfo $ "Bucket contents" :# ["keys" .= keys]
```
<!--
```haskell
main :: IO ()
main = pure ()
```
-->
This package also provides a number of options for execution:
- Through a concrete transformer: `Control.Monad.AWS.EnvT`
- Through your own reader env and deriving-via: `Control.Monad.AWS.ViaReader`
This package also provides mechanisms for mocking AWS in tests:
- Through a concrete transformer: `Control.Monad.AWS.MockT`
- Through your own reader env and deriving-via: `Control.Monad.AWS.ViaMock`
Please see the [documentation on hackage][hackage] for all the details.
[hackage]: https://hackage.haskell.org/package/amazonka-mtl
## Development & Tests
```console
stack build --fast --pedantic --test --file-watch
```
---
[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)