<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>∃xistential Type</title>
	<atom:link href="http://existentialtype.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://existentialtype.net</link>
	<description>For People Who Like Type and Types</description>
	<pubDate>Mon, 21 Jul 2008 17:26:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Literally dependent types</title>
		<link>http://existentialtype.net/2008/07/21/literally-dependent-types/</link>
		<comments>http://existentialtype.net/2008/07/21/literally-dependent-types/#comments</comments>
		<pubDate>Mon, 21 Jul 2008 17:26:29 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[hacking]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[types]]></category>

		<category><![CDATA[dependent types]]></category>

		<category><![CDATA[implicit conversions]]></category>

		<category><![CDATA[literals]]></category>

		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=264</guid>
		<description><![CDATA[Given that the formalization of Scala Classic has ground to a halt, for reasons I may go into later, I spent part of today hacking on the Scala compiler itself to add support for singleton literals. Currently, Scala allows singleton types for stable identifiers.  My modification allows literals to be used in singleton types. [...]]]></description>
			<content:encoded><![CDATA[<p>Given that <a href="http://existentialtype.net/2008/07/13/even-better-than-the-real-thing/">the formalization of Scala Classic</a> has ground to a halt, for reasons I may go into later, I spent part of today hacking on the Scala compiler itself to add support for singleton literals. Currently, Scala allows singleton types for stable identifiers.  My modification allows literals to be used in singleton types.  I can't promise that it will be in the forthcoming Scala 2.7.2 release, but I would like it to be.</p>
<p>Overall it was far less work than I was expecting.  Scala already internally supports what it calls "constant types", there is just no way to write them in Scala source code presently.  Consequently, most of the effort was in extending the parser.</p>
<p>Given my modifications, it is now possible to write code like the following:</p>
<pre class="scala">&nbsp;
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;foo&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> <span style="color: #6666ff;">&quot;foo&quot;</span>
x<span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;foo&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> foo
&nbsp;</pre>
<p>What I was not expecting was that out-of-the-box things like the following would work:</p>
<pre class="scala">&nbsp;
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;foobar&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> <span style="color: #6666ff;">&quot;foo&quot;</span> + <span style="color: #6666ff;">&quot;bar&quot;</span>
x<span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;foobar&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> foobar
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> y <span style="color: #a00000;">:</span> <span style="color: #f78811;">10</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> <span style="color: #f78811;">2</span> <span style="color: #a00000;">*</span> <span style="color: #f78811;">5</span>
y<span style="color: #a00000;">:</span> <span style="color: #f78811;">10</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> <span style="color: #f78811;">10</span>
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> frob<span style="color: #e77801;">&#40;</span>arg <span style="color: #a00000;">:</span> <span style="color: #f78811;">10</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> <span style="color: #f78811;">6</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> arg - <span style="color: #f78811;">4</span>
frob<span style="color: #a00000;">:</span> <span style="color: #e77801;">&#40;</span><span style="color: #f78811;">10</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a><span style="color: #e77801;">&#41;</span><span style="color: #f78811;">6</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a>
&nbsp;</pre>
<p>Unfortunately the excitement soon passes when you realize all the things you can't do with singleton literals (yet).  Even if we turn on the experimental dependent method support, you can't write things like</p>
<pre class="scala">&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> add<span style="color: #e77801;">&#40;</span>arg <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> <span style="color: #e77801;">&#40;</span>arg + <span style="color: #f78811;">5</span><span style="color: #e77801;">&#41;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> <span style="color: #a00000;">=</span> arg + <span style="color: #f78811;">5</span>
&nbsp;</pre>
<p>because these are exactly what they are called, singleton literals, not full-blown dependent types.</p>
<p>One cute example, based on a use suggested by Sean McDirmid, would be that some people might do something like the following with implicits:</p>
<pre class="scala">&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">implicit</span></a> stringToColor<span style="color: #e77801;">&#40;</span>arg <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #99cc99;">String</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span> <span style="color: #a00000;">=</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span>.<span style="color: #006600;">getColor</span><span style="color: #e77801;">&#40;</span>arg<span style="color: #e77801;">&#41;</span>
&nbsp;</pre>
<p>However, with singleton literals you can tighten it up by ensuring that for some strings it will never fail:</p>
<pre class="scala">&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">implicit</span></a> redToColor<span style="color: #e77801;">&#40;</span>arg <span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;red&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span> <span style="color: #a00000;">=</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span>.<span style="color: #006600;">RED</span>
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">implicit</span></a> blueToColor<span style="color: #e77801;">&#40;</span>arg <span style="color: #a00000;">:</span> <span style="color: #6666ff;">&quot;blue&quot;</span>.<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span> <span style="color: #a00000;">=</span> java.<span style="color: #006600;">awt</span>.<span style="color: #006600;">Color</span>.<span style="color: #006600;">BLUE</span>
&nbsp;</pre>
<p>Happily, the type inferencer already chooses the most specific implicit conversions.</p>
<p>In any event, they will hopefully become more useful as the type system continues to grow.  I am also sure someone will probably come up with a clever use for them that hasn't occurred to me yet.  If so, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/21/literally-dependent-types/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fonts in LaTeX, Part Three: pdfTeX and TrueType</title>
		<link>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/</link>
		<comments>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/#comments</comments>
		<pubDate>Sat, 19 Jul 2008 16:13:22 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[typography]]></category>

		<category><![CDATA[deja vu sans]]></category>

		<category><![CDATA[fonts]]></category>

		<category><![CDATA[latex]]></category>

		<category><![CDATA[pdflatex]]></category>

		<category><![CDATA[pdftex]]></category>

		<category><![CDATA[tex]]></category>

		<category><![CDATA[tex gyre pagella]]></category>

		<category><![CDATA[truetype]]></category>

		<category><![CDATA[ttf2tfm]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=259</guid>
		<description><![CDATA[In the previous part of this tutorial, I explained how to put together the minimal infrastructure needed to use an OpenType font with pdfLaTeX.  However, I used the tool otftotfm to generate the font metrics TeX needs to lay out text. However, otftotfm only supports OpenType fonts that use PostScript font outlines, as opposed to [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/">previous part of this tutorial</a>, I explained how to put together the minimal infrastructure needed to use an <a href="http://en.wikipedia.org/wiki/OpenType">OpenType</a> font with pdfLaTeX.  However, I used the tool <code>otftotfm</code> to generate the font metrics TeX needs to lay out text. However, <code>otftotfm</code> only supports OpenType fonts that use PostScript font outlines, as opposed to <a href="http://en.wikipedia.org/wiki/TrueType">TrueType</a> font outlines. So in this part of the tutorial I will explain how to put together the necessary infrastructure for TrueType fonts. In preparation for that, we will first make a few changes to what we had done earlier.</p>
<p>For those that would find it useful, I've put together a  <a href="http://existentialtype.net/wp-content/uploads/2008/07/fonts-tutorial.zip">zip file</a> containing all the files from the tutorials (except the fonts, which I don't want to deal with distributing).</p>
<p>Firstly, we are going to move the uses of <code>\DeclareUnicodeCharacter</code> out of <code>UPagella.fd</code> and into <code>uenc.def</code>:</p>
<pre class="latex">ProvidesFile{<span style="color: #2222D0; font-weight: normal;">uenc.def</span>}
<span style="color: #808080; font-style: italic;">% We are declaring an encoding named &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontEncoding</span>{<span style="color: #2222D0; font-weight: normal;">U}{}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Technically these are not &quot;allowed&quot; in .def files,</span>
<span style="color: #808080; font-style: italic;">% but this is really the logical place to put the</span>
<span style="color: #808080; font-style: italic;">% declarations.</span>
&nbsp;
<span style="color: #808080; font-style: italic;">% τ (0x03C4) maps to 0xF8 in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C4}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F8</span>}
<span style="color: #808080; font-style: italic;">% ε (0x03B5) maps to 0xF9 in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03B5}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F9</span>}
<span style="color: #808080; font-style: italic;">% χ (0x03C7) maps to 0xFA in the encoding</span>
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C7}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;FA</span>}</pre>
<p>As I mention in the comments, the documentation on font encoding definition files does not list <code>\DeclareUnicodeCharacter</code> to be one of the allowed declarations in a such a file, but it works, and it seems like the more logical place to configure it than in the font definition file.</p>
<p>Now that we have removed the uses of <code>\DeclareUnicodeCharacter</code> from <code>UPagella.fd</code>, it looks like:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">UPagella.fd</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Delcaring a font family called &quot;Pagella&quot; for the encoding &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Declare that font family &quot;Pagella&quot;, for encoding &quot;U&quot;, has a shape</span>
<span style="color: #808080; font-style: italic;">% with weight medium (m) and normal (n) slant (in otherwords, upright)</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{m}{n</span>}{
  <span style="color: #808080; font-style: italic;">% For all sizes...</span>
  &lt;-&gt;
  <span style="color: #808080; font-style: italic;">% ... use the font named</span>
  TeXGyrePagella-Regular--custom--base
}{}</pre>
<p>I am going to use <a href="http://dejavu.sourceforge.net/wiki/index.php/Download">Deja Vu Sans</a> as the example TrueType font.  Fortunately, if you followed everything from the second part of the tutorial, there is not much that needs to be done.</p>
<p>First, we need to generate metrics for Deja Vu Sans.  As before, if you are using <a href="http://www.tug.org/texlive/">TeX Live</a>, you'll have the necessary program:</p>
<pre>% ttf2tfm DejaVuSans.ttf -q -T custom
ttf2tfm: WARNING: Cannot find character `compwordmark'
         specified in input encoding.
...
...
ttf2tfm: WARNING: Cannot find character `zdotaccent'
         specified in input encoding.
