[Haskell-cafe] How to tie knots in XML-style data structures

Auke Booij auke at tulcod.com
Tue Jan 3 10:50:59 UTC 2017


On 3 January 2017 at 00:08, Sergey Vinokurov <serg.foo at gmail.com> wrote:
> The complete code with my attempt is in the attachment.

Thanks a lot for your work, Sergey. Your suggested solution contains
many useful elements.

I am still not quite satisfied, however, as your solution does not let
me convert the following:

sampleEnv :: Map String Blah
sampleEnv = M.fromList
  [ ("first", BlahF "first" 5 [YadaF "second"])
  , ("second", BlahF "second" 3 [YadaF "first"])
  ]

(the point here is that the "tie knots" in the thread subject means
that we end up with potentially cyclic values)

> information on
> Fix type I'd recommend to read on recursion schemes/F-algebras, e.g.
> https://github.com/willtim/recursion-schemes/raw/master/slides-final.pdf.

In retrospect this indeed sounds like the right solution, thanks for
the pointer.


More information about the Haskell-Cafe mailing list