<?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/"
	>

<channel>
	<title>Elm &#8211; Other Things</title>
	<atom:link href="https://blog.adamzolo.com/category/elm/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.adamzolo.com</link>
	<description>Blog about Things by Adam Zolotarev</description>
	<lastBuildDate>Tue, 19 Apr 2016 22:24:01 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Elm on input event</title>
		<link>https://blog.adamzolo.com/elm-oninput-event/</link>
					<comments>https://blog.adamzolo.com/elm-oninput-event/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Tue, 19 Apr 2016 22:24:01 +0000</pubDate>
				<category><![CDATA[Elm]]></category>
		<guid isPermaLink="false">http://www.eazolo.com/blog/?p=270</guid>

					<description><![CDATA[Update 05/16/2016: And the stuff below becomes completely irrelevant with Elm 0.17. Just use the new Events.onInput. &#8212;&#8212;&#8212;&#8212; &#8212;&#8212;&#8212;&#8212; This could be tricky at first, since Elm doesn&#8217;t provide (yet) a built-in onInput handler. Rather, you have to use something a little more generic like this: on &#8220;input&#8221; targetValue (\v -> Signal.message address v) This&#8230;<p><a class="more-link" href="https://blog.adamzolo.com/elm-oninput-event/" title="Continue reading &#8216;Elm on input event&#8217;">Continue reading <span class="meta-nav">&#8594;</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Update 05/16/2016: And the stuff below becomes completely irrelevant with Elm 0.17. Just use the new Events.onInput.</p>
<p>&#8212;&#8212;&#8212;&#8212;<br />
&#8212;&#8212;&#8212;&#8212;<br />
This could be tricky at first, since Elm doesn&#8217;t provide (yet) a built-in onInput handler. Rather, you have to use something a little more generic like this:<br />
on &#8220;input&#8221; targetValue (\v -> Signal.message address v)</p>
<p>This will send user input to the designated address. Or, say if you want to send it to some action, then you could write something like this:<br />
<code><br />
on "input" targetValue (\v -> Signal.message address (action v))<br />
</code></p>
<p>To deconstruct what&#8217;s going on here, let&#8217;s look at all of the arguments:<br />
&#8220;input&#8221; &#8211; the type of event<br />
targetValue &#8211; A Json.Decoder for grabbing &#8216;event.target.value&#8217; from the triggered event.<br />
(\v -> Signal.message address (action v)) &#8211; function that handles the input value</p>
<p>And if you look at the definition of onClick, it basically is a shortcut for on &#8220;click&#8221;:</p>
<p>messageOn : String -> Signal.Address a -> a -> Attribute<br />
messageOn name addr msg =<br />
  on name value (\_ -> Signal.message addr msg)</p>
<p>onClick : Signal.Address a -> a -> Attribute<br />
onClick =<br />
  messageOn &#8220;click&#8221;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/elm-oninput-event/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Elm Resources</title>
		<link>https://blog.adamzolo.com/elm-resources/</link>
					<comments>https://blog.adamzolo.com/elm-resources/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Sun, 17 Apr 2016 10:32:59 +0000</pubDate>
				<category><![CDATA[Elm]]></category>
		<guid isPermaLink="false">http://www.eazolo.com/blog/?p=262</guid>

					<description><![CDATA[Slack channel Official Elm docs Elm Tutorial with the source code Pragmatic Studio &#8211; they have pretty good courses on Elm ($20 each as of this writing) Elm Meetup if you happen to be in SF Who&#8217;s Hiring Elm Developers? Road to Elm &#8211; Structuring your application with some related source code Exercism.io Free course&#8230;<p><a class="more-link" href="https://blog.adamzolo.com/elm-resources/" title="Continue reading &#8216;Elm Resources&#8217;">Continue reading <span class="meta-nav">&#8594;</span></a></p>]]></description>
										<content:encoded><![CDATA[<p><a href="https://elmlang.slack.com" target="_blank">Slack channel</a><br />
<a href="http://elm-lang.org/docs" target="_blank">Official Elm docs</a><br />
<a href="tp://www.elm-tutorial.org/" target="_blank">Elm Tutorial</a> with the <a href="https://github.com/sporto/elm-tutorial-app/tree/master/src" target="_blank">source code</a><br />
<a href="https://online.pragmaticstudio.com" target="_blank">Pragmatic Studio</a> &#8211; they have pretty good courses on Elm ($20 each as of this writing)<br />
<a href="http://www.meetup.com/Elm-user-group-SF/" target="_blank">Elm Meetup</a> if you happen to be in SF<br />
<a href="https://www.briefs.fm/elm-quick-cast/1" target="_blank">Who&#8217;s Hiring Elm Developers?</a><br />
<a href="http://www.lambdacat.com/road-to-elm-structuring-your-application/" target="_blank">Road to Elm &#8211; Structuring your application </a> with some related <a href="https://github.com/foxdonut/adventures-reactive-web-dev/tree/master/client-elm" target="_blank">source code</a><br />
<a href="http://exercism.io/" target="_blank">Exercism.io</a><br />
<a href="http://courses.knowthen.com/courses/elm-for-beginners" target="_blank">Free course for beginners</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/elm-resources/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Format DateTime in Elm</title>
		<link>https://blog.adamzolo.com/format-datetime-elm/</link>
					<comments>https://blog.adamzolo.com/format-datetime-elm/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Thu, 14 Apr 2016 01:53:54 +0000</pubDate>
				<category><![CDATA[Elm]]></category>
		<guid isPermaLink="false">http://www.eazolo.com/blog/?p=258</guid>

					<description><![CDATA[This took me a bit to figure out. Assuming we&#8217;re using rluiten/elm-date-extra package Get your import: import Date.Config.Config_en_us exposing (config) Get the DateTime string: format config &#8220;%m/%d/%Y&#8221; yourDateTime]]></description>
										<content:encoded><![CDATA[<p>This took me a bit to figure out.</p>
<p>Assuming we&#8217;re using rluiten/elm-date-extra package</p>
<p>Get your import:<br />
import Date.Config.Config_en_us exposing (config)</p>
<p>Get the DateTime string:<br />
format config &#8220;%m/%d/%Y&#8221; yourDateTime</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/format-datetime-elm/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>From .Net Developer to Elm. Part 2 – Making a Simple Project.</title>
		<link>https://blog.adamzolo.com/making-simple-elm-project/</link>
					<comments>https://blog.adamzolo.com/making-simple-elm-project/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Mon, 11 Apr 2016 11:46:33 +0000</pubDate>
				<category><![CDATA[Elm]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://www.eazolo.com/blog/?p=243</guid>

					<description><![CDATA[In this article I&#8217;ll write a simple Bayesian Calculator using Elm. Link to final project &#8211; Bayesian Calculator &#8211; Source Code Create a directory for your project. cd into it. Run &#8220;elm-make&#8221; to initialize a new elm project. Install some packages for working with web: elm-package install &#8220;evancz/elm-html&#8221; elm-package install &#8220;evancz/start-app&#8221; start-app takes care of&#8230;<p><a class="more-link" href="https://blog.adamzolo.com/making-simple-elm-project/" title="Continue reading &#8216;From .Net Developer to Elm. Part 2 – Making a Simple Project.&#8217;">Continue reading <span class="meta-nav">&#8594;</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>In this article I&#8217;ll write a simple Bayesian Calculator using Elm.<br />
Link to final project &#8211; <a href="https://www.eazolo.com/apps/bayesiancalculator/calculator.html" target="_blank">Bayesian Calculator</a> &#8211; <a href="https://github.com/adamzolotarev/elm-bayesian-calculator" target="_blank">Source Code</a></p>
<p>Create a directory for your project.<br />
cd into it.<br />
Run &#8220;elm-make&#8221; to initialize a new elm project.<br />
Install some packages for working with web:</p>
<p>elm-package install &#8220;evancz/elm-html&#8221;<br />
elm-package install &#8220;evancz/start-app&#8221;</p>
<p>start-app takes care of some application wiring,&#8221;<a href="https://github.com/evancz/start-app" target="_blank">setting everything up so you can focus entirely on writing your app</a>&#8221;</p>
<p>If you open elm-package.json, you will see that the packages, which we just installed, were added to &#8220;dependencies&#8221; node.</p>
<p>I&#8217;ll use npm and gulp to manage my build. Also, I&#8217;m using bootstrap (cause css is hard)<br />
npm init<br />
npm install bootstrap &#8211;save-dev<br />
npm install gulp &#8211;save-dev<br />
npm install gulp-elm &#8211;save-dev<br />
npm install gulp-rename &#8211;save-dev</p>
<p>The last piece of setting up is gulp. In the <a href="https://github.com/adamzolotarev/elm-bayesian-calculator/blob/master/gulpfile.js" target="_blank">script</a>, I just combine all css and js into bundles and copy them to dest folder.</p>
<p>We&#8217;re ready to start writing our app.</p>
<p>Create <a href="https://github.com/adamzolotarev/elm-bayesian-calculator/blob/master/src/Calculator.elm" target="_blank">Calculator.elm</a>. This is where our code will go.</p>
<p>Create <a href="https://github.com/adamzolotarev/elm-bayesian-calculator/blob/master/src/Calculator.html" target="_blank">Calculator.html</a>. This will encapsulate resulting JavaScript file from Elm. Since I&#8217;m writing a full-screen application, all we have to do is add this to the script block:</p>
<p>var app = Elm.fullscreen(Elm.Calculator);</p>
<p>Now, to the application code.</p>
<p>Our model is quite simple &#8211; consists of four string fields related to four input fields on the form.<br />
We have three inputs on the page &#8211; all encapsulated inside entryForm:</p>
<pre class="brush: plain; title: ; notranslate">
entryForm : Address Action -&gt; Model -&gt; Html
entryForm address model =
  div
    &#x5B; class &quot;form-horizontal&quot; ]
    &#x5B; formGroupItem (priorProbabilityItem address model)
    , formGroupItem (hitRateItem address model)
    , formGroupItem (falseAlarmItem address model)
    , formGroupItem (resultItem address model)
    ]
</pre>
<p>formGroupItem is simply a method to produce another div with a class of &#8220;form-group&#8221;:</p>
<pre class="brush: plain; title: ; notranslate">
formGroupItem : List Html -&gt; Html
formGroupItem body =
  div
    &#x5B; class &quot;form-group&quot; ]
    body
</pre>
<p>body in here is just a list of Html elements that we are passing to our div.</p>
<p>Let&#8217;s look at one of the inputs: </p>
<pre class="brush: plain; title: ; notranslate">
priorProbabilityItem : Address Action -&gt; Model -&gt; List Html
priorProbabilityItem address model =
  &#x5B; label
      &#x5B; for &quot;priorProbability&quot;, class &quot;col-md-3 control-label&quot; ]
      &#x5B; text &quot;Prior Probability&quot; ]
  , div
      &#x5B; class &quot;col-md-9&quot; ]
      &#x5B; input
          &#x5B; type' &quot;text&quot;
          , placeholder &quot;0.00&quot;
          , value model.priorProbability
          , id &quot;priorProbability&quot;
          , autofocus True
          , Utils.onInput address UpdateInitialProbability
          ]
          &#x5B;]
      ]
  ]
</pre>
<p>We have a label and a div with an input which maps to priorProbability field in our model.<br />
Every time a user enters something we react to it by addressing UpdateInitialProbability action:</p>
<pre class="brush: plain; title: ; notranslate">
update : Action -&gt; Model -&gt; Model
update action model =
  case action of
...
    UpdateInitialProbability probability -&gt;
      { model | priorProbability = probability }
...
</pre>
<p>In the code above we are updating our model with the new value that a user entered for priorProbability.<br />
We have the same logic for all of the other input fields.</p>
<p>Every time a model changes, we try to show the Bayes calculation result:</p>
<pre class="brush: plain; title: ; notranslate">
resultItem : Address Action -&gt; Model -&gt; List Html
resultItem address model =
  &#x5B; label
      &#x5B; for &quot;bayesResult&quot;, class &quot;col-md-3 control-label&quot; ]
      &#x5B; text &quot;New Probability&quot; ]
  , div
      &#x5B; class &quot;col-md-9&quot; ]
      &#x5B; span &#x5B;] &#x5B; text (bayesResult model) ]
      ]
  ]
</pre>
<p>bayesResult is responsible for generating new probability. If some input is invalid, we just don&#8217;t display anything. Sure, validation could be a little more sophisticated, but we&#8217;re just trying it out.</p>
<p>While in development, make sure to run elm-reactor and gulp in the command line &#8211; open two tabs or windows (depending on your console app) for each one and just run &#8220;elm-reactor&#8221; in one, and &#8220;gulp&#8221; in another. </p>
<p>In order to see your app in a browser, go to http://localhost:8000/dest/Calculator.html<br />
Every time you save your elm file, it should update the js files in the dest folder. You still have to refresh the browser to see the changes. I haven&#8217;t quite figured the auto-refresh part with gulp and elm.</p>
<p>If you want to see the build errors, they should show up in the console, which runs gulp command. Alternatively, if you use Sublime, press Ctrl + B to build it and all errors should show up directly in Sublime.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/making-simple-elm-project/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>From .Net Developer to Elm. Part 1 &#8211; Elm with Sublime.</title>
		<link>https://blog.adamzolo.com/elm-sublime/</link>
					<comments>https://blog.adamzolo.com/elm-sublime/#respond</comments>
		
		<dc:creator><![CDATA[Adam Zolo]]></dc:creator>
		<pubDate>Sat, 09 Apr 2016 10:06:59 +0000</pubDate>
				<category><![CDATA[Elm]]></category>
		<guid isPermaLink="false">http://www.eazolo.com/blog/?p=233</guid>

					<description><![CDATA[Elm is a an amazing way to build web applications that guarantees no runtime exceptions and blazingly fast rendering. This is a path -one of many possible- to start Elm development. Step One &#8211; Get the Right Tools. Sublime is my editor of choice. Amazingly fast and extensible. First, a few general tweaks Enable Go&#8230;<p><a class="more-link" href="https://blog.adamzolo.com/elm-sublime/" title="Continue reading &#8216;From .Net Developer to Elm. Part 1 &#8211; Elm with Sublime.&#8217;">Continue reading <span class="meta-nav">&#8594;</span></a></p>]]></description>
										<content:encoded><![CDATA[<p>Elm is a an amazing way to build web applications that guarantees no runtime exceptions and blazingly fast rendering.<br />
This is a path -one of many possible- to start Elm development.</p>
<p><strong>Step One &#8211; Get the Right Tools. </strong><br />
Sublime is my editor of choice. Amazingly fast and extensible.</p>
<p>First, a few general tweaks</p>
<ul>
<li>
Enable Go to Definition on Ctrl + Mouse<br />
Create a new file &#8211; &#8220;Default (Windows).sublime-mousemap&#8221; &#8211; in %appdata%\Sublime Text 3\Packages\User<br />
With the following content:<br />
[<br />
    {<br />
        &#8220;button&#8221;: &#8220;button1&#8221;,<br />
        &#8220;count&#8221;: 1,<br />
        &#8220;modifiers&#8221;: [&#8220;ctrl&#8221;],<br />
        &#8220;press_command&#8221;: &#8220;drag_select&#8221;,<br />
        &#8220;command&#8221;: &#8220;goto_definition&#8221;<br />
    }<br />
]<br />
More details on Linux and Mac <a href="https://stackoverflow.com/questions/16235706/sublime-3-set-key-map-for-function-goto-definition" target="_blank">here</a>
</li>
<li>
Add a shortcut for locating a file in the file tree sidebar.<br />
Go to Preferences -> Key Bindings-User and add:<br />
{ &#8220;keys&#8221;: [&#8220;alt+shift+l&#8221;], &#8220;command&#8221;: &#8220;reveal_in_side_bar&#8221; }
</li>
<li>
Pick a different theme, if you&#8217;d like &#8211; <a href="https://github.com/buymeasoda/soda-theme/" target="_blank">soda-theme</a>.
</li>
<li>
Install Sublime Package Control to enable easy package installation &#8211; <a href="https://packagecontrol.io/" target="_blank">Package Control</a>
</li>
</ul>
<p>Now, some Elm-specific changes.</p>
<ul>
<li>
Install <a href="https://github.com/deadfoxygrandpa/Elm.tmLanguage" target="_blank">Elm Language Package</a>
</li>
<li>
Install <a href="https://www.npmjs.com/package/elm-oracle" target="_blank"> elm-oracle</a> to enable autocompletions.
</li>
<li>
Install Highlight Build Errors from Sublime Package Control
</li>
<li>
Install <a href="https://github.com/avh4/elm-format" target="_blank">elm-format</a> to enable auto-formatting. Just download the zip and add the executable to the path to make it work.<br />
To enable automatic formatting on every save, go to Preferences -> Package Settings -> Elm Language Support -> User, and add this setting: &#8220;elm_format_on_save&#8221;: true
</li>
</ul>
<p>When you work with elm files, you can press Ctrl+B to build it. If there are any errors or warnings, they will show up in the console below and also get highlighted.</p>
<p>If you want to see the definition of a method, press Alt+Up while your cursor is on the method.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.adamzolo.com/elm-sublime/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
