From 7862e46a731194bde883386791914d94f3365c0a Mon Sep 17 00:00:00 2001 From: simonm <unknown> Date: Tue, 12 May 1998 12:41:23 +0000 Subject: [PATCH] [project @ 1998-05-12 12:41:23 by simonm] - specialise some gratuitously overloaded functions --- ghc/lib/std/Monad.lhs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ghc/lib/std/Monad.lhs b/ghc/lib/std/Monad.lhs index 2be1dba4394f..1421209e2eae 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} -- GitLab