packages feed

aws-ses-easy (empty) → 0.0.0

raw patch · 11 files changed

+342/−0 lines, 11 filesdep +amazonkadep +amazonka-sesdep +aws-ses-easysetup-changed

Dependencies added: amazonka, amazonka-ses, aws-ses-easy, base, criterion, exceptions, lens, lucid, mtl, tasty, tasty-hspec, text, text-conversions

Files

+ CHANGELOG.md view
@@ -0,0 +1,7 @@+# Change log++aws-ses-easy uses [Semantic Versioning][].+The change log is available through the [releases on GitHub][].++[Semantic Versioning]: http://semver.org/spec/v2.0.0.html+[releases on GitHub]: https://github.com/githubuser/aws-ses-easy/releases
+ LICENSE.md view
@@ -0,0 +1,30 @@+Copyright (c) 2018, Joe Vargas++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Joe Vargas nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.A
+ README.md view
@@ -0,0 +1,1 @@+# aws-ses-easy
+ Setup.hs view
@@ -0,0 +1,7 @@+-- This script is used to build and install your package. Typically you don't+-- need to change it. The Cabal documentation has more information about this+-- file: <https://www.haskell.org/cabal/users-guide/installing-packages.html>.+import qualified Distribution.Simple++main :: IO ()+main = Distribution.Simple.defaultMain
+ aws-ses-easy.cabal view
@@ -0,0 +1,80 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 4a1665dedd80d3f81d6afde6fc2e45d73d6b1fdbc8668fb88dc7324bd531c2fc++name:           aws-ses-easy+version:        0.0.0+synopsis:       Wrapper over Amazonka's SES+description:    Opinionated use of Amazonka's SES for ease+category:       Network+homepage:       https://github.com/jxv/aws-ses-easy#readme+bug-reports:    https://github.com/jxv/aws-ses-easy/issues+author:         Joe Vargas+maintainer:     Joe Vargas+license:        BSD3+license-file:   LICENSE.md+build-type:     Simple+cabal-version:  >= 1.10++extra-source-files:+    CHANGELOG.md+    LICENSE.md+    package.yaml+    README.md+    stack.yaml++source-repository head+  type: git+  location: https://github.com/jxv/aws-ses-easy++library+  hs-source-dirs:+      library+  ghc-options: -Wall+  build-depends:+      amazonka+    , amazonka-ses+    , base >=4.5 && <5+    , exceptions+    , lens+    , lucid+    , mtl+    , text+    , text-conversions+  exposed-modules:+      Aws.Ses.Easy.Email+      Aws.Ses.Easy.Service+  other-modules:+      Paths_aws_ses_easy+  default-language: Haskell2010++test-suite aws-ses-easy-test-suite+  type: exitcode-stdio-1.0+  main-is: Main.hs+  hs-source-dirs:+      test-suite+  ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N+  build-depends:+      aws-ses-easy+    , base+    , tasty+    , tasty-hspec+  other-modules:+      Paths_aws_ses_easy+  default-language: Haskell2010++benchmark aws-ses-easy-benchmarks+  type: exitcode-stdio-1.0+  main-is: Main.hs+  hs-source-dirs:+      benchmark+  ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N+  build-depends:+      aws-ses-easy+    , base+    , criterion+  other-modules:+      Paths_aws_ses_easy+  default-language: Haskell2010
+ benchmark/Main.hs view
@@ -0,0 +1,6 @@+-- You can benchmark your code quickly and effectively with Criterion. See its+-- website for help: <http://www.serpentine.com/criterion/>.+import Criterion.Main++main :: IO ()+main = defaultMain [bench "const" (whnf const ())]
+ library/Aws/Ses/Easy/Email.hs view
@@ -0,0 +1,44 @@+{-# LANGUAGE OverloadedStrings #-}+module Aws.Ses.Easy.Email+  ( Email(..)+  , fromHtml+  , center+  , blackFont+  , fromEmail+  ) where++import qualified Data.Text.Lazy as TL+import qualified Network.AWS.SES as Aws+import Control.Lens+import Data.Text (Text)+import Lucid+import Lucid.Base++data Email = Email+  { emailTo :: [Text]+  , emailFrom :: Text+  , emailTitle :: Text+  , emailBody :: Html ()+  } deriving (Show)++fromHtml :: Html a -> Text+fromHtml = TL.toStrict . renderText++center :: Html () -> Html ()+center chilens = do+    table_ [width_ "100%", makeAttribute "border" "0", makeAttribute "cellspacing" "0", makeAttribute "cellpadding" "0"] $+      tr_ $+        td_ [makeAttribute "align" "center"] $+          chilens++blackFont :: [Attribute] -> Html () -> Html ()+blackFont attributes chilens = term "font" (makeAttribute "color" "black" : attributes) chilens++fromEmail :: Email -> Aws.SendEmail+fromEmail e = Aws.sendEmail from' dest msg+  where+    from' = emailFrom e+    dest = Aws.destination & Aws.dToAddresses .~ (emailTo e)+    content = Aws.content $ fromHtml (emailBody e)+    title = Aws.content $ emailTitle e+    msg = Aws.message title (Aws.body & Aws.bHTML .~ (Just content))
+ library/Aws/Ses/Easy/Service.hs view
@@ -0,0 +1,25 @@+module Aws.Ses.Easy.Service+  ( Service(..)+  , sendEmail'+  ) where++import qualified Network.AWS as Aws+import qualified Network.AWS.SES as Aws+import Aws.Ses.Easy.Email (Email, fromEmail)+import Control.Exception.Lens (catching_)+import Control.Monad.Reader (MonadReader(..), asks)+import Control.Monad.IO.Class (MonadIO(..))+import Control.Monad.Catch (MonadCatch(..))+++class Monad m => Service m where+  sendEmail :: Email -> (Email -> m ()) -> m ()++sendEmail' :: (MonadIO m, MonadReader s m, MonadCatch m) => (s -> Aws.Env) -> Email -> (Email -> m ()) -> m ()+sendEmail' getEnv email failed = do+  env <- asks getEnv+  let msg = fromEmail email+  _ <- catching_ Aws._MessageRejected (awsSendEmail env msg >> return ()) (failed email)+  return ()+  where+    awsSendEmail env msg = liftIO $ Aws.runResourceT . Aws.runAWS env $ Aws.send msg
+ package.yaml view
@@ -0,0 +1,59 @@+name: aws-ses-easy+version: '0.0.0'+github: jxv/aws-ses-easy+license: BSD3+license-file: LICENSE.md+author: Joe Vargas+maintainer: Joe Vargas+synopsis: Wrapper over Amazonka's SES+description: Opinionated use of Amazonka's SES for ease+category: Network++extra-source-files:+- CHANGELOG.md+- LICENSE.md+- package.yaml+- README.md+- stack.yaml++ghc-options: -Wall++library:+  dependencies:+  - base >= 4.5 && <5+  - amazonka+  - amazonka-ses+  - lens+  - lucid+  - mtl+  - text+  - text-conversions+  - exceptions+  source-dirs: library++benchmarks:+  aws-ses-easy-benchmarks:+    source-dirs: benchmark+    main: Main.hs+    dependencies:+    - base+    - aws-ses-easy+    - criterion+    ghc-options:+    - -rtsopts+    - -threaded+    - -with-rtsopts=-N++tests:+  aws-ses-easy-test-suite:+    source-dirs: test-suite+    main: Main.hs+    dependencies:+    - base+    - aws-ses-easy+    - tasty+    - tasty-hspec+    ghc-options:+    - -rtsopts+    - -threaded+    - -with-rtsopts=-N
+ stack.yaml view
@@ -0,0 +1,66 @@+# This file was automatically generated by 'stack init'+#+# Some commonly used options have been documented as comments in this file.+# For advanced use and comprehensive documentation of the format, please see:+# https://docs.haskellstack.org/en/stable/yaml_configuration/++# Resolver to choose a 'specific' stackage snapshot or a compiler version.+# A snapshot resolver dictates the compiler version and the set of packages+# to be used for project dependencies. For example:+#+# resolver: lts-3.5+# resolver: nightly-2015-09-21+# resolver: ghc-7.10.2+# resolver: ghcjs-0.1.0_ghc-7.10.2+# resolver:+#  name: custom-snapshot+#  location: "./custom-snapshot.yaml"+resolver: lts-10.8++# User packages to be built.+# Various formats can be used as shown in the example below.+#+# packages:+# - some-directory+# - https://example.com/foo/bar/baz-0.0.2.tar.gz+# - location:+#    git: https://github.com/commercialhaskell/stack.git+#    commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a+#   extra-dep: true+#  subdirs:+#  - auto-update+#  - wai+#+# A package marked 'extra-dep: true' will only be built if demanded by a+# non-dependency (i.e. a user package), and its test suites and benchmarks+# will not be run. This is useful for tweaking upstream packages.+packages:+- .+# Dependency packages to be pulled from upstream that are not in the resolver+# (e.g., acme-missiles-0.3)+extra-deps: []++# Override default flag values for local packages and extra-deps+# flags: {}++# Extra package databases containing global packages+# extra-package-dbs: []++# Control whether we use the GHC we find on the path+# system-ghc: true+#+# Require a specific version of stack, using version ranges+# require-stack-version: -any # Default+# require-stack-version: ">=1.6"+#+# Override the architecture used by stack, especially useful on Windows+# arch: i386+# arch: x86_64+#+# Extra directories used by stack for building+# extra-include-dirs: [/path/to/dir]+# extra-lib-dirs: [/path/to/dir]+#+# Allow a newer minor version of GHC than the snapshot specifies+# compiler-check: newer-minor
+ test-suite/Main.hs view
@@ -0,0 +1,17 @@+-- Tasty makes it easy to test your code. It is a test framework that can+-- combine many different types of tests into one suite. See its website for+-- help: <http://documentup.com/feuerbach/tasty>.+import qualified Test.Tasty+-- Hspec is one of the providers for Tasty. It provides a nice syntax for+-- writing tests. Its website has more info: <https://hspec.github.io>.+import Test.Tasty.Hspec++main :: IO ()+main = do+    test <- testSpec "aws-ses-easy" spec+    Test.Tasty.defaultMain test++spec :: Spec+spec = parallel $ do+    it "is trivially true" $ do+        True `shouldBe` True