Evan Czaplicki claims that you can pick up Elm cold and lean on the tools to become productive early on the learning curve. I decided to put that to the test, and see if developer UX improves learning. At least for n(1)
If it compiles it (generally) works™
main =
beginnerProgram { model = 0, view = view, update = update }
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (toString model) ]
, button [ onClick Increment ] [ text "+" ]
]
type Msg = Increment | Decrement
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
type Msg = Increment | Decrement
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
Reset ->
model - 1
Detected errors in 1 module.
-- NAMING ERROR -------------------------
Cannot find pattern `Reset`
30| Reset ->
^^^^^
type Msg = Increment | Decrement | Reset
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
Reset ->
model = 0
Detected errors in 1 module.
-- SYNTAX PROBLEM --------------------------------------------------------------
I ran into something unexpected when parsing your code!
31| model = 0
^
I am looking for one of the following things:
end of input
whitespace
main =
beginnerProgram { model = 0, view = view, update = update }
view model =
div []
[ button [ onClick Decrement ] [ text "-" ]
, div [] [ text (toString model) ]
, button [ onClick Increment ] [ text "+" ]
, button [ onClick Reset ] [ text "reset" ]
]
type Msg = Increment | Decrement | Reset
update msg model =
case msg of
Increment ->
model + 1
Decrement ->
model - 1
Reset ->
0
I also kind of like Bucklescript
Elm has really nice tools and you should at least check it out so that when you write tools or libraries, you can pass some of these great ideas to your users!
iex(5)> url = "https://auth.drxwebservices.com/v1/auth/token?format=json"
"https://auth.drxwebservices.com/v1/auth/token?format=json"
iex(6)> body = "grant_type=client_credentials"
"grant_type=client_credentials"
iex(7)> headers = ["Content-Type": "application/x-www-form-urlencoded"]
["Content-Type": "application/x-www-form-urlencoded"]
iex(8)> options = [hackney: [
...(8)> basic_auth: {"my key", "my secret"}]]
[hackney: [basic_auth: {"my key",
"my secret"}]]
iex(9)> HTTPoison.post(url, body, headers, options)
{:error, %HTTPoison.Error{id: nil, reason: :closed}}
WTF does that even mean?
[27] pry(main)> cd String
[28] pry(String):1> ls
constants: BLANK_RE
Object.methods: JSON yaml_tag
JSON::Ext::Generator::GeneratorMethods::String::Extend#methods: json_create
String.methods: try_convert
String#methods:
% capitalize! each_codepoint indent purple squish to_r
* casecmp each_line indent! purpleish squish! to_s
+ center empty? index red start_with? to_str
+@ chars encode inquiry redish starts_with? to_sym
-@ chomp encode! insert remove strip to_time
# omitted because there are like 1,000,000 more
[1] pry(main)> cd String
[2] pry(String):1> show-method capitalize!
From: string.c (C Method):
Owner: String
Visibility: public
Number of lines: 33
static VALUE
rb_str_capitalize_bang(VALUE str)
{
rb_encoding *enc;
char *s, *send;
int modify = 0;
unsigned int c;
int n;
...
@chasegilliam
Avhana Health