module Eventloop.Module.StdOut.StdOut
    ( defaultStdOutModuleConfiguration
    , stdOutModuleIdentifier
    , stdOutEventSender
    ) where

import System.IO

import Eventloop.Types.EventTypes
import Eventloop.Module.StdOut.Types

defaultStdOutModuleConfiguration :: EventloopModuleConfiguration
defaultStdOutModuleConfiguration = ( EventloopModuleConfiguration 
                                    stdOutModuleIdentifier
                                    NoState
                                    Nothing
                                    Nothing
                                    Nothing
                                    Nothing
                                    Nothing
                                    (Just stdOutEventSender)
                                  )

stdOutModuleIdentifier :: EventloopModuleIdentifier
stdOutModuleIdentifier = "stdout"


stdOutEventSender :: EventSender
stdOutEventSender sharedIO state (OutStdOut (StdOutMessage str)) = do
                                                                    putStr str
                                                                    hFlush stdout
                                                                    return (sharedIO, state)