Tying the Knot with a State monad
问题 I'm working on a Haskell project that involves tying a big knot: I'm parsing a serialized representation of a graph, where each node is at some offset into the file, and may reference another node by its offset. So I need to build up a map from offsets to nodes while parsing, which I can feed back to myself in a do rec block. I have this working, and kinda-sorta-reasonably abstracted into a StateT -esque monad transformer: {-# LANGUAGE DoRec, GeneralizedNewtypeDeriving #-} import qualified