-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Model-view-controller -- -- Use the mvc library to distill concurrent programs into pure -- and single-threaded programs using the -- Model-View-Controller pattern. This -- transformation lets you: -- -- @package mvc @version 1.0.2 -- | Use the Model - View - Controller pattern to -- separate impure inputs and outputs from pure application logic so that -- you can: -- -- -- -- The mvc library uses the type system to statically enforce -- the separation of impure Views and Controllers from the -- pure Model. -- -- Here's a small example program written using the mvc library -- to illustrate the core types and concepts: -- --
--   import MVC
--   import qualified MVC.Prelude as MVC
--   import qualified Pipes.Prelude as Pipes
--   
--   external :: Managed (View String, Controller String)
--   external = do
--       c1 <- MVC.stdinLines
--       c2 <- MVC.tick 1
--       return (MVC.stdoutLines, c1 <> fmap show c2)
--   
--   model :: Model () String String
--   model = asPipe (Pipes.takeWhile (/= "quit"))
--       
--   main :: IO ()
--   main = runMVC () model external
--   
-- -- This program has three components: -- -- -- -- runMVC connects them into a complete program, which outputs a -- () every second and also echoes standard input to standard -- output until the user enters "quit": -- --
--   >>> main
--   ()
--   Test<Enter>
--   Test
--   ()
--   ()
--   42<Enter>
--   42
--   ()
--   quit<enter>
--   
--   >>> 
--   
-- -- The following sections give extended guidance for how to structure -- mvc programs. Additionally, there is an MVC.Prelude -- module, which provides several utilities and provides a more elaborate -- code example using the sdl library. module MVC -- | A concurrent source -- --
--   fmap f (c1 <> c2) = fmap f c1 <> fmap f c2
--   
--   fmap f mempty = mempty
--   
data Controller a -- | Create a Controller from an Input asInput :: Input a -> Controller a -- | Think of the type as one of the following types: -- --
--   keeps :: Prism'     a b -> Controller a -> Controller b
--   keeps :: Traversal' a b -> Controller a -> Controller b
--   
-- -- (keeps prism controller) only emits values if the -- prism matches the controller's output. -- --
--   keeps (p1 . p2) = keeps p2 . keeps p1
--   
--   keeps id = id
--   
-- --
--   keeps p (c1 <> c2) = keeps p c1 <> keeps p c2
--   
--   keeps p mempty = mempty
--   
keeps :: ((b -> Constant (First b) b) -> (a -> Constant (First b) a)) -> Controller a -> Controller b -- | An effectful sink -- --
--   contramap f (v1 <> v2) = contramap f v1 <> contramap f v2
--   
--   contramap f mempty = mempty
--   
data View a -- | Create a View from a sink asSink :: (a -> IO ()) -> View a -- | Think of the type as one of the following types: -- --
--   handles :: Prism'     a b -> View b -> View a
--   handles :: Traversal' a b -> View b -> View a
--   
-- -- (handles prism view) only runs the view if the -- prism matches the input. -- --
--   handles (p1 . p2) = handles p1 . handles p2
--   
--   handles id = id
--   
-- --
--   handles p (v1 <> v2) = handles p v1 <> handles p v2
--   
--   handles p mempty = mempty
--   
handles :: ((b -> Constant (First b) b) -> (a -> Constant (First b) a)) -> View b -> View a -- | A (Model s a b) converts a stream of (a)s into a -- stream of (b)s while interacting with a state (s) data Model s a b -- | Create a Model from a Pipe -- --
--   asPipe (p1 <-< p2) = asPipe p1 . asPipe p2
--   
--   asPipe cat = id
--   
asPipe :: Pipe a b (State s) () -> Model s a b -- | Connect a Model, View, and Controller and initial -- state into a complete application. runMVC :: s -> Model s a b -> Managed (View b, Controller a) -> IO s -- | A managed resource that you acquire using with data Managed a :: * -> * -- | Build a Managed value managed :: (forall r. (a -> IO r) -> IO r) -> Managed a -- | Create a Pipe from a ListT transformation -- --
--   loop (k1 >=> k2) = loop k1 >-> loop k2
--   
--   loop return = cat
--   
loop :: Monad m => (a -> ListT m b) -> Pipe a b m r instance Category (Model s) instance Contravariant View instance Monoid (View a) instance Monoid (Controller a) instance Functor Controller -- | Simple utilities -- -- The "Example" section at the bottom of this module contains an -- extended example of how to interact with the sdl library -- using the mvc library module MVC.Prelude -- | Create a Controller from a Producer, using the given -- Buffer -- -- If you're not sure what Buffer to use, try Single producer :: Buffer a -> Producer a IO () -> Managed (Controller a) -- | Read lines from standard input stdinLines :: Managed (Controller String) -- | Read lines from a file inLines :: FilePath -> Managed (Controller String) -- | read values from a file, one value per line, skipping failed -- parses inRead :: Read a => FilePath -> Managed (Controller a) -- | Emit empty values spaced by a delay in seconds tick :: Double -> Managed (Controller ()) -- | Create a View from a Consumer consumer :: Consumer a IO () -> Managed (View a) -- | Write lines to standard output stdoutLines :: View String -- | Write lines to a file outLines :: FilePath -> Managed (View String) -- | show values to a file, one value per line outShow :: Show a => FilePath -> Managed (View a) -- | Read from a FilePath using a Managed Handle inHandle :: FilePath -> Managed Handle -- | Write to a FilePath using a Managed Handle outHandle :: FilePath -> Managed Handle