filter returns a list, but the rhs of >>= expects an IO. Try:
getDirectoryContents "." >>= return . filter (\s -> head s /= '.')
> I'm working on a little toy program in hbc (now that I have a haskell
> compiler running I decided to give it a try ;), but I seem to
> have run into
> a monad problem. Here's the snippet in particular (and the results from
> evaluation in hbi):
> > getDirectoryContents "." >>= filter (\(x:_) -> x /= '.');
> [65] Cannot unify types:
> Prelude.IO
> and (Prelude.[])
> in (>>=) (getDirectoryContents ".") (filter (\I ->
> case I of {
> Prelude.[] -> Pfail "No match in Pinteractive"
> | (:) x I4625 -> (/=) x '.'
> }
> ))
>
> (The idea here is to filter out all the dot files from the directory
> listing)
> Unfortunately I can't make hide or hair of this. Is this because the
> function being used with filter would break when given an empty
> list (or is
> that Pfail bit there to handle that breaking?)
> TIA
> --
> -Simon Raahauge DeSantis
>