Elm-Friendly Functional Programming For The Web • Luke Westby • GOTO 2016
ฝัง
- เผยแพร่เมื่อ 10 ก.พ. 2025
- This presentation was recorded at GOTO Copenhagen 2016. #gotocon #gotocph
gotocph.com
Luke Westby - JavaScript developer and Partner at HumbleSpark
ABSTRACT
In this talk, Luke will demonstrate all of the beauties of Elm, its syntax, tools, community, and hopefully convince you that the Elm is exactly what front-end developers have been looking for. [...]
Download slides and read the full abstract here:
gotocon.com/cp...
RECOMMENDED BOOKS
Richard Feldman • Elm in Action • amzn.to/387kujI
Jeremy Fairbank • Programming Elm • amzn.to/2WhZCE8
Wolfgang Loder • Web Applications with Elm • amzn.to/3jblQ3q
Cristian Salcescu • Functional Programming in JavaScript • amzn.to/3y75jBS
/ gotocon
/ goto-
/ gotoconferences
#Elm #FunctionalProgramming #frontend
Looking for a unique learning experience?
Attend the next GOTO conference near you! Get your ticket at gotopia.tech
Sign up for updates and specials at gotopia.tech/n...
SUBSCRIBE TO OUR CHANNEL - new videos posted almost daily.
www.youtube.co...
Excellent preview of ELM!
so if i want a function with 5 parameters it would be add : int -> int -> int -> int -> int -> int -> ? that is kind of overkill and horrible to look at surely we can do better?
Functions like that are usually a code smell. In any language, if I saw that then I would suggest representing your data differently. In Java, I would recommend using a POJO. In Elm, you would consider making a type for what those first 4 ints actually mean, which is a lot more useful than 4 arbitrary Int values. Then, you would have this:
MyType -> Int
smelly
If you ever come to the point where you need five input parameters to a function - time to refactor the function and split it up into two or more functions. Don't be afraid to write tons of functions and break everything down into the simplest and smallest manageable pieces.
You'd be better off just using a function that adds a list of integers
add : List Int -> Int
add = List.foldr (
ext total -> next + total) 0 numbers
or if you really have a specific structure that is exclusively 5 integers you'd create a type alias for it rather than repeate -> int -> int in every function you give it to.
small mistake at 13.00, add10 should look like
add10 : Int -> Int
add10 input =
add input 10
Technically your code works, but so does the code from his presentation because of Partial Application. add10 has a function signature of Int -> Int because (add 10) returns a function that takes an INT and returns an INT. add10 is just assigning a name to the partially applied function of (add 10) so you don't need to declare another input variable and pass it as all the variables the add function needs were declared already.
It was a great talk overall, but no one would ever write their HTML within elm .. It's simply impractical. Perhaps it's way better to just show how it works with a templating library, like Mustache.
Except so many companies do write it. Have you tried doing it for your projects? Some things might surprise you :)