diff --git a/affection.cabal b/affection.cabal index 4f38fcd..c99d070 100644 --- a/affection.cabal +++ b/affection.cabal @@ -26,7 +26,7 @@ cabal-version: >=1.10 library exposed-modules: Affection - + extensions: OverloadedStrings -- Modules included in this library but not exported. -- other-modules: @@ -37,7 +37,8 @@ library -- Other library packages from which modules are imported. build-depends: base >=4.8 && <4.9 , sdl2 - , sdl2-image + , text + -- , sdl2-image source-repository head type: git diff --git a/src/Affection.hs b/src/Affection.hs index 4dcd024..9fd2465 100644 --- a/src/Affection.hs +++ b/src/Affection.hs @@ -1,6 +1,28 @@ module Affection - ( someFunc + ( withAllAffection + , withWindow + , withDefaultWindow + , delaySec ) where -someFunc :: IO () -someFunc = putStrLn "someFunc" +import SDL +import Data.Text +import qualified Control.Concurrent as CC + +withAllAffection :: IO () -> IO () +withAllAffection ops = do + initializeAll + ops + quit + +withWindow :: Text -> WindowConfig -> (Window -> IO ()) -> IO () +withWindow title conf ops = do + window <- createWindow title conf + ops window + destroyWindow window + +withDefaultWindow :: Text -> (Window -> IO ()) -> IO () +withDefaultWindow title ops = withWindow title defaultWindow ops + +delaySec :: Int -> IO () +delaySec dur = delay (fromIntegral $ dur * 1000)