Etage 0.1.2 → 0.1.3
raw patch · 4 files changed
+16/−6 lines, 4 files
Files
- Etage.cabal +1/−1
- lib/Control/Etage/Externals.hs +11/−1
- lib/Control/Etage/Function.hs +1/−1
- lib/Control/Etage/Incubator.hs +3/−3
Etage.cabal view
@@ -1,5 +1,5 @@ Name: Etage-Version: 0.1.2+Version: 0.1.3 Synopsis: A general data-flow framework Description: A general data-flow framework featuring nondeterminism, laziness and neurological pseudo-terminology. It can be used for example for data-flow computations or event propagation networks. It tries hard to aide type checking and to
lib/Control/Etage/Externals.hs view
@@ -56,7 +56,8 @@ prepareEnvironment, getCurrentImpulseTime, impulseEq,- impulseCompare+ impulseCompare,+ bracketOnErrorUnmasked ) where import Prelude hiding (catch)@@ -428,3 +429,12 @@ -} impulseCompare :: (Impulse i, Impulse j) => i -> j -> Ordering impulseCompare a b = (impulseTime a, impulseValue a) `compare` (impulseTime b, impulseValue b)++{-|+Similar to 'bracketOnError' only that the first computation does not have asynchronous exceptions masked.+-}+bracketOnErrorUnmasked :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c+bracketOnErrorUnmasked before after thing =+ mask $ \restore -> do+ a <- restore before+ restore (thing a) `onException` after a
lib/Control/Etage/Function.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, GADTs, FlexibleInstances, ScopedTypeVariables, DeriveDataTypeable, TypeSynonymInstances, NamedFieldPuns, BangPatterns #-}+{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, GADTs, FlexibleInstances, ScopedTypeVariables, DeriveDataTypeable, TypeSynonymInstances, NamedFieldPuns #-} {-| This module defines a 'Neuron' which applies a given function to received 'Impulse's. As Haskell is a lazy language this does
lib/Control/Etage/Incubator.hs view
@@ -54,7 +54,7 @@ -- > grow options = do -- > ... -- > nerve <- growNerve- -- > bracketOnError (attach defaultOptions nerve) detachAndWait $ \neuron -> do+ -- > bracketOnErrorUnmasked (attach defaultOptions nerve) detachAndWait $ \neuron -> do -- > ... -- > return $ YourNeuron ... neuron nerve -- >@@ -62,7 +62,7 @@ -- > detachAndWait neuron -- > ... --- -- We use 'bracketOnError' there to be sure that 'Neuron' is properly 'dissolve'd even if there is an exception later on in+ -- We use 'bracketOnErrorUnmasked' there to be sure that 'Neuron' is properly 'dissolve'd even if there is an exception later on in -- 'grow'ing the parent 'Neuron'. And we use 'detachAndWait' so that we give time for child 'Neuron' to 'dissolve' properly. -- Which 'Neuron' you want is in this case inferred from the type of the 'Nerve' you defined. growNerve,@@ -117,7 +117,7 @@ eval ns cs ats (NeuronOperation optionsSetter :>>= is) = do nerve <- liftIO growNerve let c = getFromChan nerve- bracketOnError (attach optionsSetter nerve) detachAndWait $ \n -> interpret (n:ns) (c ++ cs) ats . is $ nerve+ bracketOnErrorUnmasked (attach optionsSetter nerve) detachAndWait $ \n -> interpret (n:ns) (c ++ cs) ats . is $ nerve eval ns cs ats (AttachOperation from for :>>= is) = do let c = head . getFromChan $ from -- we know there exists from chan as type checking assures that (from is conductive) (from', ats') <- if c `notElem` ats