packages feed

free-game 0.3.2.3 → 0.3.2.4

raw patch · 4 files changed

+21/−8 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Graphics.FreeGame.Util: untick :: MonadFree GameAction m => Free GameAction a -> m (Either (Free GameAction a) a)
+ Graphics.FreeGame.Util: untickInfinite :: MonadFree GameAction m => Free GameAction Void -> m (Free GameAction Void)
- Graphics.FreeGame.Simple: untickGame :: Free GameAction a -> Free GameAction (Free GameAction a)
+ Graphics.FreeGame.Simple: untickGame :: MonadFree GameAction m => Free GameAction a -> m (Free GameAction a)
- Graphics.FreeGame.Util: untickGame :: Free GameAction a -> Free GameAction (Free GameAction a)
+ Graphics.FreeGame.Util: untickGame :: MonadFree GameAction m => Free GameAction a -> m (Free GameAction a)

Files

Graphics/FreeGame.hs view
@@ -15,6 +15,7 @@     module Graphics.FreeGame.Base,
     module Graphics.FreeGame.Data.Bitmap,
     module Graphics.FreeGame.Data.Font,
+    module Graphics.FreeGame.Data.Color,
     module Graphics.FreeGame.Input,
     module Graphics.FreeGame.Util,
     runGame,
@@ -26,6 +27,7 @@ import Graphics.FreeGame.Util
 import Graphics.FreeGame.Data.Bitmap
 import Graphics.FreeGame.Data.Font
+import Graphics.FreeGame.Data.Color
 import qualified Graphics.FreeGame.Backends.GLFW as GLFW
 import Control.Monad.Free
 
Graphics/FreeGame/Backends/GLFW.hs view
@@ -9,7 +9,7 @@ -- Portability :  non-portable
 --
 ----------------------------------------------------------------------------
-{-# LANGUAGE ImplicitParams, ScopedTypeVariables, Rank2Types #-}
+{-# LANGUAGE ImplicitParams, ScopedTypeVariables, Rank2Types, FlexibleContexts #-}
 {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-}
 module Graphics.FreeGame.Backends.GLFW (runGame, runGame') where
 import Control.Applicative
Graphics/FreeGame/Util.hs view
@@ -11,7 +11,7 @@ --
 ----------------------------------------------------------------------------
 
-module Graphics.FreeGame.Util (untickGame, randomness, degrees, radians, loadPictureFromFile, loadBitmaps) where
+module Graphics.FreeGame.Util (untick, untickGame, untickInfinite, randomness, degrees, radians, loadPictureFromFile, loadBitmaps) where
 import Control.Monad
 import Control.Monad.Free
 import Data.Char
@@ -21,13 +21,24 @@ import Language.Haskell.TH
 import System.Directory
 import System.IO.Unsafe
+import Data.Void
 
+untickGame :: MonadFree GameAction m => Free GameAction a -> m (Free GameAction a)
+untickGame (Pure a) = return (Pure a)
+untickGame (Free (Tick cont)) = return cont
+untickGame (Free fm) = wrap $ fmap untickGame fm
+{-# DEPRECATED untickGame "use untick or untickInfinite instead" #-}
+
 -- | Run a 'Game' as one frame.
-untickGame :: Free GameAction a -> Free GameAction (Free GameAction a)
-untickGame (Pure a) = Pure (Pure a)
-untickGame (Free (Tick cont)) = Pure cont
-untickGame (Free fm) = Free $ fmap untickGame fm
+untick :: MonadFree GameAction m => Free GameAction a -> m (Either (Free GameAction a) a)
+untick (Pure a) = return (Right a)
+untick (Free (Tick cont)) = return (Left cont)
+untick (Free f) = wrap $ fmap untick f
 
+-- | An infinite version of 'untick'.
+untickInfinite :: MonadFree GameAction m => Free GameAction Void -> m (Free GameAction Void)
+untickInfinite = liftM (either id absurd) . untick
+
 -- | Get a given range of value.
 randomness :: (Random r, MonadFree GameAction m) => (r, r) -> m r
 randomness r = embedIO $ randomRIO r
@@ -57,7 +68,7 @@             runIO $ putStrLn $ "Defined: " ++ fp ++ " as `" ++ name ++ "'"
             appE (varE 'unsafePerformIO) $ appE (varE 'loadBitmapFromFile) (litE $ StringL fp)
 
-getFileList :: Prelude.FilePath -> IO [FilePath]
+getFileList :: FilePath -> IO [FilePath]
 getFileList path = do
     allContents <- filter notHidden `fmap` getDirectoryContents path
     files <- filterM (doesFileExist . (path</>)) allContents
free-game.cabal view
@@ -1,5 +1,5 @@ name:                free-game
-version:             0.3.2.3
+version:             0.3.2.4
 synopsis:            Create graphical applications for free.
 description:         Cross-platform GUI library based on free monads
 homepage:            https://github.com/fumieval/free-game