packages feed

MFlow 0.0.3 → 0.0.4

raw patch · 4 files changed

+46/−25 lines, 4 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- MFlow.Forms: instance (FormInput view, FormLet a m view, FormLet b m view) => FormLet (a, b) m view
- MFlow.Forms: instance (FormInput view, FormLet a m view, FormLet b m view, FormLet c m view) => FormLet (a, b, c) m view
- MFlow.Forms: instance (FormInput view, Monoid view, Widget a b m view) => Launchable (Form a) b m view
- MFlow.Forms: instance (FormInput view, Monoid view, Widget a b m view) => Widget (Form a) b m view
- MFlow.Forms: instance (Functor m, Monad m) => Applicative (FormT view m)
- MFlow.Forms: instance (Monad m, Functor m) => Monad (FormT view m)
- MFlow.Forms: instance (MonadIO m, Functor m) => Launchable (View view m a) a m view
- MFlow.Forms: instance (MonadIO m, Functor m) => Widget (View view m a) a m view
- MFlow.Forms: instance (MonadIO m, Functor m, FormInput view) => FormLet Bool m view
- MFlow.Forms: instance (MonadIO m, Functor m, FormInput view) => FormLet User m view
- MFlow.Forms: instance (MonadIO m, Functor m, FormInput view, Read a, Show a, Eq a, Typeable a) => Widget (Selection a view) a m view
- MFlow.Forms: instance (MonadIO m, Functor m, FormInput view, Typeable a, Show a, Read a, Eq a) => Launchable (Selection a view) a m view
- MFlow.Forms: instance FormLet a m view => Widget (Maybe a) a m view
- MFlow.Forms: instance Functor (FormElm view)
- MFlow.Forms: instance Functor m => Functor (FormT view m)
- MFlow.Forms: instance Indexable User
- MFlow.Forms: instance Read User
- MFlow.Forms: instance Show User
- MFlow.Forms: instance Typeable User
+ MFlow.Forms: instance [incoherent] (FormInput view, FormLet a m view, FormLet b m view) => FormLet (a, b) m view
+ MFlow.Forms: instance [incoherent] (FormInput view, FormLet a m view, FormLet b m view, FormLet c m view) => FormLet (a, b, c) m view
+ MFlow.Forms: instance [incoherent] (FormInput view, Monoid view, Widget a b m view) => Launchable (Form a) b m view
+ MFlow.Forms: instance [incoherent] (FormInput view, Monoid view, Widget a b m view) => Widget (Form a) b m view
+ MFlow.Forms: instance [incoherent] (Functor m, Monad m) => Applicative (FormT view m)
+ MFlow.Forms: instance [incoherent] (Monad m, Functor m) => Monad (FormT view m)
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m) => Launchable (View view m a) a m view
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m) => Widget (View view m a) a m view
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m, FormInput view) => FormLet Bool m view
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m, FormInput view) => FormLet User m view
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m, FormInput view, Read a, Show a, Eq a, Typeable a) => Widget (Selection a view) a m view
+ MFlow.Forms: instance [incoherent] (MonadIO m, Functor m, FormInput view, Typeable a, Show a, Read a, Eq a) => Launchable (Selection a view) a m view
+ MFlow.Forms: instance [incoherent] FormLet a m view => Widget (Maybe a) a m view
+ MFlow.Forms: instance [incoherent] Functor (FormElm view)
+ MFlow.Forms: instance [incoherent] Functor m => Functor (FormT view m)
+ MFlow.Forms: instance [incoherent] Indexable User
+ MFlow.Forms: instance [incoherent] Read User
+ MFlow.Forms: instance [incoherent] Show User
+ MFlow.Forms: instance [incoherent] Typeable User
- MFlow.Forms: userRegister :: String -> String -> IO (DBRef User)
+ MFlow.Forms: userRegister :: String -> String -> IO ()

Files

