- π 2019-07-19
- this spans many weeks / investment times
- π π³οΈπ΅ββοΈοΈ The Elm Language Guide
- π¨βπ»ποΈ an experienced OOP programmer learning FP and Elm
Compared to my experiences using JavaScript over many years, I found installing
and running Elm to be fast and easy for an Ubuntu 18 development machine.
Running this step was required, and deduced from a few different github issue
comments:
sudo npm install -g elm --unsafe-perm=true --allow-root
The elm REPL is really nice to use.
- Records vs Objects is interesting
- you cant ask a Record for a field that does not exist
- a Record never has an
undefined
ornull
field - a Record can not be made recursive with
this
orself
keyword- ποΈ Elm tries to avoid systemic problems from OOP by forcing separation of
data and logic. The ability to saythis
breaks this separation.
- ποΈ Elm tries to avoid systemic problems from OOP by forcing separation of
- a Record supports structural typing
- dont care about the names or location in call stack something was defined
- only care that, for every
a
andb
, theb
has at least every single
feature thata
has.- this differs from duck typing, where one might only care that
b
has
at least the current interesting features thata
has.
- this differs from duck typing, where one might only care that
if you ultimately cannot use Elm at work yet, you will get a lot out of using
Elm and internalizing this pattern.
...after joining a company that provides developers with ample skill investment
time and resources π
- Model - describes the application state
- Update - describes the ways state can be updated
- View - represents the application state as HTML
There is a repository to facilitate coding along with this guide. I have made
my own fork here: π΄
-
skimming types
- cool Elm has type inference
- it helps catch bugs! ποΈ
- actually not sure why the guide says to skim this part right now, I just
want to read all the things
Β―\_(γ)_/Β―
-
types can be used to describe capabilities as data
- e.g., a type of
Increment
orDecrement
is a piece of data that is also describing a capability
- e.g., a type of
-
so, I understand how this produces an HTML view that sends messages, but how does this program actually receive the messages? the connection is not obvious to me at a glance at this extremely simple code π€οΈ
-
Model, Update, View - the essense of The Elm Architecture β’οΈ
- π³οΈπ³οΈπ³οΈ
-
I took on the programming challenge at the end, to make a Reset button. I spent a lot of time figuring out how to reassign
model
to0
! Like several other folks on stackoverflow, I diddnt see the=
at the top of the function definition!
-
Im starting to wonder what
Msg -> Model -> Model
means for the func def π€οΈ- does this mean: receives a Msg and a Model and returns a Model ?
- whats the
->
mean in this context?
-
ok, the program here mainly just persists the value you type
- the actual reversal of String is done by JS on the front end, all the Elm app does is accept a string and return it to the front end.
- other than to highlight the change to use a
Record
to representModel
, I am not sure if this is a worthwhile example on its own π€·ββοΈοΈ
-
π€οΈ what is
exposing(..)
β- imports all of the things π
-
Forms seem pretty straightforward to me.
- I do find that an absence of learning Elm makes remembering its styntax difficult!
-
TODO mess with the code as the example suggests!
-
cya next time!
π§ππ·