From: simonm Date: Tue, 12 May 1998 12:41:23 +0000 (+0000) Subject: [project @ 1998-05-12 12:41:23 by simonm] X-Git-Tag: Approx_2487_patches~707 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=7862e46a731194bde883386791914d94f3365c0a;p=ghc-hetmet.git [project @ 1998-05-12 12:41:23 by simonm] - specialise some gratuitously overloaded functions --- diff --git a/ghc/lib/std/Monad.lhs b/ghc/lib/std/Monad.lhs index 2be1dba..1421209 100644 --- a/ghc/lib/std/Monad.lhs +++ b/ghc/lib/std/Monad.lhs @@ -58,14 +58,17 @@ guard p = if p then return () else zero -- This subsumes the list-based filter function. +{-# SPECIALISE filter :: (a -> Bool) -> [a] -> [a] #-} filter :: MonadZero m => (a -> Bool) -> m a -> m a filter p = applyM (\x -> if p x then return x else zero) -- This subsumes the list-based concat function. +{-# SPECIALISE concat :: [[a]] -> [a] #-} concat :: MonadPlus m => [m a] -> m a concat = foldr (++) zero +{-# SPECIALISE applyM :: (a -> [b]) -> [a] -> [b] #-} applyM :: Monad m => (a -> m b) -> m a -> m b applyM f x = x >>= f \end{code}