
7 Apr
2017
7 Apr
'17
4:57 a.m.
Oops, there's a free variable in there, let me fix it:
first f [] = Nothing
first f (x:xs) = fmap (:xs) (f x) <|> fmap (x:) (first f xs)
Paul
On Fri, Apr 7, 2017 at 10:42 AM Paul Brauner
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 [] = Nothing first (t:ts) = fmap (:ts) (s t) <|> fmap (t:) (first ts)
Somehow it is to "traverse" as "any" is to "all".
Cheers, Paul