deepcontrol 0.5.2.0 → 0.5.3.0
raw patch · 10 files changed
+143/−49 lines, 10 filesdep ~basedep ~mtldep ~transformersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, mtl, transformers
API changes (from Hackage documentation)
+ DeepControl.Monad.Morph: (|>>>>>=) :: (Monad n, Monad m, Monad (t5 n), Monad (t5 m), Monad (t2 (t3 (t4 (t5 n)))), Monad (t2 (t3 (t4 (t5 (t5 n))))), Monad (t3 (t4 (t5 n))), Monad (t3 (t4 (t5 (t5 n)))), Monad (t4 (t5 n)), Monad (t4 (t5 (t5 n))), Monad (t5 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t5 n)), Monad (t5 (t3 (t4 (t5 n)))), Monad (t2 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t4 (t5 n))), Monad (t2 (t3 (t3 (t4 (t5 n))))), Monad (t2 (t3 (t4 (t4 (t5 n))))), Monad (t2 (t4 (t5 n))), Monad (t3 (t2 (t3 (t4 (t5 n))))), Monad (t3 (t3 (t4 (t5 n)))), Monad (t3 (t4 (t4 (t5 n)))), Monad (t3 (t4 (t5 m))), Monad (t4 (t2 (t3 (t4 (t5 n))))), Monad (t4 (t3 (t4 (t5 n)))), Monad (t4 (t4 (t5 n))), Monad (t4 (t5 m)), MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, MonadTrans_ x3 t3, Traversable x3, MonadTrans_ x4 t4, Traversable x4, SinkT t2, SinkT t3, SinkT t4, SinkT t5, MMonad t1, MMonad t2, MMonad t3, MMonad t4, MMonad t5) => t1 (t2 (t3 (t4 (t5 m)))) b -> (forall a. m a -> t1 (t2 (t3 (t4 (t5 n)))) a) -> t1 (t2 (t3 (t4 (t5 n)))) b
+ DeepControl.Monad.Morph: (|>>>>>~) :: (Monad n, Monad m, Monad (t5 n), Monad (t5 m), Monad (t2 (t3 (t4 (t5 n)))), Monad (t2 (t3 (t4 (t5 (t5 n))))), Monad (t3 (t4 (t5 n))), Monad (t3 (t4 (t5 (t5 n)))), Monad (t4 (t5 n)), Monad (t4 (t5 (t5 n))), Monad (t5 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t5 n)), Monad (t5 (t3 (t4 (t5 n)))), Monad (t2 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t4 (t5 n))), Monad (t2 (t3 (t3 (t4 (t5 n))))), Monad (t2 (t3 (t4 (t4 (t5 n))))), Monad (t2 (t4 (t5 n))), Monad (t3 (t2 (t3 (t4 (t5 n))))), Monad (t3 (t3 (t4 (t5 n)))), Monad (t3 (t4 (t4 (t5 n)))), Monad (t3 (t4 (t5 m))), Monad (t4 (t2 (t3 (t4 (t5 n))))), Monad (t4 (t3 (t4 (t5 n)))), Monad (t4 (t4 (t5 n))), Monad (t4 (t5 m)), MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, MonadTrans_ x3 t3, Traversable x3, MonadTrans_ x4 t4, Traversable x4, SinkT t2, SinkT t3, SinkT t4, SinkT t5, MMonad t1, MMonad t2, MMonad t3, MMonad t4, MMonad t5) => t1 (t2 (t3 (t4 (t5 m)))) b -> (forall a. t1 (t2 (t3 (t4 (t5 n)))) a) -> t1 (t2 (t3 (t4 (t5 n)))) b
+ DeepControl.Monad.Morph: (|>>>>~) :: (Monad n, Monad (t4 n), Monad (t4 m), Monad m, Monad (t2 (t3 (t4 n))), Monad (t2 (t3 (t4 (t4 n)))), Monad (t2 (t2 (t3 (t4 n)))), Monad (t3 (t4 n)), Monad (t3 (t4 (t4 n))), Monad (t4 (t4 n)), Monad (t4 (t2 (t3 (t4 n)))), Monad (t2 (t3 (t3 (t4 n)))), Monad (t4 (t3 (t4 n))), Monad (t2 (t4 n)), Monad (t3 (t2 (t3 (t4 n)))), Monad (t3 (t3 (t4 n))), Monad (t3 (t4 m)), MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, MonadTrans_ x3 t3, Traversable x3, SinkT t2, SinkT t3, SinkT t4, MMonad t1, MMonad t2, MMonad t3, MMonad t4) => t1 (t2 (t3 (t4 m))) b -> (forall a. t1 (t2 (t3 (t4 n))) a) -> t1 (t2 (t3 (t4 n))) b
+ DeepControl.Monad.Morph: (|>>>~) :: (Monad n, Monad (t3 n), Monad m, Monad (t3 m), Monad (t2 (t3 n)), Monad (t2 (t3 (t3 n))), Monad (t3 (t3 n)), Monad (t3 (t2 (t3 n))), Monad (t2 (t2 (t3 n))), MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, SinkT t2, SinkT t3, MMonad t1, MMonad t2, MMonad t3) => t1 (t2 (t3 m)) b -> (forall a. t1 (t2 (t3 n)) a) -> t1 (t2 (t3 n)) b
+ DeepControl.Monad.Morph: (|>>~) :: (Monad n, Monad m, Monad (t2 n), Monad (t2 (t2 n)), MonadTrans_ x t1, Traversable x, MMonad t1, MMonad t2, SinkT t2) => t1 (t2 m) b -> (forall a. t1 (t2 n) a) -> t1 (t2 n) b
+ DeepControl.Monad.Morph: (|>~) :: (Monad n, MMonad t1) => t1 m b -> (forall a. t1 n a) -> t1 n b
Files
- DeepControl/Applicative.hs +2/−1
- DeepControl/Monad.hs +3/−2
- DeepControl/Monad/Morph.hs +59/−8
- DeepControl/Monad/Trans/Except.hs +2/−10
- DeepControl/Monad/Trans/Identity.hs +0/−8
- DeepControl/Traversable.hs +1/−2
- README.md +12/−12
- deepcontrol.cabal +12/−3
- test/unit_MonadMorph-bind.hs +3/−3
- test/unit_MonadMorph-bind2.hs +49/−0
DeepControl/Applicative.hs view
@@ -1,7 +1,8 @@ {-| Module : DeepControl.Applicative Description : Deepened the usual Control.Applicative module.-Copyright : (c) 2015 KONISHI Yohsuke +Copyright : Conor McBride and Ross Paterson 2005,+ (c) 2015 KONISHI Yohsuke License : BSD-style (see the LICENSE file in the distribution) Maintainer : ocean0yohsuke@gmail.com Stability : experimental
DeepControl/Monad.hs view
@@ -1,7 +1,8 @@ {-| Module : DeepControl.Monad Description : Deepend the usual Control.Monad module.-Copyright : (c) 2015 KONISHI Yohsuke +Copyright : (c) The University of Glasgow 2001,+ (c) 2015 KONISHI Yohsuke License : BSD-style (see the LICENSE file in the distribution) Maintainer : ocean0yohsuke@gmail.com Stability : experimental@@ -13,7 +14,7 @@ Note: * This module never makes mtl(monad-transformer-library) unnessasary. - The range in which this module is helpful is regrettably confined to the range of @'Traversable'@.+ The range in which this module is helpful is disappointingly confined to the range of @'Traversable'@. * In my opinion this bad confinement is hard-wired with the ability of the compiler, that is to say GHC doesn't parse @(r->)@ or @((->) r)@ as a data constructor; thus some fundamental expressions such as @(r->)|$>@ or @fmap (r->)@ are useless.
DeepControl/Monad/Morph.hs view
@@ -24,6 +24,8 @@ -- * Level-1 -- ** trans-map (|>|), (|<|), + -- ** trans-sequence+ (|>~), -- ** trans-cover (|*|), -- ** trans-fish@@ -32,6 +34,8 @@ -- * Level-2 -- ** trans-bind (|>>=),+ -- ** trans-sequence+ (|>>~), -- ** trans-fish (|>>=>), -- ** trans-map@@ -43,6 +47,8 @@ -- * Level-3 -- ** trans-bind (|>>>=),+ -- ** trans-sequence+ (|>>>~), -- ** trans-fish (|>>>=>), -- ** trans-map@@ -55,6 +61,8 @@ -- * Level-4 -- ** trans-bind (|>>>>=),+ -- ** trans-sequence+ (|>>>>~), -- ** trans-map (|>>>>|), (|<<<<|), -- ** trans-cover@@ -64,6 +72,10 @@ (|-***|), (|*-**|), (|**-*|), -- * Level-5+ -- ** trans-bind+ (|>>>>>=),+ -- ** trans-sequence+ (|>>>>>~), -- ** trans-map (|>>>>>|), (|<<<<<|), -- ** trans-cover@@ -163,23 +175,19 @@ (|<|) :: (Monad m, MFunctor t) => t m b -> (forall a . m a -> n a) -> t n b (|<|) l r = hoist r l --- sinkT :: t1 (t2 m) a -> t2 (t1 m) a- infixl 5 |*| -- | Alias to @'lift'@ (|*|) :: (Monad m, MonadTrans t) => m a -> t m a (|*|) = lift -{---- TODO:-(|>~) :: t1 m a -> t1 n a -> t1 n a-m |>~ k = m |>= \_ -> k--}- infixr 3 |>=> (|>=>) :: (Monad m3, MMonad t) => (forall a. m1 a -> t m2 a) -> (forall b. m2 b -> t m3 b) -> m1 c -> t m3 c (|>=>) = (>|>) +infixr 3 |>~+(|>~) :: (Monad n, MMonad t1) => t1 m b -> (forall a. t1 n a) -> t1 n b+m |>~ k = m |>= \_ -> k+ ------------------------------------------------------------------------------- -- Level-2 functions @@ -191,6 +199,13 @@ t1 (t2 m) b -> (forall a. m a -> t1 (t2 n) a) -> t1 (t2 n) b m |>>= f = m |>= \x -> squash |>| (sinkT $ f |>| x) +infixr 3 |>>~+(|>>~) :: (Monad n, Monad m, Monad (t2 n), Monad (t2 (t2 n)),+ MonadTrans_ x t1, Traversable x, + MMonad t1, MMonad t2, SinkT t2) => + t1 (t2 m) b -> (forall a. t1 (t2 n) a) -> t1 (t2 n) b+m |>>~ k = m |>>= \_ -> k+ infixr 3 |>>=> (|>>=>) :: (Monad m3, Monad m2, Monad (t2 m3), Monad (t2 (t2 m3)), MonadTrans_ x t1, Traversable x, @@ -229,6 +244,16 @@ t1 (t2 (t3 m)) b -> (forall a. m a -> t1 (t2 (t3 n)) a) -> t1 (t2 (t3 n)) b m |>>>= f = m |>>= \x -> squash |>>| (sinkT2 $ f |>| x) +infixr 3 |>>>~+(|>>>~) :: + (Monad n, Monad (t3 n), Monad m, Monad (t3 m), + Monad (t2 (t3 n)), Monad (t2 (t3 (t3 n))), Monad (t3 (t3 n)), Monad (t3 (t2 (t3 n))), Monad (t2 (t2 (t3 n))), + MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, + SinkT t2, SinkT t3, + MMonad t1, MMonad t2, MMonad t3) => + t1 (t2 (t3 m)) b -> (forall a. t1 (t2 (t3 n)) a) -> t1 (t2 (t3 n)) b+m |>>>~ k = m |>>>= \_ -> k+ infixr 3 |>>>=> (|>>>=>) :: (Monad m3, Monad m2, Monad (t2 m3), Monad (t2 (t2 m3)), Monad (t2 (t2 (t3 m3))), Monad (t2 (t3 m3)), Monad (t2 (t3 (t3 m3))), Monad (t3 m3), Monad (t3 m2), Monad (t3 (t2 (t3 m3))), Monad (t3 (t3 m3)), @@ -287,6 +312,18 @@ t1 (t2 (t3 (t4 m))) b -> (forall a. m a -> t1 (t2 (t3 (t4 n))) a) -> t1 (t2 (t3 (t4 n))) b m |>>>>= f = m |>>>= \x -> squash |>>>| (sinkT3 $ f |>| x) +infixr 3 |>>>>~+(|>>>>~) :: + (Monad n, Monad (t4 n), Monad (t4 m), Monad m,+ Monad (t2 (t3 (t4 n))), Monad (t2 (t3 (t4 (t4 n)))), Monad (t2 (t2 (t3 (t4 n)))), + Monad (t3 (t4 n)), Monad (t3 (t4 (t4 n))), Monad (t4 (t4 n)), Monad (t4 (t2 (t3 (t4 n)))), Monad (t2 (t3 (t3 (t4 n)))), Monad (t4 (t3 (t4 n))),+ Monad (t2 (t4 n)), Monad (t3 (t2 (t3 (t4 n)))), Monad (t3 (t3 (t4 n))), Monad (t3 (t4 m)), + MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, MonadTrans_ x3 t3, Traversable x3,+ SinkT t2, SinkT t3, SinkT t4, + MMonad t1, MMonad t2, MMonad t3, MMonad t4) => + t1 (t2 (t3 (t4 m))) b -> (forall a. t1 (t2 (t3 (t4 n))) a) -> t1 (t2 (t3 (t4 n))) b+m |>>>>~ k = m |>>>>= \_ -> k+ infixl 4 |>>>>| (|>>>>|) :: (Monad m, Monad (t4 m), Monad (t3 (t4 m)), Monad (t2 (t3 (t4 m))), MFunctor t1, MFunctor t2, MFunctor t3, MFunctor t4) => (forall a . m a -> n a) -> t1 (t2 (t3 (t4 m))) b -> t1 (t2 (t3 (t4 n))) b@@ -358,6 +395,20 @@ MMonad t1, MMonad t2, MMonad t3, MMonad t4, MMonad t5) => t1 (t2 (t3 (t4 (t5 m)))) b -> (forall a. m a -> t1 (t2 (t3 (t4 (t5 n)))) a) -> t1 (t2 (t3 (t4 (t5 n)))) b m |>>>>>= f = m |>>>>= \x -> squash |>>>>| (sinkT4 $ f |>| x)++infixr 3 |>>>>>~+(|>>>>>~) :: + (Monad n, Monad m, Monad (t5 n), Monad (t5 m),+ Monad (t2 (t3 (t4 (t5 n)))), Monad (t2 (t3 (t4 (t5 (t5 n))))), Monad (t3 (t4 (t5 n))), Monad (t3 (t4 (t5 (t5 n)))), + Monad (t4 (t5 n)), Monad (t4 (t5 (t5 n))), Monad (t5 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t5 n)), Monad (t5 (t3 (t4 (t5 n)))), + Monad (t2 (t2 (t3 (t4 (t5 n))))), Monad (t5 (t4 (t5 n))), Monad (t2 (t3 (t3 (t4 (t5 n))))), Monad (t2 (t3 (t4 (t4 (t5 n))))), + Monad (t2 (t4 (t5 n))), Monad (t3 (t2 (t3 (t4 (t5 n))))), Monad (t3 (t3 (t4 (t5 n)))), Monad (t3 (t4 (t4 (t5 n)))), + Monad (t3 (t4 (t5 m))), Monad (t4 (t2 (t3 (t4 (t5 n))))), Monad (t4 (t3 (t4 (t5 n)))), Monad (t4 (t4 (t5 n))), Monad (t4 (t5 m)), + MonadTrans_ x1 t1, Traversable x1, MonadTrans_ x2 t2, Traversable x2, MonadTrans_ x3 t3, Traversable x3, MonadTrans_ x4 t4, Traversable x4,+ SinkT t2, SinkT t3, SinkT t4, SinkT t5, + MMonad t1, MMonad t2, MMonad t3, MMonad t4, MMonad t5) => + t1 (t2 (t3 (t4 (t5 m)))) b -> (forall a. t1 (t2 (t3 (t4 (t5 n)))) a) -> t1 (t2 (t3 (t4 (t5 n)))) b+m |>>>>>~ k = m |>>>>>= \_ -> k infixl 4 |>>>>>| (|>>>>>|) :: (Monad m, Monad (t5 m), Monad (t4 (t5 m)), Monad (t3 (t4 (t5 m))), Monad (t2 (t3 (t4 (t5 m)))), MFunctor t1, MFunctor t2, MFunctor t3, MFunctor t4, MFunctor t5) =>
DeepControl/Monad/Trans/Except.hs view
@@ -1,8 +1,7 @@ {-| Module : DeepControl.Monad.Trans.Except Description : Deepened the usual Control.Monad.Except module.-Copyright : (C) 2013 Ross Paterson,- (c) 2015 KONISHI Yohsuke +Copyright : (c) 2015 KONISHI Yohsuke License : BSD-style (see the file LICENSE) Maintainer : ocean0yohsuke@gmail.com Stability : experimental@@ -44,13 +43,7 @@ import Control.Monad.Except import Data.Functor.Identity -------------------------------------------------------------------- ----except :: Either e a -> Except e a---except = ExceptT . Identity------------------------------------------------------------------+--------------------------------------------------------------- -- Level-2 throwError2 :: (MonadError e m2, Applicative m1) => e -> m1 (m2 a)@@ -66,7 +59,6 @@ let m' = sink m h' = sink |$> h in sink $ catch m' h'- ---------------------------------------------------------------- -- Level-3
DeepControl/Monad/Trans/Identity.hs view
@@ -103,14 +103,6 @@ (*:) :: (Monad m) => Identity a -> IdentityT m a (*:) = IdentityT . (.*) . runIdentity --- TODO: ($>:)---($>:) :: (m a -> n b) -> IdentityT m a -> IdentityT n b---($>:) = mapIdentityT---- | Lift a binary operation to the new monad.--- lift2IdentityT :: (m a -> n b -> p c) -> IdentityT m a -> IdentityT n b -> IdentityT p c--- lift2IdentityT f a b = IdentityT (f (runIdentityT a) (runIdentityT b))- ---------------------------------------------------------------------- -- Level-2
DeepControl/Traversable.hs view
@@ -8,7 +8,6 @@ Stability : experimental Portability : --- -This module is deepened of @'Data.Traversable'@. -} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-}@@ -32,7 +31,7 @@ ------------------------------------------------------------------------------ -- Level-1 --- | Alias to @'Data.Traversable.sequenceA'@.+-- | Synonym to @'Data.Traversable.sequenceA'@. -- -- >>> sink $ Just [1] -- [Just 1]
README.md view
@@ -1,10 +1,10 @@ # deepcontrol -A Haskell library that enables more deeper level style programming than the usual Control.xxx modules provide, especially for Applicative and Monad.+A Haskell library that enables more deeper level style programming than the usual Control.xxx modules express, especially for Applicative and Monad. ## Examples -### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Applicative.html)+### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Applicative.html) This module enables you to program in applicative style for more deeper level than the usual Applicative module expresses. You would soon realize exactly what more deeper level means by reading the example codes below in order.@@ -182,7 +182,7 @@ Work well likewise. -### [Monad](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Monad.html)+### [Monad](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Monad.html) This module enables you to program in Monad for more deeper level than the usual Monad module expresses. You would soon realize exactly what more deeper level means by reading the example codes below in order.@@ -202,13 +202,13 @@ -- 7 ``` -#### [Traversable](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Traversable.html)+#### [Traversable](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Traversable.html) Identity, List, Maybe, Either, Except and Writer monads are sinkable monads. Prelude> :m DeepControl.Traversable > :t sink- sink :: (Applicative f, Traversable c) => c (f a) -> f (c a) -- alias to 'sequenceA'+ sink :: (Applicative f, Traversable c) => c (f a) -> f (c a) -- synonym to 'sequenceA' > sink $ Just [1] [Just 1]@@ -264,12 +264,12 @@ import Control.Monad.Writer factorial :: Int ->- IO (Maybe (Writer [Int] Int)) -- IO-Maybe-Writer monad+ IO (Maybe (Writer [Int] Int)) -- IO-Maybe-Writer monad factorial n | n < 0 = (.*) Nothing | n == 0 = (.**) $ tell [0] >> (.*) 1- | n > 0 = factorial (n-1) >>>= \v -> -- (>>>=) is the level-3 bind function, analogous to (>>=)- print v >--~ -- (>--~) is a level-3 cover-sequence function, analogous to (>>)- tell [v] -->~ -- (-->~) is a level-3 cover-sequence function too, analogous to (>>)+ | n > 0 = factorial (n-1) >>>= \v -> -- (>>>=) is the level-3 bind function, analogous to (>>=)+ print v >--~ -- (>--~) is a level-3 cover-sequence function, analogous to (>>)+ tell [v] -->~ -- (-->~) is a level-3 cover-sequence function too, analogous to (>>) (.***) (n * v) -- > runWriter |$>> factorial 5@@ -286,7 +286,7 @@ Work well likewise. -### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Monad-Trans.html)+### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Monad-Trans.html) #### Level-2 @@ -368,7 +368,7 @@ untransroll3 $ MaybeT (ListT (ExceptT (Identity (Right [Just 1])))) :: Num a => ExceptT e Identity [Maybe a] -### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Monad-Morph.html)+### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Monad-Morph.html) #### SinkT @@ -497,4 +497,4 @@ Work well likewise. -### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.5.2.0/docs/DeepControl-Arrow.html)+### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.5.3.0/docs/DeepControl-Arrow.html)
deepcontrol.cabal view
@@ -1,5 +1,5 @@ name: deepcontrol-version: 0.5.2.0+version: 0.5.3.0 synopsis: Provide more deeper level style of programming than the usual Control.xxx modules express description: This module provides more deeper level style of programming than the usual Control.xxx modules express, especially for Applicative and Monad. license: BSD3@@ -13,9 +13,7 @@ -- extra-source-files: cabal-version: >=1.10 extra-source-files: README.md- bug-reports: https://github.com/ocean0yohsuke/deepcontrol/issues- source-repository head type: git location: https://github.com/ocean0yohsuke/deepcontrol.git@@ -168,3 +166,14 @@ , HUnit >= 1.3.0 , mtl, transformers , deepcontrol+Test-Suite unit_MonadMorph-bind2+ Type: exitcode-stdio-1.0+ Default-Language: Haskell2010+ HS-Source-Dirs: test+ -- Ghc-Options: -threaded -Wall+ Main-Is: unit_MonadMorph-bind2.hs+ Build-Depends: base+ , HUnit >= 1.3.0+ , mtl, transformers+ , deepcontrol+
test/unit_MonadMorph-bind.hs view
@@ -10,7 +10,7 @@ -- Level-1 check :: IO a -> - ExceptT IOException IO a -- ExceptT-IO monad+ ExceptT IOException IO a -- ExceptT-IO monad check io = ExceptT $ (try io) viewFile :: IO () -- IO monad@@ -19,7 +19,7 @@ putStr str program :: ExceptT IOException IO () -- ExceptT-IO monad-program = (|*|) viewFile |>= check -- (|*|) is the level-1 trans-cover function, alias to 'lift', analogous to (.*)+program = (|*|) viewFile |>= check -- (|*|) is the level-1 trans-cover function, alias to 'lift', analogous to (.*) -- (|>=) is the level-1 trans-bind function, analogous to (>>=) calc_program :: IO (Either IOException ())@@ -42,7 +42,7 @@ (ExceptT IOException (MaybeT IO)) () -- ExceptT-MaybeT-IO monad program2 filename = (|*|) (viewFile2 filename) |>>= \x -> -- (|>>=) is the level-2 trans-bind function, analogous to (>>=)- (|-*|) $ check x -- (|-*|) is a level-2 trans-cover function, analogous to (-*)+ (|-*|) $ check x -- (|-*|) is a level-2 trans-cover function, analogous to (-*) calc_program2 :: String -> IO (Maybe (Either IOException ())) calc_program2 filename = runMaybeT . runExceptT $ program2 filename
+ test/unit_MonadMorph-bind2.hs view
@@ -0,0 +1,49 @@+import Test.HUnit hiding (State)++import DeepControl.Applicative+import DeepControl.Monad.Morph +import DeepControl.Monad.Trans.Except+import DeepControl.Monad.Trans.Identity++import Control.Monad.Trans.Maybe++-----------------------------------------------+-- Level-1 ++a :: MaybeT Identity a+a = (|*|) $ (.*) undefined++b :: MaybeT Identity a+b = (|*|) $ (.*) undefined++f :: Identity a -> Identity a1 -> IO a2+f x y = (.*) $ undefined++program :: MaybeT IO a+program = + a |>= \x ->+ b |>= \y -> + (|*|) (f x y)++calc_program :: IO (Maybe a)+calc_program = runMaybeT program++-- > calc_program++------------------------------------------------------+--++main :: IO ()+main = do+ --runTestTT tests_+ return ()++{-+tests_ :: Test+tests_ = test [ + "1" ~: do+ actual <- calc_program+ actual @?= Just undefined+ ]+-}+