deepcontrol 0.5.4.0 → 0.5.4.1
raw patch · 6 files changed
+103/−133 lines, 6 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- DeepControl.Applicative: infixl 3 *----|
- DeepControl.Applicative: infixl 4 |$>>>>>
- DeepControl.Applicative: infixl 5 ****->
- DeepControl.Applicative: infixl 6 ***-*
- DeepControl.Monad: infixl 1 >-
- DeepControl.Monad: infixr 1 >>>>>=>
- DeepControl.Monad.Morph: infixl 4 |<<<<<|
- DeepControl.Monad.Morph: infixl 5 |***-*|
- DeepControl.Monad.Morph: infixr 3 |>>>>>~
- DeepControl.Monad.Morph: infixr 4 |>>>>>=
- DeepControl.Monad.Trans.Identity: infixl 3 ****-:
- DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f2, Data.Foldable.Foldable f1) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
- DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f3, Data.Foldable.Foldable f2, Data.Foldable.Foldable f1) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
- DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f4, Data.Foldable.Foldable f3, Data.Foldable.Foldable f2, Data.Foldable.Foldable f1) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
- DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f5, Data.Foldable.Foldable f4, Data.Foldable.Foldable f3, Data.Foldable.Foldable f2, Data.Foldable.Foldable f1) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
- DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f2, Data.Traversable.Traversable f1) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
- DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f3, Data.Traversable.Traversable f2, Data.Traversable.Traversable f1) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
- DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f4, Data.Traversable.Traversable f3, Data.Traversable.Traversable f2, Data.Traversable.Traversable f1) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
- DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f5, Data.Traversable.Traversable f4, Data.Traversable.Traversable f3, Data.Traversable.Traversable f2, Data.Traversable.Traversable f1) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
- DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f2, GHC.Base.Functor f1) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
- DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f3, GHC.Base.Functor f2, GHC.Base.Functor f1) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
- DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f4, GHC.Base.Functor f3, GHC.Base.Functor f2, GHC.Base.Functor f1) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
- DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f5, GHC.Base.Functor f4, GHC.Base.Functor f3, GHC.Base.Functor f2, GHC.Base.Functor f1) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
+ DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f1, Data.Foldable.Foldable f2) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
+ DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f1, Data.Foldable.Foldable f2, Data.Foldable.Foldable f3) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
+ DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f1, Data.Foldable.Foldable f2, Data.Foldable.Foldable f3, Data.Foldable.Foldable f4) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
+ DeepControl.Monad.Trans.Identity: instance (Data.Foldable.Foldable f1, Data.Foldable.Foldable f2, Data.Foldable.Foldable f3, Data.Foldable.Foldable f4, Data.Foldable.Foldable f5) => Data.Foldable.Foldable (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
+ DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f1, Data.Traversable.Traversable f2) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
+ DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f1, Data.Traversable.Traversable f2, Data.Traversable.Traversable f3) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
+ DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f1, Data.Traversable.Traversable f2, Data.Traversable.Traversable f3, Data.Traversable.Traversable f4) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
+ DeepControl.Monad.Trans.Identity: instance (Data.Traversable.Traversable f1, Data.Traversable.Traversable f2, Data.Traversable.Traversable f3, Data.Traversable.Traversable f4, Data.Traversable.Traversable f5) => Data.Traversable.Traversable (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
+ DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f1, GHC.Base.Functor f2) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT2 f1 f2)
+ DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f1, GHC.Base.Functor f2, GHC.Base.Functor f3) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT3 f1 f2 f3)
+ DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f1, GHC.Base.Functor f2, GHC.Base.Functor f3, GHC.Base.Functor f4) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT4 f1 f2 f3 f4)
+ DeepControl.Monad.Trans.Identity: instance (GHC.Base.Functor f1, GHC.Base.Functor f2, GHC.Base.Functor f3, GHC.Base.Functor f4, GHC.Base.Functor f5) => GHC.Base.Functor (DeepControl.Monad.Trans.Identity.IdentityT5 f1 f2 f3 f4 f5)
Files
- DeepControl/Applicative.hs +4/−4
- DeepControl/Monad.hs +8/−8
- README.md +82/−110
- deepcontrol.cabal +2/−2
- test/unit_Monad-Level1.hs +0/−2
- test/unit_MonadTrans-ackermann.hs +7/−7
DeepControl/Applicative.hs view
@@ -8,8 +8,8 @@ Stability : experimental Portability : portable -This module enables you to program in applicative style for more __deeper__ level than the usual 'Control.Applicative' module expresses.-You would soon realize exactly what __/more deeper level/__ means by reading the example codes in order, which are attached on the functions below.+This module enables you to program in applicative style for __much deeper level__ than the usual 'Control.Applicative' module expresses.+You would soon realize exactly what __/much deeper level/__ means by reading the example codes in order, which are attached on the functions below. -} module DeepControl.Applicative ( module Control.Applicative,@@ -192,9 +192,9 @@ -- >>> foldr (\x acc -> x <$|(:)|*> acc) ((.*) []) [Just 1, Nothing, Just 3] -- Nothing ----- >>> filter (even <$|(&&)|*> (10 >)) [1..100]+-- >>> filter (even <$|(&&)|*> (10>)) [1..100] -- [2,4,6,8]--- >>> filter (even <$|(&&)|*> (10 >) <$|(&&)|*> (5 <)) [1..100]+-- >>> filter (even <$|(&&)|*> (10>) <$|(&&)|*> (5<)) [1..100] -- [6,8] (|*>) :: Applicative f => f (a -> b) -> f a -> f b (|*>) = (<*>)
DeepControl/Monad.hs view
@@ -8,17 +8,17 @@ Stability : experimental Portability : --- -This module enables you to program in Monad for more __deeper__ level than the usual 'Control.Monad' module expresses.-You would soon realize exactly what __/more deeper level/__ means by reading the example codes in order, which are attached on the Monadx(Monad, Monad, etc) classes below.+This module enables you to program in Monad for __much deeper level__ than the usual 'Control.Monad' module expresses.+You would soon realize exactly what __/much deeper level/__ means by reading the example codes in order, which are attached on the Monadx(Monad, Monad, etc) classes below. Note: - * This module never makes mtl(monad-transformer-library) unnessasary. - 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.- Theoretically it might be impossible though.+ * This module never makes mtl(monad-transformer-library) unnessasary at all. + The range of monad for which this module is effective is confined to the range that the instances of @'Traversable'@ are defined.+ This means disappointingly that this module is not effective for not-Traversable monads such as 'Reader' and 'State'.++ * In my opinion this imperfection is hard-wired with the ability of GHC on lambda expression; GHC is unable to parse @(r->)@ or @((->) r)@ yet.+ Therefore some fundamental expressions such as @(r->)|$>@ or @fmap (r->)@ are useless, it might be theoretically impossible though. -} {-# LANGUAGE TypeSynonymInstances #-}
README.md view
@@ -1,13 +1,13 @@ # deepcontrol -A Haskell library that provides more deeper level style of programming than the usual Control.Applicative and Control.Monad modules express.+A Haskell library that provides deeper level style of programming than the usual Control.Applicative and Control.Monad modules express. ## Examples -### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Applicative.html)+### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/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.+This module enables you to program in applicative style for much deeper level than the usual Control.Applicative module expresses.+You would soon realize exactly what "much deeper level" means by reading the example codes below in order. Prelude> :m DeepControl.Applicative @@ -49,14 +49,9 @@ > [0,1] <$|(+)|*> [2,3] <$|(+)|*> [4,5] [6,7,7,8,7,8,8,9] - > foldr (\x acc -> x <$|(:)|*> acc) ((.*) []) [Just 1, Just 2, Just 3]- Just [1,2,3]- > foldr (\x acc -> x <$|(:)|*> acc) ((.*) []) [Just 1, Nothing, Just 3]- Nothing-- > filter (even <$|(&&)|*> (10 >)) [1..100]+ > filter (even <$|(&&)|*> (10>)) [1..100] [2,4,6,8]- > filter (even <$|(&&)|*> (10 >) <$|(&&)|*> (5 <)) [1..100]+ > filter (even <$|(&&)|*> (10>) <$|(&&)|*> (5<)) [1..100] [6,8] cover notation:@@ -71,6 +66,11 @@ > (.*) 1 :: Either () Int Right 1 + > foldr (\x acc -> x <$|(:)|*> acc) ((.*) []) [Just 1, Just 2, Just 3]+ Just [1,2,3]+ > foldr (\x acc -> x <$|(:)|*> acc) ((.*) []) [Just 1, Nothing, Just 3]+ Nothing+ cover-braket notation: > :t (|*)@@ -106,7 +106,7 @@ bra-ket notation: - > (+1) |$>> [[2]]+ > (1+) |$>> [[2]] [[3]] > [[2]] <<$| (+1) [[3]]@@ -116,16 +116,9 @@ > [Just 1] <<$|(,)|*>> [Just 2] [Just (1,2)] - > [[1]] <<$|(+)|*>> [[2]] <<$|(-)|*>> [[3]]+ > [[1]] <<$|(+)|*>> [[2]] <<$|(^)|*>> [[3]] [[0]] - > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right (Just 2), Right (Just 3)] :: Either () (Maybe Int)- Right (Just 6)- > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right Nothing, Right (Just 3)] :: Either () (Maybe Int)- Right Nothing- > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right Nothing, Left ()]- Left ()- cover notation: > :t (.**)@@ -140,6 +133,13 @@ > (.*) [1] :: Maybe [Int] Just [1] + > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right (Just 2), Right (Just 3)] :: Either () (Maybe Int)+ Right (Just 6)+ > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right Nothing, Right (Just 3)] :: Either () (Maybe Int)+ Right Nothing+ > foldr (\n acc -> n <<$|(+)|*>> acc) ((.**) 0) [Right (Just 1), Right Nothing, Left ()]+ Left ()+ cover-braket notation: > :t (|**)@@ -182,10 +182,10 @@ Work well likewise. -### [Monad](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Monad.html)+### [Monad](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/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.+This module enables you to program in Monad for much deeper level than the usual Control.Monad module expresses.+You would soon realize exactly what "much deeper level" means by reading the example codes below in order. #### Level-0 @@ -202,7 +202,7 @@ -- 7 ``` -#### [Traversable](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Traversable.html)+#### [Traversable](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/docs/DeepControl-Traversable.html) Identity, List, Maybe, Either, Except and Writer monads are sinkable monads. @@ -286,89 +286,7 @@ Work well likewise. -### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Monad-Trans.html)--#### Level-2--Here is a monad transformer example how to implement Ackermann function improved to stop within a certain limit of time, with ReaderT-IdentityT2-IO-Maybe monad, a level-2 monad-transformation.--```haskell-import DeepControl.Applicative-import DeepControl.Traversable (sink)-import DeepControl.Monad ((>-))-import DeepControl.Monad.Morph ((|*|), (|>|))-import DeepControl.Monad.Trans (transfold2, untransfold2)-import DeepControl.Monad.Trans.Identity (Identity(..), IdentityT(..), IdentityT2(..))-import Control.Monad.Reader-import Control.Monad.Trans.Maybe--import System.Timeout (timeout)--type TimeLimit = Int--ackermannTimeLimit :: TimeLimit -> Int -> Int -> - IO (Maybe Int) -- IO-Maybe Monad-ackermannTimeLimit timelimit x y = timeout timelimit (ackermannIO x y)- where- ackermannIO :: Int -> Int -> IO Int- ackermannIO 0 n = (.*) $ n + 1- ackermannIO m n | m > 0 && n == 0 = ackermannIO (m-1) 1- | m > 0 && n > 0 = ackermannIO m (n-1) >>= ackermannIO (m-1)- -ackermann :: Int -> Int -> - ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad-ackermann x y = do- timelimit <- ask- (|*|) . IdentityT2 $ ackermannTimeLimit timelimit x y -- lift IO-Maybe function to ReaderT-IdentityT2-IO-Maybe function- -- (|*|) is the level-1 trans-cover function, alias to 'lift' and analogous to (.*)--calc_ackermann :: TimeLimit -> Int -> Int -> IO (Maybe Int)-calc_ackermann timelimit x y = ackermann x y >- \r -> runReaderT r timelimit- >- runIdentityT2---- λ> sink $ calc_ackermann 1000 |$> [0..4] |* 4--- [Just 5,Just 6,Just 11,Just 125,Nothing]--ackermann' :: Int -> Int -> - ReaderT TimeLimit (MaybeT IO) Int -- ReaderT-MaybeT-IO monad-ackermann' x y = (transfold2 . runIdentityT2) |>| ackermann x y -- You can get usual ReaderT-MaybeT-IO function from ReaderT-IdentityT2-IO-Maybe function- -- (|>|) is the level-1 trans-map function, analogous to (|$>)--ackermann'' :: Int -> Int -> - ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad-ackermann'' x y = (IdentityT2 . untransfold2) |>| ackermann' x y -- You can get ReaderT-IdentityT2-IO-Maybe function from usual ReaderT-MaybeT-IO function-```-#### Level-3, Level-4 and Level-5--Work well likewise.--transfold and untransfold:-- Prelude> :m DeepControl.Monad.Trans - > :m + Control.Monad.Trans.List Control.Monad.Trans.Maybe- > :m + DeepControl.Monad.Trans.Identity DeepControl.Monad.Trans.Except DeepControl.Monad.Trans.Writer-- > transfold3 $ ExceptT (Identity (Right [Just 1])) -- note: type Except e = ExceptT e Identity- MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))-- > :t ExceptT (Identity (Right [Just 1]))- ExceptT (Identity (Right [Just 1]))- :: Num a => ExceptT e Identity [Maybe a]- > :t transfold3 $ ExceptT (Identity (Right [Just 1]))- transfold3 $ ExceptT (Identity (Right [Just 1]))- :: Num a => MaybeT (ListT (ExceptT e Identity)) a-- > untransfold3 $ MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))- ExceptT (Identity (Right [Just 1]))-- > :t MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))- MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))- :: Num a => MaybeT (ListT (ExceptT e Identity)) a- > :t untransfold3 $ MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))- untransfold3 $ MaybeT (ListT (ExceptT (Identity (Right [Just 1]))))- :: Num a => ExceptT e Identity [Maybe a]--### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Monad-Morph.html)+### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/docs/DeepControl-Monad-Morph.html) #### SinkT @@ -410,7 +328,7 @@ tock :: StateT Int IO () tock = do generalize |>| tick :: (Monad m) => StateT Int m () -- (|>|) is the level-1 trans-map function, analogous to (|$>)- (|*|) $ putStrLn "Tock!" :: (MonadTrans t) => t IO ()+ (|*|) $ putStrLn "Tock!" :: (MonadTrans t) => t IO () -- (|*|) is the level-1 trans-cover function, the alias to 'lift' and analogous to (.*) -- λ> runStateT tock 0 -- Tock!@@ -459,7 +377,7 @@ putStr str program :: ExceptT IOException IO () -- ExceptT-IO monad-program = (|*|) viewFile |>= check -- (|*|) is the level-1 trans-cover function, alias to 'lift' and analogous to (.*)+program = (|*|) viewFile |>= check -- (|*|) is the level-1 trans-cover function, the alias to 'lift' and analogous to (.*) -- (|>=) is the level-1 trans-bind function, analogous to (>>=) calc_program :: IO (Either IOException ())@@ -497,4 +415,58 @@ Work well likewise. -### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.5.4.0/docs/DeepControl-Arrow.html)+### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/docs/DeepControl-Monad-Trans.html)++#### Level-2++Here is a monad transformer example how to implement Ackermann function improved to stop within a certain limit of time, with ReaderT-IdentityT2-IO-Maybe monad, a level-2 monad-transformation.++```haskell+import DeepControl.Applicative+import DeepControl.Traversable (sink)+import DeepControl.Monad ((>-))+import DeepControl.Monad.Morph ((|*|), (|>|))+import DeepControl.Monad.Trans (transfold2, untransfold2)+import DeepControl.Monad.Trans.Identity (Identity(..), IdentityT(..), IdentityT2(..))+import Control.Monad.Reader+import Control.Monad.Trans.Maybe++import System.Timeout (timeout)++type TimeLimit = Int++ackermannTimeLimit :: TimeLimit -> Int -> Int -> + IO (Maybe Int) -- IO-Maybe Monad+ackermannTimeLimit timelimit x y = timeout timelimit (ackermannIO x y)+ where+ ackermannIO :: Int -> Int -> IO Int+ ackermannIO 0 n = (.*) $ n + 1+ ackermannIO m n | m > 0 && n == 0 = ackermannIO (m-1) 1+ | m > 0 && n > 0 = ackermannIO m (n-1) >>= ackermannIO (m-1)+ +ackermann :: Int -> Int -> + ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad+ackermann x y = do+ timelimit <- ask+ (|*|) . IdentityT2 $ ackermannTimeLimit timelimit x y -- lift IO-Maybe function to ReaderT-IdentityT2-IO-Maybe function++calc_ackermann :: TimeLimit -> Int -> Int -> IO (Maybe Int)+calc_ackermann timelimit x y = ackermann x y >- \r -> runReaderT r timelimit+ >- runIdentityT2++-- λ> sink $ calc_ackermann 1000 |$> [0..4] |* 4+-- [Just 5,Just 6,Just 11,Just 125,Nothing]++ackermann' :: Int -> Int -> + ReaderT TimeLimit (MaybeT IO) Int -- ReaderT-MaybeT-IO monad+ackermann' x y = (transfold2 . runIdentityT2) |>| ackermann x y -- You can get the ordinary monad-transformed function from the natural one.++ackermann'' :: Int -> Int -> + ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad+ackermann'' x y = (IdentityT2 . untransfold2) |>| ackermann' x y -- You can get the natural monad-transformed function from the ordinary one.+```+#### Level-3, Level-4 and Level-5++Work well likewise.++### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.5.4.1/docs/DeepControl-Arrow.html)
deepcontrol.cabal view
@@ -1,6 +1,6 @@ name: deepcontrol-version: 0.5.4.0-synopsis: Provide deep level programming style for Applicative and Monad+version: 0.5.4.1+synopsis: A library that provides deep-level programming style or notation on Applicative and Monad description: This module provides more deeper level style of programming than the usual Applicative and Monad modules express. license: BSD3 license-file: LICENSE
test/unit_Monad-Level1.hs view
@@ -143,5 +143,3 @@ actual @?= Right (IntVal 3,9,["a","b","x","y"]) ] --
test/unit_MonadTrans-ackermann.hs view
@@ -14,7 +14,7 @@ type TimeLimit = Int ackermannTimeLimit :: TimeLimit -> Int -> Int -> - IO (Maybe Int) -- IO-Maybe Monad+ IO (Maybe Int) ackermannTimeLimit timelimit x y = timeout timelimit (ackermannIO x y) where ackermannIO :: Int -> Int -> IO Int@@ -23,10 +23,10 @@ | m > 0 && n > 0 = ackermannIO m (n-1) >>= ackermannIO (m-1) ackermann :: Int -> Int -> - ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad+ ReaderT TimeLimit (IdentityT2 IO Maybe) Int ackermann x y = do timelimit <- ask- (|*|) . IdentityT2 $ ackermannTimeLimit timelimit x y -- lift IO-Maybe function to ReaderT-IdentityT2-IO-Maybe function+ (|*|) . IdentityT2 $ ackermannTimeLimit timelimit x y calc_ackermann :: TimeLimit -> Int -> Int -> IO (Maybe Int) calc_ackermann timelimit x y = ackermann x y >- \r -> runReaderT r timelimit@@ -36,16 +36,16 @@ -- [Just 5,Just 6,Just 11,Just 125,Nothing] ackermann' :: Int -> Int -> - ReaderT TimeLimit (MaybeT IO) Int -- ReaderT-MaybeT-IO monad-ackermann' x y = (transfold2 . runIdentityT2) |>| ackermann x y -- You can get usual ReaderT-MaybeT-IO function from ReaderT-IdentityT2-IO-Maybe function+ ReaderT TimeLimit (MaybeT IO) Int +ackermann' x y = (transfold2 . runIdentityT2) |>| ackermann x y calc_ackermann' :: TimeLimit -> Int -> Int -> IO (Maybe Int) calc_ackermann' timelimit x y = ackermann' x y >- \r -> runReaderT r timelimit >- runMaybeT ackermann'' :: Int -> Int -> - ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad-ackermann'' x y = (IdentityT2 . untransfold2) |>| ackermann' x y -- You can get ReaderT-IdentityT2-IO-Maybe function from usual ReaderT-MaybeT-IO function+ ReaderT TimeLimit (IdentityT2 IO Maybe) Int +ackermann'' x y = (IdentityT2 . untransfold2) |>| ackermann' x y calc_ackermann'' :: TimeLimit -> Int -> Int -> IO (Maybe Int) calc_ackermann'' timelimit x y = ackermann'' x y >- \r -> runReaderT r timelimit