[Haskell-cafe] Generalizing takeWhile

Thomas Hartman tphyahoo at gmail.com
Wed Jul 22 14:14:55 EDT 2009


What is the use case(s) for this function?

lements from the front of a list.  However the
> criteria are somewhat complex.
>
>> walk f [] = []
>> walk f (x:xs) = case f x
>>                 of Just g -> x : walk g xs
>>                    Nothing -> []
>
> For each item the `predicate' f either returns Nothing, when it thinks
> we should not take any more elements, or return Just another
> `predicate' to apply to the next element.
>
> However the type system does not like my function.  How can I mollify it?
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list