Some cleanup

This commit is contained in:
Mats Rauhala 2021-10-27 21:10:22 +03:00
parent c200e5c98c
commit af538b9aa2
4 changed files with 19 additions and 17 deletions

View File

@ -1,8 +1,8 @@
module Main where
import qualified MyLib (someFunc)
import qualified MyLib (defaultMain)
main :: IO ()
main = do
putStrLn "Hello, Haskell!"
MyLib.someFunc
MyLib.defaultMain

View File

@ -26,7 +26,7 @@ library
exposed-modules: MyLib
Data.Config
Data.Deriving.Aeson
Network.AMQP.Reddit
Network.Reddit
Data.SubReddit
Publish

View File

@ -1,32 +1,34 @@
{-# LANGUAGE OverloadedStrings #-}
module MyLib (someFunc) where
module MyLib (defaultMain) where
import Control.Exception (bracket)
import Control.Lens
import Data.Config
import qualified Data.Text.Strict.Lens as T
import Network.AMQP
import Network.AMQP.Reddit (publishEntries)
import Network.Wreq.Session (newSession)
import Data.Text (Text)
import qualified Data.ByteString.Lazy as LB
import Control.Monad (void)
import qualified Data.Aeson as A
import Data.Functor.Contravariant ((>$<))
import Publish (Publish(..))
import qualified Data.ByteString.Lazy as LB
import Data.Config
import Data.Foldable (for_)
import Data.Functor.Contravariant ((>$<))
import Data.Text (Text)
import qualified Data.Text.Strict.Lens as T
import Network.AMQP
import Network.Reddit (publishEntries)
import Network.Wreq.Session (newSession)
import Publish (Publish(..))
amqpPublisher :: Channel -> Text -> Publish IO LB.ByteString
amqpPublisher channel exchange = Publish $ \lbs -> void $ publishMsg channel exchange "" (message lbs)
amqpPublisher channel exchange = Publish $ \lbs ->
void $ publishMsg channel exchange routingKey (message lbs)
where
routingKey = "doesn't matter on fanout"
message lbs = newMsg
{ msgBody = lbs
, msgDeliveryMode = Just Persistent
}
someFunc :: IO ()
someFunc = do
defaultMain :: IO ()
defaultMain = do
conf <- readConfig "./config.dhall"
let connect = openConnection
(conf ^. amqp . host . T.unpacked)

View File

@ -5,7 +5,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeOperators #-}
module Network.AMQP.Reddit where
module Network.Reddit where
import Control.Lens
import Data.Aeson (FromJSON, ToJSON, Value)