module Monky.Examples.Connectivity
( getConnH
, Conn
)
where
import Data.Composition ((.:))
import Data.Text (Text)
import Monky.Modules
import Monky.Connectivity hiding (getConnH)
import qualified Monky.Connectivity as C (getConnH)
showCon :: Bool -> Text
showCon False = "Unconnected"
showCon True = " Connected"
newtype Conn = Conn ConnHandle
getConnH
:: String
-> Int
-> IO Conn
getConnH = fmap Conn .: C.getConnH
instance PollModule Conn where
getOutput (Conn h) = fmap (\e -> [MonkyPlain $ showCon e]) $ hasConn h