[Haskell-cafe] a beginner question: decorate-op-undecorate
Aran Donohue
aran.donohue at gmail.com
Fri Feb 5 12:34:01 EST 2010
Hi Haskell-Cafe,
Consider a data type such as
data Binding = Binding Var (Either Value [Value])
representing a variable bound either to a fixed value or that has a list of
possible values.
I'd like to perform an operation on say, the fixed-value members of a list
of bindings. Data.Either has "partitionEithers"---I'd essentially like to
use partitionEithers, but in a way that it "peeks" into the value field of
the binding. For the sake of argument, let's say I can't or can't modify
Binding to move the Either to the outside.
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. Another
option would be to map each Binding to a new datatype that has the Either on
the outside, use partitionEithers, and map back.
Thanks,
Aran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100205/781dffd5/attachment.html
More information about the Haskell-Cafe
mailing list