Some cleanup
This commit is contained in:
parent
c200e5c98c
commit
af538b9aa2
@ -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
|
||||
|
@ -26,7 +26,7 @@ library
|
||||
exposed-modules: MyLib
|
||||
Data.Config
|
||||
Data.Deriving.Aeson
|
||||
Network.AMQP.Reddit
|
||||
Network.Reddit
|
||||
Data.SubReddit
|
||||
Publish
|
||||
|
||||
|
28
src/MyLib.hs
28
src/MyLib.hs
@ -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)
|
||||
|
@ -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)
|
Loading…
Reference in New Issue
Block a user