<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>On Jan 28, 2013, at 3:21 AM, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br><br></div><blockquote type="cite"><div>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Verdana","sans-serif";
        color:#1F497D;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:809787669;
        mso-list-type:hybrid;
        mso-list-template-ids:1178094236 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1
        {mso-list-id:1250696558;
        mso-list-type:hybrid;
        mso-list-template-ids:-1053914936 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l1:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:40.8pt;
        text-indent:-18.0pt;
        font-family:Symbol;}
@list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:o;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:76.8pt;
        text-indent:-18.0pt;
        font-family:"Courier New";}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal" style="margin-left:36.0pt">I would like to explore making a backend for .NET. I've done a lot of background reading about previous .NET and JVM attempts for Haskell. It seems like several folks have made significant progress in the past
and, with the exception of UHC, I can't find any code around the internet from the previous efforts. I realize that in total it's a huge undertaking and codegen is only one of several significant hurdles to success.<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Someone should start a wiki page about this! It comes up regularly. (That doesn’t mean it’s a bad idea; just that we should share wisdom on it.) Maybe there
is one, in which case perhaps it could be updated?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Some thoughts (which, if someone would like to transfer these to the wiki page, perhaps in more coherent form):<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Check out Frege. Maybe others. I think several folk are working on .NET or JVM projects.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Do you want to inter-operate with .NET, or compile to .NET bytecode. These are very different? I’ll assume the latter.</span></p></div></div></blockquote><div><br></div>Yes, the latter.<div><br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Do you want to compile to verifiable .NET bytecode? This is hard. GHC’s type system is more expressive than .NET’s in many ways (higher kinded type
variables, kind polymorphism...). And less expressive in others (sub-typing). Compiling to verifiable bytecode would require lots of run-time type-tests (which we know will succeed) to reassure .NET that it’s all kosher. Figuring out how to minimise these
tests would be a challenge in itself.</span></p></div></div></blockquote><div><br></div>I'm okay with slow code. That's something I can improve later. :)</div><div><br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">And of course this affects whether you can go via C#, since that requires the program to be well typed in the .NET sense.</span></p></div></div></blockquote><div><br></div>I'm not sure yet about going via C# or directly to CIL.<br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo1">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Do you want simply to
<b>run</b> <b>Haskell programs</b> on .NET or do you want <b>Haskell programs to call .NET libraries</b>? I assume the latter. But that means that .NET types must be manifested somehow as Haskell types. A big issue is how much of .NET’s type system you
want to suck into Haskell. A stressful example: can you define in Haskell a type that sub-classes an imported .NET type.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt">
<span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Daan and Mark and Sigbjorn and I wrote papers about this stuff</span><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D">.</span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif""> </span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif";color:#1F497D">Look
at the papers under "Foreign language integration" on</span><span class="apple-converted-space"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif""> </span></span><span style="font-size:11.0pt;font-family:"Verdana","sans-serif""><a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/papers.html"><span style="color:purple">http://research.microsoft.com/en-us/um/people/simonpj/papers/papers.html</span></a>.
Oh, and this:<span class="apple-converted-space"> </span><a href="http://research.microsoft.com/en-us/um/people/simonpj/papers/oo-haskell/index.htm"><span style="color:purple">http://research.microsoft.com/en-us/um/people/simonpj/papers/oo-haskell/index.htm</span></a></span></p></div></div></blockquote><div><br></div>Thanks. I'll make sure to read over those.</div><div><br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:36.0pt"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif""><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:40.8pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<!--[if !supportLists]--><span style="font-size:10.0pt;font-family:Symbol;color:#1F497D"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif"">I’d be inclined to start from Core rather than STG, perhaps the output of CorePrep. STG is a bit encrusted (though we’re about to simplify it a bit). But honestly
they are pretty similar.</span><span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:40.8pt">
<span style="font-size:11.0pt;font-family:"Verdana","sans-serif"">Cmm would be a bad choice. It’s far too low level.</span></p></div></div></blockquote><div><br></div>Good to know.</div><div><br><blockquote type="cite"><div><div class="WordSection1"><p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:40.8pt"><span style="font-size:11.0pt;font-family:"Verdana","sans-serif""><o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:40.8pt;text-indent:-18.0pt;mso-list:l1 level1 lfo2">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:Symbol"><span style="mso-list:Ignore">·<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif"">Another major issues is that of primops (prelude/primops.txt.pp). Things like add Int# or Float# are fine, but what about forking a thread, or throwing an exception?
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:76.8pt;text-indent:-18.0pt;mso-list:l1 level2 lfo2">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:"Courier New""><span style="mso-list:Ignore">o<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif"">One possibility is to try to emulate them all. I have no idea how hard that would be, but GHC’s I/O libraries rely heavily on lightweight concurrency.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:76.8pt;text-indent:-18.0pt;mso-list:l1 level2 lfo2">
<!--[if !supportLists]--><span style="font-size:11.0pt;font-family:"Courier New""><span style="mso-list:Ignore">o<span style="font:7.0pt "Times New Roman"">
</span></span></span><!--[endif]--><span style="font-size:11.0pt;font-family:"Verdana","sans-serif"">Another is to trim the list of PrimOps, and only support some of them. That’s easier, but you’d have to dump a lot of the ‘base’ package (particularly I/O) and
re-implement it using the .NET libraries instead.<o:p></o:p></span></p>
<p class="MsoListParagraph" style="mso-margin-top-alt:6.0pt;margin-right:0cm;margin-bottom:6.0pt;margin-left:40.8pt">
<span style="font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D"></span></p></div></div></blockquote><div><br></div>I think I will do whatever gets Fibonacci working first, and then reevaluate.</div><div><br></div><div>Thanks for the pointers.</div><div><br></div><div>Jason</div><div><blockquote type="cite"><div class="WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div>
</div>
</div>
</div>
</blockquote></div></body></html>