[Haskell-cafe] a beginner question: decorate-op-undecorate

Luke Palmer lrpalmer at gmail.com
Fri Feb 5 19:24:41 EST 2010


On Fri, Feb 5, 2010 at 10:34 AM, Aran Donohue <aran.donohue at gmail.com> wrote:
> What would be an idiomatic Haskell way to accomplish this? Currently I've
> got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], [a])" which
> is my own version of partitionEithers that calls a selector first.

Since you are not using b or c anywhere else, the only thing you care
about in that Either is whether it is Left or Right.  Which makes it
seem much more like a Bool.  After this conversion, I can hoogle for
your signature.

http://haskell.org/hoogle/?hoogle=[a]+-%3E+%28a+-%3E+Bool%29+-%3E+%28[a]%2C[a]%29

Which gives, among other things, Data.List.partition :: (a -> Bool) ->
[a] -> ([a],[a]).

Without more details about the precise thing you want to accomplish, I
don't know what else to say.  Many idioms are about the details of the
problem, even down to argument order.

Luke


More information about the Haskell-Cafe mailing list