Skip to content

Commit

Permalink
Fix the nix develop shell (#130)
Browse files Browse the repository at this point in the history
`crypton` wasn't in the `nixpkgs` revision we were using, I guess.

---------

Co-authored-by: Noah Luck Easterly <[email protected]>
  • Loading branch information
9999years and rampion authored Jan 9, 2024
1 parent 46dce3e commit cf536f4
Show file tree
Hide file tree
Showing 30 changed files with 566 additions and 427 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 9 additions & 38 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
let
ghcVer = "ghc924";
ghcVer = "ghc948";
makeHaskellOverlay = overlay: final: prev: {
haskell = prev.haskell // {
packages = prev.haskell.packages // {
Expand Down Expand Up @@ -85,16 +85,14 @@
haskellPackages.shellFor {
packages = p: [ self.packages.${system}.slack-web ];
withHoogle = true;
buildInputs = with haskellPackages; [
haskell-language-server
fourmolu
# jacked on this particular nixpkgs version
# ghcid
cabal-install
fast-tags
] ++ (with pkgs; [
sqlite
]);
buildInputs = [
haskellPackages.haskell-language-server
haskellPackages.fourmolu
haskellPackages.cabal-install
haskellPackages.fast-tags
] ++ [
pkgs.sqlite
];
shellHook = self.checks.${system}.pre-commit-check.shellHook;
};
};
Expand All @@ -103,35 +101,8 @@
# this stuff is *not* per-system
overlays = {
default = makeHaskellOverlay (prev: hfinal: hprev:
let hlib = prev.haskell.lib; in
{
slack-web = hprev.callCabal2nix "slack-web" ./. { };
# test-suite doesn't compile; probably fixed in a newer nixpkgs,
# but there's other jackage on newer nixpkgs such as the ghcid bug:
# https://github.com/NixOS/nixpkgs/issues/140774#issuecomment-1186546139
# and the fourmolu/ormolu bug:
# https://github.com/tweag/ormolu/issues/927
mutable-containers = hlib.dontCheck hprev.mutable-containers;

# 0.6.3 in the repo
refined = hfinal.refined_0_7;

pretty-simple = hfinal.callHackageDirect
{
pkg = "pretty-simple";
ver = "4.1.2.0";
sha256 = "sha256-uM1oyi/isWMicKPIw0KKeRJzY8Zu5yQNE0A2mpeBPHg=";
}
{ };

# it's not yet in hackage2nix
string-variants = hfinal.callHackageDirect
{
pkg = "string-variants";
ver = "0.1.0.1";
sha256 = "sha256-7oNYwPP8xRNYxKNdNH+21zBHdeUeiWBtKOK5G43xtSQ=";
}
{ };
});
};
};
Expand Down
10 changes: 6 additions & 4 deletions main/cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ main = do

addCmd "conversations.history" $ do
conversationId <-
Slack.ConversationId . Text.pack
Slack.ConversationId
. Text.pack
<$> addParamString "CONVERSATION_ID" (paramHelpStr "ID of the conversation to fetch")
getsAll <- addSimpleBoolFlag "A" ["all"] (flagHelpStr "Get all available messages in the channel")
addCmdImpl $
if getsAll
addCmdImpl
$ if getsAll
then do
(`runReaderT` apiConfig) $ do
fetchPage <- Slack.conversationsHistoryAll $ (SlackConversation.mkHistoryReq conversationId) {SlackConversation.historyReqCount = 2}
Expand Down Expand Up @@ -101,7 +102,8 @@ main = do

addCmd "conversations.replies" $ do
conversationId <-
Slack.ConversationId . Text.pack
Slack.ConversationId
. Text.pack
<$> addParamString "CONVERSATION_ID" (paramHelpStr "ID of the conversation to fetch")
threadTimeStampStr <- addParamString "TIMESTAMP" (paramHelpStr "Timestamp of the thread to fetch")
let ethreadTimeStamp = Slack.timestampFromText $ Text.pack threadTimeStampStr
Expand Down
4 changes: 3 additions & 1 deletion slack-web.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 2.2
name: slack-web
version: 2.0.0.0
version: 2.0.0.1

