<div dir="ltr"><div style="font-size:12.8000001907349px">hello haskell-cafe,</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">suppose you have a compiler pipeline roughly similar to (from <a href="http://dev.stephendiehl.com/fun/007_path.html" target="_blank">write you a Haskell</a><div style="display:inline-block;width:16px;height:16px"></div>):</div><div style="font-size:12.8000001907349px"><br></div><span style="font-size:12.8000001907349px">modl :: FilePath -> L.Text -> CompilerM ()</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">modl fname</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    = parseP fname</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> dataP</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> groupP</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> renameP</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> desugarP</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> inferP</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">  >=> evalP</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">and suppose you have a language where you can compile multiple files and compilation must be made _as if_ files were concatenated together in the order given on the command line (there might be side effects that affect parsing of subsequent files); still in the average case there're no dependencies and files could be compiled in parallel (or some of the dependencies can be handled at the AST level as one can prove they don't affect parsing but only aspects of the AST that can be patched).</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">What are good strategies for dealing with this and rerun some of the parseP functions (and in the simplest solution the complete pipeline after it).</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">The strategy I have in mind now doesn't mix well with the above pipeline, so I'd like to see if there're alternative solutions.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Basically, what I have in mind is:</div><div style="font-size:12.8000001907349px">- each parse function gets a file, something to watch on for the result of the previous parse (let's say an MVar, or some variation of <a href="https://hackage.haskell.org/package/speculation" target="_blank">speculation</a><div style="display:inline-block;width:16px;height:16px"></div>, not sure yet) and an input environment (same for everybody). It produces an AST + what he's sensitive to (e.g. what would have affected the parsing) and what he generates that the next guy must be sensitive to.</div><div style="font-size:12.8000001907349px">- before producing the 'what it generates part', it must be sure to have completed a valid parse, so he'll wait on the input MVar to know that the previous files have been parsed properly and that whatever side effects it caised wouldn't affect parsing. This wait will be done on a thread that doesn't count towards the parallelism limit as it is presumably cheap and we don't really serialize the parsing.</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">[a similar question related to the above pipeline would be how do I fit in any kind of global transformation pass]</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Is there any library or other ideas on how to combine multiple pipelines where we want to run them with maximum parallelism but the outcome of (even a partial step of) one pipeline can invalidate and require to rerun others? </div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">Thanks for any idea,</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">  Maurizio</div></div>