Oops, there's a free variable in there, let me fix it:first f [] = Nothingfirst f (x:xs) = fmap (:xs) (f x) <|> fmap (x:) (first f xs)PaulOn Fri, Apr 7, 2017 at 10:42 AM Paul Brauner <polux2001@gmail.com> wrote:Hello Haskell Cafe,I had to write the following function and I was wondering if it (or its generalization to Alternative or Traversable) was exposed by some library under a different name:first [] = Nothingfirst (t:ts) = fmap (:ts) (s t) <|> fmap (t:) (first ts)Somehow it is to "traverse" as "any" is to "all".Cheers,Paul
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell- cafe
Only members subscribed via the mailman list are allowed to post.