mvc 1.1.3 → 1.1.4
raw patch · 2 files changed
+14/−18 lines, 2 filesdep ~foldldep ~pipes
Dependency ranges changed: foldl, pipes
Files
- mvc.cabal +5/−4
- src/MVC/Prelude.hs +9/−14
mvc.cabal view
@@ -1,5 +1,5 @@ Name: mvc-Version: 1.1.3+Version: 1.1.4 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3@@ -7,6 +7,7 @@ Copyright: 2014 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com+Tested-With: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2 Bug-Reports: https://github.com/Gabriel439/Haskell-MVC-Library/issues Synopsis: Model-view-controller Description: Use the @mvc@ library to distill concurrent programs into pure and@@ -29,13 +30,13 @@ base >= 4 && < 5 , async >= 2.0.0 && < 2.2, contravariant < 1.5,- foldl >= 1.1 && < 1.3,+ foldl >= 1.1 && < 1.4, managed < 1.1, mmorph >= 1.0.2 && < 1.1,- pipes >= 4.1.7 && < 4.2,+ pipes >= 4.1.7 && < 4.3.4, pipes-concurrency >= 2.0.3 && < 2.1, transformers >= 0.2.0.0 && < 0.6 Exposed-Modules: MVC, MVC.Prelude- GHC-Options: -O2 -Wall+ GHC-Options: -Wall
src/MVC/Prelude.hs view
@@ -147,6 +147,7 @@ the same initialization logic: > import Control.Monad (join)+> import Control.Monad.Managed (managed_) > import Graphics.UI.SDL as SDL > import Lens.Family.Stock (_Left, _Right) -- from `lens-family-core` > import MVC@@ -156,9 +157,10 @@ > data Done = Done deriving (Eq, Show) > > sdl :: Managed (View (Either Rect Done), Controller Event)-> sdl = join $ managed $ \k -> withInit [InitVideo, InitEventthread] $ do-> surface <- setVideoMode 640 480 32 [SWSurface]-> white <- mapRGB (surfaceGetPixelFormat surface) 255 255 255+> sdl = do+> managed_ (withInit [InitVideo, InitEventthread])+> surface <- liftIO $ setVideoMode 640 480 32 [SWSurface]+> white <- liftIO $ mapRGB (surfaceGetPixelFormat surface) 255 255 255 > > let done :: View Done > done = asSink (\Done -> SDL.quit)@@ -171,18 +173,11 @@ > totalOut :: View (Either Rect Done) > totalOut = handles _Left drawRect <> handles _Right done > -> k $ do-> totalIn <- producer Single (lift waitEvent >~ cat)-> return (totalOut, totalIn)-- Note the `Control.Monad.join` surrounding the `managed` block. This is- because the type before `Control.Monad.join` is:--> Managed (Managed (View (Either Rect Done), Controller Event))+> totalIn <- producer Single (lift waitEvent >~ cat)+> return (totalOut, totalIn) - More generally, note that `Managed` is a `Monad`, so you can use @do@- notation to combine multiple `Managed` resources into a single `Managed`- resource.+ Note that `Managed` is a `Monad`, so you can use @do@ notation to + combine multiple `Managed` resources into a single `Managed` resource. The second half of the program contains the pure logic.