Demos/ShoppingCart1.hs view
@@ -2,18 +2,19 @@             -XMultiParamTypeClasses -XRecordWildCards              #-}-module Test where+module Main where import MFlow.Hack.XHtml.All  import Data.Typeable import Control.Monad.Trans import qualified Data.Vector as V -import Data.TCache-main= do-   userRegister  "pepe" "pepe"  +++main= do+   userRegister  "pepe" "pepe"    putStrLn $ options messageFlows    run 80 $ hackMessageFlow messageFlows    where@@ -40,8 +41,8 @@   -- Here an example of predefined widget (`Selection`) that return an Int, combined in the same--- page with the fromLet for the introduction of a product.--- The result is a 2-tuple of Maybes+-- page with the fromLet for the introduction of a new product.+-- The result of the interaction with the user is either one or the other result  shopProds :: V.Vector Int -> [Prod]           -> View Html IO  (Either Int Prod)
MFlow.cabal view
@@ -1,8 +1,8 @@ name: MFlow-synopsis:  (Web) application server. Stateful server processes. Simple, statically correct widget combinators.+synopsis:  Web application server with stateful, type safe user interactions and widget combinators.  -version: 0.0.3+version: 0.0.4 cabal-version: -any build-type: Simple license: BSD3@@ -30,10 +30,7 @@               Console and window oriented apps are possible.               .               MFlow (MessageFlow) was created initially as the user interface for the Workflow package-            . Currently is an alpha version. It has-              only basic authentication but I plan to inprove it for serious applications.-           .-           Examples included+              Currently is an alpha version. It has only basic authentication but I plan to inprove it for serious applications.            .            It includes Application Server features such is resource an process management            and automatic recovery@@ -49,7 +46,7 @@            directly by the programmer. Persistence in files  for session and data out of the box enables            very fast prototyping.            .-           All the plumbing is hidden to the programmer, There is no methods for+           All the plumbing is hidden to the programmer, There are no methods for            session management, database query, recovery and so on. All of this is            transparent So the surface exposed to the programmer is minimal.            .
MFlow/Forms.hs view
@@ -9,6 +9,7 @@              -XFunctionalDependencies              -XFlexibleContexts              -XRecordWildCards+             -XIncoherentInstances  #-} @@ -156,9 +157,10 @@ ,setTimeouts -- * Cookies ,setCookie-) where+)+where import Data.TCache-import Data.Persistent.Queue+--import Data.Persistent.Queue import MFlow import MFlow.Cookies import Data.RefSerialize (Serialize)@@ -171,9 +173,10 @@ import Control.Exception import Control.Workflow(exec1,Workflow, waitUntilSTM, step, unsafeIOtoWF) ---import Debug.Trace++import Debug.Trace -----(!>)= flip trace+(!>)= flip trace   type UserName=  String@@ -185,6 +188,7 @@  eUser= User (error1 "username") (error1 "password") + error1 s= error $ s ++ " undefined"  userPrefix= "User#"@@ -201,26 +205,44 @@     Just x -> return x  -- | register an user/password combination-userRegister :: String -> String  -> IO(DBRef User)-userRegister user password  = atomically .-    newDBRef  $  User  user password+userRegister :: String -> String  -> IO()+userRegister user password  = withResources [] $ const [ User user password] ++--newDBRef1 ::   (IResource a, Typeable a) => a -> STM  (DBRef a)  
+--newDBRef1 x = do+--  let ref= getDBRef $ keyResource x+--  mr <- readDBRef  ref+--  case mr of+--    Nothing -> writeDBRef ref x >> return ref+--    Just r -> return ref+++-- let u=   User  user password+-- let ref= getDBRef $ key u+-- atomically $ do+--   mr <- readDBRef  ref+--   case mr of+--     Nothing ->  writeDBRef ref u -- !> (show mr)+--     Just u -> return ()+-- return ref+ -- | authentication against `userRegister`ed users. -- to be used with `validate` userAuthenticate :: MonadIO m =>  User -> m (Maybe String) userAuthenticate user@User{..} = liftIO $ atomically      $ withSTMResources [user]      $ \ mu -> case mu of-         [Nothing] -> resources{toReturn= just }+         [Nothing] -> resources{toReturn= err }          [Just (User _ p )] -> resources{toReturn=                case upassword==p  of                  True -> Nothing-                 False -> just+                 False -> err                 }       where-     just= Just "Username or password invalid"+     err= Just "Username or password invalid"   type FlowM view = StateT (MFlowState view)
MFlow/Hack.hs view
@@ -30,8 +30,7 @@ 
 import MFlow
 import MFlow.Cookies-import MFlow.Hack.Response
-+import MFlow.Hack.Response import Data.Monoid  --(!>)= flip trace@@ -59,6 +58,8 @@ instance Indexable Flow where
   key _= "Flow"
 
++ 
 newFlow= do
         fl <- atomically $ do