deepcontrol 0.4.2.0 → 0.4.2.1
raw patch · 17 files changed
+541/−324 lines, 17 filesdep ~basedep ~mtldep ~transformersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, mtl, transformers
API changes (from Hackage documentation)
- DeepControl.Monad.Trans.Except: instance DeepControl.Monad.Monad2 (Control.Monad.Trans.Except.Except e)
- DeepControl.Monad.Trans.Except: instance DeepControl.Monad.Monad3 (Control.Monad.Trans.Except.Except e)
- DeepControl.Monad.Trans.Except: instance DeepControl.Monad.Monad4 (Control.Monad.Trans.Except.Except e)
- DeepControl.Monad.Trans.Except: instance DeepControl.Monad.Monad5 (Control.Monad.Trans.Except.Except e)
- 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)
- DeepControl.Monad.Trans.Writer: instance GHC.Base.Monoid w => DeepControl.Monad.Monad2 (Control.Monad.Trans.Writer.Lazy.Writer w)
- DeepControl.Monad.Trans.Writer: instance GHC.Base.Monoid w => DeepControl.Monad.Monad3 (Control.Monad.Trans.Writer.Lazy.Writer w)
- DeepControl.Monad.Trans.Writer: instance GHC.Base.Monoid w => DeepControl.Monad.Monad4 (Control.Monad.Trans.Writer.Lazy.Writer w)
- DeepControl.Monad.Trans.Writer: instance GHC.Base.Monoid w => DeepControl.Monad.Monad5 (Control.Monad.Trans.Writer.Lazy.Writer w)
+ DeepControl.Applicative: (****->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f5 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (***-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (***-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (**-**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (**-*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (**--*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (**--->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*-***>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*-**->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*-*-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*-*-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*--**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*--*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*---*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (*---->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-****>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-***->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-**-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-**-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-*-**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-*-*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-*--*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (-*--->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (--***>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (--**->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (--*-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (--*-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (---**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (---*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ DeepControl.Applicative: (----*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f4 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))
+ 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: instance DeepControl.Monad.Monad2 (Control.Monad.Trans.Except.Except e)
+ DeepControl.Monad: instance DeepControl.Monad.Monad3 (Control.Monad.Trans.Except.Except e)
+ DeepControl.Monad: instance DeepControl.Monad.Monad4 (Control.Monad.Trans.Except.Except e)
+ DeepControl.Monad: instance DeepControl.Monad.Monad5 (Control.Monad.Trans.Except.Except e)
+ DeepControl.Monad: instance GHC.Base.Monoid w => DeepControl.Monad.Monad2 (Control.Monad.Trans.Writer.Lazy.Writer w)
+ DeepControl.Monad: instance GHC.Base.Monoid w => DeepControl.Monad.Monad3 (Control.Monad.Trans.Writer.Lazy.Writer w)
+ DeepControl.Monad: instance GHC.Base.Monoid w => DeepControl.Monad.Monad4 (Control.Monad.Trans.Writer.Lazy.Writer w)
+ DeepControl.Monad: instance GHC.Base.Monoid w => DeepControl.Monad.Monad5 (Control.Monad.Trans.Writer.Lazy.Writer w)
+ DeepControl.Monad.Morph: infixl 2 |>>>>>|
+ DeepControl.Monad.Morph: infixr 2 |<<<<<|
+ DeepControl.Monad.Trans: -> (* -> *) -> (* -> *) -> (* -> *) -> * -> *;
+ DeepControl.Monad.Trans: infixl 3 |****-|
+ DeepControl.Monad.Trans: type family Trans5Down t5 :: (* -> *)
+ DeepControl.Monad.Trans: }
+ 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: class (MonadTrans (Trans2Down t2), MonadTrans2 t2) => MonadTrans2Down t2 where type family Trans2Down t2 :: (* -> *) -> * -> *
+ DeepControl.Monad.Trans: class (MonadTrans (Trans2Down t2), MonadTrans2 t2) => MonadTrans2Down t2 where type Trans2Down t2 :: (* -> *) -> * -> * where {
- DeepControl.Monad.Trans: class (MonadTrans2 (Trans3Down t3), MonadTrans3 t3) => MonadTrans3Down t3 where type family Trans3Down t3 :: (* -> *) -> (* -> *) -> * -> *
+ DeepControl.Monad.Trans: class (MonadTrans2 (Trans3Down t3), MonadTrans3 t3) => MonadTrans3Down t3 where type Trans3Down t3 :: (* -> *) -> (* -> *) -> * -> * where {
- DeepControl.Monad.Trans: class (MonadTrans3 (Trans4Down t4), MonadTrans4 t4) => MonadTrans4Down t4 where type family Trans4Down t4 :: (* -> *) -> (* -> *) -> (* -> *) -> * -> *
+ DeepControl.Monad.Trans: class (MonadTrans3 (Trans4Down t4), MonadTrans4 t4) => MonadTrans4Down t4 where type Trans4Down t4 :: (* -> *) -> (* -> *) -> (* -> *) -> * -> * where {
- DeepControl.Monad.Trans: class (MonadTrans4 (Trans5Down t5), MonadTrans5 t5) => MonadTrans5Down t5 where type family Trans5Down t5 :: (* -> *) -> (* -> *) -> (* -> *) -> (* -> *) -> * -> *
+ DeepControl.Monad.Trans: class (MonadTrans4 (Trans5Down t5), MonadTrans5 t5) => MonadTrans5Down t5 where type Trans5Down t5 :: (* -> *) -> (* -> *) -> (* -> *) -> (* -> *) -> * -> * where {
- DeepControl.Monad.Trans: class (Monad (TransDown t1), MonadTrans t1) => MonadTransDown t1 where type family TransDown t1 :: * -> *
+ DeepControl.Monad.Trans: class (Monad (TransDown t1), MonadTrans t1) => MonadTransDown t1 where type TransDown t1 :: * -> * where {
Files
- DeepControl/Applicative.hs +172/−99
- DeepControl/Monad.hs +107/−47
- DeepControl/Monad/Trans.hs +2/−2
- DeepControl/Monad/Trans/Except.hs +0/−13
- DeepControl/Monad/Trans/Identity.hs +1/−1
- DeepControl/Monad/Trans/Writer.hs +0/−30
- README.md +72/−30
- deepcontrol.cabal +23/−3
- test/unit_Monad-Level1.hs +1/−1
- test/unit_Monad-Level2.hs +1/−1
- test/unit_Monad-factorial.hs +30/−0
- test/unit_Monad-factorial2.hs +36/−0
- test/unit_Monad.hs +2/−1
- test/unit_MonadMorph.hs +2/−2
- test/unit_MonadTrans-2.hs +0/−85
- test/unit_MonadTrans-ackermann.hs +85/−0
- test/unit_MonadTrans.hs +7/−9
DeepControl/Applicative.hs view
@@ -22,7 +22,7 @@ (*:), -- ** bra-ket notation (|$>), (<$|), (|*>), (<*|),- -- ** braket-cover notation+ -- ** cover-bracket notation (|*), (*|), -- * Level-2@@ -30,11 +30,11 @@ (**:), (-*), -- ** bra-ket notation (|$>>), (<<$|), (|*>>), (<<*|),- -- ** braket-cover notation+ -- ** cover-bracket notation (|**), (**|), (|-*), (|*-), (-*|), (*-|),- -- ** sequnce notation+ -- ** sequence notation (*>>), (<<*), - -- ** sequnce-cover notation+ -- ** cover-sequence notation (-*>), (<-*), (*->), (<*-), -- * Level-3@@ -44,16 +44,16 @@ (--*), -- ** bra-ket notation (|$>>>), (<<<$|), (|*>>>), (<<<*|),- -- ** braket-cover notation+ -- ** cover-bracket notation (|***), (|-**), (|*-*), (|**-), (|--*), (|-*-), (|*--), (***|), (-**|), (*-*|), (**-|), (--*|), (-*-|), (*--|),- -- ** sequnce notation+ -- ** sequence notation (*>>>), (<<<*),- -- ** sequnce-cover notation+ -- ** cover-sequence notation (*-->), (-*->), (--*>), (**->), (*-*>), (-**>), (<*--), (<-*-), (<--*), @@ -67,7 +67,7 @@ (-***), (*-**), (**-*), -- ** bra-ket notation (|$>>>>), (<<<<$|), (|*>>>>), (<<<<*|),- -- ** braket-cover notation+ -- ** cover-bracket notation (|****), (|-***), (|*-**), (|**-*), (|***-), (|--**), (|-*-*), (|*--*), (|*-*-), (|-**-), (|**--),@@ -76,9 +76,9 @@ (-***|), (*-**|), (**-*|), (***-|), (--**|), (-*-*|), (*--*|), (*-*-|), (-**-|), (**--|), (---*|), (--*-|), (-*--|), (*---|),- -- ** sequnce notation+ -- ** sequence notation (*>>>>), (<<<<*),- -- ** sequnce-cover notation+ -- ** cover-sequence notation (<---*), (<--*-), (<-*--), (<*---), (<--**), (<-*-*), (<*--*), (<*-*-), (<-**-), (<**--), (<-***), (<*-**), (<**-*), (<***-),@@ -95,7 +95,7 @@ (-****), (*-***), (**-**), (***-*), -- ** bra-ket notation (|$>>>>>), (<<<<<$|), (|*>>>>>), (<<<<<*|),- -- ** braket-cover notation+ -- ** cover-bracket notation (|-****), (|*-***), (|**-**), (|***-*), (|****-), (|--***), (|-*-**), (|*--**), (|*-*-*), (|-**-*), (|**--*), (|**-*-), (|*-**-), (|-***-), (|***--), (|---**), (|--*-*), (|-*--*), (|*---*), (|*--*-), (|-*-*-), (|--**-), (|-**--), (|*-*--), (|**---),@@ -104,13 +104,17 @@ (--***|), (-*-**|), (*--**|), (*-*-*|), (-**-*|), (**--*|), (**-*-|), (*-**-|), (-***-|), (***--|), (---**|), (--*-*|), (-*--*|), (*---*|), (*--*-|), (-*-*-|), (--**-|), (-**--|), (*-*--|), (**---|), (----*|), (---*-|), (--*--|), (-*---|), (*----|),- -- ** sequnce notation+ -- ** sequence notation (*>>>>>), (<<<<<*),- -- ** sequnce-cover notation+ -- ** cover-sequence notation (<----*), (<---*-), (<--*--), (<-*---), (<*----), (<---**), (<--*-*), (<-*--*), (<*---*), (<*--*-), (<-*-*-), (<--**-), (<-**--), (<*-*--), (<**---), (<--***), (<-*-**), (<*--**), (<*-*-*), (<-**-*), (<**--*), (<**-*-), (<*-**-), (<-***-), (<***--), (<-****), (<*-***), (<**-**), (<***-*), (<****-),+ (----*>), (---*->), (--*-->), (-*--->), (*---->),+ (---**>), (--*-*>), (-*--*>), (*---*>), (*--*->), (-*-*->), (--**->), (-**-->), (*-*-->), (**--->),+ (--***>), (-*-**>), (*--**>), (*-*-*>), (-**-*>), (**--*>), (**-*->), (*-**->), (-***->), (***-->),+ (-****>), (*-***>), (**-**>), (***-*>), (****->), ) where @@ -146,14 +150,12 @@ -- Level-1 functions infixl 6 *:---- | Alias for @'pure'@.+-- | Alias to @'pure'@. (*:) :: (Applicative f) => a -> f a (*:) = pure infixl 4 |$>---- | Alias for @'<$>'@.+-- | Alias to @'<$>'@. -- -- >>> (1+) |$> [2] -- [3]@@ -172,7 +174,7 @@ (<$|) :: Functor f => f a -> (a -> b) -> f b (<$|) = flip (|$>) --- | Alias for @'<*>'@.+-- | Alias to @'<*>'@. -- -- >>> [(1+)] |*> [2] -- [3]@@ -200,7 +202,7 @@ (<*|) :: Applicative f => f a -> f (a -> b) -> f b (<*|) = flip (|*>) --- | Combination consisted of ket @'|*>'@ and cover @'*:'@, defined as @f |* x = f |*> (*:) x@.+-- | Definition: @ f |* x = f |*> (*:) x @ -- -- >>> [(1+)] |* 2 -- [3]@@ -240,16 +242,22 @@ infixl 6 **: infixl 6 -*--- | Combination consisted of cover @'*:'@ twice, defined as @(**:) = (*:) . (*:)@.+-- | Definition: @ (**:) = (*:) . (*:) @+--+-- >>> (**:) 1 :: Maybe [Int]+-- Just [1] (**:) :: (Applicative f1, Applicative f2) => a -> f1 (f2 a) (**:) = (*:) . (*:)--- | Combination consisted of cover @'*:'@ and ket @'|$>'@, defined as @(-*) = ((*:)|$>)@.+-- | Definition: @ (-*) = ((*:)|$>) @+--+-- >>> (-*) (Just 1) :: Maybe [Int]+-- Just [1] (-*) :: (Applicative f1, Applicative f2) => f1 a -> f1 (f2 a) (-*) = ((*:)|$>) infixl 4 |$>> --- | Combination consisted of cover @'|$>'@ twice, defined as @(|$>>) = (|$>) . (|$>)@.+-- | Definition: @ (|$>>) = (|$>) . (|$>) @ -- -- >>> (+1) |$>> [[2]] -- [[3]]@@ -267,7 +275,7 @@ (<<$|) :: (Functor f1, Functor f2) => f1 (f2 a) -> (a -> b) -> f1 (f2 b) (<<$|) = flip (|$>>) --- | The lifted function of @'|*>'@, defined as @(|*>>) = liftA2 (|*>)@.+-- | Definition: @ (|*>>) = liftA2 (|*>) @ -- -- >>> [Just 1] <<$|(+)|*>> [Just 2] -- [Just 3]@@ -287,18 +295,18 @@ (|*>>) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> f1 (f2 a) -> f1 (f2 b) (|*>>) = liftA2 (|*>) --- | The lifted function of @'<*|'@, defined as @(<<*|) = liftA2 (<*|)@.+-- | Definition: @ (<<*|) = liftA2 (<*|) @ (<<*|) :: (Applicative f1, Applicative f2) => f1 (f2 a) -> f1 (f2 (a -> b)) -> f1 (f2 b) (<<*|) = liftA2 (<*|) --- | Combination consisted of ket @'|*>>'@ and cover @'**:'@, defined as @f |** x = f |*>> (**:) x@.+-- | Definition: @ f |** x = f |*>> (**:) x @ -- -- >>> [Just 1] <<$|(+)|** 2 -- [Just 3] (|**) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> a -> f1 (f2 b) f |** x = f |*>> (**:) x --- | The auguments-flipped function for @'|**'@.+-- | Definition: @ x **| f = (**:) x <<*| f @ -- -- >>> 1 **|(+)|$>> [Just 2] -- [Just 3]@@ -308,30 +316,30 @@ -- >>> 1 **|[Just (+), Just (-), Just (*), Nothing]|** 2 -- [Just 3,Just (-1),Just 2,Nothing] (**|) :: (Applicative f1, Applicative f2) => a -> f1 (f2 (a -> b)) -> f1 (f2 b)-(**|) = flip (|**)+x **| f = (**:) x <<*| f --- | Combination consisted of ket @'|*>>'@ and cover @'-*'@, defined as @f |-* x = f |*>> (-*) x@.+-- | Definition: @ f |-* x = f |*>> (-*) x @ -- -- >>> [Just 1] <<$|(+)|-* [2] -- [Just 3] (|-*) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> f1 a -> f1 (f2 b) f |-* x = f |*>> (-*) x --- | Combination consisted of ket @'|*>>'@ and cover @'*-'@, defined as @f |*- x = f |*>> (*-) x@.+-- | Definition: @ f |*- x = f |*>> (*:) x @ -- -- >>> [Just 1] <<$|(+)|*- Just 2 -- [Just 3] (|*-) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> f2 a -> f1 (f2 b) f |*- x = f |*>> (*:) x --- | The auguments-flipped function for @'|-*'@.+-- | Definition: @ x -*| f = (-*) x <<*| f @ -- -- >>> [1] -*|(+)|$>> [Just 2] -- [Just 3] (-*|) :: (Applicative f1, Applicative f2) => f1 a -> f1 (f2 (a -> b)) -> f1 (f2 b)-(-*|) = flip (|-*)+x -*| f = (-*) x <<*| f --- | The auguments-flipped function for @'|*-'@.+-- | Definition: @ x *-| f = (*:) x <<*| f @ -- -- >>> Just 1 *-|(+)|$>> [Just 2] -- [Just 3]@@ -351,12 +359,12 @@ -- 2 -- [3] (*-|) :: (Applicative f1, Applicative f2) => f2 a -> f1 (f2 (a -> b)) -> f1 (f2 b)-(*-|) = flip (|*-)+x *-| f = (*:) x <<*| f infixl 5 <<*, *>> infixl 5 *->, <*-, -*>, <-* --- | The lifted function of @'*>'@, defined as @liftA2 (*>)@.+-- | Definition: @ (*>>) = liftA2 (*>) @ -- -- >>> sequence $ Just (print 1) *>> (**:) 2 -- 1@@ -368,7 +376,7 @@ (*>>) :: (Applicative f1, Applicative f2) => f1 (f2 a) -> f1 (f2 b) -> f1 (f2 b) (*>>) = liftA2 (*>) --- | The lifted function of @'<*'@, defined as @liftA2 (<*)@.+-- | Definition: @ (<<*) = liftA2 (<*) @ -- -- >>> sequence $ (**:) 2 <<* Just (print 1) -- 1@@ -383,7 +391,7 @@ (<<*) :: (Applicative f1, Applicative f2) => f1 (f2 a) -> f1 (f2 b) -> f1 (f2 a) (<<*) = liftA2 (<*) --- | Combination consisted of sequence @'*>>'@ and cover @'-*'@.+-- | Definition: @ a -*> x = (-*) a *>> x @ -- -- >>> print 1 -*> (*:) (Just 2) -- 1@@ -391,7 +399,7 @@ (-*>) :: (Applicative f1, Applicative f2) => f1 a -> f1 (f2 b) -> f1 (f2 b) a -*> x = (-*) a *>> x --- | Combination consisted of sequence @'<<*'@ and cover @'-*'@.+-- | Definition: @ x <-* a = x <<* (-*) a @ -- -- >>> (*:) (Just 2) <-* print 1 -- 1@@ -406,7 +414,7 @@ (<-*) :: (Applicative f1, Applicative f2) => f1 (f2 b) -> f1 a -> f1 (f2 b) x <-* a = x <<* (-*) a --- | Combination consisted of sequence @'*>>'@ and cover @'*:'@.+-- | Definition: @ a *-> x = (*:) a *>> x @ -- -- >>> sequence $ print 1 *-> Just ((*:) 2) -- 1@@ -414,7 +422,7 @@ (*->) :: (Applicative f1, Applicative f2) => f2 a -> f1 (f2 b) -> f1 (f2 b) a *-> x = (*:) a *>> x --- | Combination consisted of sequence @'<<*'@ and cover @'*:'@.+-- | Definition: @ x <*- a = x <<* (*:) a @ -- -- >>> sequence $ Just ((*:) 2) <*- print 1 -- 1@@ -428,7 +436,7 @@ (<*-) :: (Applicative f1, Applicative f2) => f1 (f2 b) -> f2 a -> f1 (f2 b) x <*- a = x <<* (*:) a --- -----------------------------------------------------------------------------+------------------------------------------------------------------------------- -- Level-3 functions infixl 6 ***:@@ -599,35 +607,35 @@ infixl 3 -***|, *-**|, **-*|, ***-| (-***|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 a -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x -***| f = f |*>>>> (-***) x+x -***| f = (-***) x <<<<*| f (*-**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 a -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x *-**| f = f |*>>>> (*-**) x+x *-**| f = (*-**) x <<<<*| f (**-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f3 a -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x **-*| f = f |*>>>> (**-*) x+x **-*| f = (**-*) x <<<<*| f (***-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f4 a -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x ***-| f = f |*>>>> (***:) x+x ***-| f = (***:) x <<<<*| f infixl 3 --**|, -*-*|, *--*|, *-*-|, -**-|, **--| (--**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x --**| f = f |*>>>> (--**) x+x --**| f = (--**) x <<<<*| f (-*-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f3 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x -*-*| f = f |*>>>> (-*-*) x+x -*-*| f = (-*-*) x <<<<*| f (*--*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f3 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x *--*| f = f |*>>>> (*--*) x+x *--*| f = (*--*) x <<<<*| f (*-*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f4 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x *-*-| f = f |*>>>> (*-*) x+x *-*-| f = (*-*) x <<<<*| f (-**-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f4 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x -**-| f = f |*>>>> (-**) x+x -**-| f = (-**) x <<<<*| f (**--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f3 (f4 a) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x **--| f = f |*>>>> (**:) x+x **--| f = (**:) x <<<<*| f infixl 3 ---*|, --*-|, -*--|, *---| (---*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 (f3 a)) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x ---*| f = f |*>>>> (---*) x+x ---*| f = (---*) x <<<<*| f (--*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 (f4 a)) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x --*-| f = f |*>>>> (--*) x+x --*-| f = (--*) x <<<<*| f (-*--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x -*--| f = f |*>>>> (-*) x+x -*--| f = (-*) x <<<<*| f (*---|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (a -> b)))) -> f1 (f2 (f3 (f4 b)))-x *---| f = f |*>>>> (*:) x+x *---| f = (*:) x <<<<*| f infixl 5 <<<<*, *>>>> (*>>>>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 (f3 (f4 a))) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))@@ -669,37 +677,37 @@ infixl 5 ---*>, --*->, -*-->, *---> (---*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 (f3 a)) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a ---*> x = x <<<<* (---*) a+a ---*> x = (---*) a *>>>> x (--*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 (f4 a)) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a --*-> x = x <<<<* (--*) a+a --*-> x = (--*) a *>>>> x (-*-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f3 (f4 a)) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a -*--> x = x <<<<* (-*) a+a -*--> x = (-*) a *>>>> x (*--->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f3 (f4 a)) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a *---> x = x <<<<* (*:) a+a *---> x = (*:) a *>>>> x infixl 5 --**>, -*-*>, *--*>, *-*->, -**->, **--> (--**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f2 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a --**> x = x <<<<* (--**) a+a --**> x = (--**) a *>>>> x (-*-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f3 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a -*-*> x = x <<<<* (-*-*) a+a -*-*> x = (-*-*) a *>>>> x (*--*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f3 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a *--*> x = x <<<<* (*--*) a+a *--*> x = (*--*) a *>>>> x (*-*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 (f4 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a *-*-> x = x <<<<* (*-*) a+a *-*-> x = (*-*) a *>>>> x (-**->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 (f4 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a -**-> x = x <<<<* (-**) a+a -**-> x = (-**) a *>>>> x (**-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f3 (f4 a) -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a **--> x = x <<<<* (**:) a+a **--> x = (**:) a *>>>> x infixl 5 -***>, *-**>, **-*>, ***-> (-***>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f1 a -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a -***> x = x <<<<* (-***) a+a -***> x = (-***) a *>>>> x (*-**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f2 a -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a *-**> x = x <<<<* (*-**) a+a *-**> x = (*-**) a *>>>> x (**-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f3 a -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a **-*> x = x <<<<* (**-*) a+a **-*> x = (**-*) a *>>>> x (***->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4) => f4 a -> f1 (f2 (f3 (f4 b))) -> f1 (f2 (f3 (f4 b)))-a ***-> x = x <<<<* (***:) a+a ***-> x = (***:) a *>>>> x --- -----------------------------------------------------------------------------+------------------------------------------------------------------------------- -- Level-5 functions infixl 6 *****:@@ -818,68 +826,68 @@ infixl 3 -****|, *-***|, **-**|, ***-*|, ****-| (-****|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 a -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -****| f = f |*>>>>> (-****) x+x -****| f = (-****) x <<<<<*| f (*-***|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 a -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *-***| f = f |*>>>>> (*-***) x+x *-***| f = (*-***) x <<<<<*| f (**-**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 a -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x **-**| f = f |*>>>>> (**-**) x+x **-**| f = (**-**) x <<<<<*| f (***-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 a -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ***-*| f = f |*>>>>> (***-*) x+x ***-*| f = (***-*) x <<<<<*| f (****-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f5 a -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ****-| f = f |*>>>>> (****:) x+x ****-| f = (****:) x <<<<<*| f infixl 3 --***|, -*-**|, *--**|, *-*-*|, -**-*|, **--*|, **-*-|, *-**-|, -***-|, ***--| (--***|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x --***| f = f |*>>>>> (--***) x+x --***| f = (--***) x <<<<<*| f (-*-**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -*-**| f = f |*>>>>> (-*-**) x+x -*-**| f = (-*-**) x <<<<<*| f (*--**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *--**| f = f |*>>>>> (*--**) x+x *--**| f = (*--**) x <<<<<*| f (*-*-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *-*-*| f = f |*>>>>> (*-*-*) x+x *-*-*| f = (*-*-*) x <<<<<*| f (-**-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -**-*| f = f |*>>>>> (-**-*) x+x -**-*| f = (-**-*) x <<<<<*| f (**--*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x **--*| f = f |*>>>>> (**--*) x+x **--*| f = (**--*) x <<<<<*| f (**-*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f5 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x **-*-| f = f |*>>>>> (**-*) x+x **-*-| f = (**-*) x <<<<<*| f (*-**-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f5 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *-**-| f = f |*>>>>> (*-**) x+x *-**-| f = (*-**) x <<<<<*| f (-***-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f5 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -***-| f = f |*>>>>> (-***) x+x -***-| f = (-***) x <<<<<*| f (***--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 (f5 a) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ***--| f = f |*>>>>> (***:) x+x ***--| f = (***:) x <<<<<*| f infixl 3 ---**|, --*-*|, -*--*|, *---*|, *--*-|, -*-*-|, --**-|, -**--|, *-*--|, **---| (---**|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ---**| f = f |*>>>>> (---**) x+x ---**| f = (---**) x <<<<<*| f (--*-*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x --*-*| f = f |*>>>>> (--*-*) x+x --*-*| f = (--*-*) x <<<<<*| f (-*--*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -*--*| f = f |*>>>>> (-*--*) x+x -*--*| f = (-*--*) x <<<<<*| f (*---*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *---*| f = f |*>>>>> (*---*) x+x *---*| f = (*---*) x <<<<<*| f (*--*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *--*-| f = f |*>>>>> (*--*) x+x *--*-| f = (*--*) x <<<<<*| f (-*-*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -*-*-| f = f |*>>>>> (-*-*) x+x -*-*-| f = (-*-*) x <<<<<*| f (--**-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x --**-| f = f |*>>>>> (--**) x+x --**-| f = (--**) x <<<<<*| f (-**--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -**--| f = f |*>>>>> (-**) x+x -**--| f = (-**) x <<<<<*| f (*-*--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *-*--| f = f |*>>>>> (*-*) x+x *-*--| f = (*-*) x <<<<<*| f (**---|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x **---| f = f |*>>>>> (**:) x+x **---| f = (**:) x <<<<<*| f infixl 3 ----*|, ---*-|, --*--|, -*---|, *----| (----*|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f4 a))) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ----*| f = f |*>>>>> (----*) x+x ----*| f = (----*) x <<<<<*| f (---*-|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f5 a))) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x ---*-| f = f |*>>>>> (---*) x+x ---*-| f = (---*) x <<<<<*| f (--*--|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x --*--| f = f |*>>>>> (--*) x+x --*--| f = (--*) x <<<<<*| f (-*---|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x -*---| f = f |*>>>>> (-*) x+x -*---| f = (-*) x <<<<<*| f (*----|) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 (a -> b))))) -> f1 (f2 (f3 (f4 (f5 b))))-x *----| f = f |*>>>>> (*:) x+x *----| f = (*:) x <<<<<*| f infixl 5 <<<<<*, *>>>>> (*>>>>>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f4 (f5 a)))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))@@ -951,4 +959,69 @@ x <***-* a = x <<<<<* (***-*) a (<****-) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f4 (f5 b)))) -> f5 a -> f1 (f2 (f3 (f4 (f5 b)))) x <****- a = x <<<<<* (****:) a++infixl 5 ----*>, ---*->, --*-->, -*--->, *---->+(----*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f4 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ----*> x = (----*) a *>>>>> x+(---*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ---*-> x = (---*) a *>>>>> x+(--*-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a --*--> x = (--*) a *>>>>> x+(-*--->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -*---> x = (-*) a *>>>>> x+(*---->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 (f5 a))) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *----> x = (*:) a *>>>>> x+infixl 5 ---**>, --*-*>, -*--*>, *---*>, *--*->, -*-*->, --**->, -**-->, *-*-->, **--->+(---**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f3 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ---**> x = (---**) a *>>>>> x+(--*-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a --*-*> x = (--*-*) a *>>>>> x+(-*--*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -*--*> x = (-*--*) a *>>>>> x+(*---*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f4 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *---*> x = (*---*) a *>>>>> x+(*--*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *--*-> x = (*--*) a *>>>>> x+(-*-*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -*-*-> x = (-*-*) a *>>>>> x+(--**->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a --**-> x = (--**) a *>>>>> x+(-**-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -**--> x = (-**) a *>>>>> x+(*-*-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *-*--> x = (*-*) a *>>>>> x+(**--->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 (f5 a)) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a **---> x = (**:) a *>>>>> x+infixl 5 --***>, -*-**>, *--**>, *-*-*>, -**-*>, **--*>, **-*->, *-**->, -***->, ***-->+(--***>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f2 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a --***> x = (--***) a *>>>>> x+(-*-**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f3 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -*-**> x = (-*-**) a *>>>>> x+(*--**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f3 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *--**> x = (*--**) a *>>>>> x+(*-*-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *-*-*> x = (*-*-*) a *>>>>> x+(-**-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -**-*> x = (-**-*) a *>>>>> x+(**--*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f4 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a **--*> x = (**--*) a *>>>>> x+(**-*->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a **-*-> x = (**-*) a *>>>>> x+(*-**->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *-**-> x = (*-**) a *>>>>> x+(-***->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -***-> x = (-***) a *>>>>> x+(***-->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 (f5 a) -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ***--> x = (***:) a *>>>>> x+infixl 5 -****>, *-***>, **-**>, ***-*>, ****->+(-****>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f1 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a -****> x = (-****) a *>>>>> x+(*-***>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f2 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a *-***> x = (*-***) a *>>>>> x+(**-**>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f3 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a **-**> x = (**-**) a *>>>>> x+(***-*>) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f4 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ***-*> x = (***-*) a *>>>>> x+(****->) :: (Applicative f1, Applicative f2, Applicative f3, Applicative f4, Applicative f5) => f5 a -> f1 (f2 (f3 (f4 (f5 b)))) -> f1 (f2 (f3 (f4 (f5 b))))+a ****-> x = (****:) a *>>>>> x
DeepControl/Monad.hs view
@@ -20,6 +20,8 @@ Theoretically it might be impossible though. -}+{-# LANGUAGE TypeSynonymInstances #-}+{-# LANGUAGE FlexibleInstances #-} module DeepControl.Monad ( module Control.Monad, @@ -34,9 +36,9 @@ Monad2(..), -- ** sequence (>>~), - -- ** bind-cover+ -- ** cover-bind (>-==), (->==), - -- ** sequence-cover+ -- ** cover-sequence (>-~), (->~), -- ** composite (>==>), @@ -46,9 +48,9 @@ Monad3(..), -- ** sequence (>>>~),- -- ** bind-cover + -- ** cover-bind (>>-==), (->>==), (>->==) ,(>--==),(->-==), (-->==), - -- ** sequence-cover + -- ** cover-sequence (>--~), (->-~), (-->~), (>>-~), (->>~), (>->~), -- ** composite (>===>),@@ -58,11 +60,11 @@ Monad4(..), -- ** sequence (>>>>~), - -- ** bind-cover + -- ** cover-bind (--->==), (-->-==), (->--==), (>---==), (-->>==), (->->==), (>-->==), (>->-==), (->>-==), (>>--==), (->>>==), (>->>==), (>>->==), (>>>-==),- -- ** sequence-cover + -- ** cover-sequence (--->~), (-->-~), (->--~), (>---~), (-->>~), (->->~), (>-->~), (>->-~), (->>-~), (>>--~), (->>>~), (>->>~), (>>->~), (>>>-~),@@ -74,12 +76,12 @@ Monad5(..), -- ** sequence (>>>>>~), - -- ** bind-cover + -- ** cover-bind (---->==), (--->-==), (-->--==), (->---==), (>----==), (--->>==), (-->->==), (->-->==), (>--->==), (>-->-==), (->->-==), (-->>-==), (->>--==), (>->--==), (>>---==), (-->>>==), (->->>==), (>-->>==), (>->->==), (->>->==), (>>-->==), (>>->-==), (>->>-==), (->>>-==), (>>>--==), (->>>>==), (>->>>==), (>>->>==), (>>>->==), (>>>>-==),- -- ** sequence-cover + -- ** cover-sequence (---->~), (--->-~), (-->--~), (->---~), (>----~), (--->>~), (-->->~), (->-->~), (>--->~), (>-->-~), (->->-~), (-->>-~), (->>--~), (>->--~), (>>---~), (-->>>~), (->->>~), (>-->>~), (>->->~), (->>->~), (>>-->~), (>>->-~), (>->>-~), (->>>-~), (>>>--~),@@ -90,13 +92,18 @@ ) where import DeepControl.Applicative+ import Control.Monad+import Control.Monad.Writer (Writer, WriterT(..), runWriter)+import Control.Monad.Except (Except, ExceptT(..), runExcept)+import Data.Functor.Identity+import Data.Monoid (Monoid, (<>)) ------------------------------------------------------------------------------- -- Level-0 functions infixl 1 -<, >---- | Anologous for @'$'@; (-<) is left associative.+-- | Anologous for @'$'@, but (-<) is left associative. -- -- >>> Just -< 3 -- Just 3@@ -121,7 +128,7 @@ (>-) = flip (-<) infixr 1 <-<, >->--- | Anologous for @'.'@. +-- | Anologous for @'.'@, but the infix preference is low. -- -- >>> ((3+) <-< (2*) <-< (1+)) -< 1 -- 7@@ -145,7 +152,7 @@ infixr 1 ->==, >-== infixr 1 ->~, >-~ --- | The 'Monad2' class defines the Monad function for level-2 types @m1 (m2 a)@; such as [[a]], Maybe [a], Either () (Maybe a), a -> [b], IO [a], etc.+-- | The 'Monad2' class defines the bind function for level-2 types @m1 (m2 a)@ such as [[a]], Maybe [a], Either () (Maybe a), a -> [b], IO [a], etc. -- -- >>> :{ -- -- List-List monad@@ -169,41 +176,67 @@ -- [Just 35.0,Nothing] -- class (Monad m2) => Monad2 m2 where- -- | The level-2 bind function.+ -- | The level-2 bind function, analogous for @'>>='@. (>>==) :: (Monad m1) => m1 (m2 a) -> (a -> m1 (m2 b)) -> m1 (m2 b) +-- | The level-2 composite function, analogous for @'>=>'@. (>==>) :: (Monad m1, Monad2 m2) => (a -> m1 (m2 b)) -> (b -> m1 (m2 c)) -> a -> m1 (m2 c) f >==> g = \x -> f x >>== g+-- | The level-2 sequence function, analogous for @'>>'@.+--+-- Definition: @ m >>~ f = m >>== \\_ -> f @ (>>~) :: (Monad m1, Monad2 m2) => m1 (m2 a) -> m1 (m2 b) -> m1 (m2 b)-m >>~ k = m >>== \_ -> k+m >>~ f = m >>== \_ -> f+-- | A level-2 cover-bind function, analogous for @'>>='@.+--+-- Definition: @ m >-== f = (-*) m >>== f @ (>-==) :: (Monad m1, Monad2 m2) => m1 a -> (a -> m1 (m2 b)) -> m1 (m2 b)-m >-== k = (-*) m >>== k+m >-== f = (-*) m >>== f+-- | A level-2 cover-bind function, analogous for @'>>='@.+--+-- Definition: @ m ->== f = (*:) m >>== f @ (->==) :: (Monad m1, Monad2 m2) => m2 a -> (a -> m1 (m2 b)) -> m1 (m2 b)-m ->== k = (*:) m >>== k+m ->== f = (*:) m >>== f+-- | A level-2 cover-sequence function, analogous for @'>>'@.+--+-- Definition: @ m >-~ f = (-*) m >>~ f @ (>-~) :: (Monad m1, Monad2 m2) => m1 a -> m1 (m2 b) -> m1 (m2 b)-m >-~ k = (-*) m >>~ k+m >-~ f = (-*) m >>~ f+-- | A level-2 cover-sequence function, analogous for @'>>'@.+--+-- Definition: @ m ->~ f = (*:) m >>~ f @ (->~) :: (Monad m1, Monad2 m2) => m2 a -> m1 (m2 b) -> m1 (m2 b)-m ->~ k = (*:) m >>~ k+m ->~ f = (*:) m >>~ f instance Monad2 Maybe where- mmv >>== f = - mmv >>= \mv ->+ mv >>== f = + mv >>= \mv -> case mv of Nothing -> (*:) Nothing Just a -> f a instance Monad2 [] where- mmv >>== f = - mmv >>= \xs -> + mv >>== f = + mv >>= \xs -> foldr (\x acc -> f x <$|(++)|*> acc) ((*:) []) xs instance Monad2 (Either e) where- mmv >>== f = - mmv >>= \mv -> + mv >>== f = + mv >>= \mv -> case mv of Left l -> (*:) (Left l) Right r -> f r +instance Monad2 (Except e) where+ m >>== f = (ExceptT . Identity |$>) $ (runExcept |$> m) >>== runExcept |$>> f++instance (Monoid w) => Monad2 (Writer w) where+ mv >>== f = + mv >>= \x -> runWriterT x >- \(Identity (a, w)) ->+ f a <$| (\x -> runWriterT x >- \(Identity (b, w')) ->+ WriterT $ Identity (b, w <> w'))++ ------------------------------------------------------------------------------- -- Level-3 functions @@ -212,11 +245,11 @@ infixr 1 >--==, ->-==, -->==, >>-==, >->==, ->>== infixr 1 >--~, ->-~, -->~, >>-~, >->~, ->>~ --- | The 'Monad3' class defines the Monad function for level-3 types @m1 (m2 (m3 a)@.+-- | The 'Monad3' class defines the bind function for level-3 types @m1 (m2 (m3 a)@. -- -- >>> :{ -- -- IO-List-List monad--- (*:) [["a","b"]] >>>== \x -> -- (>>>==) is the level-3 bind-cover function, analogous for (>>=)+-- (*:) [["a","b"]] >>>== \x -> -- (>>>==) is the level-3 bind function, analogous for (>>=) -- (*:) [[0],[1,2]] >>>== \y -> -- (-**) (print (x,y)) >>>~ -- (>>>~) is the level-3 sequence function, analogous for (>>) -- (***:) (x ++ show y)@@ -229,13 +262,13 @@ -- ("b",2) -- [["a0","b0"],["a0","b1","b2"],["a1","a2","b0"],["a1","a2","b1","b2"]] ----- This messy code above can be neatly rewritten to the code below.+-- This messy code above can be neatly rewritten to the code below with cover functions. -- -- >>> :{ -- -- IO-List-List monad--- [["a","b"]] ->>== \x -> -- (->>==) is a level-3 bind-cover function, analogous for (>>=)+-- [["a","b"]] ->>== \x -> -- (->>==) is a level-3 cover-bind function, analogous for (>>=) -- [[0],[1,2]] ->>== \y ->--- print (x,y) >--~ -- (>--~) is a level-3 bind-cover function, analogous for (>>)+-- print (x,y) >--~ -- (>--~) is a level-3 cover-sequence function, analogous for (>>) -- (***:) (x ++ show y) -- :} -- ("a",0)@@ -247,6 +280,7 @@ -- [["a0","b0"],["a0","b1","b2"],["a1","a2","b0"],["a1","a2","b1","b2"]] -- class (Monad2 m3) => Monad3 m3 where+ -- | The level-3 bind function, analogous for @'>>='@. (>>>==) :: (Monad m1, Monad2 m2) => m1 (m2 (m3 a)) -> (a -> m1 (m2 (m3 b))) -> m1 (m2 (m3 b)) (>===>) :: (Monad m1, Monad2 m2, Monad3 m3) => (a -> m1 (m2 (m3 b))) -> (b -> m1 (m2 (m3 c))) -> a -> m1 (m2 (m3 c))@@ -280,24 +314,33 @@ m >>-~ k = (--*) m >>>~ k instance Monad3 Maybe where- mmmv >>>== f = - mmmv >>== \mv ->+ mv >>>== f = + mv >>== \mv -> case mv of Nothing -> (**:) Nothing Just a -> f a instance Monad3 [] where- mmmv >>>== f = - mmmv >>== \xs -> + mv >>>== f = + mv >>== \xs -> foldr (\x acc -> f x <<$|(++)|*>> acc) ((**:) []) xs instance Monad3 (Either e) where- mmmv >>>== f = - mmmv >>== \mv -> + mv >>>== f = + mv >>== \mv -> case mv of Left l -> (**:) (Left l) Right r -> f r +instance Monad3 (Except e) where+ m >>>== f = (ExceptT . Identity |$>>) $ (runExcept |$>> m) >>>== runExcept |$>>> f++instance (Monoid w) => Monad3 (Writer w) where+ mv >>>== f = + mv >>== \x -> runWriterT x >- \(Identity (a, w)) ->+ f a <<$| (\x -> runWriterT x >- \(Identity (b, w')) ->+ WriterT $ Identity (b, w <> w'))+ ------------------------------------------------------------------------------- -- Level-4 functions @@ -381,24 +424,33 @@ m >>>-~ k = (---*) m >>>>~ k instance Monad4 Maybe where- mmmmv >>>>== f = - mmmmv >>>== \mv ->+ mv >>>>== f = + mv >>>== \mv -> case mv of Nothing -> (***:) Nothing Just a -> f a instance Monad4 [] where- mmmmv >>>>== f = - mmmmv >>>== \xs -> + mv >>>>== f = + mv >>>== \xs -> foldr (\x acc -> f x <<<$|(++)|*>>> acc) ((***:) []) xs instance Monad4 (Either e) where- mmmmv >>>>== f = - mmmmv >>>== \mv -> + mv >>>>== f = + mv >>>== \mv -> case mv of Left l -> (***:) (Left l) Right r -> f r +instance Monad4 (Except e) where+ m >>>>== f = (ExceptT . Identity |$>>>) $ (runExcept |$>>> m) >>>>== runExcept |$>>>> f++instance (Monoid w) => Monad4 (Writer w) where+ mv >>>>== f = + mv >>>== \x -> runWriterT x >- \(Identity (a, w)) ->+ f a <<<$| (\x -> runWriterT x >- \(Identity (b, w')) ->+ WriterT $ Identity (b, w <> w'))+ ------------------------------------------------------------------------------- -- Level-5 functions @@ -498,7 +550,6 @@ (>----~) :: (Monad m1, Monad2 m2, Monad3 m3, Monad4 m4, Monad5 m5) => m1 a -> m1 (m2 (m3 (m4 (m5 b)))) -> m1 (m2 (m3 (m4 (m5 b)))) m >----~ k = (-****) m >>>>>~ k - (--->>~) :: (Monad m1, Monad2 m2, Monad3 m3, Monad4 m4, Monad5 m5) => m4 (m5 a) -> m1 (m2 (m3 (m4 (m5 b)))) -> m1 (m2 (m3 (m4 (m5 b)))) m --->>~ k = (***:) m >>>>>~ k (-->->~) :: (Monad m1, Monad2 m2, Monad3 m3, Monad4 m4, Monad5 m5) => m3 (m5 a) -> m1 (m2 (m3 (m4 (m5 b)))) -> m1 (m2 (m3 (m4 (m5 b))))@@ -553,21 +604,30 @@ m >>>>-~ k = (----*) m >>>>>~ k instance Monad5 Maybe where- mmmmmv >>>>>== f = - mmmmmv >>>>== \mv ->+ mv >>>>>== f = + mv >>>>== \mv -> case mv of Nothing -> (****:) Nothing Just a -> f a instance Monad5 [] where- mmmmmv >>>>>== f = - mmmmmv >>>>== \xs -> + mv >>>>>== f = + mv >>>>== \xs -> foldr (\x acc -> f x <<<<$|(++)|*>>>> acc) ((****:) []) xs instance Monad5 (Either e) where- mmmmmv >>>>>== f = - mmmmmv >>>>== \mv -> + mv >>>>>== f = + mv >>>>== \mv -> case mv of Left l -> (****:) (Left l) Right r -> f r++instance Monad5 (Except e) where+ m >>>>>== f = (ExceptT . Identity |$>>>>) $ (runExcept |$>>>> m) >>>>>== runExcept |$>>>>> f++instance (Monoid w) => Monad5 (Writer w) where+ mv >>>>>== f = + mv >>>>== \x -> runWriterT x >- \(Identity (a, w)) ->+ f a <<<<$| (\x -> runWriterT x >- \(Identity (b, w')) ->+ WriterT $ Identity (b, w <> w'))
DeepControl/Monad/Trans.hs view
@@ -601,8 +601,8 @@ >import DeepControl.Monad (Monad2) >import DeepControl.Monad.Morph ((|>|)) >import DeepControl.Monad.Trans (liftT, (|*|), (|-*|), (|*-|))->import DeepControl.Monad.Trans.Writer >import DeepControl.Monad.Trans.Identity+>import Control.Monad.Writer >import Control.Monad.State > >tick :: State Int ()@@ -626,7 +626,7 @@ >program = replicateM_ 4 $ do > ((|-*|).liftT) |>| tock -- (|-*|) is a level-2 trans-cover function, analogous for (-*) > :: (Monad2 m) => StateT Int (IdentityT2 IO m ) ()-> ((|*-|).liftT) |>| save -- (|*-|) is a level-2 trans-cover function, analogous for (*-)+> ((|*-|).liftT) |>| save -- (|*-|) is a level-2 trans-cover function, analogous for (*:) > :: (Monad m) => StateT Int (IdentityT2 m (Writer [Int])) () > >-- λ> execWriter |$> runIdentityT2 (runStateT program 0)
DeepControl/Monad/Trans/Except.hs view
@@ -39,14 +39,10 @@ import DeepControl.Monad.Signatures import Control.Monad.Except-import Control.Monad.Identity ---------------------------------------------------------------- -- Level-2 -instance Monad2 (Except e) where- m >>== f = (ExceptT . Identity |$>) $ (runExcept |$> m) >>== runExcept |$>> f- throwError2 :: (MonadError e m2, Applicative m1) => e -> m1 (m2 a) throwError2 = (*:) |$> throwError @@ -64,9 +60,6 @@ ---------------------------------------------------------------- -- Level-3 -instance Monad3 (Except e) where- m >>>== f = (ExceptT . Identity |$>>) $ (runExcept |$>> m) >>>== runExcept |$>>> f- throwError3 :: (MonadError e m3, Applicative m1, Applicative m2) => e -> m1 (m2 (m3 a)) throwError3 = (**:) |$> throwError @@ -84,9 +77,6 @@ ---------------------------------------------------------------- -- Level-4 -instance Monad4 (Except e) where- m >>>>== f = (ExceptT . Identity |$>>>) $ (runExcept |$>>> m) >>>>== runExcept |$>>>> f- throwError4 :: (MonadError e m4, Applicative m1, Applicative m2, Applicative m3) => e -> m1 (m2 (m3 (m4 a))) throwError4 = (***:) |$> throwError @@ -103,9 +93,6 @@ ---------------------------------------------------------------- -- Level-5--instance Monad5 (Except e) where- m >>>>>== f = (ExceptT . Identity |$>>>>) $ (runExcept |$>>>> m) >>>>>== runExcept |$>>>>> f throwError5 :: (MonadError e m5, Applicative m1, Applicative m2, Applicative m3, Applicative m4) => e -> m1 (m2 (m3 (m4 (m5 a)))) throwError5 = (****:) |$> throwError
DeepControl/Monad/Trans/Identity.hs view
@@ -8,7 +8,7 @@ Stability : experimental Portability : --- -This module enables dealing with deep monads in monad-transformer. +This module enables you to deal with deep monads in any monad-transformer. -} {-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}
DeepControl/Monad/Trans/Writer.hs view
@@ -11,7 +11,6 @@ This module extended Writer monad of mtl(monad-transformer-library). -}-{-# LANGUAGE FlexibleInstances #-} module DeepControl.Monad.Trans.Writer ( module Control.Monad.Writer, @@ -27,24 +26,13 @@ ) where import DeepControl.Applicative-import DeepControl.Commutative-import DeepControl.Monad-import DeepControl.Monad.Signatures-import DeepControl.Monad.Trans import Control.Monad.Writer-import Control.Monad.Identity import Data.Monoid ---------------------------------------------------------------------- -- Level-2 -instance (Monoid w) => Monad2 (Writer w) where- mv >>== f = - mv >>= \x -> runWriterT x >- \(Identity (a, w)) ->- f a <$| (\x -> runWriterT x >- \(Identity (b, w')) ->- WriterT $ Identity (b, w <> w'))- listen2 :: (MonadWriter w m2, Applicative m1) => m1 (m2 a) -> m1 (m2 (a, w)) listen2 m = listen |$> m pass2 :: (MonadWriter w m2, Applicative m1) => m1 (m2 (a, w -> w)) -> m1 (m2 a)@@ -53,12 +41,6 @@ ---------------------------------------------------------------------- -- Level-3 -instance (Monoid w) => Monad3 (Writer w) where- mv >>>== f = - mv >>== \x -> runWriterT x >- \(Identity (a, w)) ->- f a <<$| (\x -> runWriterT x >- \(Identity (b, w')) ->- WriterT $ Identity (b, w <> w'))- listen3 :: (MonadWriter w m3, Applicative m1, Applicative m2) => m1 (m2 (m3 a)) -> m1 (m2 (m3 (a, w))) listen3 m = listen2 |$> m pass3 :: (MonadWriter w m3, Applicative m1, Applicative m2) => m1 (m2 (m3 (a, w -> w))) -> m1 (m2 (m3 a))@@ -67,12 +49,6 @@ ---------------------------------------------------------------------- -- Level-4 -instance (Monoid w) => Monad4 (Writer w) where- mv >>>>== f = - mv >>>== \x -> runWriterT x >- \(Identity (a, w)) ->- f a <<<$| (\x -> runWriterT x >- \(Identity (b, w')) ->- WriterT $ Identity (b, w <> w'))- listen4 :: (MonadWriter w m4, Applicative m1, Applicative m2, Applicative m3) => m1 (m2 (m3 (m4 a))) -> m1 (m2 (m3 (m4 (a, w)))) listen4 m = listen3 |$> m pass4 :: (MonadWriter w m4, Applicative m1, Applicative m2, Applicative m3) => m1 (m2 (m3 (m4 (a, w -> w)))) -> m1 (m2 (m3 (m4 a)))@@ -80,12 +56,6 @@ ---------------------------------------------------------------------- -- Level-5--instance (Monoid w) => Monad5 (Writer w) where- mv >>>>>== f = - mv >>>>== \x -> runWriterT x >- \(Identity (a, w)) ->- f a <<<<$| (\x -> runWriterT x >- \(Identity (b, w')) ->- WriterT $ Identity (b, w <> w')) listen5 :: (MonadWriter w m5, Applicative m1, Applicative m2, Applicative m3, Applicative m4) => m1 (m2 (m3 (m4 (m5 a)))) -> m1 (m2 (m3 (m4 (m5 (a, w))))) listen5 m = listen4 |$> m
README.md view
@@ -4,7 +4,7 @@ ## Examples -### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Applicative.html)+### [Applicative](https://hackage.haskell.org/package/deepcontrol-0.4.2.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.@@ -59,8 +59,23 @@ > filter (even <$|(&&)|*> (10 >) <$|(&&)|*> (5 <)) [1..100] [6,8] -braket-cover notation:+cover notation: + > :t (*:)+ (*:) :: Applicative f => a -> f a++ > (*:) 1 :: Maybe Int+ Just 1+ > (*:) 1 :: [Int]+ [1]+ > (*:) 1 :: Either () Int+ Right 1++cover-braket notation:++ > :t (|*)+ (|*) :: Applicative f => f (a -> b) -> a -> f b+ > [(1+)] |* 2 [3] > [1] <$|(+)|* 2@@ -111,8 +126,25 @@ > foldr (\n acc -> n <<$|(+)|*>> acc) ((**:) 0) [Right (Just 1), Right Nothing, Left ()] Left () -braket-cover notation:+cover notation: + > :t (**:)+ (**:) :: (Applicative f1, Applicative f2) => a -> f1 (f2 a)+ > :t (-*)+ (-*) :: (Applicative f1, Applicative f2) => f1 a -> f1 (f2 a)++ > (**:) 1 :: Maybe [Int]+ Just [1]+ > (-*) (Just 1) :: Maybe [Int]+ Just [1]+ > (*:) [1] :: Maybe [Int]+ Just [1]++cover-braket notation:++ > :t (|**)+ (|**) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> a -> f1 (f2 b)+ > [Just 1] <<$|(+)|** 2 [Just 3] > 1 **|(+)|$>> [Just 2]@@ -122,6 +154,11 @@ > 1 **|[Just (+), Just (-), Just (*), Nothing]|** 2 [Just 3,Just (-1),Just 2,Nothing] + > :t (|-*)+ (|-*) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> f1 a -> f1 (f2 b)+ > :t (|*-)+ (|*-) :: (Applicative f1, Applicative f2) => f1 (f2 (a -> b)) -> f2 a -> f1 (f2 b)+ > [Just 1] <<$|(+)|-* [2] [Just 3] > [Just 1] <<$|(+)|*- Just 2@@ -145,10 +182,15 @@ Work well likewise. -### [Commutative](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Commutative.html)+### [Commutative](https://hackage.haskell.org/package/deepcontrol-0.4.2.1/docs/DeepControl-Commutative.html) + Prelude> :m DeepControl.Commutative+ [], Maybe, Either, Except and Writer monads are all commutative each other. + > :t commute+ commute :: (Applicative f, Commutative c) => c (f a) -> f (c a)+ > commute $ Just [1] [Just 1] > commute $ [Just 1]@@ -161,12 +203,12 @@ So these monads can be deepened to Monad2, Monad3, Monad4 and Monad5. -### [Monad](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Monad.html)+### [Monad](https://hackage.haskell.org/package/deepcontrol-0.4.2.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. -### Level-0+#### Level-0 ```haskell import DeepControl.Monad ((>-))@@ -185,7 +227,7 @@ ```haskell import DeepControl.Applicative ((**:))-import DeepControl.Monad+import DeepControl.Monad ((>>==)) listlist :: [[String]] -- List-List monad listlist = [["a","b"]] >>== \x -> -- (>>==) is the level-2 bind function, analogous for (>>=)@@ -197,16 +239,16 @@ ``` ```haskell-import DeepControl.Applicative-import DeepControl.Monad-import DeepControl.Monad.Trans.Writer+import DeepControl.Applicative ((|$>), (-*), (*:), (**:))+import DeepControl.Monad ((>>), (>>==), (->~))+import Control.Monad.Writer factorial :: Int ->- Maybe (Writer [Int] Int) -- Maybe-Writer Monad+ Maybe (Writer [Int] Int) -- Maybe-Writer monad factorial n | n < 0 = (-*) Nothing- | n == 0 = (*:) $ tell [0] >> return 1+ | n == 0 = (*:) $ tell [0] >> (*:) 1 | n > 0 = factorial (n-1) >>== \v -> - tell [v] ->~ -- (->~) is a level-2 bind-cover function, analogous for (>>)+ tell [v] ->~ -- (->~) is a level-2 cover-bind function, analogous for (>>) (**:) (n * v) -- > runWriter |$> factorial 5@@ -216,17 +258,17 @@ #### Level-3 ```haskell-import DeepControl.Applicative-import DeepControl.Monad-import DeepControl.Monad.Trans.Writer+import DeepControl.Applicative ((|$>>), (*-*), (*:), (**:), (***:))+import DeepControl.Monad ((>>), (>>>==), (>--~), (-->~))+import Control.Monad.Writer factorial :: Int ->- IO (Maybe (Writer [Int] Int)) -- IO-Maybe-Writer Monad-factorial n | n < 0 = (*-*) Nothing- | n == 0 = (**:) $ tell [0] >> return 1+ IO (Maybe (Writer [Int] Int)) -- IO-Maybe-Writer monad+factorial n | n < 0 = (*-*) Nothing -- (*-*) is a level-3 cover function+ | n == 0 = (**:) $ tell [0] >> (*:) 1 | n > 0 = factorial (n-1) >>>== \v -> -- (>>>==) is the level-3 bind function, analogous for (>>=)- print v >--~ -- (>--~) is a level-3 bind-cover function, analogous for (>>)- tell [v] -->~ -- (-->~) is a level-3 bind-cover function too, analogous for (>>)+ print v >--~ -- (>--~) is a level-3 cover-bind function, analogous for (>>)+ tell [v] -->~ -- (-->~) is a level-3 cover-bind function too, analogous for (>>) (***:) (n * v) -- > runWriter |$>> factorial 5@@ -237,11 +279,11 @@ -- 24 -- Just (120,[0,1,1,2,6,24]) ```-#### Level-3, Level-4 and Level-5+#### Level-4 and Level-5 Work well likewise. -### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Monad-Trans.html)+### [Monad-Transformer](https://hackage.haskell.org/package/deepcontrol-0.4.2.1/docs/DeepControl-Monad-Trans.html) #### Level-2 @@ -262,7 +304,7 @@ type TimeLimit = Int ackermannTimeLimit :: TimeLimit -> Int -> Int -> - IO (Maybe Int) -- IO-Maybe Monad+ IO (Maybe Int) -- IO-Maybe monad ackermannTimeLimit timelimit x y = timeout timelimit (ackermannIO x y) where ackermannIO :: Int -> Int -> IO Int@@ -300,7 +342,7 @@ import DeepControl.Monad.Morph ((|>|)) import DeepControl.Monad.Trans (liftT, (|*|), (|-*|), (|*-|)) import DeepControl.Monad.Trans.Identity-import DeepControl.Monad.Trans.Writer+import Control.Monad.Writer import Control.Monad.State tick :: State Int ()@@ -324,7 +366,7 @@ program = replicateM_ 4 $ do ((|-*|).liftT) |>| tock -- (|-*|) is a level-2 trans-cover function, analogous for (-*) :: (Monad2 m) => StateT Int (IdentityT2 IO m ) ()- ((|*-|).liftT) |>| save -- (|*-|) is a level-2 trans-cover function, analogous for (*-)+ ((|*-|).liftT) |>| save -- (|*-|) is a level-2 trans-cover function, analogous for (*:) :: (Monad m) => StateT Int (IdentityT2 m (Writer [Int])) () -- λ> execWriter |$> runIdentityT2 (runStateT program 0)@@ -338,14 +380,14 @@ Work well likewise. -### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Monad-Morph.html)+### [Monad-Morph](https://hackage.haskell.org/package/deepcontrol-0.4.2.1/docs/DeepControl-Monad-Morph.html) Here is a monad-morph example, a level-2 monad-morph. ```haskell import DeepControl.Monad.Morph-import DeepControl.Monad.Trans.Writer-import Control.Trans.State+import Control.Monad.Writer+import Control.Monad.State -- i.e. :: StateT Int Identity () tick :: State Int ()@@ -385,4 +427,4 @@ Work well likewise. -### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.4.2.0/docs/DeepControl-Arrow.html)+### [Arrow](https://hackage.haskell.org/package/deepcontrol-0.4.2.1/docs/DeepControl-Arrow.html)
deepcontrol.cabal view
@@ -1,5 +1,5 @@ name: deepcontrol-version: 0.4.2.0+version: 0.4.2.1 synopsis: Provide more deeper level style of programming than the usual Control.xxx modules express description: This module enables more deeper level style of programming than the usual Control.xxx modules express, especially for Applicative and Monad. license: BSD3@@ -108,12 +108,32 @@ , HUnit >= 1.3.0 , mtl, transformers , deepcontrol-Test-Suite unit_MonadTrans-2+Test-Suite unit_Monad-factorial Type: exitcode-stdio-1.0 Default-Language: Haskell2010 HS-Source-Dirs: test -- Ghc-Options: -threaded -Wall- Main-Is: unit_MonadTrans-2.hs+ Main-Is: unit_Monad-factorial.hs+ Build-Depends: base+ , HUnit >= 1.3.0+ , mtl, transformers+ , deepcontrol+Test-Suite unit_Monad-factorial2+ Type: exitcode-stdio-1.0+ Default-Language: Haskell2010+ HS-Source-Dirs: test+ -- Ghc-Options: -threaded -Wall+ Main-Is: unit_Monad-factorial2.hs+ Build-Depends: base+ , HUnit >= 1.3.0+ , mtl, transformers+ , deepcontrol+Test-Suite unit_MonadTrans-ackermann+ Type: exitcode-stdio-1.0+ Default-Language: Haskell2010+ HS-Source-Dirs: test+ -- Ghc-Options: -threaded -Wall+ Main-Is: unit_MonadTrans-ackermann.hs Build-Depends: base , HUnit >= 1.3.0 , mtl, transformers
test/unit_Monad-Level1.hs view
@@ -3,8 +3,8 @@ import DeepControl.Applicative ((|$>)) import DeepControl.Monad ((>-))-import DeepControl.Monad.Trans.Except +import Control.Monad.Except import Control.Monad.RWS import qualified Data.Map as M
test/unit_Monad-Level2.hs view
@@ -5,9 +5,9 @@ import DeepControl.Monad ((>-)) import DeepControl.Monad.Morph import DeepControl.Monad.Trans-import DeepControl.Monad.Trans.Except import DeepControl.Monad.Trans.Identity +import Control.Monad.Except import Control.Monad.State import Control.Monad.Trans.Maybe
+ test/unit_Monad-factorial.hs view
@@ -0,0 +1,30 @@+import Test.HUnit hiding (State)++import DeepControl.Applicative ((|$>), (-*), (*:), (**:))+import DeepControl.Monad ((>>), (>>==), (->~))+import Control.Monad.Writer++factorial :: Int ->+ Maybe (Writer [Int] Int) -- Maybe-Writer monad+factorial n | n < 0 = (-*) Nothing+ | n == 0 = (*:) $ tell [0] >> (*:) 1+ | n > 0 = factorial (n-1) >>== \v -> + tell [v] ->~ -- (->~) is a level-2 bind-cover function, analogous for (>>)+ (**:) (n * v)++-- > runWriter |$> factorial 5+-- Just (120,[0,1,1,2,6,24])++main :: IO ()+main = do+ runTestTT tests_+ return ()++tests_ :: Test+tests_ = test [ + "factorial" ~: do+ let actual = runWriter |$> factorial 5+ actual @?= Just (120,[0,1,1,2,6,24])++ ]+
+ test/unit_Monad-factorial2.hs view
@@ -0,0 +1,36 @@+import Test.HUnit hiding (State)++import DeepControl.Applicative ((|$>>), (*-*), (*:), (**:), (***:))+import DeepControl.Monad ((>>), (>>>==), (>--~), (-->~))+import Control.Monad.Writer++factorial :: Int ->+ IO (Maybe (Writer [Int] Int)) -- IO-Maybe-Writer monad+factorial n | n < 0 = (*-*) Nothing -- (*-*) is a level-3 cover function+ | n == 0 = (**:) $ tell [0] >> (*:) 1+ | n > 0 = factorial (n-1) >>>== \v -> -- (>>>==) is the level-3 bind function, analogous for (>>=)+ print v >--~ -- (>--~) is a level-3 bind-cover function, analogous for (>>)+ tell [v] -->~ -- (-->~) is a level-3 bind-cover function too, analogous for (>>)+ (***:) (n * v)++-- > runWriter |$>> factorial 5+-- 1+-- 1+-- 2+-- 6+-- 24+-- Just (120,[0,1,1,2,6,24])++main :: IO ()+main = do+ runTestTT tests_+ return ()++tests_ :: Test+tests_ = test [ + "factorial" ~: do+ actual <- runWriter |$>> factorial 5+ actual @?= Just (120,[0,1,1,2,6,24])++ ]+
test/unit_Monad.hs view
@@ -2,8 +2,9 @@ import DeepControl.Applicative import DeepControl.Monad-import DeepControl.Monad.Trans.Writer import DeepControl.Monad.Trans.Identity++import Control.Monad.Writer import Control.Monad.Reader import Safe
test/unit_MonadMorph.hs view
@@ -10,7 +10,7 @@ tock :: StateT Int IO () tock = do- generalize |>| tick :: (Monad m) => StateT Int m ()+ generalize |>| tick :: (Monad m) => StateT Int m () -- (|>|) is the level-1 trans-map function, analogous for (|$>) lift $ putStrLn "Tock!" :: (MonadTrans t) => t IO () -- λ> runStateT tock 0@@ -27,7 +27,7 @@ program = replicateM_ 4 $ do lift |>| tock :: (MonadTrans t) => StateT Int (t IO) ()- generalize |>>| save+ generalize |>>| save -- (|>>|) is the level-2 trans-map function, analogous for (|$>>) :: (Monad m) => StateT Int (WriterT [Int] m ) () -- λ> execWriterT (runStateT program 0)
− test/unit_MonadTrans-2.hs
@@ -1,85 +0,0 @@-import Test.HUnit--import DeepControl.Applicative-import DeepControl.Commutative (commute)-import DeepControl.Monad ((>-))-import DeepControl.Monad.Morph ((|>|))-import DeepControl.Monad.Trans (liftTT2, transfold2, untransfold2)-import DeepControl.Monad.Trans.Identity-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- liftTT2 $ 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---- λ> commute $ 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 = (runIdentityT . transfold2) |>| ackermann x y -- You can get usual ReaderT-MaybeT-IO function from 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- >- runMaybeT--ackermann'' :: Int -> Int -> - ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad-ackermann'' x y = (untransfold2 . IdentityT) |>| ackermann' x y -- You can get ReaderT-IdentityT2-IO-Maybe function from usual ReaderT-MaybeT-IO function--calc_ackermann'' :: TimeLimit -> Int -> Int -> IO (Maybe Int)-calc_ackermann'' timelimit x y = ackermann'' x y >- \r -> runReaderT r timelimit- >- runIdentityT2--------------------------------------------------------------------- unit test-------------------------------------------------------------------main :: IO ()-main = do- runTestTT tests_1- runTestTT tests_2- runTestTT tests_3- return ()--tests_1 :: Test-tests_1 = test [ - "calc" ~: do- actual <- commute $ calc_ackermann 1000 |$> [0..4] |* 4- actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]- ]--tests_2 :: Test-tests_2 = test [ - "calc" ~: do- actual <- commute $ calc_ackermann' 1000 |$> [0..4] |* 4- actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]- ]--tests_3 :: Test-tests_3 = test [ - "calc" ~: do- actual <- commute $ calc_ackermann'' 1000 |$> [0..4] |* 4- actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]- ]-
+ test/unit_MonadTrans-ackermann.hs view
@@ -0,0 +1,85 @@+import Test.HUnit++import DeepControl.Applicative+import DeepControl.Commutative (commute)+import DeepControl.Monad ((>-))+import DeepControl.Monad.Morph ((|>|))+import DeepControl.Monad.Trans (liftTT2, transfold2, untransfold2)+import DeepControl.Monad.Trans.Identity+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+ liftTT2 $ 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++-- λ> commute $ 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 = (runIdentityT . transfold2) |>| ackermann x y -- You can get usual ReaderT-MaybeT-IO function from 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+ >- runMaybeT++ackermann'' :: Int -> Int -> + ReaderT TimeLimit (IdentityT2 IO Maybe) Int -- ReaderT-IdentityT2-IO-Maybe monad+ackermann'' x y = (untransfold2 . IdentityT) |>| ackermann' x y -- You can get ReaderT-IdentityT2-IO-Maybe function from usual ReaderT-MaybeT-IO function++calc_ackermann'' :: TimeLimit -> Int -> Int -> IO (Maybe Int)+calc_ackermann'' timelimit x y = ackermann'' x y >- \r -> runReaderT r timelimit+ >- runIdentityT2++----------------------------------------------------------------+-- unit test+----------------------------------------------------------------++main :: IO ()+main = do+ runTestTT tests_1+ runTestTT tests_2+ runTestTT tests_3+ return ()++tests_1 :: Test+tests_1 = test [ + "calc" ~: do+ actual <- commute $ calc_ackermann 1000 |$> [0..4] |* 4+ actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]+ ]++tests_2 :: Test+tests_2 = test [ + "calc" ~: do+ actual <- commute $ calc_ackermann' 1000 |$> [0..4] |* 4+ actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]+ ]++tests_3 :: Test+tests_3 = test [ + "calc" ~: do+ actual <- commute $ calc_ackermann'' 1000 |$> [0..4] |* 4+ actual @?= [Just 5,Just 6,Just 11,Just 125,Nothing]+ ]+
test/unit_MonadTrans.hs view
@@ -5,7 +5,7 @@ import DeepControl.Monad.Morph ((|>|)) import DeepControl.Monad.Trans (liftT, (|*|), (|-*|), (|*-|)) import DeepControl.Monad.Trans.Identity-import DeepControl.Monad.Trans.Writer+import Control.Monad.Writer import Control.Monad.State tick :: State Int ()@@ -13,23 +13,23 @@ tock :: StateT Int IO () tock = do- (|*|) tick :: (Monad m) => StateT Int m ()- liftT $ putStrLn "Tock!" :: (MonadTrans t) => t IO ()+ (|*|) tick :: (Monad m) => StateT Int m () -- (|*|) is the level-1 trans-cover function, analogous for (*:)+ liftT $ putStrLn "Tock!" :: (MonadTrans t) => t IO () -- 'liftT' is the level-1 trans-lift function, alias to 'lift' -- λ> runStateT tock 0 -- Tock! -- ((),1) -save :: StateT Int (Writer [Int]) ()+save :: StateT Int (Writer [Int]) () save = do n <- get liftT $ tell [n] -program :: StateT Int (IdentityT2 IO (Writer [Int])) ()+program :: StateT Int (IdentityT2 IO (Writer [Int])) () -- StateT-IdentityT2-IO-Writer monad, a level-2 monad-transform program = replicateM_ 4 $ do- ((|-*|).liftT) |>| tock+ ((|-*|).liftT) |>| tock -- (|-*|) is a level-2 trans-cover function, analogous for (-*) :: (Monad2 m) => StateT Int (IdentityT2 IO m ) ()- ((|*-|).liftT) |>| save+ ((|*-|).liftT) |>| save -- (|*-|) is a level-2 trans-cover function, analogous for (*:) :: (Monad m) => StateT Int (IdentityT2 m (Writer [Int])) () -- λ> execWriter |$> runIdentityT2 (runStateT program 0)@@ -58,6 +58,4 @@ actual <- execWriter |$> runIdentityT2 (runStateT program 0) actual @?= [1,2,3,4] ]--