This article contains promotional content. (November 2012) |
Elm is a functional programming language for declaratively creating graphical user interfaces. Elm uses the Functional Reactive Programming style and purely functional graphical layout to build user interface without any destructive updates.
Elm | |
---|---|
Paradigm | functional reactive |
Designed by | Evan Czaplicki |
First appeared | 2011 |
Stable release | 2.5.8 (August 18, 2005[±] | )
Filename extensions | .elm |
Website | elm-lang.org |
Description
The primary implementation of Elm compiles to HTML, CSS, and JavaScript. Functional Reactive Programming takes the place of event handlers and callbacks; it also manages all screen updates automatically. Purely functional graphical layout takes the place of working with the DOM.
Elm allows Markdown to be embedded directly, so users can create text content in a familiar and natural way.
Elm's version of Functional Reactive Programming is event-driven, meaning that updates are only performed as necessary. It shares the closest resemblance to Event-Driven FRP and Arrowized FRP.
Code Examples
The following program displays the position of the mouse as it moves around the screen, automatically updating the screen in real-time.
main = lift asText Mouse.position
The value of main is displayed on screen. Function asText turns any value into a displayable textual representation. Mouse.position is a value that changes over time, called a signal. Function lift ensures that asText is applied to Mouse.position every time the mouse moves.
Elm's list interpolation allows sequences of numbers to be easily created.
factorial n = product [1..n]