import { syntaxHighlighterPrism } from '@mdx-deck/themes' import { future } from '@mdx-deck/themes' import { Appear } from '@mdx-deck/components' import { FullScreenCode } from '@mdx-deck/layouts'
export const themes = [ future, syntaxHighlighterPrism ]
Elm is a statically typed functional language that compiles to JavaScript, focusing on building frontend application.
this is javascript
const add = (a, b) => a + b
this is elm
add a b = a + b
add : number -> number -> number
add a b = a + b
add 1 2 -- 3 : number
what does
->
mean
why not..
add : (number, number) -> number
but
add : number -> number -> number
?
add 1
-- <function> : number -> number
cuz
add : number -> number -> number
=
add : number -> (number -> number)
oneIsPositive =
if 1 > 0 then
"positive"
else
"not positive"
checkIfPositive n =
if n > 0 then
"positive"
else
"not positive"
oneIsPositive = checkIfPositive 1
const xs = []
xs[0]
❌ TypeError: undefined is not a function
const numbers = []
numbers[0] * 10
List.head []
List.head []
-- Nothing : Maybe a
List.head ["hello", "world"]
-- Just "hello" : Maybe String
type Maybe a
= Just a
| Nothing
compiler that talks to you
"The Elm Architecture is a simple pattern for architecting webapps. It is great for modularity, code reuse, and testing. Ultimately, it makes it easy to create complex web apps that stay healthy as you refactor and add features."
model / view / update
<iframe style={{ backgroundColor: "white" }} src="http://localhost:8000/" />
And that's the intro.
Hopes that it generates interest and curiosity!