<div dir="ltr"><div><div><div>Hi all, thank you for the replies!<br><br></div>The language this will interpret does not expose pointers (so it acts like the more modern languages).<br><br></div>I have started to try to wrap my head around IORef and that monad (anyone know of a "for dummies" guide to those?). I think that they will likely be exactly what I need.<br><br></div>Thanks again,<br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div>- Jeremy Mikkola</div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Dec 18, 2017 at 12:31 PM, Joachim Durchholz <span dir="ltr"><<a href="mailto:jo@durchholz.org" target="_blank">jo@durchholz.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Am 17.12.2017 um 22:03 schrieb Jeremy Mikkola:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How does one go about interpreting a language with mutable objects in Haskell?<br>
<br>
<br>
The best approach I can think of is to represent the language's memory as a `Data.Map.Map RefID LanguageObject` where RefID is some type (probably Int) used as a reference.<br>
</blockquote>
<br></span>
It depends on how data is addressed in the language.<br>
If you wanto interpret a C-style language where every address can be cast to an int, then that's the most straightforward (though not necessarily best) approach.<br>
If it is just references to objects as in most, erm, "more modern" languages, the Id can be any type. E.g. something based on the language's data model - Int | Real | Record | Array, with type parameters as appropriate. Upside is that you leverage the Haskell GC that way, downside is that you'll need a recursive type (Array is really Array RefId, and my Haskell-fu is hilariously inadequate to properly flesh out that recursion).<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br></div>