[Haskell-cafe] an advanced foldification problem

2007-01-11 Thread Seth Gordon
I have a data type Group, representing a group of geographic information that is all referring to the same location, and a function mergeGroups that tries to merge two groups: mergeGroups :: Group - Group - Maybe Group Then I have a function mergeGroupToList that tries to merge its first

Re: [Haskell-cafe] an advanced foldification problem

2007-01-11 Thread Henning Thielemann
On Thu, 11 Jan 2007, Seth Gordon wrote: I have a data type Group, representing a group of geographic information that is all referring to the same location, and a function mergeGroups that tries to merge two groups: mergeGroups :: Group - Group - Maybe Group Then I have a function

Re: [Haskell-cafe] an advanced foldification problem

2007-01-11 Thread Spencer Janssen
Take this obscure function: \begin{code} func :: (a - a - Maybe a) - a - [a] - [a] func f s0 xs0 = foldr (\x xs s - maybe (xs s) ((x:) . xs) (f s x)) return xs0 s0 \end{code} And mergeGroupToList becomes: \begin{code} mergeGroupToList g xs = func mergeGroups g xs \end{code} Cheers, Spencer