{- |
These functions work in arbitrary monads
but are especially helpful when working with the @CodeGenFunction@ monad.
-}
module LLVM.Extra.Monad
   {-# DEPRECATED "use utility-ht:Control.Monad.HT" #-} where

import Control.Monad (liftM2, liftM3, join, (<=<), )


{-# DEPRECATED chain "use utility-ht:Control.Monad.HT.chain" #-}
chain :: (Monad m) => [a -> m a] -> (a -> m a)
chain =
   foldr (flip (<=<)) return

{-# DEPRECATED liftR2 "use utility-ht:Control.Monad.HT.liftJoin2" #-}
liftR2 :: (Monad m) => (a -> b -> m c) -> m a -> m b -> m c
liftR2 f ma mb =
   join (liftM2 f ma mb)

{-# DEPRECATED liftR3 "use utility-ht:Control.Monad.HT.liftJoin3" #-}
liftR3 :: (Monad m) => (a -> b -> c -> m d) -> m a -> m b -> m c -> m d
liftR3 f ma mb mc =
   join (liftM3 f ma mb mc)
