<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Playing with prefixes</title>
	<atom:link href="http://therning.org/magnus/archives/354/feed" rel="self" type="application/rss+xml" />
	<link>http://therning.org/magnus/archives/354</link>
	<description>Incoherent mumblings</description>
	<lastBuildDate>Wed, 08 Aug 2012 00:21:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: therning.org/ magnus &#187; Blog Archive &#187; More prefixes</title>
		<link>http://therning.org/magnus/archives/354/comment-page-1#comment-137803</link>
		<dc:creator>therning.org/ magnus &#187; Blog Archive &#187; More prefixes</dc:creator>
		<pubDate>Tue, 29 Jul 2008 23:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/?p=354#comment-137803</guid>
		<description><![CDATA[&lt;p&gt;[...] Incoherent mumblings          &#171; Playing with prefixes [...]&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>[...] Incoherent mumblings          &laquo; Playing with prefixes [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward Kmett</title>
		<link>http://therning.org/magnus/archives/354/comment-page-1#comment-133956</link>
		<dc:creator>Edward Kmett</dc:creator>
		<pubDate>Sun, 13 Jul 2008 14:17:14 +0000</pubDate>
		<guid isPermaLink="false">http://therning.org/magnus/?p=354#comment-133956</guid>
		<description><![CDATA[&lt;p&gt;Your (.+.) is going to lead to a lot of explicit type signatures because what is the type of the intermediate result generated in ((a .+. b) .+. c) ?&lt;/p&gt;

&lt;p&gt;Two possible approaches spring to mind.&lt;/p&gt;

&lt;p&gt;One thought is to take the second approach, but supply each prefix an instance of Num and rely on fromIntegral whenever you mix values of different units. This has the benefit of simplicity and recovering Num sugar.&lt;/p&gt;

&lt;p&gt;Another thought is to define a meet semi-lattice of measures such that if one measure subsumes the other. i.e. I can define everything with a K that I can with an M (assuming you use Integer rather than Int). then that measure is lower than the other in the lattice. Then take the meet of the two values you supply to (.+./.-.) in the lattice.&lt;/p&gt;

&lt;p&gt;Since KiB and K can only be added by lowering to your unprefixed representation IB. Then you get V shaped meet semi-lattice:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;GiB -&gt; MiB -&gt; KiB -&gt; IB &lt;- K &lt;- M &lt;- G&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and you can add a chain dangling down from your IB for smaller units, Deci, Centi, Milli, Micro, Nano, etc to obtain a Y shaped figure.&lt;/p&gt;

&lt;p&gt;And you can define the semi-lattice at the type level with functional dependencies so that you get forward type inference to figure out the type of the lvalue of an assignment at least.&lt;/p&gt;

&lt;p&gt;For large type-level (semi)lattices like this, I tend to just let template haskell define all of the instances for me, because you&#039;ll wind up with a number of instances equal to the square of the number of prefixes you define unless you exploit the structure of the lattice.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Your (.+.) is going to lead to a lot of explicit type signatures because what is the type of the intermediate result generated in ((a .+. b) .+. c) ?</p>

<p>Two possible approaches spring to mind.</p>

<p>One thought is to take the second approach, but supply each prefix an instance of Num and rely on fromIntegral whenever you mix values of different units. This has the benefit of simplicity and recovering Num sugar.</p>

<p>Another thought is to define a meet semi-lattice of measures such that if one measure subsumes the other. i.e. I can define everything with a K that I can with an M (assuming you use Integer rather than Int). then that measure is lower than the other in the lattice. Then take the meet of the two values you supply to (.+./.-.) in the lattice.</p>

<p>Since KiB and K can only be added by lowering to your unprefixed representation IB. Then you get V shaped meet semi-lattice:</p>

<blockquote>
  <p>GiB -&gt; MiB -&gt; KiB -&gt; IB &lt;- K &lt;- M &lt;- G</p>
</blockquote>

<p>and you can add a chain dangling down from your IB for smaller units, Deci, Centi, Milli, Micro, Nano, etc to obtain a Y shaped figure.</p>

<p>And you can define the semi-lattice at the type level with functional dependencies so that you get forward type inference to figure out the type of the lvalue of an assignment at least.</p>

<p>For large type-level (semi)lattices like this, I tend to just let template haskell define all of the instances for me, because you&#8217;ll wind up with a number of instances equal to the square of the number of prefixes you define unless you exploit the structure of the lattice.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
