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

Update fourmolu version #276

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ jobs:
- name: Download fourmolu
uses: supplypike/setup-bin@v1
with:
uri: 'https://github.com/fourmolu/fourmolu/releases/download/v0.9.0.0/fourmolu-0.9.0.0-linux-x86_64'
uri: 'https://github.com/fourmolu/fourmolu/releases/download/v0.13.1.0/fourmolu-0.13.1.0-linux-x86_64'
name: 'fourmolu'
version: '0.9.0.0'
version: '0.13.1.0'

- name: Checkout project
uses: actions/checkout@v2
Expand Down
6 changes: 3 additions & 3 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ ccPrefs =
prefShowHelpOnEmpty = True
}

-- |Set the encoding on the given handle in such a way that unsupported
-- characters are replaced with a replacement character.
-- See: https://hackage.haskell.org/package/base-4.14.0.0/docs/System-IO.html#v:mkTextEncoding
-- | Set the encoding on the given handle in such a way that unsupported
-- characters are replaced with a replacement character.
-- See: https://hackage.haskell.org/package/base-4.14.0.0/docs/System-IO.html#v:mkTextEncoding
setReplacement :: Handle -> IO ()
setReplacement h = do
ce' <- hGetEncoding h
Expand Down
2 changes: 1 addition & 1 deletion deps/concordium-base
Submodule concordium-base updated 140 files
18 changes: 16 additions & 2 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
indentation: 4 # How many spaces to use as an indent.
column-limit: none # We do not set a limit as it may break idempotence.
function-arrows: trailing # Where to place arrows in type signatures.
comma-style: trailing # Where to place commas in lists, tuples, etc.
import-export-style: diff-friendly # How to format multiline import/export lists (diff-friendly lists have trailing commas but keep the opening parenthesis on the same line as import).
record-brace-space: false # rec {x = 1} vs. rec{x = 1}.
indent-wheres: false # 'false' means save space by only half-indenting the 'where' keyword.
record-brace-space: false # rec {x = 1} vs. rec{x = 1}.
newlines-between-decls: 1 # number of newlines between top-level declarations.
haddock-style: single-line # Use -- |, {- |, or {-| for multiline haddocks (single-line haddocks always use --).
let-style: auto # How to style let blocks (auto uses newline if there's a newline in the input and inline otherwise, and mixed uses inline only when the let has exactly one binding).
in-style: left-align # How to align the in keyword with respect to let.
single-constraint-parens: always # Whether to put parentheses round a single constraint
unicode: never
respectful: true # Be less aggressive in reformatting input, e.g. keep empty lines in import list.
fixities: [] # Override fixities of operators.
fixities: # Override fixities of operators.
# This operator is defined in Concordium.Utils. Fourmolu seems to ignore its fixity specification.
- infixr 0 $!!
# Fourmolu incorrectly determines the fixity of operators re-exported in Lens.Micro.Platform.
# We make explicit those that are in Lens.Micro.Mtl, since it does not seem sufficient to
# use a reexport directive.
- infixl 1 &, <&>, &~
- infixr 2 <~
- infix 4 .=, ?=, +=, -=, *=, //=, <%=, <.=, <?=, <<%=, <<.=
- infix 4 .=
reexports:
- module Lens.Micro.Platform exports Lens.Micro
20 changes: 10 additions & 10 deletions generator/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import Options.Applicative
import System.Exit

