packages feed

dunai 0.6.0 → 0.7.0

raw patch · 6 files changed

+80/−27 lines, 6 filesdep +dunaidep +tastydep +tasty-hunitdep ~basePVP ok

version bump matches the API change (PVP)

Dependencies added: dunai, tasty, tasty-hunit, transformers-compat

Dependency ranges changed: base

API changes (from Hackage documentation)

+ Control.Monad.Trans.MSF.Except: listToMSFExcept :: Monad m => [b] -> MSFExcept m a b ()
+ Control.Monad.Trans.MSF.Except: step_ :: Monad m => b -> MSFExcept m a b ()
+ Control.Monad.Trans.MSF.Maybe: exceptToMaybeS :: (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF (MaybeT m) a b
- Control.Monad.Trans.MSF.Maybe: listToMaybeS :: Monad m => [b] -> MSF (MaybeT m) a b
+ Control.Monad.Trans.MSF.Maybe: listToMaybeS :: (Functor m, Monad m) => [b] -> MSF (MaybeT m) a b

Files

dunai.cabal view
@@ -1,5 +1,5 @@ name:                dunai-version:             0.6.0+version:             0.7.0 synopsis:            Generalised reactive framework supporting classic, arrowized and monadic FRP. homepage:            https://github.com/ivanperez-keera/dunai description:@@ -88,9 +88,12 @@   default-language:  Haskell2010   ghc-options:       -Wall -fno-warn-unused-do-bind +  if impl(ghc <= 7.8.4)+    build-depends: transformers-compat+ test-suite hlint   type: exitcode-stdio-1.0-  main-is: hlint.hs+  main-is: HLintMain.hs   hs-source-dirs: tests   default-language:  Haskell2010   if !flag(test-hlint)@@ -121,3 +124,16 @@ source-repository head   type:     git   location: git@github.com:ivanperez-keera/dunai.git++test-suite regression-tests+  type: exitcode-stdio-1.0+  main-is: RegressionTests.hs+  ghc-options: -Wall+  hs-source-dirs: tests+  default-language:  Haskell2010+  build-depends:+    base >=4 && <5,+    transformers,+    dunai,+    tasty,+    tasty-hunit
src/Control/Monad/Trans/MSF/Except.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE Arrows              #-} {-# LANGUAGE CPP                 #-} {-# LANGUAGE Rank2Types          #-}+{-# LANGUAGE TupleSections       #-} -- | 'MSF's in the 'ExceptT' monad are monadic stream functions --   that can throw exceptions, --   i.e. return an exception value instead of a continuation.@@ -173,6 +174,7 @@ -- | Monad instance for 'MSFExcept'. Bind uses the exception as the 'return' -- value in the monad. instance Monad m => Monad (MSFExcept m a b) where+  return = pure   MSFExcept msf >>= f = MSFExcept $ handleExceptT msf $ runMSFExcept . f  handleExceptT@@ -224,6 +226,17 @@   (b, e) <- arrM (lift . f) -< a   _      <- throwOn'        -< (n > (1 :: Int), e)   returnA                   -< b++-- | Advances a single tick outputting the value,+--   and then throws '()'.+step_ :: Monad m => b -> MSFExcept m a b ()+step_ = step . const . return . (, ())++-- | Converts a list to an 'MSFExcept',+--   which outputs an element of the list at each step,+--   throwing '()' when the list ends.+listToMSFExcept :: Monad m => [b] -> MSFExcept m a b ()+listToMSFExcept = mapM_ step_  -- * Utilities definable in terms of 'MSFExcept' 
src/Control/Monad/Trans/MSF/Maybe.hs view
@@ -65,11 +65,15 @@  -- * Converting to and from 'MaybeT' +-- | Convert exceptions into `Nothing`, discarding the exception value.+exceptToMaybeS :: (Functor m, Monad m) => MSF (ExceptT e m) a b -> MSF (MaybeT m) a b+exceptToMaybeS = morphS $ MaybeT . fmap (either (const Nothing) Just) . runExceptT+ -- | Converts a list to an 'MSF' in 'MaybeT', --   which outputs an element of the list at each step, --   throwing 'Nothing' when the list ends.-listToMaybeS :: Monad m => [b] -> MSF (MaybeT m) a b-listToMaybeS = foldr iPost exit+listToMaybeS :: (Functor m, Monad m) => [b] -> MSF (MaybeT m) a b+listToMaybeS = exceptToMaybeS . runMSFExcept . listToMSFExcept  -- * Running 'MaybeT' -- | Remove the 'MaybeT' layer by outputting 'Nothing' when the exception occurs.
+ tests/HLintMain.hs view
@@ -0,0 +1,23 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  Main (hlint)+-- Copyright   :  (C) 2013 Edward Kmett+-- License     :  BSD-style (see the file LICENSE)+-- Maintainer  :  Ivan Perez <ivan.perez@keera.co.uk>+-- Stability   :  provisional+-- Portability :  portable+--+-- This module runs HLint on the lens source tree.+-----------------------------------------------------------------------------+module Main where++import Control.Monad+import Language.Haskell.HLint+import System.Environment+import System.Exit++main :: IO ()+main = do+    args <- getArgs+    hints <- hlint $ ["src", "--cross", "--hint=tests/HLint.hs" ] ++ args+    unless (null hints) exitFailure
+ tests/RegressionTests.hs view
@@ -0,0 +1,20 @@+module Main where++-- transformers+import Control.Monad.Trans.Class (lift)+import Control.Monad.Trans.Maybe+import Control.Monad.Trans.Writer.Lazy++-- dunai+import Control.Monad.Trans.MSF.Maybe+import Data.MonadicStreamFunction++-- tasty+import Test.Tasty+import Test.Tasty.HUnit++main :: IO ()+main = defaultMain $ testGroup "listToMaybeS"+    [ testCase "First emits all list elements before throwing exception" $+        "Hello" @?= (execWriter $ runMaybeT $ flip embed [(1 :: Integer)..] $ listToMaybeS ["H", "el", "lo"] >>> arrM (tell >>> lift))+    ]
− tests/hlint.hs
@@ -1,23 +0,0 @@--------------------------------------------------------------------------------- |--- Module      :  Main (hlint)--- Copyright   :  (C) 2013 Edward Kmett--- License     :  BSD-style (see the file LICENSE)--- Maintainer  :  Edward Kmett <ekmett@gmail.com>--- Stability   :  provisional--- Portability :  portable------ This module runs HLint on the lens source tree.-------------------------------------------------------------------------------module Main where--import Control.Monad-import Language.Haskell.HLint-import System.Environment-import System.Exit--main :: IO ()-main = do-    args <- getArgs-    hints <- hlint $ ["src", "--cross", "--hint=tests/HLint.hs" ] ++ args-    unless (null hints) exitFailure