Hello,<br>I am trying to move a web application I wrote that initially used raw sockets for doing HTTP by &quot;hand&quot; to a more sensible Wai-based framework, and I am running into a design issue.<br>I initially thought it would be a good idea to be able to support various I/O methods so I defined a layer called CommandIO (this is a game application) to insulate business-level code from the detials of reading commands and outputting results to the outside world. Here is the signature for this simple monad: <br>
<br>class (Monad io) =&gt; CommandIO io where<br>   readCommand :: io Command<br>   writeResult      :: CommandResult -&gt; io ()<br><br>then I have an interpret function which looks like:<br><br>interpret :: (CommandIO io, Map t) =&gt; Commands t io CommandResult<br>
<br>which reads a command from the io, execute it producing a CommandResult, then request output from the io using writeResult.<br><br>This works nicely using Reader-based data containing a Handle, both for HTTP-based and console-based I/O.<br>
<br>But when I try to move to WAI, I am a little bit stuck. The core of Wai is an application which rougly has type Request -&gt; Response and this basically breaks my (simple) model of read commands / write results. I suspect there might be a way to stick to my current model using enumerators/streams for I/O and a custom type for encapsulating the underlying state of the HTTP exchange. I also thought about reversing the dependency : ensuring that interpret does not need to know about low-level I/O and only dealing with Command/CommandResult, with I/O being handled by wrappers. <br>
<br>Thanks in advance for any insights,<br><br>Arnaud<br><br>PS: the code is on github: <a href="http://github.com/abailly/crete1941">http://github.com/abailly/crete1941</a>. Not that I deem it ready for prime-time though...<br>