[Haskell-cafe] Re: filterFirst
apfelmus
apfelmus at quantentunnel.de
Mon Jul 23 14:31:25 EDT 2007
Alexteslin wrote:
> filterAlpha :: (a -> Bool) -> [a] -> [a]
> filterAlpha f [] = []
> filterAlpha f (x:xs)
> |f x = x : filterAlpha xs
> |otherwise = filterAlpha xs
>
>
> and i am getting this error message:
>
> Type error in application
> Expression :filterAlpha xs
> Type : [b]
> Dous not match : a -> Bool
filterAlpha :: (a -> Bool) -> [a] -> [a]
filterAlpha f [] = []
filterAlpha f (x:xs)
| f x = x : filterAlpha f xs
| otherwise = filterAlpha f xs
filterAlpha has two parameters. The first parameter is a function (a ->
Bool), the second is a list [a]. The error message complains that xs ,
which you actidentially gave as first parameter, is a list [a] and not a
function (a -> Bool).
Regards,
apfelmus
More information about the Haskell-Cafe
mailing list