data TxOptions = TxOptions
{ -- |How many transactions to send per second.
{ -- | How many transactions to send per second.
tps :: !Int,
-- |Whether to output a log after each transaction that is sent.
-- | Whether to output a log after each transaction that is sent.
logit :: !Bool,
-- |File with JSON encoded keys for the source account.
-- | File with JSON encoded keys for the source account.
keysFile :: !FilePath,
-- |Optional file with addresses and (optionally) public keys of the accounts to send to.
-- If not given or empty all transfers will be self-transfers.
-- This option is mandatory if encrypted transfers are desired.
-- The format of the file should be a JSON array of objects with keys "address" and "encryptionPublicKey", the latter being optional.
-- | Optional file with addresses and (optionally) public keys of the accounts to send to.
-- If not given or empty all transfers will be self-transfers.
-- This option is mandatory if encrypted transfers are desired.
-- The format of the file should be a JSON array of objects with keys "address" and "encryptionPublicKey", the latter being optional.
receiversFile :: !(Maybe FilePath),
-- |If this is `True` then we send encrypted transfer transactions.
-- | If this is `True` then we send encrypted transfer transactions.
encrypted :: !Bool
}

Expand All @@ -63,7 +63,7 @@ parser =
(helper <*> ((,) <$> backendParser <*> txOptions))
(fullDesc <> progDesc "Generate transactions for a fixed contract.")

sendTx :: MonadIO m => BareBlockItem -> ClientMonad m BareBlockItem
sendTx :: (MonadIO m) => BareBlockItem -> ClientMonad m BareBlockItem
sendTx tx = do
sbiRes <- sendBlockItem tx
let res = case sbiRes of
Expand All @@ -75,7 +75,7 @@ sendTx tx = do
Left err -> liftIO $ die $ "Could not send transaction: " <> err
Right _ -> return tx

iterateM_ :: Monad m => (a -> m a) -> a -> m b
iterateM_ :: (Monad m) => (a -> m a) -> a -> m b
iterateM_ f a = f a >>= iterateM_ f

go :: Backend -> Bool -> Int -> a -> (Nonce -> a -> IO (AccountAddress, BareBlockItem, a)) -> Nonce -> IO ()
Expand Down
62 changes: 31 additions & 31 deletions src/Concordium/Client/Cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ import Prelude hiding (fail, log)

data Level = Info | Warn | Err deriving (Eq)

-- |Log a list of sentences. The sentences are pretty printed (capital first letter and dot at the end),
-- so the input messages should only contain capital letters for names and have no dot suffix.
-- Sentences will be joined on the same line as long as the resulting line doesn't exceed 90 chars.
-- Depending on the log level, an appropriate prefix is added to the first line.
-- All lines will be indented such that they align with the first line
-- (i.e. as if they had all been prefixed).
log :: MonadIO m => Level -> Maybe Color -> [String] -> m ()
-- | Log a list of sentences. The sentences are pretty printed (capital first letter and dot at the end),
-- so the input messages should only contain capital letters for names and have no dot suffix.
-- Sentences will be joined on the same line as long as the resulting line doesn't exceed 90 chars.
-- Depending on the log level, an appropriate prefix is added to the first line.
-- All lines will be indented such that they align with the first line
-- (i.e. as if they had all been prefixed).
log :: (MonadIO m) => Level -> Maybe Color -> [String] -> m ()
log lvl color msgs = do
let doc = prefix <+> fsep (expandLines $ map (prettyMsg ".") msgs)
out = logStrLn $ renderStyle s doc
Expand All @@ -61,26 +61,26 @@ log lvl color msgs = do
Warn -> text "Warning:"
Err -> text "Error:"

logSuccess :: MonadIO m => [String] -> m ()
logSuccess :: (MonadIO m) => [String] -> m ()
logSuccess = log Info $ Just Green

logInfo :: MonadIO m => [String] -> m ()
logInfo :: (MonadIO m) => [String] -> m ()
logInfo = log Info Nothing

logWarn :: MonadIO m => [String] -> m ()
logWarn :: (MonadIO m) => [String] -> m ()
logWarn = log Warn $ Just Yellow

logError :: MonadIO m => [String] -> m ()
logError :: (MonadIO m) => [String] -> m ()
logError = log Err $ Just Red

logFatal :: MonadIO m => [String] -> m a
logFatal :: (MonadIO m) => [String] -> m a
logFatal msgs = logError msgs >> liftIO exitFailure

withLogFatal :: MonadIO m => Either e' a -> (e' -> String) -> m a
withLogFatal :: (MonadIO m) => Either e' a -> (e' -> String) -> m a
withLogFatal (Left x) f = logFatal [f x]
withLogFatal (Right x) _ = return x

