dgs 0.1 → 0.2
raw patch · 2 files changed
+27/−14 lines, 2 filesdep +mtlPVP ok
version bump matches the API change (PVP)
Dependencies added: mtl
API changes (from Hackage documentation)
- Network.DGS: type DGS a = BrowserAction (HandleStream String) a
+ Network.DGS: DGS :: BrowserAction (HandleStream String) a -> DGS a
+ Network.DGS: browseDGS :: DGS a -> IO a
+ Network.DGS: instance Functor DGS
+ Network.DGS: instance Monad DGS
+ Network.DGS: instance MonadIO (BrowserAction conn)
+ Network.DGS: instance MonadIO DGS
+ Network.DGS: newtype DGS a
+ Network.DGS: runDGS :: DGS a -> BrowserAction (HandleStream String) a
Files
- Network/DGS.hs +22/−10
- dgs.cabal +5/−4
Network/DGS.hs view
@@ -7,24 +7,26 @@ Here are some sample interactions from ghci, with a fictitious password: -> *Network.DGS> browse (silence >> login development "smartypants" "password")+> *Network.DGS> browseDGS (silence >> login development "smartypants" "password") > LoginSuccess-> *Network.DGS> browse (silence >> statusUID production 4155) >>= mapM_ print+> *Network.DGS> browseDGS (silence >> statusUID production 4155) >>= mapM_ print > (453881,"jedge42",False,"2009-12-21 03:14 GMT","F: 30d 1h") > (532927,"bartnix",False,"2009-12-20 06:06 GMT","F: 21d 13h")-> *Network.DGS> browse (silence >> statusUser production "dmwit") >>= mapM_ print+> *Network.DGS> browseDGS (silence >> statusUser production "dmwit") >>= mapM_ print > (453881,"jedge42",False,"2009-12-21 03:14 GMT","F: 30d 1h") > (532927,"bartnix",False,"2009-12-20 06:06 GMT","F: 21d 13h") > *Network.DGS> :{-> *Network.DGS| browse $ do {+> *Network.DGS| browseDGS $ do { > *Network.DGS| silence; > *Network.DGS| login development "smartypants" "password";-> *Network.DGS| (_, [(gid, _, black, _, _)]) <- status development;+> *Network.DGS| (_, (gid, _, black, _, _):_) <- status development; > *Network.DGS| move development gid black (16, 18) (17, 16) > *Network.DGS| } > *Network.DGS| :} > MoveSuccess -}++{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Network.DGS ( -- * Logging in LoginResult(..),@@ -45,34 +47,44 @@ -- * Miscellaneous module Network.Browser,- DGS,+ DGS(..), development, production,- silence+ silence,+ browseDGS ) where +-- TODO: remove this imports when the instance is available from the HTTP package+import Control.Monad.Trans import Data.List import Data.List.Split import Network.Browser import Network.HTTP import Network.URI+import qualified Network.Browser as B -- }}} -- helpers {{{ -- | a convenient type synonym for HTTP's browser monad-type DGS a = BrowserAction (HandleStream String) a+newtype DGS a = DGS { runDGS :: BrowserAction (HandleStream String) a } deriving (Functor, Monad, MonadIO) +-- TODO: port this upstream to the HTTP package+instance MonadIO (BrowserAction conn) where liftIO = ioAction+ uri :: String -> String -> URI uri server path = full where auth = URIAuth { uriRegName = server, uriUserInfo = "", uriPort = "" } full = nullURI { uriScheme = "http:", uriAuthority = Just auth, uriPath = '/' : path } get :: (String -> a) -> URI -> [(String, String)] -> DGS a-get f uri = fmap (f . rspBody . snd) . request . formToRequest . Form GET uri+get f uri = DGS . fmap (f . rspBody . snd) . request . formToRequest . Form GET uri -- | by default, HTTP's browser chatters a lot on stdout; this action turns off -- the chatter silence :: DGS ()-silence = setErrHandler quiet >> setOutHandler quiet where quiet _ = return ()+silence = DGS $ setErrHandler quiet >> setOutHandler quiet where quiet _ = return ()++browseDGS :: DGS a -> IO a+browseDGS = B.browse . runDGS -- }}} -- servers {{{ -- | the address of the development server, @\"dragongoserver.sourceforge.net\"@
dgs.cabal view
@@ -1,5 +1,5 @@ name: dgs-version: 0.1+version: 0.2 author: Daniel Wagner maintainer: daniel@wagner-home.com homepage: http://www.dmwit.com/dgs@@ -20,15 +20,16 @@ exposed-modules: Network.DGS build-depends: base >=3 && < 4,+ mtl >= 1.1, HTTP, network, split source-repository head type: git- location: http://www.dmwit.com/dgs+ location: http://www.dmwit.com/dgs/.git source-repository this type: git- location: http://www.dmwit.com/dgs- tag: 0.1+ location: http://www.dmwit.com/dgs/.git+ tag: 0.2