packages feed

lvish 1.0.0.2 → 1.0.0.4

raw patch · 9 files changed

+37/−9 lines, 9 files

Files

Control/LVish/DeepFrz.hs view
@@ -8,7 +8,7 @@  {-| -The `DeepFrz` module rovides a way to return arbitrarily complex data+The `DeepFrz` module provides a way to return arbitrarily complex data structures containing LVars from `Par` computations.  The important thing to know is that to use `runParThenFreeze` to run a@@ -42,7 +42,7 @@           -- * Some supporting types          DeepFrz(), FrzType,-         Frzn, Trvrsbl,+         NonFrzn, Frzn, Trvrsbl,                  ) where @@ -51,7 +51,7 @@ import GHC.Prim (unsafeCoerce#)  -- import Control.LVish (LVarData1(..))-import Control.LVish.DeepFrz.Internal (DeepFrz(..), Frzn, Trvrsbl)+import Control.LVish.DeepFrz.Internal (DeepFrz(..), NonFrzn, Frzn, Trvrsbl) import Control.LVish.Internal (Determinism(..), Par(WrapPar)) import Control.LVish.SchedIdempotent (runPar, runParIO) --------------------------------------------------------------------------------@@ -75,7 +75,7 @@ -- Significantly, the freeze at the end of `runParThenFreeze` has /no/ runtime cost, in -- spite of the fact that it enables a /deep/ (recursive) freeze of the value returned -- by the `Par` computation.-runParThenFreeze :: DeepFrz a => Par Det s a -> FrzType a+runParThenFreeze :: DeepFrz a => Par Det NonFrzn a -> FrzType a runParThenFreeze (WrapPar p) = frz $ runPar p  -- | This version works for nondeterministic computations as well.
Control/LVish/DeepFrz/Internal.hs view
@@ -7,11 +7,11 @@ -- new LVar types. module Control.LVish.DeepFrz.Internal        (-         DeepFrz(..), Frzn, Trvrsbl +         DeepFrz(..), NonFrzn, Frzn, Trvrsbl         )        where --- | DeepFreezing is a type-level (guaranteed O(1) time complexity)+-- | DeepFreezing is a type-level (guaranteed /O(1)/ time complexity) -- operation.  It marks an LVar and its contents (recursively) as -- frozen.  DeepFreezing is not an action that can be taken directly -- by the user, however.  Rather, it is the final step in a@@ -35,6 +35,10 @@ -- | An uninhabited type that signals that an LVar has been frozen. -- LVars should use this in place of their `s` parameter. data Frzn++-- | This exists only for the purpose of being a type which is /not/ equal to `Frzn`.+-- One could just as well have used @()@, but this is more descriptive.+data NonFrzn  -- | An uninhabited type that signals that an LVar is not only frozen, -- but it may be traversed in whatever order its internal
Control/LVish/Internal.hs view
@@ -66,6 +66,10 @@ -- | The generic representation of LVars used by the scheduler.  The -- end-user can't actually do anything with these and should not try -- to.++-- LK: I don't care if we use `a` and `d` or `all` and `delt`, but why+-- not be consistent between here and SchedIdempotent.hs?  Also, what+-- does `all` mean? newtype LVar s all delt = WrapLVar { unWrapLVar :: L.LVar all delt }  -- | Unsafe: drops type information to go from the safe `Par` monad to
Control/LVish/SchedIdempotent.hs view
@@ -272,6 +272,7 @@ -- | Do a threshold read on an LVar getLV :: (LVar a d)                  -- ^ the LVar        -> (a -> Bool -> IO (Maybe b)) -- ^ already past threshold?+                                     -- The @Bool@ indicates whether the LVar is FROZEN.       -> (d ->         IO (Maybe b)) -- ^ does @d@ pass the threshold?       -> Par b getLV lv@(LVar {state, status}) globalThresh deltaThresh = mkPar $ \k q -> do
Data/LVar/Generic.hs view
@@ -58,7 +58,7 @@ castFrzn x = unsafeCoerceLVar x  -- | LVish `Par` actions must commute, therefore one safe way to consume a frozen (but--- unordered) LVar, /even in another `runPar` session/, is to run a `Par` computation for+-- unordered) LVar, even in another `runPar` session, is to run a `Par` computation for -- each element. forFrzn :: LVarData1 f => f Frzn a -> (a -> Par d s ()) -> Par d s () forFrzn fzn fn =
Data/LVar/Generic/Internal.hs view
@@ -87,7 +87,7 @@ unsafeCoerceLVar = unsafeCoerce#  -- | Here we gain permission to expose the nondeterministic internal structure of an--- LVar: namely, the order in which its contents occur  We pay the piper with an `IO`+-- LVar: namely, the order in which its contents occur.  We pay the piper with an `IO` -- action. unsafeTraversable :: LVarData1 f => f Frzn a -> IO (f Trvrsbl a) unsafeTraversable x = return (unsafeCoerceLVar x) 
Data/LVar/PureMap.hs view
@@ -8,6 +8,7 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE IncoherentInstances #-}  {-| 
lvish.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             1.0.0.2+version:             1.0.0.4  -- Changelog: -- 0.2     -- switch SLMap over to O(1) freeze@@ -32,6 +32,11 @@   .    If the haddocks are not building, here is a mirror:   <http://www.cs.indiana.edu/~rrnewton/haddock/lvish/>+  .+  Change Log: +  .+  * 1.0.0.4 - this is a critical bugfix release; please do not use earlier versions.+  license:             BSD3 license-file:        LICENSE
unit-tests.hs view
@@ -226,6 +226,19 @@         mapM_ IV.get ivs -- Join point.         return s +escape01 :: IV.IVar Frzn Int+escape01 = runParThenFreeze $ do v <- IV.new; IV.put v (3::Int); return v++-- | This is VERY BAD:+escape01B :: Par d Frzn String+escape01B = +            do IV.put escape01 (4::Int)+               return "uh oh"++-- | [2013.10.06] Fixed this by requiring a SPECIFIC type, NonFrzn.+-- major_bug :: String+-- major_bug = runParThenFreeze escape01B+                -- | Simple callback test. -- case_v3a :: Assertion -- case_v3a = v3a >>= assertEqual "simple callback test"