packages feed

state (empty) → 0.0.2

raw patch · 3 files changed

+58/−0 lines, 3 filesdep +arrowsdep +basedep +mtlbuild-type:Customsetup-changed

Dependencies added: arrows, base, mtl

Files

+ Setup.hs view
@@ -0,0 +1,5 @@+#!/usr/bin/env runhaskell++import Distribution.Simple++main = defaultMainWithHooks defaultUserHooks
+ src/Data/State.hs view
@@ -0,0 +1,37 @@+{-# options -fglasgow-exts -farrows #-}++module Data.State where++import Control.Arrow+import qualified Control.Arrow.Operations as AO+import Control.Monad.State as ST+import Data.Dynamic++class LocalState sg sl where+ getState :: sg -> sl+ putState :: sl -> sg -> sg++instance LocalState a a where+ getState = id+ putState a _ = a++class DynamicState sg where+ getDynamic :: sg -> Dynamic+ putDynamic :: Dynamic -> sg -> sg++class ZeroState sl where+ zeroState :: sl++get :: (ST.MonadState sg m, LocalState sg sl) => m sl+get = liftM getState ST.get++put :: (ST.MonadState sg m, LocalState sg sl) => sl -> m ()+put sl = do+ sg <- ST.get+ ST.put (putState sl sg)++fetch :: (AO.ArrowState sg a, LocalState sg sl) => a e sl+fetch = getState ^<< AO.fetch++store :: (ArrowApply a, AO.ArrowState sg a, LocalState sg sl) => a sl ()+store = proc sl -> AO.store <<< putState sl ^<< AO.fetch -<< ()
+ state.cabal view
@@ -0,0 +1,16 @@+Name: state+Version: 0.0.2+License: LGPL+Maintainer: Evgeny Jukov <masloed@gmail.com>+Author: Evgeny Jukov+Stability: Alpha+Copyright: Copyright (c) 2007 Evgeny Jukov+license-file: COPYRIGHT+Homepage: http://macode.sourceforge.net+Synopsis: Data.State+description: Data.State+Category: Data+Hs-Source-Dirs: src+Exposed-Modules: Data.State+Build-Depends: base, arrows, mtl+GHC-Options: -O2