PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Elm

Elm

Elm is a pl created in 2012 by Evan Czaplicki.

#71on PLDB 10Years Old 11.4kUsers
5Books 2Papers 20kRepos

Try now: Web · Riju

Elm is a domain-specific programming language for declaratively creating web browser-based graphical user interfaces. Elm is purely functional, and is developed with emphasis on usability, performance, and robustness. It advertises "no runtime exceptions in practice," made possible by the Elm compiler's static type checking.. Read more on Wikipedia...


Example from Riju:
module Main exposing (..) output : String output = "Hello, world!"
Example from hello-world:
import Html exposing (text) main = text "Hello World"
Example from the Hello World Collection:
-- Hello world in Elm import Text main = Text.plainText "Hello, world!"
Example from Linguist:
main = asText (qsort [3,9,1,8,5,4,7]) qsort lst = case lst of x:xs -> qsort (filter ((>=)x) xs) ++ [x] ++ qsort (filter ((<)x) xs) [] -> [] {--------------------- QuickSort works as follows: - Choose a pivot element which be placed in the "middle" of the sorted list. In our case we are choosing the first element as the pivot. - Gather all of the elements less than the pivot (the first filter). We know that these must come before our pivot element in the sorted list. Note: ((>=)x) === (\y -> (>=) x y) === (\y -> x >= y) - Gather all of the elements greater than the pivot (the second filter). We know that these must come after our pivot element in the sorted list. - Run `qsort` on the lesser elements, producing a sorted list that contains only elements less than the pivot. Put these before the pivot. - Run `qsort` on the greater elements, producing a sorted list. Put these after the pivot. Note that choosing a bad pivot can have bad effects. Take a sorted list with N elements. The pivot will always be the lowest member, meaning that it does not divide the list very evenly. The list of lessers has 0 elements and the list of greaters has N-1 elemens. This means qsort will be called N times, each call looking through the entire list. This means, in the worst case, QuickSort will make N^2 comparisons. ----------------------}
Example from Wikipedia:
-- This is a single line comment {- This is a multi-line comment. It can span multiple lines. -} {- It is possible to {- nest -} multi-line comments -} -- Here we define a value named ''greeting''. The type is inferred as a String. greeting = "Hello World!" -- It is best to add type annotations to top-level declarations. hello : String hello = "Hi there." -- Functions are declared the same way, with arguments following the function name. add x y = x + y -- Again, it is best to add type annotations. hypotenuse : Float -> Float -> Float hypotenuse a b = sqrt (a^2 + b^2) -- Functions are also curried; here we've curried the multiplication -- infix operator with a `2` multiplyBy2 : number -> number multiplyBy2 = (*) 2 -- If-expressions are used to branch on values absoluteValue : number -> number absoluteValue number = if number < 0 then negate number else number -- Records are used to hold values with named fields book : { title : String, author : String, pages : Int } book = { title = "Steppenwolf" , author = "Hesse" , pages = 237 } -- Record access is done with `.` title : String title = book.title -- Record access `.` can also be used as a function author : String author = .author book -- We can create entirely new types with the `type` keyword. -- The following value represents a binary tree. type Tree a = Empty | Node a (Tree a) (Tree a) -- It is possible to inspect these types with case-expressions. depth : Tree a -> Int depth tree = case tree of Empty -> 0 Node value left right -> 1 + max (depth left) (depth right)

Language features

Feature Supported Example Token
Integers
-- _?\d+
Floats
-- _?\d+\.(?=\d+)
Strings
"Hello world"
"
Semantic Indentation
MultiLine Comments
{- A comment
-}
{- -}
Line Comments
-- A comment
--
Comments

Books about Elm from ISBNdb

title authors year publisher
Practical Elm For A Busy Developer Alex S. Korban 2019
Programming Elm Jeremy Fairbank 20190702 O'Reilly Media, Inc.
Elm Web Development Ajdin Imsirovic 2018-03-30 Packt Publishing
Elm in Action Richard Feldman 20200404 Manning Publications
Web Applications with Elm Wolfgang Loder 20180821 Springer Nature

Publications about Elm from Semantic Scholar

title authors year citations influentialCitations
Model-View-Update-Communicate: Session Types meet the Elm Architecture S. Fowler 2019 5 2
Using Elm to Introduce Algebraic Thinking to K-8 Students Curtis D'Alves and Tanya Bouman and Christopher W. Schankula and J. Hogg and Levin Noronha and Emily Horsman and R. Siddiqui and C. Anand 2018 4 0
powerpc.html · elm.html · d.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com