On Mon, May 23, 2011 at 6:21 PM, Richard O'Keefe <o...@cs.otago.ac.nz> wrote:
> > On 24/05/2011, at 5:49 AM, Alexander Solla wrote: > > There's a library function for it, but also: > > > > > filter ((/=) Nothing) > > The problem with that in general is that it only > applies to [Maybe t] if Eq t, but you don't > actually _need_ t to support equality. > filter isJust > will do the job, where isJust is in Data.Maybe. > > Indeed, isJust will do the job. Sometimes it is acceptable to just use the tools you know. For example, filtering a list of (Maybe Int)s. This is a balance that is tough to get right. Personally, I find non-functional values without Eq instances to be degenerate. So I really do not mind superfluous Eq constraints. I would not hesitate to use filter ((/=) Nothing) in a function whose type has no free type variables. It's just a bit of plumbing inside of a more complex function. But the point of avoiding unnecessary constraints is a good one, especially for constraints that constrain more strongly, e.g., Ord.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe