packages feed

sub-state (empty) → 0.0.0.1

raw patch · 4 files changed

+109/−0 lines, 4 filesdep +QuickCheckdep +basedep +mtl

Dependencies added: QuickCheck, base, mtl, quickcheck-instances, sets, tasty, tasty-hunit, tasty-quickcheck

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2015, Athan Clark++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Athan Clark nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ src/Control/Monad/State/Sub.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE+    MultiParamTypeClasses+  , FlexibleInstances+  #-}++module Control.Monad.State.Sub where++import Data.Set.Class as Sets+import Control.Monad.State+import Control.Monad.Reader+++-- | > lookup i =<< (putSingle x >> getTotal) ~ return (Just x)+class MonadSubState i a s m where+  getTotal  :: m s+  putSingle :: a -> m ()++instance ( HasInsertWith i a s+         , MonadState s m+         , MonadReader i m+         ) => MonadSubState i a s m where+  getTotal = get+  putSingle x = do+    i <- ask+    s <- get+    put $ insertWith i x s
+ sub-state.cabal view
@@ -0,0 +1,40 @@+Name:                   sub-state+Version:                0.0.0.1+Author:                 Athan Clark <athan.clark@gmail.com>+Maintainer:             Athan Clark <athan.clark@gmail.com>+License:                BSD3+License-File:           LICENSE+Synopsis:               Get the total, put a single element+Description:+  Restrain your data modification to /insert/ minimal amounts, while allowing+  read access to the whole set.+Cabal-Version:          >= 1.10+Build-Type:             Simple+Category:               Control++Library+  Default-Language:     Haskell2010+  HS-Source-Dirs:       src+  GHC-Options:          -Wall+  Exposed-Modules:      Control.Monad.State.Sub+  Build-Depends:        base >= 4.6 && < 5+                      , sets+                      , mtl++Test-Suite spec+  Type:                 exitcode-stdio-1.0+  Default-Language:     Haskell2010+  Hs-Source-Dirs:       src+                      , test+  Ghc-Options:          -Wall+  Main-Is:              Spec.hs+  Build-Depends:        base+                      , tasty+                      , tasty-quickcheck+                      , tasty-hunit+                      , QuickCheck+                      , quickcheck-instances++Source-Repository head+  Type:                 git+  Location:             https://github.com/athanclark/sub-state
+ test/Spec.hs view
@@ -0,0 +1,13 @@+module Spec where++import Control.Monad.State.SubSpec++import Test.Tasty+++main :: IO ()+main = defaultMain tests++tests :: TestTree+tests = testGroup "Testing..."+  [spec]