<?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: Vector space bases via type families</title>
	<atom:link href="http://conal.net/blog/posts/vector-space-bases-via-type-families/feed" rel="self" type="application/rss+xml" />
	<link>http://conal.net/blog/posts/vector-space-bases-via-type-families</link>
	<description>Inspirations &#38; experiments, mainly about denotative/functional programming in Haskell</description>
	<lastBuildDate>Sat, 26 Sep 2020 21:06:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.17</generator>
	<item>
		<title>By: traeger</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-189</link>
		<dc:creator><![CDATA[traeger]]></dc:creator>
		<pubDate>Wed, 29 Dec 2010 12:56:00 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-189</guid>
		<description><![CDATA[&lt;p&gt;First of all, great work, I get inspired&lt;/p&gt;

&lt;p&gt;Worked further with your lib, and get stucked at the magnitude definition. why don&#039;t use field-axioms for your scalar (eg. by introducing a new class field and/or group..) to have an abstract inverse and so on, to avoid the (Fractional in ^/). Also I miss a &quot;VectorSpace with Norm&quot; and &quot;VectorSpace with Metric&quot;. by using those kind of abstractions you can avoid the &quot;Floating&quot; in &quot;magnitude&quot; and all the definions will be real-generic.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>First of all, great work, I get inspired</p>

<p>Worked further with your lib, and get stucked at the magnitude definition. why don&#8217;t use field-axioms for your scalar (eg. by introducing a new class field and/or group..) to have an abstract inverse and so on, to avoid the (Fractional in ^/). Also I miss a &#8220;VectorSpace with Norm&#8221; and &#8220;VectorSpace with Metric&#8221;. by using those kind of abstractions you can avoid the &#8220;Floating&#8221; in &#8220;magnitude&#8221; and all the definions will be real-generic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: traeger</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-188</link>
		<dc:creator><![CDATA[traeger]]></dc:creator>
		<pubDate>Sun, 26 Dec 2010 02:40:34 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-188</guid>
		<description><![CDATA[&lt;p&gt;I just needed high dimentional vectors, looked at your source and saw the &#039;vector-trick&#039;; I wrote a little extention with lists instead of vectors. The Vector-Vector-operators (^+^, &lt;.&gt;) are using the zero element for component-vise operations if one list is shorter than the other.&lt;/p&gt;

&lt;p&gt;e.g.: [1,1,1] ^+^ [1,1] = [2,2,1]&lt;/p&gt;

&lt;pre&gt;
import Data.VectorSpace

instance (AdditiveGroup v) =&gt; AdditiveGroup [v] where
  zeroV         = []
  v ^+^ u       = zipWithDefault (^+^) zeroV zeroV v u
  negateV v     = map negateV v

instance (VectorSpace v, s ~ Scalar v) =&gt; VectorSpace [v] where
  type Scalar [v] = Scalar v
  s *^ v = map (s *^) v

instance (InnerSpace v, AdditiveGroup (Scalar v)) =&gt; InnerSpace [v] where
  v &lt;.&gt; u = foldl (^+^) zeroV $ zipWithDefault (&lt;.&gt;) zeroV zeroV v u

-- like zipWith(Prelude) but with default values which
-- will be used if one list is shorter than the other
zipWithDefault :: (a -&gt; b -&gt; c) -&gt; a -&gt; b -&gt; [a] -&gt; [b] -&gt; [c]
zipWithDefault z ad bd (a:as) (b:bs) = z a b : zipWithDefault z ad bd as bs
zipWithDefault z ad _ [] bs = map (z ad) bs
zipWithDefault z _ bd as [] = map ((flip z) bd) as
&lt;/pre&gt;
]]></description>
		<content:encoded><![CDATA[<p>I just needed high dimentional vectors, looked at your source and saw the &#8216;vector-trick'; I wrote a little extention with lists instead of vectors. The Vector-Vector-operators (^+^, &lt;.&gt;) are using the zero element for component-vise operations if one list is shorter than the other.</p>

<p>e.g.: [1,1,1] ^+^ [1,1] = [2,2,1]</p>

<pre>
import Data.VectorSpace

instance (AdditiveGroup v) =&gt; AdditiveGroup [v] where
  zeroV         = []
  v ^+^ u       = zipWithDefault (^+^) zeroV zeroV v u
  negateV v     = map negateV v

instance (VectorSpace v, s ~ Scalar v) =&gt; VectorSpace [v] where
  type Scalar [v] = Scalar v
  s *^ v = map (s *^) v

instance (InnerSpace v, AdditiveGroup (Scalar v)) =&gt; InnerSpace [v] where
  v &lt;.&gt; u = foldl (^+^) zeroV $ zipWithDefault (&lt;.&gt;) zeroV zeroV v u

-- like zipWith(Prelude) but with default values which
-- will be used if one list is shorter than the other
zipWithDefault :: (a -&gt; b -&gt; c) -&gt; a -&gt; b -&gt; [a] -&gt; [b] -&gt; [c]
zipWithDefault z ad bd (a:as) (b:bs) = z a b : zipWithDefault z ad bd as bs
zipWithDefault z ad _ [] bs = map (z ad) bs
zipWithDefault z _ bd as [] = map ((flip z) bd) as
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-187</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Mon, 20 Oct 2008 16:57:44 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-187</guid>
		<description><![CDATA[&lt;blockquote&gt;
  &lt;p&gt;What do you mean by a canonical basis? A vector space doesn’t have one distinguished basis.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The library distinguishes one basis out of the many possible.  I mean a canonical basis in that sense, not universally.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<blockquote>
  <p>What do you mean by a canonical basis? A vector space doesn’t have one distinguished basis.</p>
</blockquote>

<p>The library distinguishes one basis out of the many possible.  I mean a canonical basis in that sense, not universally.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-186</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Mon, 20 Oct 2008 16:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-186</guid>
		<description><![CDATA[&lt;blockquote&gt;
Please help set the trend and document typeclass laws in plain sight.
&lt;/blockquote&gt;

&lt;p&gt;I agree.  Thanks for the reminder, Luke.  And not just as comments but as executable QuickCheck test generators.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<blockquote>
Please help set the trend and document typeclass laws in plain sight.
</blockquote>

<p>I agree.  Thanks for the reminder, Luke.  And not just as comments but as executable QuickCheck test generators.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominic Steinitz</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-185</link>
		<dc:creator><![CDATA[Dominic Steinitz]]></dc:creator>
		<pubDate>Mon, 20 Oct 2008 08:44:41 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-185</guid>
		<description><![CDATA[&lt;p&gt;What do you mean by a canonical basis? A vector space doesn&#039;t have one distinguished basis. Bases are related by invertible linear maps.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>What do you mean by a canonical basis? A vector space doesn&#8217;t have one distinguished basis. Bases are related by invertible linear maps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke Palmer</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-184</link>
		<dc:creator><![CDATA[Luke Palmer]]></dc:creator>
		<pubDate>Mon, 20 Oct 2008 06:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-184</guid>
		<description><![CDATA[&lt;p&gt;Nice article.&lt;/p&gt;

&lt;p&gt;I have a feature request for vector-space.  The definition of AdditiveGroup you gave is incomplete; it is missing essential documentation.  Please help set the trend and document typeclass laws in plain sight.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Nice article.</p>

<p>I have a feature request for vector-space.  The definition of AdditiveGroup you gave is incomplete; it is missing essential documentation.  Please help set the trend and document typeclass laws in plain sight.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Conal Elliott &#187; Blog Archive &#187; Simpler, more efficient, functional linear maps</title>
		<link>http://conal.net/blog/posts/vector-space-bases-via-type-families#comment-183</link>
		<dc:creator><![CDATA[Conal Elliott &#187; Blog Archive &#187; Simpler, more efficient, functional linear maps]]></dc:creator>
		<pubDate>Mon, 20 Oct 2008 01:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=56#comment-183</guid>
		<description><![CDATA[&lt;p&gt;[...] About      &#171; Vector space bases via type families [...]&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] About      &laquo; Vector space bases via type families [&#8230;]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
