There's a lot of type terminology and jargon going around when discussing types in Elm. This glossary attempts to list some of the most common type terms along with synonyms, terms from other language communities, examples, and links to more detailed articles on each topic.
# This imagines `.unfold` to be an alternate constructor for `Enumerator` that's | |
# more complex than `.produce` but not as custom as the full `.new`. It follows the rules | |
# of anamorphisms (at least for arrays, not sure if this genericises to other structures) | |
class CustomEnumerator | |
def self.unfold(seed, &block) | |
Enumerator.new do |yielder| | |
loop do | |
seed, value = block.call(seed) | |
raise StopIteration if value.nil? |
class Dollar | |
attr_reader :cents | |
def initialize(cents:) | |
@cents = cents | |
end | |
def hash | |
[self.class, cents].hash | |
end |
require "date" | |
class Month | |
include Comparable | |
MONTHS_PER_YEAR = 12 | |
def self.from_date(date) | |
self.from_parts(date.year, date.month) | |
end |
class Tree | |
attr_reader :val, :left, :right | |
def self.empty | |
EmptyTree.new | |
end | |
def self.leaf(val) | |
new(val, empty, empty) | |
end |
-- 0.19 | |
randomToTask : Generator a -> Task x a | |
randomToTask generator = | |
Time.now | |
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis) | |
-- 0.18 |
class Tally | |
def self.empty | |
new({}) | |
end | |
def initialize(raw) | |
@raw = empty_hash.merge raw.slice(:small, :medium, :large) | |
end | |
# Accessors |
This is the source for the scripts discussed in https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts
Both scripts are in the bin/
directory of the repo that contains all the markdown documents for blog posts.
Users run bin/server
and everything is automatically set up for them to view a local preview of the blog.
bin/server-setup
is a dependency of bin/server
and is never run directly by users.
Maitre-d is the name of the "blog engine" discussed in the article.
"That ticket touches the wizard code? Why don't YOU take that one". The wizard in question is so gnarly my colleagues are afraid to touch it.
Looking at the code through the lens of conditional cardinality reveals what went wrong and how we can make things better. This mental model will change the way you think about structuring logic and help you take your conditional code from scary to delightful.
This talk is aimed at an intermediate to advanced audience. While it will driven by a practical example (refactoring a multi-step form), it will mainly be about some more theoretical principles and mental models for structuring conditional code.