build-type: Simple

Expand Down Expand Up @@ -186,6 +186,7 @@ test-suite tests
Web.Slack.Experimental.RequestVerificationSpec
Web.Slack.Experimental.Events.TypesSpec
Web.Slack.Experimental.BlocksSpec
Web.Slack.Experimental.Blocks.TypesSpec
TestImport
TestImport.Aeson
build-tool-depends:
Expand All @@ -205,6 +206,7 @@ test-suite tests
, mtl
, pretty-simple ^>= 4.1
, quickcheck-instances
, refined
, slack-web
, string-conversions
, string-variants
Expand Down
55 changes: 27 additions & 28 deletions src/Web/Slack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,33 @@
-- *Since 0.4.0.0*: The API functions is now more intuitive for newbies
-- than before. If you need compatiblity with the previous version, use
-- 'Web.Slack.Classy' instead.
module Web.Slack
( SlackConfig (..),
mkSlackConfig,

-- * Endpoints
apiTest,
authTest,
chatPostMessage,
chatUpdate,
conversationsList,
conversationsListAll,
conversationsHistory,
conversationsHistoryAll,
conversationsReplies,
repliesFetchAll,
getUserDesc,
usersList,
usersListAll,
userLookupByEmail,
UsersConversations.usersConversations,
UsersConversations.usersConversationsAll,

-- * Requests and responses
authenticateReq,
Response,
LoadPage,
)
where
module Web.Slack (
SlackConfig (..),
mkSlackConfig,

-- * Endpoints
apiTest,
authTest,
chatPostMessage,
chatUpdate,
conversationsList,
conversationsListAll,
conversationsHistory,
conversationsHistoryAll,
conversationsReplies,
repliesFetchAll,
getUserDesc,
usersList,
usersListAll,
userLookupByEmail,
UsersConversations.usersConversations,
UsersConversations.usersConversationsAll,

-- * Requests and responses
authenticateReq,
Response,
LoadPage,
) where

-- FIXME: Web.Slack.Prelude

Expand Down
4 changes: 2 additions & 2 deletions src/Web/Slack/AesonUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ objectOptional :: [Maybe Pair] -> Value
objectOptional = J.object . catMaybes

-- | Encode a value for 'objectOptional'
(.=!) :: ToJSON v => Key -> v -> Maybe Pair
(.=!) :: (ToJSON v) => Key -> v -> Maybe Pair
key .=! val = Just (key .= val)

infixr 8 .=!

-- | Encode a Maybe value for 'objectOptional'
(.=?) :: ToJSON v => Key -> Maybe v -> Maybe Pair
(.=?) :: (ToJSON v) => Key -> Maybe v -> Maybe Pair
key .=? mVal = fmap (key .=) mVal

infixr 8 .=?
Expand Down
11 changes: 5 additions & 6 deletions src/Web/Slack/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
-- |
-- Module: Web.Slack.Api
-- Description:
module Web.Slack.Api
( TestReq (..),
mkTestReq,
TestRsp (..),
)
where
module Web.Slack.Api (
TestReq (..),
mkTestReq,
TestRsp (..),
) where

-- FIXME: Web.Slack.Prelude

Expand Down
19 changes: 9 additions & 10 deletions src/Web/Slack/Chat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

module Web.Slack.Chat
( PostMsg (..),
PostMsgReq (..),
mkPostMsgReq,
PostMsgRsp (..),
UpdateReq (..),
mkUpdateReq,
UpdateRsp (..),
)
where
module Web.Slack.Chat (
PostMsg (..),
PostMsgReq (..),
mkPostMsgReq,
PostMsgRsp (..),
UpdateReq (..),
mkUpdateReq,
UpdateRsp (..),
) where