logFatalOnError :: MonadIO m => Either String a -> m a
logFatalOnError :: (MonadIO m) => Either String a -> m a
logFatalOnError x = x `withLogFatal` id

withLogFatalIO :: IO (Either e' a) -> (e' -> String) -> IO a
Expand All @@ -94,15 +94,15 @@ withLogFatalIO' e action =
Nothing -> logFatal [e]
Just x -> return x

logExit :: MonadIO m => [String] -> m a
logExit :: (MonadIO m) => [String] -> m a
logExit msgs = logInfo msgs >> liftIO exitSuccess

-- |Expand each string into a document of the string's lines joined together using vcat.
-- | Expand each string into a document of the string's lines joined together using vcat.
expandLines :: [String] -> [Doc]
expandLines = map $ vcat . map text . lines

-- |Ensure that a string is printable as a sentence by converting the first letter to upper case
-- and, unless it already ends with "standard" punctuation, appending the provided punctionation.
-- | Ensure that a string is printable as a sentence by converting the first letter to upper case
-- and, unless it already ends with "standard" punctuation, appending the provided punctionation.
prettyMsg :: String -> String -> String
prettyMsg punctuation = \case
"" -> ""
Expand All @@ -115,16 +115,16 @@ prettyMsg punctuation = \case
where
p = ".,:;?!{}" :: String

logStr :: MonadIO m => String -> m ()
logStr :: (MonadIO m) => String -> m ()
logStr = liftIO . hPutStr stderr

logStrLn :: MonadIO m => String -> m ()
logStrLn :: (MonadIO m) => String -> m ()
logStrLn = liftIO . hPutStrLn stderr

-- |Ask the user to "confirm" on stdin and return the result.
-- Note that this only appends " [yN]: " if the prompt does not end in
-- one of ".,:;?!{}"
askConfirmation :: MonadIO m => Maybe String -> m Bool
-- | Ask the user to "confirm" on stdin and return the result.
-- Note that this only appends " [yN]: " if the prompt does not end in
-- one of ".,:;?!{}"
askConfirmation :: (MonadIO m) => Maybe String -> m Bool
askConfirmation prompt = liftIO $ do
putStr $ prettyMsg " [yN]: " $ fromMaybe defaultPrompt prompt
input <- T.getLine
Expand Down Expand Up @@ -209,8 +209,8 @@ decryptAccountEncryptionSecretKeyInteractive secret = do
pwd <- liftIO $ askPassword $ "Enter password for decrypting the secret encryption key: "
decryptAccountEncryptionSecretKey pwd secret

-- |Standardized method of exiting the command because the transaction is cancelled.
exitTransactionCancelled :: MonadIO m => m a
-- | Standardized method of exiting the command because the transaction is cancelled.
exitTransactionCancelled :: (MonadIO m) => m a
exitTransactionCancelled = liftIO $ logExit ["transaction cancelled"]

getLocalTimeOfDay :: IO TimeOfDay
Expand Down Expand Up @@ -259,7 +259,7 @@ data BakerKeys = BakerKeys
bkAggrVerifyKey :: Bls.PublicKey,
bkElectionSignKey :: VRF.SecretKey,
bkElectionVerifyKey :: VRF.PublicKey,
-- |The id of the baker these keys belong to, if known.
-- | The id of the baker these keys belong to, if known.
bkBakerId :: Maybe BakerId
}

Expand Down Expand Up @@ -305,13 +305,13 @@ bakerPublicKeysToPairs v =
]
++ ["bakerId" .= bid | bid <- maybeToList (bkBakerId v)]

-- |Hardcoded network ID.
-- | Hardcoded network ID.
defaultNetId :: Int
defaultNetId = 100

-- |If the string starts with @ we assume the remaining characters are a file name
-- and we try to read the contents of that file.
decodeJsonArg :: FromJSON a => String -> Maybe (IO (Either String a))
-- | If the string starts with @ we assume the remaining characters are a file name
-- and we try to read the contents of that file.
decodeJsonArg :: (FromJSON a) => String -> Maybe (IO (Either String a))
decodeJsonArg s =
Just $ do
res <- case uncons s of
Expand Down
Loading