diff options
author | Max Bolingbroke <batterseapower@hotmail.com> | 2011-09-09 13:45:41 +0100 |
---|---|---|
committer | Max Bolingbroke <batterseapower@hotmail.com> | 2011-09-09 14:11:00 +0100 |
commit | b3bc5f4f49a01be12aff0e4369db62331c147179 (patch) | |
tree | 0321f6f04b86128e236e265a353313e05381e632 /compiler/utils/Util.lhs | |
parent | c2bd94c1d91dcd90007fe9f33b8e45ceb509c995 (diff) | |
parent | 99a52b00cc77a38f66202ddb3d6ce1dd4a654081 (diff) | |
download | haskell-b3bc5f4f49a01be12aff0e4369db62331c147179.tar.gz |
Merge branch 'no-pred-ty'
Conflicts:
compiler/iface/BuildTyCl.lhs
compiler/iface/MkIface.lhs
compiler/iface/TcIface.lhs
compiler/typecheck/TcTyClsDecls.lhs
compiler/types/Class.lhs
compiler/utils/Util.lhs
Diffstat (limited to 'compiler/utils/Util.lhs')
-rw-r--r-- | compiler/utils/Util.lhs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index ef36e8a9e3..5ce405bef1 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -32,6 +32,7 @@ module Util ( -- * Tuples fstOf3, sndOf3, thirdOf3, + firstM, first3M, uncurry3, -- * List operations controlled by another list @@ -105,7 +106,7 @@ import Data.List hiding (group) import FastTypes #endif -import Control.Monad ( unless ) +import Control.Monad ( unless, liftM ) import System.IO.Error as IO ( isDoesNotExistError ) import System.Directory ( doesDirectoryExist, createDirectory, getModificationTime ) @@ -214,6 +215,14 @@ uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d uncurry3 f (a, b, c) = f a b c \end{code} +\begin{code} +firstM :: Monad m => (a -> m c) -> (a, b) -> m (c, b) +firstM f (x, y) = liftM (\x' -> (x', y)) (f x) + +first3M :: Monad m => (a -> m d) -> (a, b, c) -> m (d, b, c) +first3M f (x, y, z) = liftM (\x' -> (x', y, z)) (f x) +\end{code} + %************************************************************************ %* * \subsection[Utils-lists]{General list processing} |