A quick overview of Elm and comparison with Ruby (including how to write better Ruby code). Instructions are provided on how to easily configure your Ruby on Rails app with Elm so you can be up and running in only a few minutes!
A strong focus on simplicity with a concise syntax. • No runtime exceptions (no null or undefined)! • Has a friendly, time traveling, debugger! • Runs on Rails (via the Webpacker gem)! https://elm-lang.org
=> String def label prefix, message "#{prefix}: #{message}" end ℹ Ruby 3.x.x might support this. Requires a gem... ...which then allows for type checking:
true} # Conditional: if planet[:habitable] "habitable" end # Result: "habitable" http://www.rubyist.net/~slagell/ruby/control.html ℹ Has potential to answer a nil.
habitable: true} # Conditional: if planet[:habitable] "habitable" else "inhabitable" end # Result: "habitable" http://www.rubyist.net/~slagell/ruby/control.html Can be enforced by Rubocop.
= case planet.status of Terraforming -> "Under construction." Habitable -> "Life is good, stop by!" Barren -> "The humans are dead." https://elm-lang.org/docs/syntax#conditionals ℹ A `_ ->` branch can be used as a catch all (in some situations). planet = {name = "Earth", status = Habitable}
:habitable "Life is good, stop by!" when :barren "The humans are dead." end http://www.rubyist.net/~slagell/ruby/control.html Planet = Struct.new :name, :status planet = Planet.new "Earth", :habitable
when :habitable "Life is good, stop by!" when :barren "The humans are dead." else fail "Unknown planet status." end http://www.rubyist.net/~slagell/ruby/control.html Can be enforced by Rubocop.
0, second = 0 first + second end https://www.rubyist.net/~slagell/ruby/methods.html # Example 2: def add first, second return unless first && second first + second end # Example 3: def add first, second Integer(first) + Integer(second) end
book) • Functional Programming in Elm (online book, partially complete) Read in order listed. Diving Deeper • Elm in Action by Richard Feldman - Book. $40. • Building Web Apps with Elm by The Pragmatic Studio - Screencasts. $50. • Integrating Elm by The Pragmatic Studio - Screencasts. Free. https://elm-lang.org/docs