speculation-transformers (empty) → 0.1
raw patch · 4 files changed
+137/−0 lines, 4 filesdep +basedep +speculationdep +stmsetup-changed
Dependencies added: base, speculation, stm, transformers
Files
- Control/Monad/Trans/Cont/Speculation.hs +70/−0
- LICENSE +30/−0
- Setup.lhs +7/−0
- speculation-transformers.cabal +30/−0
+ Control/Monad/Trans/Cont/Speculation.hs view
@@ -0,0 +1,70 @@+-----------------------------------------------------------------------------+-- |+-- Module : Control.Monad.Trans.Cont.Speculation+-- Copyright : (C) 2011 Edward Kmett, Jake McArthur+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : Edward Kmett <ekmett@gmail.com>+-- Stability : provisional+-- Portability : portable+--+-- Versions of the combinators from the 'speculation' package+-- with the signature rearranged to enable them to be used+-- directly as actions in the 'Cont' and 'ContT' monads.+----------------------------------------------------------------------------+module Control.Monad.Trans.Cont.Speculation where++import Control.Monad.Trans.Cont+import qualified Control.Concurrent.Speculation as Prim+import Control.Concurrent.STM++-- * Basic speculation++-- | When a is unevaluated, @'spec' g a@ evaluates the current continuation +-- with @g@ while testing if @g@ '==' @a@, if they differ, it re-evalutes the+-- continuation with @a@. If @a@ was already evaluated, the continuation is+-- just directly applied to @a@ instead.+spec :: Eq a => a -> a -> ContT r m a+spec g a = ContT $ \k -> Prim.spec g k a ++-- | As per 'spec', without the check for whether or not the second argument+-- is already evaluated.+spec' :: Eq a => a -> a -> ContT r m a+spec' g a = ContT $ \k -> Prim.spec' g k a++-- | @spec@ with a user supplied comparison function+specBy :: (a -> a -> Bool) -> a -> a -> ContT r m a+specBy f g a = ContT $ \k -> Prim.specBy f g k a++-- | @spec'@ with a user supplied comparison function+specBy' :: (a -> a -> Bool) -> a -> a -> ContT r m a+specBy' f g a = ContT $ \k -> Prim.specBy' f g k a++-- | @spec'@ with a user supplied comparison function+specOn :: Eq c => (a -> c) -> a -> a -> ContT r m a+specOn f g a = ContT $ \k -> Prim.specOn f g k a++-- | @spec'@ with a user supplied comparison function+specOn' :: Eq c => (a -> c) -> a -> a -> ContT r m a+specOn' f g a = ContT $ \k -> Prim.specOn' f g k a++-- * STM-based speculation++specSTM :: Eq a => STM a -> a -> ContT r STM a+specSTM g a = ContT $ \k -> Prim.specSTM g k a ++specSTM' :: Eq a => STM a -> a -> ContT r STM a+specSTM' g a = ContT $ \k -> Prim.specSTM' g k a ++specOnSTM :: Eq c => (a -> STM c) -> STM a -> a -> ContT r STM a+specOnSTM f g a = ContT $ \k -> Prim.specOnSTM f g k a ++specOnSTM' :: Eq c => (a -> STM c) -> STM a -> a -> ContT r STM a+specOnSTM' f g a = ContT $ \k -> Prim.specOnSTM' f g k a ++specBySTM :: (a -> a -> STM Bool) -> STM a -> a -> ContT r STM a+specBySTM f g a = ContT $ \k -> Prim.specBySTM f g k a ++specBySTM' :: (a -> a -> STM Bool) -> STM a -> a -> ContT r STM a+specBySTM' f g a = ContT $ \k -> Prim.specBySTM' f g k a +
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright 2011 Edward Kmett, Jake McArthur++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions+are met:++1. Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++2. 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.++3. Neither the name of the author nor the names of his contributors+ may be used to endorse or promote products derived from this software+ without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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.
+ Setup.lhs view
@@ -0,0 +1,7 @@+#!/usr/bin/runhaskell+> module Main (main) where++> import Distribution.Simple++> main :: IO ()+> main = defaultMain
+ speculation-transformers.cabal view
@@ -0,0 +1,30 @@+name: speculation-transformers+category: Control, Comonads+version: 0.1+license: BSD3+cabal-version: >= 1.6+license-file: LICENSE+author: Edward A. Kmett+maintainer: Edward A. Kmett <ekmett@gmail.com>+stability: provisional+homepage: http://github.com/ekmett/speculation-transformers/+copyright: Copyright (C) 2011 Edward A. Kmett, Jake McArthur+synopsis: Safe, programmable, speculative parallelism with monads.+description: Safe, programmable, speculative parallelism with monads.+build-type: Simple++source-repository head+ type: git+ location: git://github.com/ekmett/speculation-transformers.git++library+ build-depends: + base >= 4 && < 4.5,+ stm >= 2.1.2 && <= 2.2,+ speculation >= 1.0.0 && < 1.1,+ transformers >= 0.2.0 && < 0.3++ exposed-modules:+ Control.Monad.Trans.Cont.Speculation++ ghc-options: -Wall