Skip to content

Commit

Permalink
Upgrade Ormolu to 0.0.5.0 (#1078)
Browse files Browse the repository at this point in the history
* update ormolu version

* run new ormolu

* don't exclude CPP anymore

* format Sodium.Crypt.Sign

Changelog:
https://github.com/tweag/ormolu/blob/master/CHANGELOG.md

Most changes are caused by:

* Records with a single data constructor are now formatted more compactly. [Issue 425](tweag/ormolu#425).

* Added experimental support for simple CPP. [Issue 415](tweag/ormolu#415).

Other notable changes we can start making use of:

* Grouping of statements in `do`-blocks is now preserved. [Issue 74](tweag/ormolu#74).

* Comments on pragmas are now preserved. [Issue 216](tweag/ormolu#216).
  • Loading branch information
mheinzel committed Apr 27, 2020
1 parent decf0d2 commit f80faf3
Show file tree
Hide file tree
Showing 193 changed files with 3,454 additions and 3,959 deletions.
14 changes: 6 additions & 8 deletions libs/api-bot/src/Network/Wire/Bot/Clients.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ import qualified Data.Set as Set
import Imports
import System.CryptoBox (Session)

data Clients
= Clients
{ members :: TVar (Map ConvId (Set UserId)),
sessions :: TVar Sessions
}
data Clients = Clients
{ members :: TVar (Map ConvId (Set UserId)),
sessions :: TVar Sessions
}

newtype Sessions
= Sessions
{clients :: Map UserId (Map ClientId Session)}
newtype Sessions = Sessions
{clients :: Map UserId (Map ClientId Session)}

empty :: IO Clients
empty = Clients <$> newTVarIO Map.empty <*> newTVarIO (Sessions Map.empty)
Expand Down
9 changes: 4 additions & 5 deletions libs/api-bot/src/Network/Wire/Bot/Crypto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ decryptMessage clt e = do
-----------------------------------------------------------------------------
-- Auxiliary Symmetric Encryption

data SymmetricKeys
= SymmetricKeys
{ symmetricEncKey :: !ByteString,
symmetricMacKey :: !ByteString
}
data SymmetricKeys = SymmetricKeys
{ symmetricEncKey :: !ByteString,
symmetricMacKey :: !ByteString
}
deriving (Eq, Show)

instance Serialize SymmetricKeys where
Expand Down
22 changes: 10 additions & 12 deletions libs/api-bot/src/Network/Wire/Bot/Email.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ import Network.HaskellNet.IMAP.Connection
import Network.HaskellNet.IMAP.SSL
import Network.Wire.Client.API.User

data MailboxSettings
= MailboxSettings
{ mailboxHost :: String,
mailboxUser :: Email,
mailboxPassword :: String,
mailboxConnections :: Int
}
data MailboxSettings = MailboxSettings
{ mailboxHost :: String,
mailboxUser :: Email,
mailboxPassword :: String,
mailboxConnections :: Int
}

instance FromJSON MailboxSettings where
parseJSON = withObject "mailbox-settings" $ \o ->
Expand All @@ -62,11 +61,10 @@ instance FromJSON MailboxSettings where
<*> o .: "pass"
<*> o .: "conn"

data Mailbox
= Mailbox
{ mailboxSettings :: MailboxSettings,
mailboxPool :: Pool IMAPConnection
}
data Mailbox = Mailbox
{ mailboxSettings :: MailboxSettings,
mailboxPool :: Pool IMAPConnection
}

data MailException
= -- | Missing e-mail headers needed for automation.
Expand Down
105 changes: 50 additions & 55 deletions libs/api-bot/src/Network/Wire/Bot/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,19 @@ import qualified System.Random.MWC as MWC

-- * BotNetEnv

data BotNetEnv
= BotNetEnv
{ botNetGen :: MWC.GenIO,
botNetMailboxes :: [Mailbox],
botNetSender :: Email,
botNetUsers :: Cache,
botNetServer :: Server,
botNetLogger :: Logger,
botNetAssert :: !Bool,
botNetSettings :: BotSettings,
botNetMetrics :: Metrics,
botNetReportDir :: Maybe FilePath,
botNetMailboxFolders :: [String]
}
data BotNetEnv = BotNetEnv
{ botNetGen :: MWC.GenIO,
botNetMailboxes :: [Mailbox],
botNetSender :: Email,
botNetUsers :: Cache,
botNetServer :: Server,
botNetLogger :: Logger,
botNetAssert :: !Bool,
botNetSettings :: BotSettings,
botNetMetrics :: Metrics,
botNetReportDir :: Maybe FilePath,
botNetMailboxFolders :: [String]
}

newBotNetEnv :: Manager -> Logger -> BotNetSettings -> IO BotNetEnv
newBotNetEnv manager logger o = do
Expand Down Expand Up @@ -322,25 +321,24 @@ runBotSession b (BotSession s) = liftBotNet $ runReaderT s b
newtype BotTag = BotTag {unTag :: Text}
deriving (Eq, Show, IsString)

data Bot
= Bot
{ botTag :: BotTag,
botSettings :: BotSettings,
botUser :: User,
-- TODO: Move into BotClient?
botAuth :: IORef (Auth, UTCTime),
botEvents :: TVar (Word16, [(UTCTime, Event)]),
botAsserts :: TQueue EventAssertion,
botBacklog :: TVar [EventAssertion],
botAssertCount :: TVar Word16,
botPushThread :: IORef (Maybe (Async ())),
botHeartThread :: IORef (Maybe (Async ())),
botAssertThread :: IORef (Maybe (Async ())),
botMetrics :: BotMetrics,
-- END TODO
botClients :: TVar [BotClient], -- TODO: IORef?
botPassphrase :: PlainTextPassword
}
data Bot = Bot
{ botTag :: BotTag,
botSettings :: BotSettings,
botUser :: User,
-- TODO: Move into BotClient?
botAuth :: IORef (Auth, UTCTime),
botEvents :: TVar (Word16, [(UTCTime, Event)]),
botAsserts :: TQueue EventAssertion,
botBacklog :: TVar [EventAssertion],
botAssertCount :: TVar Word16,
botPushThread :: IORef (Maybe (Async ())),
botHeartThread :: IORef (Maybe (Async ())),
botAssertThread :: IORef (Maybe (Async ())),
botMetrics :: BotMetrics,
-- END TODO
botClients :: TVar [BotClient], -- TODO: IORef?
botPassphrase :: PlainTextPassword
}

instance Show Bot where
showsPrec _ b =
Expand All @@ -356,13 +354,12 @@ instance Show Bot where
instance Eq Bot where
a == b = botId a == botId b

data BotClient
= BotClient
{ botClientId :: !ClientId,
botClientLabel :: !(Maybe Text),
botClientBox :: !Box,
botClientSessions :: !Clients -- TODO: Map UserId (Map ClientId Session)
}
data BotClient = BotClient
{ botClientId :: !ClientId,
botClientLabel :: !(Maybe Text),
botClientBox :: !Box,
botClientSessions :: !Clients -- TODO: Map UserId (Map ClientId Session)
}

instance Eq BotClient where
a == b = botClientId a == botClientId b
Expand Down Expand Up @@ -518,14 +515,13 @@ withCachedBot t f = do
-------------------------------------------------------------------------------
-- Assertions

data EventAssertion
= EventAssertion
{ _assertType :: !EventType,
_assertTime :: !UTCTime,
_assertPred :: Event -> Bool,
_assertOut :: !(Maybe (TMVar (Maybe Event))),
_assertStack :: !CallStack
}
data EventAssertion = EventAssertion
{ _assertType :: !EventType,
_assertTime :: !UTCTime,
_assertPred :: Event -> Bool,
_assertOut :: !(Maybe (TMVar (Maybe Event))),
_assertStack :: !CallStack
}

whenAsserts :: MonadBotNet m => BotNet () -> m ()
whenAsserts ma = liftBotNet $ do
Expand Down Expand Up @@ -890,13 +886,12 @@ decrBotsAlive :: MonadBotNet m => m ()
decrBotsAlive = getMetrics >>= liftIO . Metrics.gaugeDecr Metrics.botsAlive

-- Note: Separate TVars to avoid contention.
data BotMetrics
= BotMetrics
{ botEventsRcvd :: TVar (HashMap Metrics.Path Double),
botEventsAckd :: TVar (HashMap Metrics.Path Double),
botEventsIgnd :: TVar (HashMap Metrics.Path Double),
botEventsMssd :: TVar (HashMap Metrics.Path Double)
}
data BotMetrics = BotMetrics
{ botEventsRcvd :: TVar (HashMap Metrics.Path Double),
botEventsAckd :: TVar (HashMap Metrics.Path Double),
botEventsIgnd :: TVar (HashMap Metrics.Path Double),
botEventsMssd :: TVar (HashMap Metrics.Path Double)
}

newBotMetrics :: IO BotMetrics
newBotMetrics =
Expand Down
35 changes: 16 additions & 19 deletions libs/api-bot/src/Network/Wire/Bot/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ import Network.Wire.Client.API.Push (EventType (..), eventTypeText)

-- * Create Reports

data Report
= Report
{ reportTitle :: !Text,
reportDate :: !UTCTime,
reportSections :: [Section],
_data :: !Data
}
data Report = Report
{ reportTitle :: !Text,
reportDate :: !UTCTime,
reportSections :: [Section],
_data :: !Data
}
deriving (Eq)

-- | Create a 'Report' of the metrics in the given 'Section's.
Expand Down Expand Up @@ -90,13 +89,12 @@ createReport t m (SectionS (Endo f)) = do

-- * Access Report Data

data Data
= Data
{ _counters :: HashMap Path Double,
_labels :: HashMap Path Text,
_histograms :: HashMap Path (Map Bucket Int),
_gauges :: HashMap Path Double
}
data Data = Data
{ _counters :: HashMap Path Double,
_labels :: HashMap Path Text,
_histograms :: HashMap Path (Map Bucket Int),
_gauges :: HashMap Path Double
}
deriving (Eq)

instance Semigroup Data where
Expand Down Expand Up @@ -124,11 +122,10 @@ reportBucket r p = fromMaybe mempty $ HashMap.lookup p (_histograms (_data r))

newtype SectionS = SectionS (Endo [Section]) deriving (Semigroup, Monoid)

data Section
= Section
{ sectionName :: !Text,
sectionMetrics :: [Metric]
}
data Section = Section
{ sectionName :: !Text,
sectionMetrics :: [Metric]
}
deriving (Eq)

data Metric
Expand Down
42 changes: 20 additions & 22 deletions libs/api-bot/src/Network/Wire/Bot/Settings.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,20 @@ import Options.Applicative
-------------------------------------------------------------------------------
-- BotNetSettings

data BotNetSettings
= BotNetSettings
{ setBotNetApiHost :: !ByteString,
setBotNetApiPort :: !Word16,
setBotNetApiWsHost :: !(Maybe ByteString),
setBotNetApiWsPort :: !(Maybe Word16),
setBotNetApiSSL :: !Bool,
setBotNetAssert :: !Bool,
setBotNetMailboxConfig :: !(Maybe FilePath),
setBotNetSender :: !Email,
setBotNetUsersFile :: !(Maybe FilePath),
setBotNetReportDir :: !(Maybe FilePath),
setBotNetBotSettings :: !BotSettings,
setBotNetMailboxFolders :: ![String]
}
data BotNetSettings = BotNetSettings
{ setBotNetApiHost :: !ByteString,
setBotNetApiPort :: !Word16,
setBotNetApiWsHost :: !(Maybe ByteString),
setBotNetApiWsPort :: !(Maybe Word16),
setBotNetApiSSL :: !Bool,
setBotNetAssert :: !Bool,
setBotNetMailboxConfig :: !(Maybe FilePath),
setBotNetSender :: !Email,
setBotNetUsersFile :: !(Maybe FilePath),
setBotNetReportDir :: !(Maybe FilePath),
setBotNetBotSettings :: !BotSettings,
setBotNetMailboxFolders :: ![String]
}
deriving (Eq, Show)

botNetSettingsParser :: Parser BotNetSettings
Expand Down Expand Up @@ -164,13 +163,12 @@ mailboxFoldersOption =
-------------------------------------------------------------------------------
-- BotSettings

data BotSettings
= BotSettings
{ _botMaxEvents :: Word16,
_botEventTimeout :: NominalDiffTime,
_botMaxAsserts :: Word16,
_botAssertTimeout :: NominalDiffTime
}
data BotSettings = BotSettings
{ _botMaxEvents :: Word16,
_botEventTimeout :: NominalDiffTime,
_botMaxAsserts :: Word16,
_botAssertTimeout :: NominalDiffTime
}
deriving (Eq, Show)

defBotSettings :: BotSettings
Expand Down
9 changes: 4 additions & 5 deletions libs/api-client/src/Network/Wire/Client/API/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ import Web.Cookie (parseSetCookie)

newtype AuthCookie = AuthCookie Cookie

data Auth
= Auth
{ authCookie :: !AuthCookie,
authToken :: !AccessToken
}
data Auth = Auth
{ authCookie :: !AuthCookie,
authToken :: !AccessToken
}

-------------------------------------------------------------------------------
-- Unauthenticated
Expand Down
22 changes: 10 additions & 12 deletions libs/api-client/src/Network/Wire/Client/API/Push.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ import qualified System.Logger as Log

newtype NotifId = NotifId UUID deriving (Eq, Show)

data Notification
= Notification
{ notifId :: NotifId,
notifEvents :: [Event]
}
data Notification = Notification
{ notifId :: NotifId,
notifEvents :: [Event]
}

awaitNotifications ::
(MonadSession m, Functor m) =>
Expand Down Expand Up @@ -190,13 +189,12 @@ instance Show Event where
show (EOtrMessage x) = "EOtrMessage: " ++ show x

-- | An event in a 'Conversation'.
data ConvEvent a
= ConvEvent
{ convEvtConv :: !ConvId,
convEvtFrom :: !UserId,
convEvtTime :: !UTCTime,
convEvtData :: !a
}
data ConvEvent a = ConvEvent
{ convEvtConv :: !ConvId,
convEvtFrom :: !UserId,
convEvtTime :: !UTCTime,
convEvtData :: !a
}
deriving (Eq, Show)

data NoData = NoData deriving (Show)
Expand Down
13 changes: 6 additions & 7 deletions libs/api-client/src/Network/Wire/Client/API/Search.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ import Network.HTTP.Types.Status (status200)
import Network.Wire.Client.HTTP
import Network.Wire.Client.Session

data SearchParams
= SearchParams
{ searchText :: !Text,
searchDistance :: !Word8,
searchLimit :: !Word8,
searchDirectory :: !Bool
}
data SearchParams = SearchParams
{ searchText :: !Text,
searchDistance :: !Word8,
searchLimit :: !Word8,
searchDirectory :: !Bool
}
deriving (Show)

instance Default SearchParams where
Expand Down
Loading

0 comments on commit f80faf3

Please sign in to comment.