eternal 0.1.1 → 0.1.3
raw patch · 9 files changed
+85/−61 lines, 9 files
Files
- LICENSE +30/−30
- eternal.cabal +7/−7
- src/Control/Eternal.hs +2/−0
- src/Control/Eternal/Reactive.hs +13/−7
- src/Control/Eternal/Syntax.hs +2/−0
- src/Control/Eternal/Syntax/Lift.hs +14/−12
- src/Control/Eternal/Syntax/Logic.hs +7/−3
- src/Control/Eternal/Syntax/Operators.hs +5/−1
- src/Control/Eternal/Syntax/Unicode.hs +5/−1
LICENSE view
@@ -1,30 +1,30 @@-Copyright 2014 Heather Cynede - -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. +Copyright 2014 Heather Cynede++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.
eternal.cabal view
@@ -1,8 +1,8 @@-name: eternal -category: Control -version: 0.1.1 +name: eternal +category: Control +version: 0.1.3 author: Heather Cynede -maintainer: Heather Cynede <Cynede@Gentoo.org> +maintainer: Heather Cynede <Heather@live.ru> license: BSD3 license-file: LICENSE synopsis: everything breaking the Fairbairn threshold @@ -18,16 +18,16 @@ exposed-modules: Control.Eternal - + Control.Eternal.Syntax Control.Eternal.Reactive - + Control.Eternal.Syntax.Operators Control.Eternal.Syntax.Unicode Control.Eternal.Syntax.Lift Control.Eternal.Syntax.Logic - Build-Depends: + Build-Depends: base >= 4.3 && < 5 , transformers , utf8-string
src/Control/Eternal.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE Safe #-} + module Control.Eternal ( module Control.Eternal.Syntax , module Control.Eternal.Reactive
src/Control/Eternal/Reactive.hs view
@@ -1,6 +1,13 @@-{-# LANGUAGE RankNTypes, GADTs, ScopedTypeVariables, LambdaCase, UnicodeSyntax #-} +{-# LANGUAGE + UnicodeSyntax + , RankNTypes + , GADTs + , ScopedTypeVariables + , LambdaCase + , Safe + #-} -module Control.Eternal.Reactive +module Control.Eternal.Reactive ( Action , Request , reactiveObjectIO @@ -17,7 +24,6 @@ import Control.Concurrent.Chan import Control.Concurrent -import Control.Exception as Ex -- An action is an IO-based change to an explicit state type Action s = s → IO s -- only state change @@ -26,14 +32,14 @@ -- Choices: -- * do the Requests see the failure -- * Actions do not see anything --- * +-- * data Msg s = Act (Action s) | ∀ a . Req (Request s a) (MVar a) | Done (MVar ()) reactiveObjectIO :: ∀ state object. state - → ( ThreadId + → ( ThreadId → (∀ r. Request state r → IO r) -- requests → (Action state → IO ()) -- actions → IO () -- done @@ -41,7 +47,7 @@ ) → IO object reactiveObjectIO state mkObject = do chan ← newChan - let dispatch st = + let dispatch st = readChan chan >>= \case Act act → do state1 ← act st dispatch $! state1 Req req box → do (state1,ret) ← req st @@ -65,7 +71,7 @@ -- This turns a reactive style call into a pausing IO call. pauseIO :: (a → Sink b → IO ()) → a → IO b pauseIO fn a = do var ← newEmptyMVar - forkIO $ do fn a (\ b → putMVar var b) + forkIO $ fn a (putMVar var) takeMVar var -- This turns a pausing IO call into a reactive style call.
src/Control/Eternal/Syntax.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE Safe #-} + module Control.Eternal.Syntax ( module Control.Eternal.Syntax.Operators , module Control.Eternal.Syntax.Unicode
src/Control/Eternal/Syntax/Lift.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE UnicodeSyntax #-} +{-# LANGUAGE + UnicodeSyntax + , Safe + #-} + module Control.Eternal.Syntax.Lift ( liftM_ , liftM2_ @@ -6,16 +10,14 @@ , liftM4_ ) where -import Control.Monad - -liftM_ :: Monad m ⇒ (a1 → m a) → m a1 → m a -liftM_ a1 r = join ( liftM a1 r ) - -liftM2_ :: Monad m ⇒ (a1 → a2 → m a) → m a1 → m a2 → m a -liftM2_ a1 a2 r = join ( liftM2 a1 a2 r ) +import Control.Monad (join, liftM, liftM2, liftM3, liftM4) -liftM3_ :: Monad m ⇒ (a1 → a2 → a3 → m a) → m a1 → m a2 → m a3 → m a -liftM3_ a1 a2 a3 r = join ( liftM3 a1 a2 a3 r ) +liftM_ ∷ Monad m ⇒ (α1 → m α) → m α1 → m α +liftM2_ ∷ Monad m ⇒ (α1 → α2 → m α) → m α1 → m α2 → m α +liftM3_ ∷ Monad m ⇒ (α1 → α2 → α3 → m α) → m α1 → m α2 → m α3 → m α +liftM4_ ∷ Monad m ⇒ (α1 → α2 → α3 → α4 → m α) → m α1 → m α2 → m α3 → m α4 → m α -liftM4_ :: Monad m ⇒ (a1 → a2 → a3 → a4 → m a) → m a1 → m a2 → m a3 → m a4 → m a -liftM4_ a1 a2 a3 a4 r = join ( liftM4 a1 a2 a3 a4 r ) +liftM_ a1 r = join $ liftM a1 r +liftM2_ a1 a2 r = join $ liftM2 a1 a2 r +liftM3_ a1 a2 a3 r = join $ liftM3 a1 a2 a3 r +liftM4_ a1 a2 a3 a4 r = join $ liftM4 a1 a2 a3 a4 r
src/Control/Eternal/Syntax/Logic.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE UnicodeSyntax #-} +{-# LANGUAGE + UnicodeSyntax + , Safe + #-} + module Control.Eternal.Syntax.Logic ( ifSo , ifNot @@ -6,8 +10,8 @@ import Control.Monad (when, unless) -ifSo :: IO () → Bool → IO () +ifSo ∷ IO () → Bool → IO () ifSo = flip when -ifNot :: IO () → Bool → IO () +ifNot ∷ IO () → Bool → IO () ifNot = flip unless
src/Control/Eternal/Syntax/Operators.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE UnicodeSyntax #-} +{-# LANGUAGE + UnicodeSyntax + , Safe + #-} + module Control.Eternal.Syntax.Operators ( (<|) , (|>)
src/Control/Eternal/Syntax/Unicode.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE UnicodeSyntax #-} +{-# LANGUAGE + UnicodeSyntax + , Safe + #-} + module Control.Eternal.Syntax.Unicode ( (⊳) , (⊲)