Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonadFail upgrade to the modern base #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Aws/General.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module Aws.General
import Control.Applicative
import Control.DeepSeq
import Control.Monad
import qualified Control.Monad.Fail as MF

import Data.Aeson (ToJSON(..), FromJSON(..), withText)
import qualified Data.Attoparsec.Text as AP
Expand All @@ -89,7 +90,7 @@ import Text.Printf

class AwsType a where
toText :: (IsString b, Monoid b) => a -> b
parse :: (Monad m, P.CharParsing m) => m a
parse :: (MF.MonadFail m, P.CharParsing m) => m a

fromText :: T.Text -> Either String a
fromText = AP.parseOnly $ parse <* P.eof
Expand Down
5 changes: 3 additions & 2 deletions src/Aws/SignatureV4.hs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ import Control.Applicative
import Control.Arrow hiding (left)
import Control.DeepSeq
import Control.Monad.IO.Class
import qualified Control.Monad.Fail as MF

import Crypto.Hash

Expand Down Expand Up @@ -462,7 +463,7 @@ credentialScopeToText s =
<> "/" <> toText (credentialScopeService s)
<> "/" <> terminationString

parseCredentialScope :: (Monad m, P.CharParsing m) => m CredentialScope
parseCredentialScope :: (MF.MonadFail m, P.CharParsing m) => m CredentialScope
parseCredentialScope = CredentialScope
<$> time
<*> (P.char '/' *> parseRegion)
Expand All @@ -472,7 +473,7 @@ parseCredentialScope = CredentialScope
time = do
str <- P.count 8 P.digit
case p credentialScopeDateFormat str of
Nothing -> fail $ "failed to parse credential scope date: " <> str
Nothing -> MF.fail $ "failed to parse credential scope date: " <> str
Just t -> return t
#if MIN_VERSION_time(1,5,0)
p = parseTimeM True defaultTimeLocale
Expand Down