Something that trips me up occasionally in C# is syntactic sugar with properties. Specifically, the difference between the fat arrow (
=>) and assignment (
=) with properties. Here’s a quick note to help clear up any confusion.
This post continues a series I’ve been writing as I toy with the mdgriffith/elm-style-animation Elm package. I’ve primarily been focused on both learning how to use the animation package, but as I’ve explored, there seems to be room for leveraging a higher layer of abstraction to more rapidly compose and deploy animations. Maybe things will work out, or maybe I’ll crash and burn. Either way, it has been a fun journey so far and I’ve enjoyed talking with the Elm community and the animation package’s author, Michael!
Let’s recap what we’ve covered so far. I’ll be mainly discussing changes that I’ve made to the previous code, so you’ll want to take a look at these posts (especially the first post) before we begin.
- In the first post, I discussed a basic framework for Elm animations that seemed to have fallen out naturally as I was manipulating data types for composing animations.
- In the second post, I extended this framework to perform more complex behavior like swapping view elements for controlling transitions in flow control.
In this post, I’m going to explore detecting the lifecycle of animations and triggering commands based on that lifecycle.
Read on for details, or just grab the code from this Github repo and run with it. You’ll want to look for the
Hey, let’s draw some triangles! If you’ve been following my last two posts on mouse chasing and drawing rays using Elm, this post will be a simple extension. If you haven’t already read those posts, I encourage you to start from the beginning, because we’ll be making iterative updates to practice getting our hands dirty with Elm.
Once again, this is targeted at newcomers to Elm, so we won’t be covering any advanced topics. If you want to see a quick demo, follow this link and start clicking around!
Signals are a non-obvious concept to grasp at first glance. The Reactivity guide contains good in-depth instruction about how Signals work, but spending a little time playing with them can really help grasp how they work.
We’ll walk through a simple example to generate a snake-line line that follows the mouse. To see what we’re going to build, you can open up the demo here. (Note that this only works with a mouse, not with touch events. Exercise: Extend this example to support touch events using Elm’s Touch module.)
(This is the first in what will hopefully be a series of useful code snippets to solve problems. For each snippet, I’ll try to provide a basic solution to the problem, then ask my readers to post alternatives in the comments.)
Haskell provides some greatly composable functions in its standard Prelude library (accessible by default) that make performing operations on large lists of data very easy.
However, when dealing with certain resources (especially I/O resources, like file handles and network connections), these simple abstractions can get you in to trouble by easily exhausting available system resources.
What follows is a (very) simple method for mapping over large numbers of resources. It’s really just intended as an example for newcomers to Haskell, that may have encountered this problem.