DejaVuSans   DejaVuSans.ttf Encoding=custom.enc</pre>
<p>The program <code>ttf2tfm</code> is kind of unusual in that it first takes the filename argument and then all the options.  So we've passed it the TrueType font we want to generate metrics for, <code>DejaVuSans.ttf</code>, the option <code>-q</code> to tell it not to print quite so much information, and the option <code>-T custom</code> which tells it to use the encoding defined in the file <code>custom.enc</code> we created in previous part.</p>
<p>Unlike <code>otftotfm</code>, <code>ttf2tfm</code> does not generate an entry that we could use in our <code>map</code> file, <code>custom.map</code>, so we need to write one ourselves.  You will want to start with the <code>map</code> we generated by <code>otftotfm</code> for Tex Gyre Pagella, and you will want to add the line:</p>
<pre>DejaVuSans &lt;custom.enc &lt;DejaVuSans.ttf</pre>
<p>This says to map the TeX font name <code>DejaVuSans</code> to the file <code>DejaVuSans.ttf</code> using the encoding <code>custom.enc</code>.  To learn more about the format of <code>map</code> files, there is a section on them in the <a href="http://sarovar.org/docman/view.php/106/66/pdftex-s.pdf">pdfTeX manual</a>.</p>
<p>Now we just need to create a font definition file for Deja Vu Sans.  However, it is essentially the same as the one we created for TeX Gyre Pagella:</p>
<pre class="latex">ProvidesFile{<span style="color: #2222D0; font-weight: normal;">UDejaVuSans.fd</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Delcaring a font family called &quot;DejaVuSans&quot; for the encoding &quot;U&quot;</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{DejaVuSans}{</span>}
&nbsp;
<span style="color: #808080; font-style: italic;">% Declare that font family &quot;DejaVuSans&quot;, for encoding &quot;U&quot;, has a shape</span>
<span style="color: #808080; font-style: italic;">% with weight medium (m) and normal (n) slant (in otherwords, upright)</span>
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{DejaVuSans}{m}{n</span>}{
  <span style="color: #808080; font-style: italic;">% For all sizes...</span>
  &lt;-&gt;
  <span style="color: #808080; font-style: italic;">% ... use the font named</span>
  DejaVuSans
}{}</pre>
<p>We have just replaced all occurrences of <code>Pagella</code> with <code>DejaVuSans</code>.</p>
<p>Finally, we just need to update our example document to use Deja Vu Sans:</p>
<pre class="latex">documentclass{<span style="color: #2222D0; font-weight: normal;">article</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">utf8</span>]{<span style="color: #2222D0; font-weight: normal;">inputenc</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">U</span>]{<span style="color: #2222D0; font-weight: normal;">fontenc</span>}
<span style="color: #800000; font-weight: normal;">\pdfmapfile</span>{<span style="color: #2222D0; font-weight: normal;">+custom.map</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\rmdefault</span>}{Pagella</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\sfdefault</span>}{DejaVuSans</span>} 
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">sffamily</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">sffamily</span>}
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}</pre>
<p>Here we have used <code>\renewcommand</code> to set the default sans serif font, <code>\sfdefault</code>, to be <code>DejaVuSans</code>.  In the body of the document, we've copied the text and surrounded it with the <code>sffamily</code> environment to have it typeset in sans serif.</p>
<p>Now we have everything we need to run <code>pdflatex</code>:</p>
<pre>% pdflatex test-pdflatex.tex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&amp;-line parsing enabled.
...
...
(./test-pdflatex.aux) (./upagella.fd) (./udejavusans.fd) [1]
(./test-pdflatex.aux) ){custom.enc}{a_qnnnfc.enc}&lt;./TeXGyrePage
lla-Regular.pfb&gt;
Output written on test-pdflatex.pdf (1 page, 34857 bytes).
Transcript written on test-pdflatex.log.</pre>
<p>And we have the desired output:</p>
<div style="text-align: center"><a href="http://existentialtype.net/wp-content/uploads/2008/07/test-pdflatex.png"><img class="aligncenter size-full wp-image-260" title="test-pdflatex" src="http://existentialtype.net/wp-content/uploads/2008/07/test-pdflatex.png" alt="Testing pdfLaTeX with both OpenType and TrueType fonts" width="245" height="140" /></a></div>
<p>And that's everything you need to get started with TrueType fonts and pdfLaTeX.  Again, if you encounter any problems or notice any omissions, let me kow. I'll do some investigation and there will possibly be a fourth part on using <a href="http://www.tug.org/applications/fontinst/">fontinst</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/19/fonts-in-latex-part-three-pdftex-and-truetype/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fonts in LaTeX, an intermission</title>
		<link>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/</link>
		<comments>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:58:01 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[meta]]></category>

		<category><![CDATA[typography]]></category>

		<category><![CDATA[fontinst]]></category>

		<category><![CDATA[lua]]></category>

		<category><![CDATA[luatex]]></category>

		<category><![CDATA[opentype]]></category>

		<category><![CDATA[pdftex]]></category>

		<category><![CDATA[reddit]]></category>

		<category><![CDATA[truetype]]></category>

		<category><![CDATA[xetex]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=258</guid>
		<description><![CDATA[Part one of my tutorial attracted a considerable number of visitors, far more than any single entry in the past, partly because it was posted to reddit.
Looking at the comments on reddit, I figured that I would say that luatex does resolve pdfTeX's internal limitation of 256 glyphs that I mentioned in part two, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/">Part one</a> of my tutorial attracted a considerable number of visitors, far more than any single entry in the past, partly because it was posted to <a href="http://www.reddit.com/r/programming/info/6rg7f/comments/">reddit</a>.</p>
<p>Looking at the comments on reddit, I figured that I would say that <a href="http://www.luatex.org/">luatex</a> does resolve pdfTeX's internal limitation of 256 glyphs that I mentioned in <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/">part two</a>, and it should directly support OpenType fonts with PostScript outlines.</p>
<p>However, my understanding is that the authors of luatex do not intend to make using TrueType and OpenType fonts as simple as XeTeX directly.  Instead, luatex merely makes the machinery available for someone else to build upon.  So someone will need to write a LaTeX package for luatex to put it all together, and as far as I know, no one has done this yet (let me know if I'm wrong!).  Also, while the plan is for luatex to eventually be merged back into pdfTeX, I think it is an overstatement to say that it will happen "soon".  The current luatex roadmap says that a "production" ready version will be available in <a href="http://www.luatex.org/roadmap.html">August 2009</a>.  I doubt that the merge back to pdfTeX will happen any sooner than 2010 given that.  But yes, in the long term I think luatex will be a great thing.</p>
<p>It also sounds like I should probably write a fourth part to my tutorial on using <a href="http://www.tug.org/applications/fontinst/">fontinst</a>.  I've never personally used it myself, and when I first started working with OpenType fonts and LaTeX I wasn't aware of its existence.  Therefore, I wrote <a href="http://free-the-mallocs.com/otftofd">otftofd</a>.  So it might take a bit longer to write as I will have to learn it at the same time.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/13/fonts-in-latex-an-intermission/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Even better than the real thing</title>
		<link>http://existentialtype.net/2008/07/13/even-better-than-the-real-thing/</link>
		<comments>http://existentialtype.net/2008/07/13/even-better-than-the-real-thing/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:23:45 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[research]]></category>

		<category><![CDATA[theory]]></category>

		<category><![CDATA[types]]></category>

		<category><![CDATA[explicit contexts]]></category>

		<category><![CDATA[featherweight scala]]></category>

		<category><![CDATA[pldi]]></category>

		<category><![CDATA[POPL]]></category>

		<category><![CDATA[scala]]></category>

		<category><![CDATA[scala classic]]></category>

		<category><![CDATA[soundness]]></category>

		<category><![CDATA[substitution]]></category>

		<category><![CDATA[teaching]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=256</guid>
		<description><![CDATA[
Several weeks ago I decided that instead of calling the core calculus that I have been working on Featherweight Scala, which could be confusing given that there is already a different calculus with that name, that I would call it Scala Classic.
I had hoped to submit a paper on Scala Classic to POPL 2009, but [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;"><a href="http://existentialtype.net/wp-content/uploads/2008/07/scalaclassic.png"><img class="aligncenter size-full wp-image-257" title="scalaclassic" src="http://existentialtype.net/wp-content/uploads/2008/07/scalaclassic.png" alt="Scala Classic" width="488" height="427" /></a></div>
<p>Several weeks ago I decided that instead of calling the core calculus that I have been working on Featherweight Scala, which could be confusing given that there is already a <a href="http://lampwww.epfl.ch/~odersky/papers/mfcs06.pdf">different calculus with that name</a>, that I would call it Scala Classic.</p>
<p>I had hoped to submit a paper on Scala Classic to <a href="http://www.cs.ucsd.edu/popl/09/">POPL 2009</a>, but it has been taking too long to work out the metatheory. Partly because I am developing a mechanized proof of type soundness in <a href="http://twelf.plparty.org/">Twelf</a>, and on my first attempt at representing heaps I think tried to be too clever.  However, a more traditional treatment of heaps leads to the need to <a href="http://www.cs.cmu.edu/~crary/papers/2008/excon.pdf">explicitly represent typing contexts</a>, rather than the implicit treatment of contexts more commonly used in Twelf.</p>
<p>This afternoon I finally finished the proof of the theorem that is traditionally called "substitution".  However, the proof of type preservation will also require another theorem formalizing a substitution-like property for singleton types.  I am hoping that I can prove that theorem more quickly now that I've built up all the explicit context theory.  I have not thought much about whether there are any unusual theorems needed to prove progress.</p>
<p>In any event, I would ideally have the proofs finished by the beginning of August.  My current plan is to try submitting the paper to <a href="http://www-plan.cs.colorado.edu/~pldi09/">PLDI</a> (which is even in Europe this year), unless some obviously better venue comes to my attention.</p>
<p>One of the reasons I would really like to have the proofs done by August is that I will be teaching a PhD level course here at <a href="http://www.epfl.ch/">EPFL</a> this fall on mechanized sepcifications and proofs, with a strong emphasis on deductive systems. It also looks like I may fill in some for a masters level course based on <a href="http://www.cis.upenn.edu/~bcpierce/tapl/">TAPL</a>.  So between those two things, I am not going to have nearly as much time for research as would be ideal.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/13/even-better-than-the-real-thing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fonts in LaTeX, Part Two: pdfTeX and OpenType</title>
		<link>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/</link>
		<comments>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 16:02:35 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[typography]]></category>

		<category><![CDATA[fontinst]]></category>

		<category><![CDATA[latex]]></category>

		<category><![CDATA[microtypography]]></category>

		<category><![CDATA[opentype]]></category>

		<category><![CDATA[otftofd]]></category>

		<category><![CDATA[otftotfm]]></category>

		<category><![CDATA[pagella]]></category>

		<category><![CDATA[pdflatex]]></category>

		<category><![CDATA[pdftex]]></category>

		<category><![CDATA[postscript]]></category>

		<category><![CDATA[tex]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=253</guid>
		<description><![CDATA[In part one of the tutorial, I commented that sometimes you would want to use pdfTeX and pdfLaTeX instead of XeTeX and XeLaTeX.  One reason to consider using pdfTeX over XeTeX is that the latter does not yet support the same microtypographic features.  When you are preparing slides, pdfTeX's microtypographic features probably will [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/">part one of the tutorial</a>, I commented that sometimes you would want to use <a href="http://www.tug.org/applications/pdftex/">pdfTeX and pdfLaTeX</a> instead of XeTeX and XeLaTeX.  One reason to consider using pdfTeX over XeTeX is that the latter does not yet support the same <a href="http://en.wikipedia.org/wiki/Microtypography">microtypographic</a> features.  When you are preparing slides, pdfTeX's microtypographic features probably will not have much of an impact on your output, but I've definitely found that while preparing articles and my dissertation, using pdfTeX's microtypographic features produces much nicer looking output with fewer bad breaks or hyphenations.</p>
<p>However, pdfTeX's architecture for handling fonts is much more like standard TeX and is <em>far</em> more complicated that XeTeX's. One option is to use a tool to do all the work for you.  For example, you could use the <a href="http://www.tug.org/applications/fontinst/">fontinst utility</a> or my own tool, <a href="http://free-the-mallocs.com/otftofd">otftofd</a>.  The other option is to do it all by hand, which is what I will explain in this tutorial.</p>
<p>One of the first complications you'll encounter with pdfTeX is that the font that is active at a given time can only refer to 256 glyphs at a time.  Therefore if you need to use more than 256 different glyphs in a document, you will need to switch between multiple "fonts".</p>
<p>The first step in using a font in pdfTeX is picking an encoding. Since most OpenType fonts contain more than 256 glyphs, an encoding provides a mapping from those glyphs to the 256 that you can reference at a given time in pdfTeX.</p>
<p>For the most part I generally just use what is called the <a href="http://en.wikipedia.org/wiki/Cork_encoding">T1 or "Cork" encoding</a>.  However, if we want to replicate the example from the first part of the tutorial, we will need to make a custom encoding to access the Greek glyphs.  So, first use <code>kpsewhich</code> to find where your system keeps <code>cork.enc</code>, and make a copy:<br />
<code><br />
% kpsewhich cork.enc<br />
/local/texlive/2007/texmf-dist/fonts/enc/dvips/base/cork.enc<br />
% cp /local/texlive/2007/texmf-dist/fonts/enc/dvips/base/cork.enc ./custom.enc<br />
</code><br />
Open <code>custom.enc</code> in you favorite editor, and go to the end. Assuming you are using the same version of TeX Live as me, the last few lines will look something like:<br />
<code><br />
/oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code><br />
You will want to edit it to look like:<br />
<code><br />
<span style="color: #ff0000;">/tau /epsilon /chi</span> /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code><br />
What we have done is changed the encoding so that glyphs 0xf8, 0xf9, 0xfa (in hexadecimal) now point to τ, ε, and χ.  The general format of entries in the encoding file is <code>/</code> followed by a name.  In the case that the software doesn't understand a name that you think it should, you can always specify the gylph using its Unicode hexadecimal name prefixed with <code>/uni</code>.  For example, we could have changed the encoding as followings:<br />
<code><br />
<span style="color: #ff0000;">/uni03c4 /uni03b5 /uni03c7</span> /ucircumflex /udieresis /yacute /thorn /germandbls<br />
] def<br />
</code></p>
<p>A complete list of glyph names can be obtained from <a href="http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt">Adobe's website</a>.  You can learn more about the encoding file format from the <a href="http://www.radicaleye.com/dvipsman/dvips.html#SEC62">dvips documentation</a>, though the eagle-eye may have noticed that actually a subset of <a href="http://en.wikipedia.org/wiki/PostScript">PostScript</a> itself.</p>
<p>Next, we need to create a file to tell LaTeX about our new encoding, which we will call U for "user-defined".  Create a file in the current directory called <code>uenc.def</code> and put the following in it:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">uenc.def</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontEncoding</span>{<span style="color: #2222D0; font-weight: normal;">U}{}{</span>}</pre>
<p>As it says, it is defining a new font encoding called "U".</p>
<p>Now that we have an encoding, we need to generate font metrics that pdfTeX can understand, and a mapping file to tell it how to map font names to encodings and actual font files.  Additionally, pdfTeX (at least last I checked) cannot handle OpenType fonts that contain PostScript rather than TrueType font outlines.  So we also need to convert our OpenType font, <a href="http://www.gust.org.pl/projects/e-foundry/tex-gyre/pagella">Pagella</a>, to <a href="http://en.wikipedia.org/wiki/Type_1_and_Type_3_fonts#Type_1">Type1 format</a>.  Fortunately, Eddie Kohler's excellent tool <a href="http://www.lcdf.org/type/otftotfm.1.html">otftotfm</a> will do most that for us.  Again, it is included with TeX Live.  We invoke it on the font we wish to use, with the encoding we have created, and redirect the output to a file called <code>custom.map</code>:</p>
<pre>
% otftotfm -e custom.enc texgyrepagella-regular.otf &gt; custom.map
otftotfm: ./custom.enc:19: warning: 'space' has no encoding, ignoring ligature
otftotfm: ./custom.enc:19: warning: 'space' has no encoding, ignoring ligature
otftotfm: ./custom.enc:30: warning: 'space' has no encoding, ignoring '{}'
otftotfm: ./custom.enc:30: warning: 'space' has no encoding, ignoring '{}'
I had to round some heights by 13.0000000 units.
I had to round some depths by 3.0000000 units.
I had to round some heights by 13.0000000 units.
I had to round some depths by 3.0000000 units.
</pre>
<p>Don't be concerned about the warnings.  The first few are just complaints because there is no "space" gylph, which is not used by TeX.  The rounding warnings occur, I assume, because PostScript metrics differ very slightly from TeX's internal representation of size metrics.  An <code>otftotfm</code> unit is about one thousandth of an em.</p>
<p>We now have have several new files in the current directory:</p>
<pre>
a_qnnnfc.enc
custom.map
TeXGyrePagella-Regular--custom--base.tfm
TeXGyrePagella-Regular--custom.tfm
TeXGyrePagella-Regular--custom.vf
TeXGyrePagella-Regular.pfb</pre>
<p>The <code>pfb</code> file is the PostScript Type 1 version of our original OpenType font, the file <code>custom.map</code> is used to tell pdfTeX how to map a font name to files, the two <code>tfm</code> provide the font metric information TeX needs to format text, the <code>vf</code> file is a "virtual font" file that depending on the options you gave to <code>otftotfm</code> may perform some operations on the basic glyphs, and the file <code>a_qnnnfc.enc</code> is an encoding <code>otftotfm</code> generated based upon the encoding we supplied it.  Depending on the options, <code>otftotfm</code> may try to include some additional glyphs to deal with ligatures or in the case that a glyph in the encoding we specified doesn't exist in the font, it will replace its entry with <code>/.notdef</code>, etc.</p>
<p>Next we want to take a peek inside of <code>custom.map</code>. It's contents will look something like the following:<br />
<code><br />
TeXGyrePagella-Regular--custom--base TeXGyrePagella-Regular "AutoEnc_qnnnfca3qut7llkesqq3eddyzc ReEncodeFont" &lt;[a_qnnnfc.enc<br />
</code><br />
You can get away without understanding the structure of the map file, but we need know the name LaTeX should use to refer to the font.  In this case it is the somewhat lengthy <code>TeXGyrePagella-Regular--custom--base</code>.  We could edit <code>custom.map</code> to give it a different name, but then we would need to make sure to rename the <code>tfm</code> files appropriately.  So we'll just leave it alone.</p>
<p>At this point we are ready to describe the font to LaTeX.  To to this we'll create a file called <code>UPagella.fd</code> where <code>fd</code> stands for "font definition".  Assuming you are using TeX Live, you can learn more about the format of font definition files by running: <code>texdoc fntguide</code>, which will bring up the <em>LATEX 2ε font selection</em> document. Put the following into <code>UPagella.fd</code>:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\ProvidesFile</span>{<span style="color: #2222D0; font-weight: normal;">UPagella.fd</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontFamily</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{</span>}
<span style="color: #800000; font-weight: normal;">\DeclareFontShape</span>{<span style="color: #2222D0; font-weight: normal;">U}{Pagella}{m}{n}{ &amp;lt;-&amp;gt; TeXGyrePagella-Regular--custom--base }{</span>}
&nbsp;
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C4}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F8</span>}
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03B5}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;F9</span>}
<span style="color: #800000; font-weight: normal;">\DeclareUnicodeCharacter</span>{<span style="color: #2222D0; font-weight: normal;">03C7}{<span style="color: #800000; font-weight: normal;">\char</span>&quot;FA</span>}
&nbsp;</pre>
<p>The second line declares for the font encoding U, a font family named Pagella. The third line defines an available shape for the Pagella family.  It has a medium weight (m) and normal/upright (n), and for all sizes (&lt;-&gt;) the font named <code>TeXGyrePagella-Regular--custom--base</code> should be used.  The three <code>\DeclareUnicodeCharacter</code> lines map the Unicode glyphs for τ, ε, and χ to their locations in the encoding we defined.  Note that the hexadecimal numbers must all be in uppercase for LaTeX to parse them correctly.</p>
<p>Now we are all set to revisit our original example.  In <code>test.tex</code> enter:</p>
<pre class="latex">&nbsp;
<span style="color: #800000; font-weight: normal;">\documentclass</span>{<span style="color: #2222D0; font-weight: normal;">article</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">utf8</span>]{<span style="color: #2222D0; font-weight: normal;">inputenc</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>[<span style="color: #2222D0; font-weight: normal;">U</span>]{<span style="color: #2222D0; font-weight: normal;">fontenc</span>}
<span style="color: #800000; font-weight: normal;">\pdfmapfile</span>{<span style="color: #2222D0; font-weight: normal;">+custom.map</span>}
<span style="color: #800000; font-weight: normal;">\renewcommand</span>{<span style="color: #2222D0; font-weight: normal;"><span style="color: #800000; font-weight: normal;">\rmdefault</span>}{Pagella</span>} 
&nbsp;
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
Testing pdfLaTeX!
&nbsp;
Greek: τεχ.
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
&nbsp;</pre>
<p>The second line here tells LaTeX to load the <code>inputenc</code> package and pass it the option <code>utf8</code> to tell it to parse the remainder of the input as UTF8 encoded text.  The third line tells LaTeX to load the <code>fontenc</code> package and pass it the option <code>U</code> telling it to set the default encoding to be U.  The fourth line is specific to pdfTeX and tells it to add to its internal mapping the definitions in <code>custom.map</code>.  Finally, <code>\renewcommand</code> is used to change the default serif (Roman, rm) font to be Pagella.</p>
<p>We can now go ahead and run <code>pdflatex</code>:</p>
<pre>
% pdflatex test.tex
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&amp;-line parsing enabled.
entering extended mode
(./test.tex
...
...
(./test.aux) (./upagella.fd) [1] (./test.aux) ){a_qnnnfc.enc}&lt;./TeXGyrePagella-
Regular.pfb&gt;
Output written on test.pdf (1 page, 22850 bytes).
Transcript written on test.log.
</pre>
<p>Again, we now get a PDF with the desired output:<br />
<a href='http://existentialtype.net/wp-content/uploads/2008/07/test2.png'><img src="http://existentialtype.net/wp-content/uploads/2008/07/test2.png" alt="pdfLaTeX test" title="test2" width="224" height="122" class="aligncenter size-full wp-image-255" /></a></p>
<p>That concludes the second part of the tutorial.  The third, and probably final, part of the tutorial will cover what needs to change in the above process if you would like to use a TrueType font rather than an OpenType font containing PostScript outline data.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/12/fonts-in-latex-part-two-pdftex-and-opentype/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fonts in LaTeX, Part One: XeLaTeX</title>
		<link>http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/</link>
		<comments>http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 11:02:58 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[typography]]></category>

		<category><![CDATA[fonts]]></category>

		<category><![CDATA[fontspec]]></category>

		<category><![CDATA[latex]]></category>

		<category><![CDATA[opentype]]></category>

		<category><![CDATA[pagella]]></category>

		<category><![CDATA[tex]]></category>

		<category><![CDATA[tex gyre]]></category>

		<category><![CDATA[tex live]]></category>

		<category><![CDATA[truetype]]></category>

		<category><![CDATA[xelatex]]></category>

		<category><![CDATA[xetex]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=251</guid>
		<description><![CDATA[Now and then I get asked about how to use some TrueType or OpenType font with LaTeX, so I figured I would take the time to write up some simple tutorials on how to do so. The first part will focus on the easiest route to making use of TrueType and OpenType fonts in LaTeX: [...]]]></description>
			<content:encoded><![CDATA[<p>Now and then I get asked about how to use some <a href="http://en.wikipedia.org/wiki/TrueType">TrueType</a> or <a href="http://en.wikipedia.org/wiki/OpenType">OpenType</a> font with LaTeX, so I figured I would take the time to write up some simple tutorials on how to do so. The first part will focus on the easiest route to making use of TrueType and OpenType fonts in LaTeX: <a href="http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&amp;id=xetex">XeTeX and XeLaTeX</a>.</p>
<p>XeLaTeX also has the advantage of not only giving easy access to modern fonts, but also accepting Unicode input files.</p>
<p>The first thing you need to do is find out if you have XeLaTeX installed, and if it is a sufficiently up to date version.  This is easiest to do from the command-line:<br />
<code><br />
% xelatex<br />
This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6)<br />
%&amp;-line parsing enabled.<br />
**^C<br />
</code><br />
This is the version that I am using for the tutorial, and is what comes with <a href="http://www.tug.org/texlive/">TeX Live 2007</a>.  I highly recommend just installing and using the entire TeX Live CD/DVD, even if you're using a Linux system that offers TeX Live packages, because, in particular for <a href="http://www.debian.org/">Debian</a>/<a href="http://www.ubuntu.com/">Ubuntu</a>, I've found that the default installation often doesn't install some important packages, and it can be a pain sort through all the available packages using Synaptics or whatnot to find what it didn't install.</p>
<p>I am also assuming that you are using a (modern) Unix or MacOS X system.  I assume that most of this material should also apply when using Windows, but if someone can comment, let me know.</p>
<p>Now, as an example, say you want to use the <a href="http://www.gust.org.pl/projects/e-foundry/tex-gyre/pagella">Pagella</a> font from the <a href="http://www.gust.org.pl/projects/e-foundry/tex-gyre">TeX Gyre</a> project.  First download them and install the fonts (the <code>otf</code> files) as you normally would on your computer.  Under MacOS X, this means using Font Book.  If you double-click on an <code>otf</code> file it will load Font Book for you and there will be dialog with a button to install the font.  If you load Font Book yourself, you can use the "Add Fonts..." menu item under the File menu to select the files.  Under a modern Unix, I would recommend just placing the <code>otf</code> files in your <code>~/.fonts</code> folder, though I think file managers like Nautilus also understand how to install fonts.</p>
<p>And that was all the installation work necessary; as I said, XeLaTeX is the easiest solution unless you have specialized needs.  Now just create a small LaTeX document:</p>
<pre class="latex">documentclass{<span style="color: #2222D0; font-weight: normal;">article</span>}
<span style="color: #800000; font-weight: normal;">\usepackage</span>{<span style="color: #2222D0; font-weight: normal;">fontspec</span>}
<span style="color: #800000; font-weight: normal;">\setromanfont</span>{<span style="color: #2222D0; font-weight: normal;">TeX Gyre Pagella</span>}
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\begin</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}
Testing XeLaTeX!
&nbsp;
Greek: τεχ.
<span style="color: #800000; font-weight: normal;"><span style="color: #F00000; font-weight: normal;">\end</span></span>{<span style="color: #2222D0; font-weight: normal;">document</span>}</pre>
<p>The <code>fontspec</code> package isn't necessary, but it makes dealing with fonts in XeLaTeX much easier, for example it defines the convenient <code>\setromanfont</code> command.  You can learn more about all of its great features from its beautifully formatted <a href="http://www.ctan.org/get/macros/xetex/latex/fontspec/fontspec.pdf">manual</a>.</p>
<p>The other thing you might need to know is what XeLaTeX thinks your font is called.  If you're using TeX Live, like I suggest, you will have the program <code>otfinfo</code> at your disposal that can do that for you:<br />
<code><br />
% otfinfo --family texgyrepagella-regular.otf<br />
TeX Gyre Pagella<br />
</code><br />
Note that despite its name, <code>otfinfo</code> will also work on <code>ttf</code> files, assuming that they include OpenType data in them.  The other option is to use Font Book on MacOS X or <code>fc-list</code> from the command-line in Unix.</p>
<p>Now you just run <code>xelatex</code>:<br />
<code><br />
% xelatex test.tex<br />
This is XeTeXk, Version 3.141592-2.2-0.996 (Web2C 7.5.6)<br />
%&amp;-line parsing enabled.<br />
entering extended mode<br />
(./test.tex<br />
...<br />
...<br />
Output written on test.pdf (1 page).<br />
Transcript written on test.log.<br />
</code><br />
And you have your document:</p>
<p><a href="http://existentialtype.net/wp-content/uploads/2008/07/test.png"><img class="aligncenter size-full wp-image-252" title="test" src="http://existentialtype.net/wp-content/uploads/2008/07/test.png" alt="XeLaTeX test" width="356" height="121" /></a></p>
<p>I think that is about everything you need to know, but if you try this tutorial out and find that something doesn't work, let me know.  If you have more specialized or demanding typographical needs, you may want to use pdfTeX and pdfLaTeX, and part two of the tutorial will explain how to do the necessary configuration to use TrueType and OpenType fonts with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/07/12/fonts-in-latex-part-one-xelatex/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Font identification</title>
		<link>http://existentialtype.net/2008/06/10/font-identification/</link>
		<comments>http://existentialtype.net/2008/06/10/font-identification/#comments</comments>
		<pubDate>Tue, 10 Jun 2008 07:56:45 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[papers]]></category>

		<category><![CDATA[typography]]></category>

		<category><![CDATA[epfl]]></category>

		<category><![CDATA[fonts]]></category>

		<category><![CDATA[image recognition]]></category>

		<category><![CDATA[warnock]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=250</guid>
		<description><![CDATA[I've mentioned Identifont in the past, but I was just thinking that I should point out the existence of
WhatTheFont, a tool that will identify a font for you from an image.  If failed to identify anything useful for the EPFL logo, but I doubt that corresponds to a real font.  From a screen [...]]]></description>
			<content:encoded><![CDATA[<p>I've mentioned <a href="http://www.identifont.com/">Identifont</a> in <a href="http://existentialtype.net/2007/07/18/those-crazy-sans-serifs/">the past</a>, but I was just thinking that I should point out the existence of<br />
<a href="http://www.myfonts.com/WhatTheFont/">WhatTheFont</a>, a tool that will identify a font for you from an image.  If failed to identify anything useful for the <a href="http://www.epfl.ch/">EPFL logo</a>, but I doubt that corresponds to a real font.  From a screen capture, it did correctly identify that the &exist;xistential Type header at the top of the page is made from a member of the Warnock Pro family.</p>
<p><a href="http://www.myfonts.com/WhatTheFont/">WhatTheFont</a> was first brought to my attention on <a href="http://daringfireball.net/linked/2008/may#wed-28-whatthefont">Daring Fireball</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/06/10/font-identification/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The other Scala</title>
		<link>http://existentialtype.net/2008/06/09/the-other-scala/</link>
		<comments>http://existentialtype.net/2008/06/09/the-other-scala/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 18:51:11 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[languages]]></category>

		<category><![CDATA[typography]]></category>

		<category><![CDATA[ff scala]]></category>

		<category><![CDATA[ff scala sans]]></category>

		<category><![CDATA[scala]]></category>

		<category><![CDATA[scala's bistro]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=248</guid>
		<description><![CDATA[A post by James Iry on the Scala mailing list today reminded me of the existence of FF Scala (along with its companion FF Scala Sans).  I haven't received confirmation, but I suspect that Programming in Scala does not, unfortunately,  use any members of the FF Scala family.  I was sorely tempted to [...]]]></description>
			<content:encoded><![CDATA[<p>A post by <a href="http://james-iry.blogspot.com/">James Iry</a> on the <a href="http://www.nabble.com/-scala--Scala-is-so-cool-it%27s-fashionable-td17735295.html">Scala mailing list</a> today reminded me of the existence of <a href="http://en.wikipedia.org/wiki/FF_Scala">FF Scala</a> (along with its companion <a href="http://en.wikipedia.org/wiki/FF_Scala_Sans">FF Scala Sans</a>).  I haven't received confirmation, but I suspect that <a href="http://www.artima.com/shop/forsale">Programming in Scala</a> does not, unfortunately,  use any members of the FF Scala family.  I was sorely tempted to purchase the fonts, <a href="http://www.fontshop.com/search/?q=scala&amp;x=0&amp;y=0">until I saw the prices</a>.  Maybe someday.</p>
<p>And there are plenty of other Scalas about.  In San Francisco:</p>
<p><a href="http://existentialtype.net/wp-content/uploads/2008/06/photo.jpg"><img class="aligncenter size-full wp-image-249" title="Scala\'s Bistro" src="http://existentialtype.net/wp-content/uploads/2008/06/photo.jpg" alt="" width="500" height="375" /></a></p>
<p>Alas, we did not succeed in getting Martin to <a href="http://www.scalasbistro.com/">eat there</a> while he was at <a href="http://java.sun.com/javaone/sf/index.jsp">JavaOne</a>.  Photo courtesy of <a href="http://people.cs.uchicago.edu/~robby/">Robby Findler</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/06/09/the-other-scala/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Even more modules in Scala</title>
		<link>http://existentialtype.net/2008/05/26/even-more-modules-in-scala/</link>
		<comments>http://existentialtype.net/2008/05/26/even-more-modules-in-scala/#comments</comments>
		<pubDate>Mon, 26 May 2008 21:26:13 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=247</guid>
		<description><![CDATA[In response to Rossberg's challenge to encode the following:
&#160;
signature S =
sig
   structure A : sig type t; val x : t end
   val f : A.t -&#62; int
end
&#160;
structure M =
struct
   structure A = struct type t = int; val x = 666 end
   fun f x = [...]]]></description>
			<content:encoded><![CDATA[<p>In response to <a href="http://lambda-the-ultimate.org/node/2808#comment-41847">Rossberg's challenge</a> to encode the following:</p>
<pre>&nbsp;
signature S =
sig
   structure A : sig type t; val x : t end
   val f : A.t -&gt; int
end
&nbsp;
structure M =
struct
   structure A = struct type t = int; val x = 666 end
   fun f x = x
end
&nbsp;
structure N = M :&gt; S
&nbsp;</pre>
<p>In Scala, the above becomes:</p>
<pre class="scala">&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> S <span style="color: #a00000;">=</span> <span style="color: #e77801;">&#123;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> A<span style="color: #a00000;">:</span> <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T<span style="color: #a00000;">;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x<span style="color: #a00000;">:</span> T <span style="color: #e77801;">&#125;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> f<span style="color: #e77801;">&#40;</span>arg<span style="color: #a00000;">:</span> A.<span style="color: #006600;">T</span><span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a>
<span style="color: #e77801;">&#125;</span>
&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> M <span style="color: #a00000;">=</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">new</span></a> <span style="color: #e77801;">&#123;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> A <span style="color: #a00000;">=</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">new</span></a> <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T <span style="color: #a00000;">=</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a><span style="color: #a00000;">;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">=</span> <span style="color: #f78811;">666</span> <span style="color: #e77801;">&#125;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> f<span style="color: #e77801;">&#40;</span>arg<span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a><span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">=</span> arg
<span style="color: #e77801;">&#125;</span>
&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> N <span style="color: #a00000;">=</span> M <span style="color: #a00000;">:</span> S
&nbsp;</pre>
<p>And using <code lang="scala">N.f</code> on <code lang="scala">N.A.x</code> is even well-typed, but still encounters the same problems with evaluation <a href="http://existentialtype.net/2008/05/26/modules-in-scala/">I mentioned earlier</a>.  And yes, the type <code lang="scala">N.A.T</code> is hidden:</p>
<pre class="scala">&nbsp;
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a> <span style="color: #a00000;">=</span> M.<span style="color: #006600;">A</span>.<span style="color: #006600;">x</span>
x<span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a> <span style="color: #a00000;">=</span> <span style="color: #f78811;">666</span>
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a> <span style="color: #a00000;">=</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">x</span>
<span style="color: #a00000;">&lt;</span>console<span style="color: #a00000;">&gt;:</span><span style="color: #f78811;">7</span><span style="color: #a00000;">:</span> error<span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> mismatch<span style="color: #a00000;">;</span>
 found   <span style="color: #a00000;">:</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">T</span>
 required<span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a>
       <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a> <span style="color: #a00000;">=</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">x</span>
                         ^
&nbsp;
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">T</span> <span style="color: #a00000;">=</span> <span style="color: #f78811;">42</span>
<span style="color: #a00000;">&lt;</span>console<span style="color: #a00000;">&gt;:</span><span style="color: #f78811;">7</span><span style="color: #a00000;">:</span> error<span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> mismatch<span style="color: #a00000;">;</span>
 found   <span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Int</span></a><span style="color: #e77801;">&#40;</span><span style="color: #f78811;">42</span><span style="color: #e77801;">&#41;</span>
 required<span style="color: #a00000;">:</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">T</span>
       <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">val</span></a> x <span style="color: #a00000;">:</span> N.<span style="color: #006600;">A</span>.<span style="color: #006600;">T</span> <span style="color: #a00000;">=</span> <span style="color: #f78811;">42</span>
                       ^
&nbsp;</pre>
<p>As for how Scala, solves the double vision problem, I would look at the work on &nu;Obj, and the forthcoming paper on Featherweight Scala.</p>
<p><strong>Update</strong>: Looking more closely at the definition of "double vision" as defined by <a href="http://ttic.uchicago.edu/~dreyer/papers/recmod/main-short.pdf">Dreyer</a>, the Scala implementation cannot currently handle his motivating example.  I will need to think about how the example works in Featherweight Scala, which to my knowledge shouldn't have a problem with at least defining the type signatures.  I think the short answer is that &nu;Obj and Featherweight Scala (the non-algorithmic version) solve the problem in a vacuous fashion, as the type checking problem for them is undecidable.  Scala proper possibly could resolve the problem by using a less restrictive cycle detection algorithm.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/05/26/even-more-modules-in-scala/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Functors in Scala</title>
		<link>http://existentialtype.net/2008/05/26/functors-in-scala/</link>
		<comments>http://existentialtype.net/2008/05/26/functors-in-scala/#comments</comments>
		<pubDate>Mon, 26 May 2008 19:42:19 +0000</pubDate>
		<dc:creator>washburn</dc:creator>
		
		<category><![CDATA[hacking]]></category>

		<category><![CDATA[software]]></category>

		<category><![CDATA[types]]></category>

		<category><![CDATA[functors]]></category>

		<category><![CDATA[modules]]></category>

		<category><![CDATA[scala]]></category>

		<category><![CDATA[sml]]></category>

		<guid isPermaLink="false">http://existentialtype.net/?p=246</guid>
		<description><![CDATA[Following on my earlier entry on modules in Scala, I'll give an encoding of Standard ML style functors here.  You can get a pretty close approximation by using class constructor arguments.  However, I am going to cheat a little to get the closest encoding I think is possible by using the experimental support [...]]]></description>
			<content:encoded><![CDATA[<p>Following on my earlier entry on <a href="http://existentialtype.net/2008/05/26/modules-in-scala/">modules in Scala</a>, I'll give an encoding of Standard ML style functors here.  You can get a pretty close approximation by using <code>class</code> constructor arguments.  However, I am going to cheat a little to get the closest encoding I think is possible by using the experimental support for dependent method types.  You can get this by running <code>scala</code> or <code>scalac</code> with the option <code>-Xexperimental</code>.  It works okay at least some of the time, but no one has the time at the moment to commit to getting it in shape for general consumption.</p>
<p>So here is my example of how the encoding works.  First, the SML version:</p>
<pre>&nbsp;
signature Eq = sig
  type t
  val eq: t -&gt; t -&gt; bool
end
&nbsp;
signature RicherEq = sig
  include Eq
  val neq: t -&gt; t -&gt; bool
end
&nbsp;
functor mkRicherEq(arg : Eq) :&gt; RicherEq where type t = arg.t = struct
  type t = arg.t
  val eq = arg.eq
  fun neq x y = not (eq x y)
end
&nbsp;</pre>
<p>We can transliterate this example into Scala as:</p>
<pre class="scala">&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> Eq <span style="color: #a00000;">=</span> <span style="color: #e77801;">&#123;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> eq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a>
<span style="color: #e77801;">&#125;</span>
&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> RicherEq <span style="color: #a00000;">=</span> <span style="color: #e77801;">&#123;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> eq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> neq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a>
<span style="color: #e77801;">&#125;</span>
&nbsp;
<a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> mkRicherEq<span style="color: #e77801;">&#40;</span>arg<span style="color: #a00000;">:</span> Eq<span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">:</span> RicherEq <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T <span style="color: #a00000;">=</span> arg.<span style="color: #006600;">T</span> <span style="color: #e77801;">&#125;</span> <span style="color: #a00000;">=</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">new</span></a> <span style="color: #e77801;">&#123;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> T <span style="color: #a00000;">=</span> arg.<span style="color: #006600;">T</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> eq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">=</span> arg.<span style="color: #006600;">eq</span><span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">,</span> y<span style="color: #e77801;">&#41;</span>
  <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> neq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span>T<span style="color: #e77801;">&#41;</span> <span style="color: #a00000;">=</span> <span style="color: #a00000;">!</span>eq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">,</span> y<span style="color: #e77801;">&#41;</span>
<span style="color: #e77801;">&#125;</span>
&nbsp;</pre>
<p>The only problem I discovered is that it is not possible to define <code>RicherEq</code> in terms of <code>Eq</code> as we could in SML:</p>
<pre class="scala">&nbsp;
scala<span style="color: #a00000;">&gt;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> RicherEq <span style="color: #a00000;">=</span> Eq <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> neq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a> <span style="color: #e77801;">&#125;</span>
<span style="color: #a00000;">&lt;</span>console<span style="color: #a00000;">&gt;:</span><span style="color: #f78811;">5</span><span style="color: #a00000;">:</span> error<span style="color: #a00000;">:</span> Parameter <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> in structural refinement may
not refer to <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">abstract</span></a> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> defined outside that same refinement
       <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> RicherEq <span style="color: #a00000;">=</span> Eq <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> neq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a> <span style="color: #e77801;">&#125;</span>
                                       ^
<span style="color: #a00000;">&lt;</span>console<span style="color: #a00000;">&gt;:</span><span style="color: #f78811;">5</span><span style="color: #a00000;">:</span> error<span style="color: #a00000;">:</span> Parameter <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> in structural refinement may
not refer to <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">abstract</span></a> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> defined outside that same refinement
       <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">type</span></a> RicherEq <span style="color: #a00000;">=</span> Eq <span style="color: #e77801;">&#123;</span> <a href="http://www.scala-lang.org/docu/files/ScalaReference.pdf"><span style="color: #009900;">def</span></a> neq<span style="color: #e77801;">&#40;</span>x<span style="color: #a00000;">:</span> T<span style="color: #a00000;">,</span> y<span style="color: #a00000;">:</span> T<span style="color: #e77801;">&#41;</span><span style="color: #a00000;">:</span> <a href="http://www.scala-lang.org/docu/files/api/index.html"><span style="color: #5555cc;">Boolean</span></a> <span style="color: #e77801;">&#125;</span>
                                             ^
&nbsp;</pre>
<p>Why this restriction exists I don't know.  In fact, this sort of refinement should work in the current version of Featherweight Scala, so perhaps it can be lifted eventually.</p>
<p>I still need to think about higher-order functors, and probably spend a few minutes researching existing proposals.  I think this is probably something that cannot be easily supported in Scala if it will require allowing method invocations to appear in paths.  However, off hand that only seems like it should be necessary for applicative higher-order functors, but again I definitely need to think it through.</p>
]]></content:encoded>
			<wfw:commentRss>http://existentialtype.net/2008/05/26/functors-in-scala/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
