<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Enough Blogging!</title>
	<atom:link href="http://noamlewis.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://noamlewis.wordpress.com</link>
	<description>Haskell, FRP, and other technicalities</description>
	<lastBuildDate>Mon, 23 Jan 2012 17:48:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='noamlewis.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Enough Blogging!</title>
		<link>http://noamlewis.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://noamlewis.wordpress.com/osd.xml" title="Enough Blogging!" />
	<atom:link rel='hub' href='http://noamlewis.wordpress.com/?pushpress=hub'/>
		<item>
		<title>When to scroll? The problem of infinite-sized UI elements inside a scrollviewer</title>
		<link>http://noamlewis.wordpress.com/2012/01/23/when-to-scroll-the-problem-of-infinite-sized-ui-elements-inside-a-scrollviewer/</link>
		<comments>http://noamlewis.wordpress.com/2012/01/23/when-to-scroll-the-problem-of-infinite-sized-ui-elements-inside-a-scrollviewer/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 17:48:05 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=92</guid>
		<description><![CDATA[While refactoring a WPF application, I&#8217;ve stumbled into a general problem in UI layout. WPF has an element called ScrollViewer, which is basically a panel that contains elements and shows scroll bars when the content inside is too big to fit in the size of the ScrollViewer&#8217;s visible area. Consider the following three cases. Case [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=92&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While refactoring a WPF application, I&#8217;ve stumbled into a general problem in UI layout.</p>
<p>WPF has an element called ScrollViewer, which is basically a panel that contains elements and shows scroll bars when the content inside is too big to fit in the size of the ScrollViewer&#8217;s visible area. Consider the following three cases.</p>
<h3>Case 1: Finite-sized UI content within a ScrollViewer</h3>
<p>In this case, obviously the scroll bars should only appear if the visible area of the ScrollViewer is too small to show the content. If the window is large enough, there entire finite-sized content will fit in the screen and no scroll bars are necessary (although we may want to still show them, disabled, for stylistic reasons).</p>
<h3>Case 2: Infinite-sized UI content within a limited container (NOT a ScrollViewer)</h3>
<p>Sometimes we have content that can use any size assigned to it. For example, a grid (in my case, DevExpress&#8217; WPF GridControl) of data rows. Assuming a huge (or even infinite) data source, the grid&#8217;s size on the screen has no upper bound &#8211; it can always grow more and always show more content. The grid&#8217;s size in the UI must be limited somehow. There are two ways to limit the size of such a UI control:</p>
<ol>
<li>Set a maximum size on the control, or</li>
<li>Place the infinitely-sized control in a container that has a maximum size defined.</li>
</ol>
<p>In other words, the infinite control must lie in a tree of containers where at least one container up the ancestry must have defined a maximum size. If no parent container specifies a maximum size, eventually the top-level container &#8211; the window &#8211; DOES have a maximum size and the infinite-sized control will fill the whole window (and nothing more).</p>
<h3>Case 3: Infinite-sized UI content within a ScrollViewer</h3>
<p>Now, consider that the container of the infinite UI control (such as a grid with infinite rows in the data source), is actually container within a ScrollViewer. In this case, the ScrollViewer, being what it is, does NOT limit the size of its contents, so the infinitely-sized control will &#8220;explode&#8221; and will, by our algorithm, try to occupy an infinite size. Specifically in the case of a DevExpress WPF GridControl, the authors of that control know to detect that situation &#8211; and an exception is thrown, stating:</p>
<blockquote><p><span style="color:#808080;">DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled</span><br />
<span style="color:#808080;">   Message=<span style="color:#000000;">&#8220;</span></span>By default, an infinite grid height is not allowed since all grid rows will be rendered and hence the grid will work very slowly. To fix this issue, you should place the grid into a container that will give a finite height to the grid, or you should manually specify the grid&#8217;s Height or MaxHeight. Note that you can also avoid this exception by setting the GridControl.AllowInfiniteGridSize static property to True, but in that case the grid will run slowly.&#8221;</p></blockquote>
<p>Problem is, sometimes we want to put that grid in a ScrollViewer so that when the screen is too small, the grid will assume some minimal size, and a scroll bar will be shown if the screen (or window) is smaller than the minimum. If the window is huge, what we want is to expand the grid to fill the available space in the window &#8211; as big as the window can be, with no limit. If someone is using the application on a 5000-inch screen, we want to use all that space. If someone is using a 1-inch screen, we want the grid to be 3 inches and show a scroll bar.</p>
<p>So, the solution seems simple enough: we can tell the ScrollViewer to have dual behavior:</p>
<ol>
<li>If the available screen size is smaller than some minimum, allow scrolling, and set the size available for the content to be that minimum size.</li>
<li>If the available screen size is larger than the minimum, behave like a regular container that gives its children only the space it has on the screen.</li>
</ol>
<p>For example, if we decide the content requires at least 100 pixels, if the ScrollViewer has 80 pixels available &#8211; make the content within the scrollable area exactly 100 pixels, and show scroll bars. If the size available for the ScrollViewer is 200 pixels (more than the minimum 100 pixels) &#8211; don&#8217;t allow scrolling, and let the contained UI content use up to 200 pixels. Here&#8217;s a WPF behavior for ScrollViewer that does exactly that:</p>
<pre>    public class ScrollViewerMaxSizeBehavior : Behavior&lt;ScrollViewer&gt;
    {
        public static readonly DependencyProperty MinContentHeightProperty = DependencyProperty.Register("MinContentHeight", typeof(int),
            typeof(ScrollViewerMaxSizeBehavior), new UIPropertyMetadata() { PropertyChangedCallback = MinSizeChanged } );
        public int MinContentHeight
        {
            get { return (int)GetValue(MinContentHeightProperty); }
            set { SetValue(MinContentHeightProperty, value); }
        }

        public static readonly DependencyProperty MinContentWidthProperty = DependencyProperty.Register("MinContentWidth", typeof(int),
            typeof(ScrollViewerMaxSizeBehavior), new UIPropertyMetadata() { PropertyChangedCallback = MinSizeChanged });
        public int MinContentWidth
        {
            get { return (int)GetValue(MinContentWidthProperty); }
            set { SetValue(MinContentWidthProperty, value); }
        }

        protected static void MinSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var self = d as ScrollViewerMaxSizeBehavior;
            if (null == self)
            {
                return;
            }
            self.Update();
        }

        protected override void OnAttached()
        {
            base.OnAttached();
            this.AssociatedObject.SizeChanged += this.ParentSizeChanged;
            this.Update();
        }

        protected override void OnDetaching()
        {
            this.AssociatedObject.SizeChanged -= this.ParentSizeChanged;
            base.OnDetaching();
        }

        protected void ParentSizeChanged(Object sender, SizeChangedEventArgs e)
        {
            this.Update();
        }

        private void Update()
        {
            if (null == this.AssociatedObject)
            {
                return;
            }
            var content = this.AssociatedObject.Content as FrameworkElement;

            if ((0 &gt;= this.AssociatedObject.ActualHeight)
                || (0 &gt;= this.AssociatedObject.ActualWidth))
            {
                // The attached ScrollViewer was probably not laid out yet, or has zero size.
                this.AssociatedObject.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                this.AssociatedObject.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                return;
            }

            int minHeight = this.MinContentHeight;
            int minWidth = this.MinContentWidth;

            if ((minHeight &lt;= 0) || (minWidth &lt;= 0))
            {
                // Probably our attached properties were not initialized. By default we disable the scrolling completely,
                // to prevent exceptions from infinitely-sized objects within us.
                this.AssociatedObject.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                this.AssociatedObject.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                return;
            }

            this.AssociatedObject.SizeChanged -= this.ParentSizeChanged;

            if (this.AssociatedObject.ActualHeight &lt; minHeight)
            {
                this.AssociatedObject.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
                if (null != content)
                {
                    content.MaxHeight = minHeight - (content.Margin.Bottom + content.Margin.Top);
                }
            }
            else
            {
                this.AssociatedObject.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled;
                if (null != content)
                {
                    content.MaxHeight = Double.PositiveInfinity;
                }
            }

            if (this.AssociatedObject.ActualWidth &lt; minWidth)
            {
                this.AssociatedObject.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto;
                if (null != content)
                {
                    content.MaxWidth = minWidth - (content.Margin.Left + content.Margin.Right);
                }
            }
            else
            {
                this.AssociatedObject.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                if (null != content)
                {
                    content.MaxWidth = Double.PositiveInfinity;
                }
            }

            this.AssociatedObject.SizeChanged += this.ParentSizeChanged;
        }
    }

An here's how to use it in a XAML file (assuming the above class was defined in a namespace known as "custom" within the XML namespace):
Somewhere at the top: xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Then:

    &lt;ScrollViewer Style="{StaticResource AppHost_ScrollViewer}"&gt;
        &lt;Interactivity:Interaction.Behaviors&gt;
            &lt;custom:ScrollViewerMaxSizeBehavior MinContentWidth="600"
                                                MinContentHeight="500"/&gt;
        &lt;/Interactivity:Interaction.Behaviors&gt;

        &lt;!-- content --&gt;

    &lt;/ScrollViewer&gt;</pre>
<h3>Almost, but not quite</h3>
<p>Continuing the 100-pixel example &#8211; what happens if we have some <em>statically sized</em> content (no infinite sizes) that requires more than what we defined as a minimum? For example, what if instead of a dynamically-sizable grid we have content that requires 200 pixels, and the window size is 100 pixels? In this case, the previous solution is bad: it will not allow scrolling to see the full 200 pixels. So our dual-behavior needs to know, somehow, if the content within it can expand at all an infinite size (and therefore requires the dual behavior defined above to prevent explosion to infinite size). Because if the content has a <em>finite</em> size, we simply want the ScrollViewer to behave as usual and allow scrolling to see that maximum size.</p>
<h3>Conclusion &#8211; what&#8217;s missing in WPF (and possibly other UI frameworks)</h3>
<p>What I&#8217;d expect is that there would be some property on UI controls specifying whether or not this element can expand infinitely (in height, width, or both). If any node in the UI&#8217;s element containment tree has this &#8220;infinite size&#8221; property set, then the ScrollViewer that contains this tree must act using the dual behavior and must have a minimum size defined (smaller size means we allow scrolling and set the content exactly to the minimum size; bigger-than-minimum size means we don&#8217;t allow scrolling and give the content whatever space we have and no more). If the &#8220;infinite size&#8221; property, propagated to the ScrollViewer from the contained tree is <em>not</em> set, the ScrollViewer acts like a regular ScrollViewer &#8211; allowing the content to grow to whatever size it needs, and showing scroll bars if needed.</p>
<p>For now, since there is no such feature in WPF, I&#8217;ll be using the aforementioned ScrollViewer behavior with appropriately defined minimum sizes for those screens that need them &#8211; hard coded, ugly, but works.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=92&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2012/01/23/when-to-scroll-the-problem-of-infinite-sized-ui-elements-inside-a-scrollviewer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>I, Robot</title>
		<link>http://noamlewis.wordpress.com/2011/06/23/i-robot/</link>
		<comments>http://noamlewis.wordpress.com/2011/06/23/i-robot/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 06:56:54 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[FRP]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=72</guid>
		<description><![CDATA[So what? I&#8217;ve graduated (actually almost a year ago). You can see the presentation I gave for my project: Here is the robot from my project: And here is a draft of the poster I made (click for larger version): A picture from the projects conference:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=72&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So what? I&#8217;ve graduated (actually almost a year ago).</p>
<p>You can see the presentation I gave for my project:<br />
<iframe src="https://docs.google.com/present/embed?id=dgc77gfh_27g5tb89z5" frameborder="0" width="410" height="342"  marginheight="0" marginwidth="0"></iframe></p>
<p>Here is the <a title="Haskell-controlled Segway robot" href="http://noamlewis.wordpress.com/2010/06/03/haskell-controlled-segway-robot/">robot from my project</a>:</p>
<p><a href="http://noamlewis.files.wordpress.com/2010/06/robot_small.jpg"><img class="aligncenter size-medium wp-image-73" title="Haskell-controlled Segway RMP" src="http://noamlewis.files.wordpress.com/2010/06/robot_small.jpg?w=224&#038;h=300" alt="Haskell-controlled Segway RMP" width="224" height="300" /></a></p>
<p>And here is a draft of the poster I made (click for larger version):</p>
<p><a href="http://noamlewis.files.wordpress.com/2011/06/poster-2-small-final1.jpg"><img class="aligncenter size-medium wp-image-84" title="Poster for my project" src="http://noamlewis.files.wordpress.com/2011/06/poster-2-small-final1.jpg?w=292&#038;h=389" alt="" width="292" height="389" /></a></p>
<p>A picture from the projects conference:</p>
<p><img class="aligncenter" title="Robot + Poster in conference" src="http://projects.ee.bgu.ac.il/Data/Conference/2010/24052010758.jpg" alt="Robot + Poster in conference" width="474" height="594" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/72/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/72/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/72/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=72&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2011/06/23/i-robot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>

		<media:content url="http://noamlewis.files.wordpress.com/2010/06/robot_small.jpg?w=224" medium="image">
			<media:title type="html">Haskell-controlled Segway RMP</media:title>
		</media:content>

		<media:content url="http://noamlewis.files.wordpress.com/2011/06/poster-2-small-final1.jpg?w=225" medium="image">
			<media:title type="html">Poster for my project</media:title>
		</media:content>

		<media:content url="http://projects.ee.bgu.ac.il/Data/Conference/2010/24052010758.jpg" medium="image">
			<media:title type="html">Robot + Poster in conference</media:title>
		</media:content>
	</item>
		<item>
		<title>How to run any windows program from cygwin, still using cygwin-style path</title>
		<link>http://noamlewis.wordpress.com/2011/03/22/how-to-run-any-windows-program-from-cygwin-still-using-cygwin-style-path/</link>
		<comments>http://noamlewis.wordpress.com/2011/03/22/how-to-run-any-windows-program-from-cygwin-still-using-cygwin-style-path/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 15:36:18 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=79</guid>
		<description><![CDATA[In my previous post I posted a script useful for running kdiff3 for windows correctly from within cygwin. Here&#8217;s a more general version that can be used for any windows program. Save the following as ~/cygwinify.sh (or whatever you like): #!/usr/bin/bash RESULT="" for arg do if [[ "" != "$arg" ]] &#38;&#38; [[ -e $arg [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=79&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous post I posted a script useful for running kdiff3 for windows correctly from within cygwin. Here&#8217;s a more general version that can be used for any windows program. Save the following as <strong> ~/cygwinify.sh</strong> (or whatever you like):</p>
<p><code><br />
#!/usr/bin/bash<br />
RESULT=""<br />
for arg<br />
do<br />
    if [[ "" != "$arg" ]] &amp;&amp; [[ -e $arg ]];<br />
        then<br />
            OUT=`cygpath -wa $arg`<br />
        else<br />
            if [[ $arg == -* ]];<br />
            then<br />
                OUT=$arg<br />
            else<br />
                OUT="'$arg'"<br />
            fi<br />
    fi<br />
    RESULT=$RESULT$OUT" "<br />
done<br />
echo "$RESULT"<br />
</code></p>
<p>The script tries to find any file or directory names in your command line arguments, and converts them to absolute, windows-style path names using <strong>cygpath -wa</strong>. You can then run something like:</p>
<p><code>explorer `~/cygwinify.sh /tmp`</code></p>
<p>And it will open Windows Explorer in the correct folder.</p>
<p>Also, the script to run kdiff3 becomes (just replace the path to the executable with your own):</p>
<p><code><br />
#!/usr/bin/bash<br />
"/cygdrive/d/Program Files (x86)/KDiff3/kdiff3.exe" `~/cygwinify.sh "$@"`<br />
</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/79/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/79/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/79/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=79&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2011/03/22/how-to-run-any-windows-program-from-cygwin-still-using-cygwin-style-path/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>How to use kdiff3 as a difftool / mergetool with cygwin git</title>
		<link>http://noamlewis.wordpress.com/2011/03/22/how-to-use-kdiff3-as-a-difftool-mergetool-with-cygwin-git/</link>
		<comments>http://noamlewis.wordpress.com/2011/03/22/how-to-use-kdiff3-as-a-difftool-mergetool-with-cygwin-git/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 15:10:32 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=75</guid>
		<description><![CDATA[First, install kdiff3 for windows. Second, create the following script somewhere (such as ~/kdiff3.sh, and change the location of your kdiff3.exe to an appropriate cygwin-style path to where you executable really is). The script is based on Pete Goodliffe&#8217;s one he used for svn. I&#8217;ve expanded on the idea to make it more flexible. See [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=75&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First, install kdiff3 for windows.</p>
<p>Second, create the following script somewhere (such as ~/kdiff3.sh, and change the location of your kdiff3.exe to an appropriate cygwin-style path to where you executable really is). The script is based on <a href="http://goodliffe.blogspot.com/2009/04/subversion-kdiff3-and-cygwin.html?showComment=1300806241031">Pete Goodliffe&#8217;s one he used for svn</a>. I&#8217;ve expanded on the idea to make it more flexible. <strong>See my <a href="http://noamlewis.wordpress.com/2011/03/22/how-to-run-any-windows-program-from-cygwin-still-using-cygwin-style-path/">next post</a> for a more general version that can be used for any windows program</strong></p>
<p><code>#!/bin/sh<br />
RESULT=""<br />
for arg<br />
do<br />
    if [[ "" != "$arg" ]] &amp;&amp; [[ -e $arg ]];<br />
        then<br />
            OUT=`cygpath -wa $arg`<br />
        else<br />
            OUT=$arg<br />
            if [[ $arg == -* ]];<br />
            then<br />
                OUT=$arg<br />
            else<br />
                OUT="'$arg'"<br />
            fi<br />
    fi<br />
    RESULT=$RESULT" "$OUT<br />
done<br />
/cygdrive/d/Program\ Files\ \(x86\)/KDiff3/kdiff3.exe $RESULT<br />
</code></p>
<p>Finally, configure your ~/.gitconfig to:<br />
<code><br />
[diff]<br />
        tool = kdiff3<br />
[merge]<br />
        tool = kdiff3<br />
[mergetool "kdiff3"]<br />
        path = ~/kdiff3.sh<br />
        keepBackup = false<br />
        trustExitCode = false<br />
</code></p>
<p>No thanks to wordpress for ruining the whitespace formatting&#8230; <img src='http://s0.wp.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>Try running <strong>git difftool</strong> (make sure you have some modified files) to make sure it works.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=75&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2011/03/22/how-to-use-kdiff3-as-a-difftool-mergetool-with-cygwin-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>Axioms for FRP: Discussing insensitivity</title>
		<link>http://noamlewis.wordpress.com/2010/06/13/axioms-for-frp-discussing-insensitivity/</link>
		<comments>http://noamlewis.wordpress.com/2010/06/13/axioms-for-frp-discussing-insensitivity/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 01:33:31 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[FRP]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=39</guid>
		<description><![CDATA[Last post I proposed a set of (five) properties that every system should have. In following posts I&#8217;ll try to refine these properties and perhaps change, add or discard some of them. The comments I got really made me think, so thanks for commenting (keep it up!). Insensitivity The first property I defined, was given [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=39&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a title="Axiomatic basis for FRP" href="http://noamlewis.wordpress.com/2010/06/10/axiomatic-basis-for-frp/">Last post</a> I proposed a set of (five) properties that every system should have. In following posts I&#8217;ll try to refine these properties and perhaps change, add or discard some of them. The comments I got really made me think, so thanks for commenting (keep it up!).</p>
<h2>Insensitivity</h2>
<p>The first property I defined, was given the made-up name of &#8220;insensitivity&#8221;:</p>
<blockquote><p>If two inputs are almost the same&#8230; the output will be<em> (almost?) </em>the same.</p></blockquote>
<p>Here are a few points about it. To make things clearer, let&#8217;s define &#8220;almost everywhere&#8221; as &#8220;everywhere except a set of measure zero&#8221;.</p>
<p>The reason for not using only continuity conditions on systems was to avoid the various pitfalls encountered by mathematicians as they developed integration and analysis. I&#8217;m no mathematician (not even an undergraduate one) but I do know that <a href="http://en.wikipedia.org/wiki/Lebesgue_integration">Lebesgue integration</a> is considered the best (even final) solution to those various problems, and I&#8217;m trying to base my systems on this result. A good example is that of the characteristic function of the rationals (also known as <a href="http://mathworld.wolfram.com/DirichletFunction.html">Dirichlet&#8217;s function</a>) which equals 1 for rationals and 0 for all other reals. Traditional integration is undefined on such functions &#8211; which means that integrals are not total functions. With Lebesgue integration, the issue is solved.</p>
<p>On the other hand, we <em>do</em> want our systems to &#8220;behave nicely&#8221; and not wildly change their outputs with every small change of input. I&#8217;m not talking about changes of the input signal in time &#8211; rather, I mean that if we replace the entire input signal with one that is very similar, the output should be similar. I&#8217;m still not sure how to cure this problem completely, but the way I defined &#8220;insensitivity&#8221; ensures that at least for inputs that differ at a <em>very</em> small (&#8220;almost nowhere&#8221;) subset of time, the output will be the same. I&#8217;m not sure, but we may still want to require systems to be continuous (changes in input that are <em>more</em> than &#8220;almost nowhere&#8221; cause small changes in the output).</p>
<p>This last point brings up the following question, raised by both Derek Elkins and Luke in the comments on that last post. Citing Derek:</p>
<blockquote><p>&#8230;without the “almost” on the output you would disallow the identity “system” which I highly doubt you want to do.</p></blockquote>
<p>The identity system is a good way to bring out the meaning of insensitivity. I do think that the guiding principle should be that &#8220;almost identical&#8221; <em>signals</em> are considered identical, and in the same spirit &#8220;almost identical&#8221; <em>systems </em>are also identical. Thus if two systems are the identity system almost everywhere, except for a zero-measure set of different values between the systems, they are still considered the same system. My opinion is that it&#8217;s better to not require the existence of a single identity system. Alternatively, we define that every two systems that produce the same output almost everywhere for all inputs, are &#8220;equal&#8221;.</p>
<p>Note I&#8217;ve added the &#8220;(almost?)&#8221; on the insensitivity requirement on the output (see above). I think I still want to keep that &#8220;almost&#8221; on the output. The reasoning is twofold. First, for consistency we should make no distinction between output signals that are the same almost everywhere. Secondly, I don&#8217;t want to <em>force</em> systems to give exactly the same output when inputs are not exactly the same (not just &#8220;almost everywhere&#8221;).  I&#8217;m not entirely certain about this, though.</p>
<p>In any case I don&#8217;t want the &#8220;almost&#8221; on the output be used as way to process events. Since we consider &#8220;almost identical&#8221; systems to be equal, such usage is pointless anyway. So what do we do with events?</p>
<h3>Is this an implementation thing?</h3>
<p>No, I&#8217;m not requiring insensitivity because the implementation may cause &#8220;glitches&#8221; in the output (if I understand correctly that was one of Derek&#8217;s questions). In fact I&#8217;m not considering implementation at all at this point. I&#8217;m trying to come up with the basic properties that we would require of systems in an ideal setting.</p>
<h3>Wait! What about events?</h3>
<p>Almost all the comments raised this point. Truth is I sort of ignored events when I wrote that post, but I did originally have them in mind (and then forgot about them completely). Since we ignore differences that occur on zero-measured subsets of the input, there is indeed no way to &#8220;detect&#8221; or differentiate between inputs that contain single-point values. So how do we handle events, or values that occur at single points in time?</p>
<p>Recall that we defined the time domain as an arbitrary ordered, measurable set. Here is where the generality of that definition comes in. If we ignore the idea of signals combining events and continuous values, I think we can solve this. We can try to handle events by defining an appropriate time domain, and allowing systems&#8217; outputs and inputs have a different time domain (unlike the definition I gave in the previous post).</p>
<h4>An attempt at defining event signals</h4>
<p>The following is an attempted definition for event signals. Note that this attempt does not allow simultaneous events (which can be worked around by having compound types for the event values) or combined discrete/continuous time signals. Perhaps these two issues demand direct resolution, but to make progress in the current direction I&#8217;m ignoring them.</p>
<p>Let T (the time domain) be a countable set of positively increasing reals signifying event times. It is easy to define an ordering between disjoint interval-type subsets, based on the natural ordering of the reals. For a measure, we can count the number of elements in a subset (the <a href="http://en.wikipedia.org/wiki/Counting_measure">counting measure</a>). A single event (a subset containing one time element) would have measure 1, two events &#8211; measure 2, etc.</p>
<p>Thus, an event signal is a function T -&gt; A that maps every element of the time set to an event value. Notice how the T here is necessarily different for each event signal (the times contained in the set are different). I&#8217;m not sure it&#8217;s bad &#8211; we can still define comparisons between event signals. The insensitivity condition in this case, is still valid: T is measurable and every non-empty subset in T has non-zero measure, so no events get &#8220;missed&#8221; by the insensitivity.</p>
<p>So to summarize, we can handle events by considering a different time domain (a discrete one, essentially) and use an appropriate measure on that domain. It makes sense to allow systems to have outputs with different time-types than the input &#8211; for example a &#8220;sampling system&#8221; takes real time in the input, and outputs in a discrete time. Remember, I&#8217;m not talking about how to implement or represent this in Haskell (or otherwise) &#8211; I&#8217;m just trying to define the desired model in an ideal setting.</p>
<h4>Delta functions</h4>
<p>Some (including myself) have suggested to use something akin to <a href="http://en.wikipedia.org/wiki/Dirac%27s_delta_function">Dirac&#8217;s  delta function</a> (which isn&#8217;t a function, but a measure or a distribution) to represent events on real, continuous time. Adequate discussion is too long for this post. My guess is that since these &#8220;mathematical constructs&#8221; are not functions of time at all, and since they are originally used as measures, we will more or less need to re-invent them for our wider context.</p>
<p>One way to define the delta is given here. The <em>δ</em> function is an operator that takes a &#8220;test function&#8221; <em>f</em> of time, and then for any given time interval (or more generally, a subset of time) has one of two values. So &lt;δ,f&gt; on U where U is a subset of R, is:</p>
<ul>
<li>If U contains the origin (0 is zero in this font), the value is <em>f(0)</em>.</li>
<li>Otherwise, the value is 0.</li>
</ul>
<p>The delta can be shifted to obtain the same on points other than the origin. Essentially, the delta function tells us whether the given subset of time contains a particular point, and then evaluates to either a default value (0) or the value of the given function at that point. The sum of two non-overlapping deltas is one which yields the value of the test function at <em>two</em> points, etc.</p>
<p><strong>EDIT: The following definition is flawed. I correct it in the first  comment.</strong></p>
<p>An equivalent construct in our context is an operator that takes a subset of time and maps it to an event value (&#8220;Just x&#8221;) if the event has occurred within that subset. Otherwise, it maps it onto &#8220;Nothing&#8221;. We can then define &#8220;sums&#8221; (or more appropriately, <em>mappend</em>) of two of these operators: map to each of the preceding values if each event has occurred in the given time subset, just like the sum of two deltas. For completeness we must also deal with combination of simultaneous events, and maybe also with the question of how to define a system that can work with both these and plain functions of time.</p>
<p>If we follow this plan, it&#8217;s easy to see that using sums of deltas (&#8220;<a href="http://en.wikipedia.org/wiki/Dirac_comb">impulse train</a>&#8220;) to define event streams resembles the definition of events as functions from real time to <em>Maybe a</em>. This possibility has been suggested previously and I&#8217;m sure it&#8217;s been discussed by FRP proponents &#8211; I&#8217;d like to know what conclusions or arguments were raised in this regard (<strong>enlighten me if you know</strong>).</p>
<p>However, the delta approach is not exactly the same as functions from time to <em>Maybe.</em> They are operators that take test functions and produce these <em>Maybe </em>total functions. The type can be written as (this is not really Haskell notation):</p>
<p><code>delta : (T -&gt; A) -&gt; T -&gt; (U -&gt; Maybe A)<br />
</code></p>
<p>Where U is the set of subsets of T, the first argument is the test function, the second argument is the time shift of the delta &#8211; the location of the event value, and the result is a function that yields <em>Nothing</em> everywhere except for subsets of time that happen to contain the shift value.</p>
<p>An event stream using this definition of delta would be a function from <em>subsets of time</em> (not from time values) to <em>Maybe a</em>. To incorporate these events in our model we&#8217;ll need can try different approaches. One way is to change the definition of a system to take inputs of this type (subsets of time → <em>Maybe a</em>), and to output a similar type. The only way I see to define the regular continuous time signals in this model is:</p>
<p><code>f : U -&gt; Maybe (T -&gt; A)</code></p>
<p>Where again U is the set of subsets of time. That is, for every <em>subset of</em> time, the function yields a<em> function of</em> time that gives the value of the signal at each point in the subset.</p>
<p>There is surely more to explore in the delta direction, but for now that&#8217;s all I can think of.</p>
<h1>Conclusions</h1>
<p>The idea of a measurable time domain apparently makes it possible to define both continuous and discrete timed signals and systems at once. In addition we explored the alternative route of using delta functions. The first approach (based on measurable time) for events seems simpler and more straightforward than the delta function approach. Maybe there&#8217;s a simpler formulation that uses the delta approach and incorporates also regular signals in one general definition.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=39&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2010/06/13/axioms-for-frp-discussing-insensitivity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>Axiomatic basis for FRP</title>
		<link>http://noamlewis.wordpress.com/2010/06/10/axiomatic-basis-for-frp/</link>
		<comments>http://noamlewis.wordpress.com/2010/06/10/axiomatic-basis-for-frp/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 22:39:20 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[FRP]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=23</guid>
		<description><![CDATA[Our systems should satisfy certain requirements. First question is: what are the requirements? Then, we need to find building blocks that allow us to express only these systems.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=23&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1>What&#8217;s this about?</h1>
<p>I&#8217;ve been thinking about ways to lay firm, logical foundations for a model of FRP. Rather than trying to cook up the &#8220;next best thing&#8221;, we should perhaps review what we really want and try to infer what we need. Unfortunately I&#8217;ve very little time to think about this and I&#8217;ve hardly discussed this. Hopefully this blog post will give my effort another small push.</p>
<h1>Goal</h1>
<p>The idea is to define a set of building blocks that allow one to express  only systems that satisfy a few basic properties. Specifically we want  systems that <em>don&#8217;t</em> satisfy these properties, to be inexpressible within our model. It makes sense to start by defining the properties we want to satisfy, and then to try and deduce the most general model that satisfies them and only them.</p>
<p>The basic concept is that of a &#8220;system&#8221;, which we define as a function:</p>
<p style="padding-left:30px;"><code>f :: (T -&gt; A) -&gt; (T -&gt; B)</code></p>
<p>Where <em>T</em> is an ordered, measurable set, usually denoting time. This is what Conal Elliott called an &#8220;<a title="interactive behavior" href="http://conal.net/blog/posts/why-classic-FRP-does-not-fit-interactive-behavior/" target="_blank">interactive behavior</a>&#8220;, and what is known in Yampa as a &#8220;signal function&#8221;. I use the term &#8220;system&#8221; because that&#8217;s how this is called in engineering, and I see no reason to invent new names.</p>
<h1>Desired properties of systems</h1>
<p><strong>Edit: the properties as defined below are not <em>exactly</em> what we want. See comments for discussion.</strong></p>
<p>So, here are the requirements I&#8217;d like to propose. Every expressible system must satisfy the following:</p>
<ol>
<li><strong>Insensitivity:</strong> If two inputs are almost the same (differ at most at a set of measure zero), the output will be<em><span style="color:#000000;"> (almost?) </span></em>the same.</li>
<li><strong>Causality</strong>: For all t in T, output(t) can only depend on input(t-s) where <em>s ≥ 0</em>. Meaning, for every two inputs x1, x2 that have the same past, the output for the present is the same. And to be more precise, for every <em>t</em>, if <em>x1(t-s) = x2(t-s)</em> for almost all <em>s ≥ 0</em>, the output at <em>t</em> will be the same.</li>
<li><strong>Markovity:</strong> Same as (2), but with the condition that <em>|s| &lt; ∞</em>. In words,  the output does not depend on inputs from the infinitely remote past or  future.<em><br />
</em></li>
<li><strong>Finite memory:</strong> given the current input (a single value), the current output depends additionally at most on a finite-length binary string (that may have been computed from past inputs).</li>
<li><strong>Time invariance </strong>(<em>optional</em>):<strong> </strong>If <em>x(t)</em> produces output<em> y(t)</em>, then <em>x(t &#8211; s)</em> produces output <em>y(t &#8211; s)</em>.</li>
</ol>
<h2>Discussion</h2>
<p>The first property means that the system is not overly sensitive. Integration is one example of a system that satisfies this property: changing the value of a function at finite number of points does not affect the value of its integral. I don&#8217;t know how to call this &#8211; if anyone knows a name for this property, please tell me. For now I&#8217;ll call it <em>insensitivity</em>.</p>
<p>The second property is<em> causality.</em> It stems from the physical intuition that we can&#8217;t know the future, and every value that we  (or our systems, or any other natural thing) compute at the present, should depend only on inputs from the past (or at most, the present). Otherwise, we&#8217;d have to wait until the future &#8220;arrives&#8221; to complete the computation.</p>
<p>Causality is one of the properties that are easily violated if we consider a model that allows us to arbitrarily sample our input, one that allows us to actually treat the input as a function of time. Mathematically, a function is just a mapping and has no rules regarding which part of the domain can be evaluated and when. So, the first realization from our requirements is that we can&#8217;t  have signals (inputs, outputs, etc.) as directly accessible values in our model, or that they shouldn&#8217;t be modeled as functions. Yampa (or in it&#8217;s other name, AFRP) imposes the no-access rule and doesn&#8217;t have signals as values that can be passed around. Instead, they are indirectly manipulated by constructing systems that transform them &#8211; a sort of &#8220;wiring up&#8221;. There&#8217;s a big debate on the pros and cons of an Arrow-based FRP, but I&#8217;ve yet to understand the full consequences.</p>
<p>As for a non-functional description of signals, I haven&#8217;t though about it enough to know if there&#8217;s any obviously useful alternative that solves the causality problem. So in my case, I choose to go the Yampa way &#8211; I won&#8217;t provide any means to access signals directly.</p>
<p>Besides causality, we also want to make sure the system does not depend on the infinitely remote past. Physical intuition says that we&#8217;ll never be able to know what happened that far back. This is the defining property of Markov processes (of any order), so I&#8217;ll call this <em>Markovity</em>. Note that the requirement is defined as going both ways, but our previous demand for causality means that it only has meaning regarding past inputs. Perhaps the more general formulation (that includes both past and future) is redundant, but to me it seems nicer to have it symmetric even though only one direction (past) matters in our case.</p>
<p>The fourth property is <em>finite memory</em>, which is physically intuitive. Especially in the context of computers, we don&#8217;t want our systems to endlessly accumulate information until we run out of memory. Mathematically, this requirement needs elaboration to be made precise. The formulation I&#8217;ve given above (depending on a finite-length binary string) is simple and describes what I want, but it will require extra work to figure out what implications it has on our systems.</p>
<p>Finally, <em>time invariance</em> can be interpreted as not being able to tell the absolute &#8220;wall clock&#8221; time. Physically this is true: we don&#8217;t know about any absolute time. Although in reality engineered systems do in fact evolve over time (wear and tear, for one) it is not some intrinsic property of the system that causes this change &#8211; rather it is that the entire observable universe serves as inputs to our systems, which can never be fully isolated. Thus the only thing that should matter for our system&#8217;s output is how the input evolves over time, not the exact position in global time of the input. We forbid sensitivity to input time shifts. I noted this requirement as optional because I&#8217;m not sure we really want it as a limitation. I do have a gut feeling that we don&#8217;t miss out any desirable systems by adding this limitation &#8211; please correct me if you have any ideas against this.</p>
<h1>What&#8217;s next?</h1>
<p>In this blog post I&#8217;ve identified the five basic properties that we desire in a system. The next step should be to define a set of operations that can serve as universal building blocks for any system that satisfies the requirements. Perhaps more importantly, our building blocks should <em>prevent </em>us from accidentally expressing systems that violate the requirements. I&#8217;ll even say that it&#8217;s ok if a few valid systems are inexpressible (our &#8220;systems filter&#8221; has false positives) as long as no violating system is expressible (no false negatives).</p>
<p>I&#8217;m waiting for your comments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=23&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2010/06/10/axiomatic-basis-for-frp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>Haskell-controlled Segway robot</title>
		<link>http://noamlewis.wordpress.com/2010/06/03/haskell-controlled-segway-robot/</link>
		<comments>http://noamlewis.wordpress.com/2010/06/03/haskell-controlled-segway-robot/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 06:29:07 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[FRP]]></category>
		<category><![CDATA[robot]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=19</guid>
		<description><![CDATA[As part of my final project for an undergraduate degree in electrical engineering, I&#8217;ve demonstrated how FRP can be used to control a robot. At first I meant to use one of the existing FRP frameworks. I wrote a prototype program (a visual graph editor) using Yampa but I had a few problems with it. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=19&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<span style="text-align:center; display: block;"><a href="http://noamlewis.wordpress.com/2010/06/03/haskell-controlled-segway-robot/"><img src="http://img.youtube.com/vi/2ZblWWxeLsY/2.jpg" alt="" /></a></span>
<p>As part of my final project for an undergraduate degree in electrical engineering, I&#8217;ve demonstrated how FRP can be used to control a robot.</p>
<p>At first I meant to use one of the existing FRP frameworks. I wrote a prototype program (a visual graph editor) using Yampa but I had a few problems with it. First, I was confused by the mess in the library&#8217;s API. There are literally dozens of functions, some with apparently overlapping purposes, and it&#8217;s hard to figure out which ones I should be using and when. Secondly, I was looking for a library that has a semantic model, or at least an approximation of one &#8211; and Yampa only has this for the basic notions of signals and signal functions, but not for many of the &#8220;magic primitives&#8221; that appear in the API, such as &#8220;pre&#8221;. Specifically, the function &#8220;pre&#8221; is problematic because it doesn&#8217;t have any logical meaning in the context of continuous time. It&#8217;s ok to say that it&#8217;s only valid in the context of discrete time, but then the function can have different effects when the system has different sampling rates. </p>
<p>About the Reactive framework, from what I understand it is slightly too buggy to be useful. I hope the bugs will be fixed in Reactive and that Yampa undergoes reorganization so that these most serious attempts at implementing FRP will be more useful.</p>
<p>In any case I decided to implement a small subset of the FRP ideas in my own code (the &#8220;allocated-processor&#8221; package), add bindings for OpenCV and for controlling the Segway RMP, and provide high-level functional primitives for these. The robot in the video is the result of that effort.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=19&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2010/06/03/haskell-controlled-segway-robot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
		<item>
		<title>Point-wise FRP, plus memory &#8211; Part 1</title>
		<link>http://noamlewis.wordpress.com/2010/03/21/point-wise-frp-plus-memory-part-1/</link>
		<comments>http://noamlewis.wordpress.com/2010/03/21/point-wise-frp-plus-memory-part-1/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 00:51:07 +0000</pubDate>
		<dc:creator>sinelaw</dc:creator>
				<category><![CDATA[FRP]]></category>

		<guid isPermaLink="false">http://noamlewis.wordpress.com/?p=5</guid>
		<description><![CDATA[After Conal&#8217;s blog post, I&#8217;ve been thinking about possible models of FRP that satisfy the &#8220;no arbitrary time access&#8221; restriction. Normally, we restrict models of time-dependent systems to causality: we disallow access to future values. The extended restriction here is about not allowing us to sample time-dependent values at any point we choose, even in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=5&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After <a title="Conal's blog post" href="http://conal.net/blog/posts/garbage-collecting-the-semantics-of-frp/">Conal&#8217;s blog post</a>, I&#8217;ve been thinking about possible models of FRP that satisfy the &#8220;no arbitrary time access&#8221; restriction. Normally, we restrict models of time-dependent systems to causality: we disallow access to future values. The extended restriction here is about not allowing us to sample time-dependent values at any point we choose, even in the past.</p>
<p>We can&#8217;t arbitrarily check what a sensor input was at any point in the past. We can only tell what it is <em>right now</em>, in the present. Alternatively, we can store some information about a sensor&#8217;s input as time goes by, and later probe the store information to answer questions about the past. But one thing is clear: we are limited in what we can know about a past event, because our memory doesn&#8217;t perfectly describe reality and it also must be finite. We can call this &#8220;point-wise time access&#8221;, or maybe a better name would be &#8220;real time access&#8221;.</p>
<p>But if we can access only the current time, how is it possible to perform things such as integration, that seem to require knowledge of the value at least at a finite time interval? Obviously the way we do it is by accumulating the sum, not by remembering what the value was at every time instant and later summing those.</p>
<p>As a result of that idea and a few others, I wrote the <a title="Behavioral Amnesia" href="http://www.ee.bgu.ac.il/~noamle/_downloads/gaccum.pdf">short report titled &#8220;Behavioral Amnesia&#8221;</a>. I&#8217;d be glad to hear feedback. It discusses also other various related points.</p>
<p>In short, the only new (to me) idea in there is that we <em>can </em>build a model that is point-wise (disallows arbitrary access in time) but still allows memory. One way to do so is to define a generalized operator that scans over time, I call it <em>scanlT</em>, and it works like this:</p>
<pre>scanlT :: (a -&gt; a -&gt; DTime -&gt; b -&gt; b) -&gt; [(Time,a)] -&gt; [(Time,b)]
scanlT f y xs = scanl f' y xs'
  where f' ((t1,x1),(t2,x2)) = f x1 x2 (t2-t1)
        xs' = zip xs (tail xs)
</pre>
<p>Where the lists of (Time,a) and (Time,b) pairs are the time-dependent input and output values, respectively. The first argument, the function, performs the memory-full calculation. The implementation, and even the type-signature, live in the semantic domain &#8211; they describe what the model is, not how it is to be implemented.</p>
<p>If the time-dependent values are defined as lists, what about continuous time? The report describes a (admittedly naive) way to tackle the problem: the continuous version of <em>scanlT</em> is the limit on <em>scanlT</em> applied to the list of samples of the continuous input, where the limit is on the sampling rate going to infinity. I&#8217;m sure there are alternative, perhaps more general formulations &#8211; but this one suffices for me, at the present. One implication of the sampling representation is that the input must satisfy certain conditions (and if I&#8217;m correct, mainly that they be L2-integrable).</p>
<p>With <em>scanlT </em>defined it&#8217;s possible to work out integration:</p>
<pre>integrate :: Fractional a =&gt; Temporal a -&gt; Temporal a
integrate = scanlT psum 0
   where psum y1 y2 dt s = s + dt*(y1 + y2)/2
</pre>
<p>Where &#8220;Temporal a&#8221; is the yet-to-be-defined type of continuous time-dependent values. Note that there are many different formulations possible, because <em>psum </em>is not really trapezoidal approximation &#8211; remember that <em>scanlT</em> is taken at the limit of <em>dt </em>going to zero. Also note that obviously a real formulation of integrals would be defined for the most general type &#8211; probably vector spaces, measurable spaces or the such (excuse my sketchy math knowledge).</p>
<p>As far as I know, all publicized FRP formulations to date have used integrals as built-in primitives <strong>(correct me if I&#8217;m wrong!). </strong>The idea I&#8217;m trying to push is that there should be nothing magic or special about integration or even general accumulation. What we want is a general way to implement realistic, non-arbitrary-time, memory.</p>
<p>We can also define differentiation. Differentiation is weaker in that it is local, it doesn&#8217;t really need to know much about history to tell you the current value (note the _ in the definition):</p>
<pre>differentiate :: Fractional a =&gt; Temporal a -&gt; Temporal a
differentiate = scanlT pdiff 0
   where pdiff y1 y2 dt _ = (y2-y1) / dt
</pre>
<p>It&#8217;s fun to verify that <em>pdiff</em> and <em>psum</em> are inverses of each other, when you take the limit.</p>
<p>Finally, we can even implement maximum (or minimum). I use the imaginary typeclass &#8220;<em>MinBounded</em>&#8221; that contains the value <em>MinBound</em>:</p>
<pre>maximum :: (Ord a, MinBounded a) =&gt; Temporal a -&gt; Temporal a
maximum = scanlT pmax MinBound
   where pmax _ y2 _ m = max m y2
</pre>
<p>That&#8217;s basically the idea, I&#8217;d love to hear comments. The <a title="Behavioral Amensia" href="http://www.ee.bgu.ac.il/%7Enoamle/_downloads/gaccum.pdf">report</a> I wrote contains more discussion, but is currently slightly outdated only with respect to the function definitions I just gave.</p>
<p>In the next part I&#8217;ll describe one possible model for FRP that uses this as its basis.</p>
<p>Lastly, comments are welcome!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/noamlewis.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/noamlewis.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/noamlewis.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=noamlewis.wordpress.com&amp;blog=12721713&amp;post=5&amp;subd=noamlewis&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://noamlewis.wordpress.com/2010/03/21/point-wise-frp-plus-memory-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e45fac9babb490daae1db58df6d744a8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">sinelaw</media:title>
		</media:content>
	</item>
	</channel>
</rss>
