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

added brittany workflow #4

Open
wants to merge 6 commits 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
14 changes: 8 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ on:

jobs:
# TODO: autoformatting
#ormolu:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: mrkkrp/ormolu-action@v4
brittany:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: tfausak/brittany-action@v1
with:
version: 0.13.1.2
build:
name: Build
runs-on: ubuntu-latest
#needs: ormolu
needs: brittany
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
Expand Down
1 change: 1 addition & 0 deletions brittany.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brittany --config-file=brittany.yaml --write-mode=inplace $(git ls-files '*.hs')
48 changes: 48 additions & 0 deletions brittany.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
conf_disable_formatting: false
conf_debug:
dconf_roundtrip_exactprint_only: false
dconf_dump_bridoc_simpl_par: false
dconf_dump_ast_unknown: false
dconf_dump_bridoc_simpl_floating: false
dconf_dump_config: false
dconf_dump_bridoc_raw: false
dconf_dump_bridoc_final: false
dconf_dump_bridoc_simpl_alt: false
dconf_dump_bridoc_simpl_indent: false
dconf_dump_annotations: false
dconf_dump_bridoc_simpl_columns: false
dconf_dump_ast_full: false
conf_forward:
options_ghc: []
conf_errorHandling:
econf_ExactPrintFallback: ExactPrintFallbackModeInline
econf_Werror: false
econf_omit_output_valid_check: false
econf_produceOutputOnErrors: false
conf_preprocessor:
ppconf_CPPMode: CPPModeAbort
ppconf_hackAroundIncludes: false
conf_obfuscate: false
conf_roundtrip_exactprint_only: false
conf_version: 1
conf_layout:
lconfig_reformatModulePreamble: true
lconfig_altChooser:
tag: AltChooserBoundedSearch
contents: 3
lconfig_allowSingleLineExportList: false
lconfig_importColumn: 50
lconfig_hangingTypeSignature: false
lconfig_importAsColumn: 50
lconfig_alignmentLimit: 30
lconfig_allowHangingQuasiQuotes: true
lconfig_indentListSpecial: true
lconfig_indentAmount: 2
lconfig_alignmentBreakOnMultiline: true
lconfig_experimentalSemicolonNewlines: false
lconfig_cols: 80
lconfig_indentPolicy: IndentPolicyFree
lconfig_indentWhereSpecial: true
lconfig_columnAlignMode:
tag: ColumnAlignModeMajority
contents: 0.7
21 changes: 10 additions & 11 deletions examples/cache.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{-# LANGUAGE OverloadedStrings #-}

import qualified Data.Text.IO as TIO
import UnliftIO (liftIO)

import Discord
import qualified Data.Text.IO as TIO
import Discord
import UnliftIO ( liftIO )

-- There's not much information in the Cache for now
-- but this program will show you what its got
Expand All @@ -13,11 +12,11 @@ cacheExample :: IO ()
cacheExample = do
tok <- TIO.readFile "./examples/auth-token.secret"

_ <- runDiscord $ def { discordToken = tok
, discordOnStart = do
cache <- readCache
liftIO $ putStrLn ("Cached info from gateway: " <> show cache)
stopDiscord
}
_ <- runDiscord $ def
{ discordToken = tok
, discordOnStart = do
cache <- readCache
liftIO $ putStrLn ("Cached info from gateway: " <> show cache)
stopDiscord
}
pure ()

34 changes: 18 additions & 16 deletions examples/gateway.hs
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
{-# LANGUAGE OverloadedStrings #-}

import Control.Monad (forever)
import Control.Concurrent (forkIO, killThread)
import UnliftIO (liftIO)
import Control.Concurrent.Chan
import qualified Data.Text.IO as TIO
import Control.Concurrent ( forkIO
, killThread
)
import Control.Concurrent.Chan
import Control.Monad ( forever )
import qualified Data.Text.IO as TIO
import UnliftIO ( liftIO )

import Discord
import Discord.Types
import Discord
import Discord.Types

-- | Prints every event as it happens
gatewayExample :: IO ()
gatewayExample = do
tok <- TIO.readFile "./examples/auth-token.secret"
tok <- TIO.readFile "./examples/auth-token.secret"

outChan <- newChan :: IO (Chan String)
outChan <- newChan :: IO (Chan String)

-- Events are processed in new threads, but stdout isn't
-- synchronized. We get ugly output when multiple threads
-- write to stdout at the same time
threadId <- forkIO $ forever $ readChan outChan >>= putStrLn

err <- runDiscord $ def { discordToken = tok
, discordOnStart = startHandler
, discordOnEvent = eventHandler outChan
, discordOnEnd = killThread threadId
}
err <- runDiscord $ def { discordToken = tok
, discordOnStart = startHandler
, discordOnEvent = eventHandler outChan
, discordOnEnd = killThread threadId
}
TIO.putStrLn err

-- Events are enumerated in the discord docs
Expand All @@ -37,8 +39,8 @@ eventHandler out event = liftIO $ writeChan out (show event <> "\n")
startHandler :: DiscordHandler ()
startHandler = do
let opts = RequestGuildMembersOpts
{ requestGuildMembersOptsGuildId = 453207241294610442
, requestGuildMembersOptsLimit = 100
{ requestGuildMembersOptsGuildId = -1
, requestGuildMembersOptsLimit = 100
, requestGuildMembersOptsNamesStartingWith = ""
}

Expand Down
Loading