import Web.FormUrlEncoded
import Web.Slack.Conversation (ConversationId)
Expand Down
41 changes: 20 additions & 21 deletions src/Web/Slack/Classy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@
-- |
-- Module: Web.Slack.Classy
-- Description: For compatibility with Web.Slack prior to v0.4.0.0.
module Web.Slack.Classy
( SlackConfig (..),
mkSlackConfig,
apiTest,
authTest,
chatPostMessage,
conversationsList,
conversationsHistory,
conversationsHistoryAll,
conversationsReplies,
repliesFetchAll,
getUserDesc,
usersList,
userLookupByEmail,
authenticateReq,
Response,
LoadPage,
HasManager (..),
HasToken (..),
)
where
module Web.Slack.Classy (
SlackConfig (..),
mkSlackConfig,
apiTest,
authTest,
chatPostMessage,
conversationsList,
conversationsHistory,
conversationsHistoryAll,
conversationsReplies,
repliesFetchAll,
getUserDesc,
usersList,
userLookupByEmail,
authenticateReq,
Response,
LoadPage,
HasManager (..),
HasToken (..),
) where

import Data.Map qualified as Map
import Network.HTTP.Client (Manager)
Expand Down
29 changes: 14 additions & 15 deletions src/Web/Slack/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
-- |
-- Module: Web.Slack.Common
-- Description:
module Web.Slack.Common
( Color (..),
UserId (..),
ConversationId (..),
TeamId (..),
Cursor (..),
SlackTimestamp (..),
mkSlackTimestamp,
timestampFromText,
Message (..),
MessageType (..),
SlackClientError (..),
SlackMessageText (..),
)
where
module Web.Slack.Common (
Color (..),
UserId (..),
ConversationId (..),
TeamId (..),
Cursor (..),
SlackTimestamp (..),
mkSlackTimestamp,
timestampFromText,
Message (..),
MessageType (..),
SlackClientError (..),
SlackMessageText (..),
) where

-- FIXME: Web.Slack.Prelude

Expand Down
43 changes: 21 additions & 22 deletions src/Web/Slack/Conversation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,26 @@
-- |
-- Module: Web.Slack.Channel
-- Description: Types and functions related to <https://api.slack.com/docs/conversations-api Conversation API>
module Web.Slack.Conversation
( Conversation (..),
ConversationId (..),
ConversationType (..),
ChannelConversation (..),
GroupConversation (..),
ImConversation (..),
TeamId (..),
Purpose (..),
Topic (..),
ListReq (..),
mkListReq,
ListRsp (..),
HistoryReq (..),
mkHistoryReq,
HistoryRsp (..),
RepliesReq (..),
mkRepliesReq,
ResponseMetadata (..),
)
where
module Web.Slack.Conversation (
Conversation (..),
ConversationId (..),
ConversationType (..),
ChannelConversation (..),
GroupConversation (..),
ImConversation (..),
TeamId (..),
Purpose (..),
Topic (..),
ListReq (..),
mkListReq,
ListRsp (..),
HistoryReq (..),
mkHistoryReq,
HistoryRsp (..),
RepliesReq (..),
mkRepliesReq,
ResponseMetadata (..),
) where

import Data.Aeson
import Data.Aeson.Encoding
Expand Down Expand Up @@ -209,7 +208,7 @@ instance FromJSON Conversation where
-- This uses the outer Parser monad since deciding which parser to use
-- is monadic, then the Maybe to decide which parser is picked, then
-- finally the inner parser to actually run it
parseWhen :: FromJSON a => Key -> (a -> b) -> Object -> Parser (Maybe (Parser b))
parseWhen :: (FromJSON a) => Key -> (a -> b) -> Object -> Parser (Maybe (Parser b))
parseWhen key con o = do
-- Slack only inconsistently includes the is_* attributes if false.
is <- o .:? key .!= False
Expand Down
Loading

0 comments on commit cf536f4

Please sign in to comment.